aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/explain.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-12-13 00:17:52 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-12-13 00:17:52 +0000
commit92065453d7210c72201c347150e32e4e4e733373 (patch)
tree311857dd1bd00d0f465c6ad0521a78a8d62d2408 /src/backend/commands/explain.c
parent79c1011fb78b7098a202529e87505aede23210ab (diff)
downloadpostgresql-92065453d7210c72201c347150e32e4e4e733373.tar.gz
postgresql-92065453d7210c72201c347150e32e4e4e733373.zip
Back-patch copyOject fix for EXPLAIN/PREPARE.
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r--src/backend/commands/explain.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 1b34b17585f..5295583f171 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
- * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.117 2003/10/17 01:14:26 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.117.2.1 2004/12/13 00:17:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -74,6 +74,16 @@ ExplainQuery(ExplainStmt *stmt, DestReceiver *dest)
List *rewritten;
List *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));