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

Commit9cbd0c1

Browse files
committed
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 theplanner at the top of a completed plan tree; this carries just the fields ofQuery that are still needed at runtime. The statement lists kept in portalsetc. now consist of intermixed PlannedStmt and bare utility-statement nodes--- no Query. This incidentally allows us to remove some fields from Queryand Plan nodes that shouldn't have been there in the first place.Still to do: simplify the execution-time range table; at the moment therange table passed to the executor still contains Query trees for subqueries.initdb forced due to change of stored rules.
1 parent71b0cf2 commit9cbd0c1

39 files changed

+1162
-887
lines changed

‎src/backend/commands/copy.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.275 2007/01/25 02:17:26 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.276 2007/02/2017:32:13 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -986,10 +986,11 @@ DoCopy(const CopyStmt *stmt)
986986
{
987987
Query*query=stmt->query;
988988
List*rewritten;
989-
Plan*plan;
989+
PlannedStmt*plan;
990990
DestReceiver*dest;
991991

992992
Assert(query);
993+
Assert(query->commandType==CMD_SELECT);
993994
Assert(!is_from);
994995
cstate->rel=NULL;
995996

@@ -999,6 +1000,7 @@ DoCopy(const CopyStmt *stmt)
9991000
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
10001001
errmsg("COPY (SELECT) WITH OIDS is not supported")));
10011002

1003+
/* Query mustn't use INTO, either */
10021004
if (query->into)
10031005
ereport(ERROR,
10041006
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -1016,7 +1018,6 @@ DoCopy(const CopyStmt *stmt)
10161018
* shouldn't modify its input ... FIXME someday.
10171019
*/
10181020
query=copyObject(query);
1019-
Assert(query->commandType==CMD_SELECT);
10201021

10211022
/*
10221023
* Must acquire locks in case we didn't come fresh from the parser.
@@ -1051,7 +1052,7 @@ DoCopy(const CopyStmt *stmt)
10511052
((DR_copy*)dest)->cstate=cstate;
10521053

10531054
/* Create a QueryDesc requesting no output */
1054-
cstate->queryDesc=CreateQueryDesc(query,plan,
1055+
cstate->queryDesc=CreateQueryDesc(plan,
10551056
ActiveSnapshot,InvalidSnapshot,
10561057
dest,NULL, false);
10571058

‎src/backend/commands/explain.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.155 2007/02/19 02:23:11 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.156 2007/02/20 17:32:14 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -149,7 +149,7 @@ static void
149149
ExplainOneQuery(Query*query,ExplainStmt*stmt,ParamListInfoparams,
150150
TupOutputState*tstate)
151151
{
152-
Plan*plan;
152+
PlannedStmt*plan;
153153
QueryDesc*queryDesc;
154154
boolisCursor= false;
155155
intcursorOptions=0;
@@ -203,7 +203,7 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, ParamListInfo params,
203203
ActiveSnapshot->curcid=GetCurrentCommandId();
204204

205205
/* Create a QueryDesc requesting no output */
206-
queryDesc=CreateQueryDesc(query,plan,
206+
queryDesc=CreateQueryDesc(plan,
207207
ActiveSnapshot,InvalidSnapshot,
208208
None_Receiver,params,
209209
stmt->analyze);
@@ -260,14 +260,14 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt,
260260

261261
es->printNodes=stmt->verbose;
262262
es->printAnalyze=stmt->analyze;
263-
es->rtable=queryDesc->parsetree->rtable;
263+
es->rtable=queryDesc->plannedstmt->rtable;
264264

265265
if (es->printNodes)
266266
{
267267
char*s;
268268
char*f;
269269

270-
s=nodeToString(queryDesc->plantree);
270+
s=nodeToString(queryDesc->plannedstmt->planTree);
271271
if (s)
272272
{
273273
if (Explain_pretty_print)
@@ -282,7 +282,8 @@ ExplainOnePlan(QueryDesc *queryDesc, ExplainStmt *stmt,
282282
}
283283

284284
initStringInfo(&buf);
285-
explain_outNode(&buf,queryDesc->plantree,queryDesc->planstate,
285+
explain_outNode(&buf,
286+
queryDesc->plannedstmt->planTree,queryDesc->planstate,
286287
NULL,0,es);
287288

288289
/*

‎src/backend/commands/portalcmds.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.60 2007/02/06 22:49:24 tgl Exp $
17+
* $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.61 2007/02/20 17:32:14 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -42,7 +42,7 @@ PerformCursorOpen(DeclareCursorStmt *stmt, ParamListInfo params)
4242
{
4343
List*rewritten;
4444
Query*query;
45-
Plan*plan;
45+
PlannedStmt*plan;
4646
Portalportal;
4747
MemoryContextoldContext;
4848

@@ -98,13 +98,12 @@ PerformCursorOpen(DeclareCursorStmt *stmt, ParamListInfo params)
9898
plan=planner(query, true,stmt->options,params);
9999

100100
/*
101-
* Create a portal and copy thequery andplan into its memory context.
101+
* Create a portal and copy the plan into its memory context.
102102
*/
103103
portal=CreatePortal(stmt->portalname, false, false);
104104

105105
oldContext=MemoryContextSwitchTo(PortalGetHeapMemory(portal));
106106

107-
query=copyObject(query);
108107
plan=copyObject(plan);
109108

110109
/*
@@ -115,7 +114,6 @@ PerformCursorOpen(DeclareCursorStmt *stmt, ParamListInfo params)
115114
NULL,
116115
debug_query_string ?pstrdup(debug_query_string) :NULL,
117116
"SELECT",/* cursor's query is always a SELECT */
118-
list_make1(query),
119117
list_make1(plan),
120118
PortalGetHeapMemory(portal));
121119

@@ -140,7 +138,7 @@ PerformCursorOpen(DeclareCursorStmt *stmt, ParamListInfo params)
140138
portal->cursorOptions=stmt->options;
141139
if (!(portal->cursorOptions& (CURSOR_OPT_SCROLL |CURSOR_OPT_NO_SCROLL)))
142140
{
143-
if (ExecSupportsBackwardScan(plan))
141+
if (ExecSupportsBackwardScan(plan->planTree))
144142
portal->cursorOptions |=CURSOR_OPT_SCROLL;
145143
else
146144
portal->cursorOptions |=CURSOR_OPT_NO_SCROLL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp