File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 7
7
* Portions Copyright (c) 1994-5, Regents of the University of California
8
8
*
9
9
* IDENTIFICATION
10
- * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.127 2004/09/30 17:42:42 tgl Exp $
10
+ * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.128 2004/12/12 20: 17:06 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -75,6 +75,16 @@ ExplainQuery(ExplainStmt *stmt, DestReceiver *dest)
75
75
List * rewritten ;
76
76
ListCell * l ;
77
77
78
+ /*
79
+ * Because the planner is not cool about not scribbling on its input,
80
+ * we make a preliminary copy of the source querytree. This prevents
81
+ * problems in the case that the EXPLAIN is in a portal or plpgsql
82
+ * function and is executed repeatedly. (See also the same hack in
83
+ * DECLARE CURSOR and PREPARE.) XXX the planner really shouldn't
84
+ * modify its input ... FIXME someday.
85
+ */
86
+ query = copyObject (query );
87
+
78
88
/* prepare for projection of tuples */
79
89
tstate = begin_tup_output_tupdesc (dest , ExplainResultDesc (stmt ));
80
90
Original file line number Diff line number Diff line change 10
10
* Copyright (c) 2002-2004, PostgreSQL Global Development Group
11
11
*
12
12
* IDENTIFICATION
13
- * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.34 2004/12/03 21:26:31 tgl Exp $
13
+ * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.35 2004/12/12 20:17:06 tgl Exp $
14
14
*
15
15
*-------------------------------------------------------------------------
16
16
*/
48
48
PrepareQuery (PrepareStmt * stmt )
49
49
{
50
50
const char * commandTag ;
51
+ Query * query ;
51
52
List * query_list ,
52
53
* plan_list ;
53
54
@@ -87,8 +88,18 @@ PrepareQuery(PrepareStmt *stmt)
87
88
* the query.
88
89
*/
89
90
91
+ /*
92
+ * Because the planner is not cool about not scribbling on its input,
93
+ * we make a preliminary copy of the source querytree. This prevents
94
+ * problems in the case that the PREPARE is in a portal or plpgsql
95
+ * function and is executed repeatedly. (See also the same hack in
96
+ * DECLARE CURSOR and EXPLAIN.) XXX the planner really shouldn't
97
+ * modify its input ... FIXME someday.
98
+ */
99
+ query = copyObject (stmt -> query );
100
+
90
101
/* Rewrite the query. The result could be 0, 1, or many queries. */
91
- query_list = QueryRewrite (stmt -> query );
102
+ query_list = QueryRewrite (query );
92
103
93
104
/* Generate plans for queries. Snapshot is already set. */
94
105
plan_list = pg_plan_queries (query_list , NULL , false);
You can’t perform that action at this time.
0 commit comments