Fix EXPLAIN ANALYZE bug noted by Wiebe Cazemier: although we were
properly advancing the CommandCounter between multiple sub-queries generated by rules, we forgot to update the snapshot being used, so that the successive sub-queries didn't actually see each others' results. This is still not *exactly* like the semantics of normal execution of the same queries, in that we don't take new transaction snapshots and hence don't see changes from concurrently committed commands, but I think that's OK and probably even preferable for EXPLAIN ANALYZE.
This commit is contained in:
parent
ef3b7cd328
commit
9fc24f2bf6
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994-5, Regents of the University of California
|
* Portions Copyright (c) 1994-5, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.138 2005/10/15 02:49:15 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.139 2005/10/21 16:43:33 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -196,6 +196,15 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate)
|
|||||||
/* plan the query */
|
/* plan the query */
|
||||||
plan = planner(query, isCursor, cursorOptions, NULL);
|
plan = planner(query, isCursor, cursorOptions, NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update snapshot command ID to ensure this query sees results of any
|
||||||
|
* previously executed queries. (It's a bit cheesy to modify
|
||||||
|
* ActiveSnapshot without making a copy, but for the limited ways in
|
||||||
|
* which EXPLAIN can be invoked, I think it's OK, because the active
|
||||||
|
* snapshot shouldn't be shared with anything else anyway.)
|
||||||
|
*/
|
||||||
|
ActiveSnapshot->curcid = GetCurrentCommandId();
|
||||||
|
|
||||||
/* Create a QueryDesc requesting no output */
|
/* Create a QueryDesc requesting no output */
|
||||||
queryDesc = CreateQueryDesc(query, plan,
|
queryDesc = CreateQueryDesc(query, plan,
|
||||||
ActiveSnapshot, InvalidSnapshot,
|
ActiveSnapshot, InvalidSnapshot,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
|
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.41 2005/10/15 02:49:15 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.42 2005/10/21 16:43:33 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -605,6 +605,15 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate)
|
|||||||
query->into = execstmt->into;
|
query->into = execstmt->into;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update snapshot command ID to ensure this query sees results of
|
||||||
|
* any previously executed queries. (It's a bit cheesy to modify
|
||||||
|
* ActiveSnapshot without making a copy, but for the limited ways
|
||||||
|
* in which EXPLAIN can be invoked, I think it's OK, because the
|
||||||
|
* active snapshot shouldn't be shared with anything else anyway.)
|
||||||
|
*/
|
||||||
|
ActiveSnapshot->curcid = GetCurrentCommandId();
|
||||||
|
|
||||||
/* Create a QueryDesc requesting no output */
|
/* Create a QueryDesc requesting no output */
|
||||||
qdesc = CreateQueryDesc(query, plan,
|
qdesc = CreateQueryDesc(query, plan,
|
||||||
ActiveSnapshot, InvalidSnapshot,
|
ActiveSnapshot, InvalidSnapshot,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user