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

Commit9fc24f2

Browse files
committed
Fix EXPLAIN ANALYZE bug noted by Wiebe Cazemier: although we were
properly advancing the CommandCounter between multiple sub-queriesgenerated by rules, we forgot to update the snapshot being used, sothat the successive sub-queries didn't actually see each others'results. This is still not *exactly* like the semantics of normalexecution of the same queries, in that we don't take new transactionsnapshots and hence don't see changes from concurrently committedcommands, but I think that's OK and probably even preferable forEXPLAIN ANALYZE.
1 parentef3b7cd commit9fc24f2

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

‎src/backend/commands/explain.c

Lines changed: 10 additions & 1 deletion
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.138 2005/10/15 02:49:15 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.139 2005/10/21 16:43:33 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -196,6 +196,15 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate)
196196
/* plan the query */
197197
plan=planner(query,isCursor,cursorOptions,NULL);
198198

199+
/*
200+
* Update snapshot command ID to ensure this query sees results of any
201+
* previously executed queries. (It's a bit cheesy to modify
202+
* ActiveSnapshot without making a copy, but for the limited ways in
203+
* which EXPLAIN can be invoked, I think it's OK, because the active
204+
* snapshot shouldn't be shared with anything else anyway.)
205+
*/
206+
ActiveSnapshot->curcid=GetCurrentCommandId();
207+
199208
/* Create a QueryDesc requesting no output */
200209
queryDesc=CreateQueryDesc(query,plan,
201210
ActiveSnapshot,InvalidSnapshot,

‎src/backend/commands/prepare.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.41 2005/10/15 02:49:15 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.42 2005/10/21 16:43:33 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -605,6 +605,15 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate)
605605
query->into=execstmt->into;
606606
}
607607

608+
/*
609+
* Update snapshot command ID to ensure this query sees results of
610+
* any previously executed queries. (It's a bit cheesy to modify
611+
* ActiveSnapshot without making a copy, but for the limited ways
612+
* in which EXPLAIN can be invoked, I think it's OK, because the
613+
* active snapshot shouldn't be shared with anything else anyway.)
614+
*/
615+
ActiveSnapshot->curcid=GetCurrentCommandId();
616+
608617
/* Create a QueryDesc requesting no output */
609618
qdesc=CreateQueryDesc(query,plan,
610619
ActiveSnapshot,InvalidSnapshot,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp