diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-12-12 20:17:06 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-12-12 20:17:06 +0000 |
commit | c604ed56e3f9d4c236e06b717a18d1a5baa27c88 (patch) | |
tree | 6c4d533182e268ea010618071e47f9df38733bc7 /src/backend/commands/explain.c | |
parent | f9a6ba184a2b8db78919eac89dc56c68ad475587 (diff) | |
download | postgresql-c604ed56e3f9d4c236e06b717a18d1a5baa27c88.tar.gz postgresql-c604ed56e3f9d4c236e06b717a18d1a5baa27c88.zip |
PREPARE and EXPLAIN need to copy the source query just like we recently
had to do in DECLARE CURSOR. AFAICS these are all the places affected.
PREPARE case per example from Michael Fuhr, EXPLAIN case located by
grepping for planner calls ...
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r-- | src/backend/commands/explain.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 34f6aa51f78..66e795d422d 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994-5, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.127 2004/09/30 17:42:42 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.128 2004/12/12 20:17:06 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -75,6 +75,16 @@ ExplainQuery(ExplainStmt *stmt, DestReceiver *dest) List *rewritten; ListCell *l; + /* + * Because the planner is not cool about not scribbling on its input, + * we make a preliminary copy of the source querytree. This prevents + * problems in the case that the EXPLAIN is in a portal or plpgsql + * function and is executed repeatedly. (See also the same hack in + * DECLARE CURSOR and PREPARE.) XXX the planner really shouldn't + * modify its input ... FIXME someday. + */ + query = copyObject(query); + /* prepare for projection of tuples */ tstate = begin_tup_output_tupdesc(dest, ExplainResultDesc(stmt)); |