Skip to content

Commit f5371fe

Browse files
committed
Fix inadequate tree-walking code in exec_eval_clear_fcache.
1 parent 08ede42 commit f5371fe

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

src/pl/plpgsql/src/pl_exec.c

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* procedural language
44
*
55
* IDENTIFICATION
6-
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.32 2000/11/16 22:30:50 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.33 2000/12/01 20:43:59 tgl Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -54,6 +54,7 @@
5454
#include "executor/spi.h"
5555
#include "executor/spi_priv.h"
5656
#include "fmgr.h"
57+
#include "optimizer/clauses.h"
5758
#include "parser/parse_expr.h"
5859
#include "tcop/tcopprot.h"
5960
#include "utils/builtins.h"
@@ -112,6 +113,7 @@ static void exec_prepare_plan(PLpgSQL_execstate * estate,
112113
static bool exec_simple_check_node(Node *node);
113114
static void exec_simple_check_plan(PLpgSQL_expr * expr);
114115
static void exec_eval_clear_fcache(Node *node);
116+
static bool exec_eval_clear_fcache_walker(Node *node, void *context);
115117
static Datum exec_eval_simple_expr(PLpgSQL_execstate * estate,
116118
PLpgSQL_expr * expr,
117119
bool *isNull,
@@ -2593,7 +2595,7 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate,
25932595
*rettype = expr->plan_simple_type;
25942596

25952597
/* ----------
2596-
* Clear the function cache
2598+
* Clear any function cache entries in the expression tree
25972599
* ----------
25982600
*/
25992601
exec_eval_clear_fcache(expr->plan_simple_expr);
@@ -2904,33 +2906,35 @@ exec_simple_check_plan(PLpgSQL_expr * expr)
29042906
static void
29052907
exec_eval_clear_fcache(Node *node)
29062908
{
2907-
Expr *expr;
2908-
List *l;
2909-
2910-
if (nodeTag(node) != T_Expr)
2911-
return;
2912-
2913-
expr = (Expr *) node;
2909+
/* This tree walk requires no special setup, so away we go... */
2910+
exec_eval_clear_fcache_walker(node, NULL);
2911+
}
29142912

2915-
switch (expr->opType)
2913+
static bool
2914+
exec_eval_clear_fcache_walker(Node *node, void *context)
2915+
{
2916+
if (node == NULL)
2917+
return false;
2918+
if (IsA(node, Expr))
29162919
{
2917-
case OP_EXPR:
2918-
((Oper *) (expr->oper))->op_fcache = NULL;
2919-
break;
2920+
Expr *expr = (Expr *) node;
29202921

2921-
case FUNC_EXPR:
2922-
((Func *) (expr->oper))->func_fcache = NULL;
2923-
break;
2924-
2925-
default:
2926-
break;
2922+
switch (expr->opType)
2923+
{
2924+
case OP_EXPR:
2925+
((Oper *) (expr->oper))->op_fcache = NULL;
2926+
break;
2927+
case FUNC_EXPR:
2928+
((Func *) (expr->oper))->func_fcache = NULL;
2929+
break;
2930+
default:
2931+
break;
2932+
}
29272933
}
2928-
2929-
foreach(l, expr->args)
2930-
exec_eval_clear_fcache(lfirst(l));
2934+
return expression_tree_walker(node, exec_eval_clear_fcache_walker,
2935+
context);
29312936
}
29322937

2933-
29342938
/* ----------
29352939
* exec_set_found Set the global found variable
29362940
* to true/false

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