mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-11-27 07:21:09 +08:00
Evaluate LIMIT/OFFSET expressions with ExecEvalExprSwitchContext, not
ExecEvalExpr, to avoid possible memory leak.
This commit is contained in:
parent
5558e15ce5
commit
7d6fbe15a2
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.6 2001/03/23 04:49:53 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.7 2001/08/06 18:05:07 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -164,10 +164,11 @@ recompute_limits(Limit *node)
|
|||||||
|
|
||||||
if (node->limitOffset)
|
if (node->limitOffset)
|
||||||
{
|
{
|
||||||
limitstate->offset = DatumGetInt32(ExecEvalExpr(node->limitOffset,
|
limitstate->offset =
|
||||||
econtext,
|
DatumGetInt32(ExecEvalExprSwitchContext(node->limitOffset,
|
||||||
&isNull,
|
econtext,
|
||||||
NULL));
|
&isNull,
|
||||||
|
NULL));
|
||||||
/* Interpret NULL offset as no offset */
|
/* Interpret NULL offset as no offset */
|
||||||
if (isNull)
|
if (isNull)
|
||||||
limitstate->offset = 0;
|
limitstate->offset = 0;
|
||||||
@ -182,10 +183,11 @@ recompute_limits(Limit *node)
|
|||||||
|
|
||||||
if (node->limitCount)
|
if (node->limitCount)
|
||||||
{
|
{
|
||||||
limitstate->count = DatumGetInt32(ExecEvalExpr(node->limitCount,
|
limitstate->count =
|
||||||
econtext,
|
DatumGetInt32(ExecEvalExprSwitchContext(node->limitCount,
|
||||||
&isNull,
|
econtext,
|
||||||
NULL));
|
&isNull,
|
||||||
|
NULL));
|
||||||
/* Interpret NULL count as no count (LIMIT ALL) */
|
/* Interpret NULL count as no count (LIMIT ALL) */
|
||||||
if (isNull)
|
if (isNull)
|
||||||
limitstate->noCount = true;
|
limitstate->noCount = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user