Skip to content

Commit 7d6fbe1

Browse files
committed
Evaluate LIMIT/OFFSET expressions with ExecEvalExprSwitchContext, not
ExecEvalExpr, to avoid possible memory leak.
1 parent 5558e15 commit 7d6fbe1

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/backend/executor/nodeLimit.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.6 2001/03/23 04:49:53 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeLimit.c,v 1.7 2001/08/06 18:05:07 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -164,10 +164,11 @@ recompute_limits(Limit *node)
164164

165165
if (node->limitOffset)
166166
{
167-
limitstate->offset = DatumGetInt32(ExecEvalExpr(node->limitOffset,
168-
econtext,
169-
&isNull,
170-
NULL));
167+
limitstate->offset =
168+
DatumGetInt32(ExecEvalExprSwitchContext(node->limitOffset,
169+
econtext,
170+
&isNull,
171+
NULL));
171172
/* Interpret NULL offset as no offset */
172173
if (isNull)
173174
limitstate->offset = 0;
@@ -182,10 +183,11 @@ recompute_limits(Limit *node)
182183

183184
if (node->limitCount)
184185
{
185-
limitstate->count = DatumGetInt32(ExecEvalExpr(node->limitCount,
186-
econtext,
187-
&isNull,
188-
NULL));
186+
limitstate->count =
187+
DatumGetInt32(ExecEvalExprSwitchContext(node->limitCount,
188+
econtext,
189+
&isNull,
190+
NULL));
189191
/* Interpret NULL count as no count (LIMIT ALL) */
190192
if (isNull)
191193
limitstate->noCount = true;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy