diff options
| author | Tom Lane | 2007-02-20 17:32:18 +0000 |
|---|---|---|
| committer | Tom Lane | 2007-02-20 17:32:18 +0000 |
| commit | 9cbd0c155d1602aad879f510256b626c58942080 (patch) | |
| tree | 6d5504a4e841313d3a29cead80067006dc408e39 /src/pl | |
| parent | 71b0cf2f6bec3129f2c3f574d4e47408c2dc2516 (diff) | |
Remove the Query structure from the executor's API. This allows us to stop
storing mostly-redundant Query trees in prepared statements, portals, etc.
To replace Query, a new node type called PlannedStmt is inserted by the
planner at the top of a completed plan tree; this carries just the fields of
Query that are still needed at runtime. The statement lists kept in portals
etc. now consist of intermixed PlannedStmt and bare utility-statement nodes
--- no Query. This incidentally allows us to remove some fields from Query
and Plan nodes that shouldn't have been there in the first place.
Still to do: simplify the execution-time range table; at the moment the
range table passed to the executor still contains Query trees for subqueries.
initdb forced due to change of stored rules.
Diffstat (limited to 'src/pl')
| -rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 09f7a99097d..68a68a6634c 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.188 2007/02/08 18:37:30 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.189 2007/02/20 17:32:18 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2380,20 +2380,20 @@ exec_stmt_execsql(PLpgSQL_execstate *estate, exec_prepare_plan(estate, expr); stmt->mod_stmt = false; spi_plan = (_SPI_plan *) expr->plan; - foreach(l, spi_plan->qtlist) + foreach(l, spi_plan->stmt_list_list) { ListCell *l2; foreach(l2, (List *) lfirst(l)) { - Query *q = (Query *) lfirst(l2); + PlannedStmt *p = (PlannedStmt *) lfirst(l2); - Assert(IsA(q, Query)); - if (q->canSetTag) + if (IsA(p, PlannedStmt) && + p->canSetTag) { - if (q->commandType == CMD_INSERT || - q->commandType == CMD_UPDATE || - q->commandType == CMD_DELETE) + if (p->commandType == CMD_INSERT || + p->commandType == CMD_UPDATE || + p->commandType == CMD_DELETE) stmt->mod_stmt = true; } } @@ -4674,6 +4674,8 @@ static void exec_simple_check_plan(PLpgSQL_expr *expr) { _SPI_plan *spi_plan = (_SPI_plan *) expr->plan; + List *sublist; + PlannedStmt *stmt; Plan *plan; TargetEntry *tle; @@ -4683,17 +4685,20 @@ exec_simple_check_plan(PLpgSQL_expr *expr) * 1. We can only evaluate queries that resulted in one single execution * plan */ - if (list_length(spi_plan->ptlist) != 1) + if (list_length(spi_plan->stmt_list_list) != 1) + return; + sublist = (List *) linitial(spi_plan->stmt_list_list); + if (list_length(sublist) != 1) return; - plan = (Plan *) linitial(spi_plan->ptlist); + stmt = (PlannedStmt *) linitial(sublist); /* * 2. It must be a RESULT plan --> no scan's required */ - if (plan == NULL) /* utility statement produces this */ + if (!IsA(stmt, PlannedStmt)) return; - + plan = stmt->planTree; if (!IsA(plan, Result)) return; |
