error_if_negative.v1.patch
text/x-patch
Filename: error_if_negative.v1.patch
Type: text/x-patch
Part: 0
Message:
Re: Negative LIMIT and OFFSET?
Patch
Format: context
Series: patch v1
| File | + | − |
|---|---|---|
| src/backend/executor/nodeLimit.c | 7 | 3 |
Index: src/backend/executor/nodeLimit.c
===================================================================
RCS file: /home/sriggs/pg/REPOSITORY/pgsql/src/backend/executor/nodeLimit.c,v
retrieving revision 1.32
diff -c -r1.32 nodeLimit.c
*** src/backend/executor/nodeLimit.c 15 Nov 2007 21:14:34 -0000 1.32
--- src/backend/executor/nodeLimit.c 14 Dec 2007 14:34:22 -0000
***************
*** 75,81 ****
/*
* Check for empty window; if so, treat like empty subplan.
*/
! if (node->count <= 0 && !node->noCount)
{
node->lstate = LIMIT_EMPTY;
return NULL;
--- 75,81 ----
/*
* Check for empty window; if so, treat like empty subplan.
*/
! if (node->count = 0 && !node->noCount)
{
node->lstate = LIMIT_EMPTY;
return NULL;
***************
*** 246,252 ****
{
node->offset = DatumGetInt64(val);
if (node->offset < 0)
! node->offset = 0;
}
}
else
--- 246,254 ----
{
node->offset = DatumGetInt64(val);
if (node->offset < 0)
! ereport(ERROR,
! (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
! errmsg("OFFSET must not be negative")));
}
}
else
***************
*** 271,277 ****
{
node->count = DatumGetInt64(val);
if (node->count < 0)
! node->count = 0;
node->noCount = false;
}
}
--- 273,281 ----
{
node->count = DatumGetInt64(val);
if (node->count < 0)
! ereport(ERROR,
! (errcode(ERRCODE_INVALID_LIMIT_VALUE),
! errmsg("LIMIT must not be negative")));
node->noCount = false;
}
}