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

Commit853a993

Browse files
committed
Remove portals from pg_execplan, temporarily add DestLog receiver. + pgindent of code processing
1 parent1cd24be commit853a993

File tree

13 files changed

+559
-469
lines changed

13 files changed

+559
-469
lines changed

‎contrib/pg_execplan/pg_execplan.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ exec_plan(char *query_string, char *plan_string)
104104
ParamListInfoparamLI=NULL;
105105
CachedPlanSource*psrc;
106106
CachedPlan*cplan;
107-
Portalportal;
107+
QueryDesc*queryDesc;
108108
DestReceiver*receiver;
109-
int16format=0;
110109
inteflags=0;
111110

112111
PG_TRY();
@@ -134,36 +133,35 @@ exec_plan(char *query_string, char *plan_string)
134133
SetRemoteSubplan(psrc,pstmt);
135134
cplan=GetCachedPlan(psrc,paramLI, false);
136135

137-
receiver=CreateDestReceiver(DestNone);
138-
portal=CreateNewPortal();
139-
portal->visible= false;
140-
PortalDefineQuery(portal,
141-
NULL,
142-
query_string,
143-
NULL,
144-
NULL,
145-
cplan);
136+
receiver=CreateDestReceiver(DestLog);
137+
146138
PG_TRY();
147139
{
148-
PortalStart(portal,paramLI,eflags,InvalidSnapshot);
149-
PortalSetResultFormat(portal,0,&format);
150-
(void)PortalRun(portal,
151-
FETCH_ALL,
152-
true,
153-
receiver,
154-
receiver,
155-
query_string);
140+
queryDesc=CreateQueryDesc(pstmt,
141+
query_string,
142+
GetActiveSnapshot(),
143+
InvalidSnapshot,
144+
receiver,
145+
paramLI,
146+
0);
147+
ExecutorStart(queryDesc,eflags);
148+
PushActiveSnapshot(queryDesc->snapshot);
149+
ExecutorRun(queryDesc,ForwardScanDirection,0);
150+
PopActiveSnapshot();
151+
ExecutorFinish(queryDesc);
152+
ExecutorEnd(queryDesc);
153+
FreeQueryDesc(queryDesc);
156154
}
157155
PG_CATCH();
158156
{
159157
elog(INFO,"BAD QUERY: '%s'.",query_string);
160-
PortalDrop(portal, false);
158+
ReleaseCachedPlan(cplan, false);
161159
PG_RE_THROW();
162160
}
163161
PG_END_TRY();
164162

165163
receiver->rDestroy(receiver);
166-
PortalDrop(portal, false);
164+
ReleaseCachedPlan(cplan, false);
167165

168166
if (EXPLAN_DEBUG_LEVEL>0)
169167
elog(INFO,"query execution finished.\n");

‎contrib/pg_execplan/tests/create_objects.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,24 @@ CREATE OPERATOR public.### (
4747
rightarg=numeric,
4848
procedure= numeric_add
4949
);
50+
51+
-- Different types and parameter types
52+
CREATETYPEbug_statusAS ENUM ('new','open','closed');
53+
54+
CREATETABLEpublic.bug (
55+
idserial,
56+
descriptionTEXT,
57+
status bug_status
58+
);
59+
60+
INSERT INTOpublic.bug (description, status)VALUES ('abc','open');
61+
INSERT INTOpublic.bug (description, status)VALUES ('abc1','closed');
62+
63+
CREATETABLEpublic.bug1 (
64+
idserial,
65+
status bug_status
66+
);
67+
INSERT INTOpublic.bug1 (status)VALUES ('new');
68+
INSERT INTOpublic.bug1 (status)VALUES ('new');
69+
INSERT INTOpublic.bug1 (status)VALUES ('closed');
70+

‎contrib/pg_execplan/tests/rpl.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,18 @@ psql -p 5432 -c "SELECT pg_store_query_plan('../test.txt', 'SELECT id ### 1 FROM
8080
psql -p 5433 -c"SELECT pg_exec_stored_plan('../test.txt');"
8181

8282
#ENUMOID -----------------------------------------------------------------------
83-
psql -p 5432 -c"CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');"
84-
psql -p 5432 -c"CREATE TABLE person ( name text, current_mood mood);"
85-
psql -p 5433 -c"CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');"
86-
psql -p 5433 -c"CREATE TABLE person ( name text, current_mood mood);"
87-
88-
psql -p 5432 -c"SELECT pg_store_query_plan('../test.txt', 'INSERT INTO person VALUES (''Moe'', ''happy'');');"
89-
psql -p 5432 -c"SELECT pg_exec_stored_plan('../test.txt');"
83+
psql -p 5432 -c"SELECT pg_store_query_plan('../test.txt', 'INSERT INTO bug (description, status) VALUES (''abc3'', ''new''::tests.bug_status);');"
9084
psql -p 5433 -c"SELECT pg_exec_stored_plan('../test.txt');"
91-
92-
psql -p 5432 -c"SELECT * FROM person WHERE current_mood = 'happy';"
93-
psql -p 5433 -c"SELECT * FROM person WHERE current_mood = 'happy';"
85+
#psql -p 5432 -c "SELECT pg_store_query_plan('../test.txt', 'SELECT * FROM bug WHERE status=''open''');"
86+
#psql -p 5433 -c "SELECT pg_exec_stored_plan('../test.txt');"
87+
echo"ENUMOID test"
88+
#psql -p 5432 -c "INSERT INTO public.bug1 (status) VALUES ('new');"
89+
psql -p 5432 -c"SELECT pg_store_query_plan('../test.txt', '
90+
SELECT A.description, B.id
91+
FROM bug as A, bug1 AS B
92+
WHERE A.status = B.status;
93+
');"
94+
psql -p 5433 -c"SELECT pg_exec_stored_plan('../test.txt');"
95+
psql -p 5432 -c"SELECT * FROM bug;"
96+
psql -p 5432 -c"SELECT * FROM bug1;"
9497

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp