mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Throw an error for negative LIMIT or OFFSET values, instead of silently
treating them as zero. Simon Riggs
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/executor/nodeLimit.c,v 1.33 2008/01/01 19:45:49 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/executor/nodeLimit.c,v 1.34 2008/03/10 03:37:59 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -246,7 +246,9 @@ recompute_limits(LimitState *node)
|
|||||||
{
|
{
|
||||||
node->offset = DatumGetInt64(val);
|
node->offset = DatumGetInt64(val);
|
||||||
if (node->offset < 0)
|
if (node->offset < 0)
|
||||||
node->offset = 0;
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
|
errmsg("OFFSET must not be negative")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -271,7 +273,9 @@ recompute_limits(LimitState *node)
|
|||||||
{
|
{
|
||||||
node->count = DatumGetInt64(val);
|
node->count = DatumGetInt64(val);
|
||||||
if (node->count < 0)
|
if (node->count < 0)
|
||||||
node->count = 0;
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
|
errmsg("LIMIT must not be negative")));
|
||||||
node->noCount = false;
|
node->noCount = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user