diff options
| author | Tom Lane | 2002-12-13 19:46:01 +0000 |
|---|---|---|
| committer | Tom Lane | 2002-12-13 19:46:01 +0000 |
| commit | 3a4f7dde16ad81b2319b9a4924a6023710a2fefd (patch) | |
| tree | 248cf66fd94d40072b5ba8bb8e5437a6ea8399e5 /src/pl | |
| parent | 77b7a740f95250af7d78f69e9c906c3e53f32e7b (diff) | |
Phase 3 of read-only-plans project: ExecInitExpr now builds expression
execution state trees, and ExecEvalExpr takes an expression state tree
not an expression plan tree. The plan tree is now read-only as far as
the executor is concerned. Next step is to begin actually exploiting
this property.
Diffstat (limited to 'src/pl')
| -rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 16 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/plpgsql.h | 4 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 23d457263e8..8908a43a786 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.73 2002/12/12 15:49:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.74 2002/12/13 19:46:01 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -1981,6 +1981,7 @@ exec_prepare_plan(PLpgSQL_execstate * estate, PLpgSQL_recfield *recfield; int i; int fno; + _SPI_plan *spi_plan; void *plan; Oid *argtypes; @@ -2030,7 +2031,8 @@ exec_prepare_plan(PLpgSQL_execstate * estate, if (plan == NULL) elog(ERROR, "SPI_prepare() failed on \"%s\"", expr->query); expr->plan = SPI_saveplan(plan); - expr->plan_argtypes = ((_SPI_plan *) expr->plan)->argtypes; + spi_plan = (_SPI_plan *) expr->plan; + expr->plan_argtypes = spi_plan->argtypes; expr->plan_simple_expr = NULL; exec_simple_check_plan(expr); @@ -3642,6 +3644,7 @@ exec_simple_check_plan(PLpgSQL_expr * expr) _SPI_plan *spi_plan = (_SPI_plan *) expr->plan; Plan *plan; TargetEntry *tle; + MemoryContext oldcontext; expr->plan_simple_expr = NULL; @@ -3688,10 +3691,13 @@ exec_simple_check_plan(PLpgSQL_expr * expr) return; /* - * Yes - this is a simple expression. Remember the expression and the - * return type + * Yes - this is a simple expression. Prepare to execute it, and + * stash away the result type. Put the expression state tree in the + * plan context so it will have appropriate lifespan. */ - expr->plan_simple_expr = (Node *) tle->expr; + oldcontext = MemoryContextSwitchTo(spi_plan->plancxt); + expr->plan_simple_expr = ExecInitExpr(tle->expr, NULL); + MemoryContextSwitchTo(oldcontext); expr->plan_simple_type = exprType((Node *) tle->expr); } diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h index 2f4c10e0356..945569b6f6a 100644 --- a/src/pl/plpgsql/src/plpgsql.h +++ b/src/pl/plpgsql/src/plpgsql.h @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.29 2002/11/10 00:35:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.30 2002/12/13 19:46:01 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -165,7 +165,7 @@ typedef struct int exprno; char *query; void *plan; - Node *plan_simple_expr; + ExprState *plan_simple_expr; Oid plan_simple_type; Oid *plan_argtypes; int nparams; |
