*** pgsql/src/backend/commands/prepare.c 2009/01/01 17:23:39 1.95 --- pgsql/src/backend/commands/prepare.c 2009/01/02 20:42:00 1.96 *************** *** 10,16 **** * Copyright (c) 2002-2009, PostgreSQL Global Development Group * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.94 2008/12/28 18:53:55 tgl Exp $ * *------------------------------------------------------------------------- */ --- 10,16 ---- * Copyright (c) 2002-2009, PostgreSQL Global Development Group * * IDENTIFICATION ! * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.95 2009/01/01 17:23:39 momjian Exp $ * *------------------------------------------------------------------------- */ *************** DropAllPreparedStatements(void) *** 636,641 **** --- 636,644 ---- /* * Implements the 'EXPLAIN EXECUTE' utility statement. + * + * Note: the passed-in queryString is that of the EXPLAIN EXECUTE, + * not the original PREPARE; we get the latter string from the plancache. */ void ExplainExecuteQuery(ExecuteStmt *execstmt, ExplainStmt *stmt, *************** ExplainExecuteQuery(ExecuteStmt *execstm *** 643,648 **** --- 646,652 ---- ParamListInfo params, TupOutputState *tstate) { PreparedStatement *entry; + const char *query_string; CachedPlan *cplan; List *plan_list; ListCell *p; *************** ExplainExecuteQuery(ExecuteStmt *execstm *** 659,664 **** --- 663,670 ---- if (!entry->plansource->fixed_result) elog(ERROR, "EXPLAIN EXECUTE does not support variable-result cached plans"); + query_string = entry->plansource->query_string; + /* Replan if needed, and acquire a transient refcount */ cplan = RevalidateCachedPlan(entry->plansource, true); *************** ExplainExecuteQuery(ExecuteStmt *execstm *** 701,711 **** pstmt->intoClause = execstmt->into; } ! ExplainOnePlan(pstmt, paramLI, stmt, tstate); } else { ! ExplainOneUtility((Node *) pstmt, stmt, queryString, params, tstate); } --- 707,718 ---- pstmt->intoClause = execstmt->into; } ! ExplainOnePlan(pstmt, stmt, query_string, ! paramLI, tstate); } else { ! ExplainOneUtility((Node *) pstmt, stmt, query_string, params, tstate); }