Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit708f82f

Browse files
committed
Fix bug noted by Bruce: FETCH in an already-aborted transaction block
would crash, due to premature invocation of SetQuerySnapshot(). Cleanup problems with handling of multiple queries by splittingpg_parse_and_plan into two routines. The old code would not, forexample, do the right thing with END; SELECT... submitted in one querystring when it had been in transaction abort state, because it'd decideto skip planning the SELECT before it had executed the END. Newarrangement is simpler and doesn't force caller to plan if onlyparse+rewrite is needed.
1 parent30d4f58 commit708f82f

File tree

6 files changed

+123
-169
lines changed

6 files changed

+123
-169
lines changed

‎src/backend/catalog/pg_proc.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.40 2000/01/26 05:56:11 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.41 2000/04/04 21:44:37 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -61,7 +61,6 @@ ProcedureCreate(char *procedureName,
6161
OidtypeObjectId;
6262
List*x;
6363
List*querytree_list;
64-
List*plan_list;
6564
Oidtypev[FUNC_MAX_ARGS];
6665
Oidrelid;
6766
Oidtoid;
@@ -222,9 +221,8 @@ ProcedureCreate(char *procedureName,
222221

223222
if (strcmp(languageName,"sql")==0)
224223
{
225-
plan_list=pg_parse_and_plan(prosrc,typev,parameterCount,
226-
&querytree_list,dest, FALSE);
227-
224+
querytree_list=pg_parse_and_rewrite(prosrc,typev,parameterCount,
225+
FALSE);
228226
/* typecheck return value */
229227
pg_checkretval(typeObjectId,querytree_list);
230228
}

‎src/backend/executor/functions.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.31 2000/01/26 05:56:22 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.32 2000/04/04 21:44:39 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -84,23 +84,24 @@ init_execution_state(FunctionCachePtr fcache,
8484
execution_state*nextes;
8585
execution_state*preves;
8686
List*queryTree_list,
87-
*planTree_list,
8887
*qtl_item;
8988
intnargs=fcache->nargs;
9089

9190
newes= (execution_state*)palloc(sizeof(execution_state));
9291
nextes=newes;
9392
preves= (execution_state*)NULL;
9493

95-
planTree_list=pg_parse_and_plan(fcache->src,fcache->argOidVect,
96-
nargs,&queryTree_list,None, FALSE);
94+
queryTree_list=pg_parse_and_rewrite(fcache->src,fcache->argOidVect,
95+
nargs, FALSE);
9796

9897
foreach(qtl_item,queryTree_list)
9998
{
10099
Query*queryTree=lfirst(qtl_item);
101-
Plan*planTree=lfirst(planTree_list);
100+
Plan*planTree;
102101
EState*estate;
103102

103+
planTree=pg_plan_query(queryTree);
104+
104105
if (!nextes)
105106
nextes= (execution_state*)palloc(sizeof(execution_state));
106107
if (preves)
@@ -141,8 +142,6 @@ init_execution_state(FunctionCachePtr fcache,
141142
nextes->estate=estate;
142143
preves=nextes;
143144
nextes= (execution_state*)NULL;
144-
145-
planTree_list=lnext(planTree_list);
146145
}
147146

148147
returnnewes;
@@ -151,15 +150,12 @@ init_execution_state(FunctionCachePtr fcache,
151150
staticTupleDesc
152151
postquel_start(execution_state*es)
153152
{
154-
#ifdefFUNC_UTIL_PATCH
155-
156153
/*
157154
* Do nothing for utility commands. (create, destroy...) DZ -
158155
* 30-8-1996
159156
*/
160157
if (es->qd->operation==CMD_UTILITY)
161158
return (TupleDesc)NULL;
162-
#endif
163159
returnExecutorStart(es->qd,es->estate);
164160
}
165161

@@ -168,20 +164,17 @@ postquel_getnext(execution_state *es)
168164
{
169165
intfeature;
170166

171-
#ifdefFUNC_UTIL_PATCH
172167
if (es->qd->operation==CMD_UTILITY)
173168
{
174-
175169
/*
176-
* Processan utility command. (create, destroy...) DZ -
170+
* Processa utility command. (create, destroy...) DZ -
177171
* 30-8-1996
178172
*/
179173
ProcessUtility(es->qd->parsetree->utilityStmt,es->qd->dest);
180174
if (!LAST_POSTQUEL_COMMAND(es))
181175
CommandCounterIncrement();
182176
return (TupleTableSlot*)NULL;
183177
}
184-
#endif
185178

186179
feature= (LAST_POSTQUEL_COMMAND(es)) ?EXEC_RETONE :EXEC_RUN;
187180

@@ -191,15 +184,12 @@ postquel_getnext(execution_state *es)
191184
staticvoid
192185
postquel_end(execution_state*es)
193186
{
194-
#ifdefFUNC_UTIL_PATCH
195-
196187
/*
197188
* Do nothing for utility commands. (create, destroy...) DZ -
198189
* 30-8-1996
199190
*/
200191
if (es->qd->operation==CMD_UTILITY)
201192
return;
202-
#endif
203193
ExecutorEnd(es->qd,es->estate);
204194
}
205195

‎src/backend/executor/spi.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* spi.c
44
*Server Programming Interface
55
*
6-
* $Id: spi.c,v 1.44 1999/12/16 22:19:44 wieck Exp $
6+
* $Id: spi.c,v 1.45 2000/04/04 21:44:39 tgl Exp $
77
*
88
*-------------------------------------------------------------------------
99
*/
@@ -622,7 +622,6 @@ _SPI_execute(char *src, int tcount, _SPI_plan *plan)
622622
List*queryTree_list;
623623
List*planTree_list;
624624
List*queryTree_list_item;
625-
List*ptlist;
626625
QueryDesc*qdesc;
627626
Query*queryTree;
628627
Plan*planTree;
@@ -645,18 +644,20 @@ _SPI_execute(char *src, int tcount, _SPI_plan *plan)
645644
nargs=plan->nargs;
646645
argtypes=plan->argtypes;
647646
}
648-
ptlist=planTree_list=
649-
pg_parse_and_plan(src,argtypes,nargs,&queryTree_list,None, FALSE);
647+
648+
queryTree_list=pg_parse_and_rewrite(src,argtypes,nargs, FALSE);
650649

651650
_SPI_current->qtlist=queryTree_list;
652651

652+
planTree_list=NIL;
653+
653654
foreach(queryTree_list_item,queryTree_list)
654655
{
655656
queryTree= (Query*)lfirst(queryTree_list_item);
656-
planTree=lfirst(planTree_list);
657-
planTree_list=lnext(planTree_list);
658-
islastquery=(planTree_list==NIL);/* assume lists are same
659-
* len */
657+
islastquery=(lnext(queryTree_list_item)==NIL);
658+
659+
planTree=pg_plan_query(queryTree);
660+
planTree_list=lappend(planTree_list,planTree);
660661

661662
if (queryTree->commandType==CMD_UTILITY)
662663
{
@@ -707,7 +708,7 @@ _SPI_execute(char *src, int tcount, _SPI_plan *plan)
707708
}
708709

709710
plan->qtlist=queryTree_list;
710-
plan->ptlist=ptlist;
711+
plan->ptlist=planTree_list;
711712

712713
returnres;
713714
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp