aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/spi.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-04-04 21:44:40 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-04-04 21:44:40 +0000
commit708f82f1916073ae9e7eafb661f68c19e3d65797 (patch)
tree6347172ace7ed49d871ecba227543c942465b398 /src/backend/executor/spi.c
parent30d4f58256c89b60f1ee7c4880e628145a531801 (diff)
downloadpostgresql-708f82f1916073ae9e7eafb661f68c19e3d65797.tar.gz
postgresql-708f82f1916073ae9e7eafb661f68c19e3d65797.zip
Fix bug noted by Bruce: FETCH in an already-aborted transaction block
would crash, due to premature invocation of SetQuerySnapshot(). Clean up problems with handling of multiple queries by splitting pg_parse_and_plan into two routines. The old code would not, for example, do the right thing with END; SELECT... submitted in one query string when it had been in transaction abort state, because it'd decide to skip planning the SELECT before it had executed the END. New arrangement is simpler and doesn't force caller to plan if only parse+rewrite is needed.
Diffstat (limited to 'src/backend/executor/spi.c')
-rw-r--r--src/backend/executor/spi.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 7c65c66814f..016d15ae8ac 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -3,7 +3,7 @@
* spi.c
* Server Programming Interface
*
- * $Id: spi.c,v 1.44 1999/12/16 22:19:44 wieck Exp $
+ * $Id: spi.c,v 1.45 2000/04/04 21:44:39 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -622,7 +622,6 @@ _SPI_execute(char *src, int tcount, _SPI_plan *plan)
List *queryTree_list;
List *planTree_list;
List *queryTree_list_item;
- List *ptlist;
QueryDesc *qdesc;
Query *queryTree;
Plan *planTree;
@@ -645,18 +644,20 @@ _SPI_execute(char *src, int tcount, _SPI_plan *plan)
nargs = plan->nargs;
argtypes = plan->argtypes;
}
- ptlist = planTree_list =
- pg_parse_and_plan(src, argtypes, nargs, &queryTree_list, None, FALSE);
+
+ queryTree_list = pg_parse_and_rewrite(src, argtypes, nargs, FALSE);
_SPI_current->qtlist = queryTree_list;
+ planTree_list = NIL;
+
foreach(queryTree_list_item, queryTree_list)
{
queryTree = (Query *) lfirst(queryTree_list_item);
- planTree = lfirst(planTree_list);
- planTree_list = lnext(planTree_list);
- islastquery = (planTree_list == NIL); /* assume lists are same
- * len */
+ islastquery = (lnext(queryTree_list_item) == NIL);
+
+ planTree = pg_plan_query(queryTree);
+ planTree_list = lappend(planTree_list, planTree);
if (queryTree->commandType == CMD_UTILITY)
{
@@ -707,7 +708,7 @@ _SPI_execute(char *src, int tcount, _SPI_plan *plan)
}
plan->qtlist = queryTree_list;
- plan->ptlist = ptlist;
+ plan->ptlist = planTree_list;
return res;
}