* Portions Copyright (c) 1994-5, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.141 2005/11/26 22:14:56 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.142 2005/11/29 01:25:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
} ExplainState;
static void ExplainOneQuery(Query *query, ExplainStmt *stmt,
- TupOutputState *tstate);
+ ParamListInfo params, TupOutputState *tstate);
static double elapsed_time(instr_time *starttime);
static void explain_outNode(StringInfo str,
Plan *plan, PlanState *planstate,
* execute an EXPLAIN command
*/
void
-ExplainQuery(ExplainStmt *stmt, DestReceiver *dest)
+ExplainQuery(ExplainStmt *stmt, ParamListInfo params, DestReceiver *dest)
{
Query *query = stmt->query;
TupOutputState *tstate;
{
/* Rewriter will not cope with utility statements */
if (query->utilityStmt && IsA(query->utilityStmt, DeclareCursorStmt))
- ExplainOneQuery(query, stmt, tstate);
+ ExplainOneQuery(query, stmt, params, tstate);
else if (query->utilityStmt && IsA(query->utilityStmt, ExecuteStmt))
- ExplainExecuteQuery(stmt, tstate);
+ ExplainExecuteQuery(stmt, params, tstate);
else
do_text_output_oneline(tstate, "Utility statements have no plan structure");
}
/* Explain every plan */
foreach(l, rewritten)
{
- ExplainOneQuery(lfirst(l), stmt, tstate);
+ ExplainOneQuery(lfirst(l), stmt, params, tstate);
/* put a blank line between plans */
if (lnext(l) != NULL)
do_text_output_oneline(tstate, "");
* print out the execution plan for one query
*/
static void
-ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate)
+ExplainOneQuery(Query *query, ExplainStmt *stmt, ParamListInfo params,
+ TupOutputState *tstate)
{
Plan *plan;
QueryDesc *queryDesc;
/* Create a QueryDesc requesting no output */
queryDesc = CreateQueryDesc(query, plan,
ActiveSnapshot, InvalidSnapshot,
- None_Receiver, NULL,
+ None_Receiver, params,
stmt->analyze);
ExplainOnePlan(queryDesc, stmt, tstate);
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.42 2005/10/21 16:43:33 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.43 2005/11/29 01:25:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* Implements the 'EXECUTE' utility statement.
*/
void
-ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest, char *completionTag)
+ExecuteQuery(ExecuteStmt *stmt, ParamListInfo params,
+ DestReceiver *dest, char *completionTag)
{
PreparedStatement *entry;
char *query_string;
* of query, in case parameters are pass-by-reference.
*/
estate = CreateExecutorState();
+ estate->es_param_list_info = params;
paramLI = EvaluateParams(estate, stmt->params, entry->argtype_list);
}
* Implements the 'EXPLAIN EXECUTE' utility statement.
*/
void
-ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate)
+ExplainExecuteQuery(ExplainStmt *stmt, ParamListInfo params,
+ TupOutputState *tstate)
{
ExecuteStmt *execstmt = (ExecuteStmt *) stmt->query->utilityStmt;
PreparedStatement *entry;
* of query, in case parameters are pass-by-reference.
*/
estate = CreateExecutorState();
+ estate->es_param_list_info = params;
paramLI = EvaluateParams(estate, execstmt->params,
entry->argtype_list);
}
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.249 2005/11/22 18:17:22 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.250 2005/11/29 01:25:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* general utility function invoker
*
* parsetree: the parse tree for the utility statement
- * params: parameters to use during execution (currently only used by DECLARE)
+ * params: parameters to use during execution
* dest: where to send results
* completionTag: points to a buffer of size COMPLETION_TAG_BUFSIZE
* in which to store a command completion status string.
break;
case T_ExecuteStmt:
- ExecuteQuery((ExecuteStmt *) parsetree, dest, completionTag);
+ ExecuteQuery((ExecuteStmt *) parsetree, params,
+ dest, completionTag);
break;
case T_DeallocateStmt:
break;
case T_ExplainStmt:
- ExplainQuery((ExplainStmt *) parsetree, dest);
+ ExplainQuery((ExplainStmt *) parsetree, params, dest);
break;
case T_VariableSetStmt:
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/explain.h,v 1.24 2004/12/31 22:03:28 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/commands/explain.h,v 1.25 2005/11/29 01:25:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "tcop/dest.h"
-extern void ExplainQuery(ExplainStmt *stmt, DestReceiver *dest);
+extern void ExplainQuery(ExplainStmt *stmt, ParamListInfo params,
+ DestReceiver *dest);
extern TupleDesc ExplainResultDesc(ExplainStmt *stmt);
*
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/commands/prepare.h,v 1.14 2005/06/22 17:45:46 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/commands/prepare.h,v 1.15 2005/11/29 01:25:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/* Utility statements PREPARE, EXECUTE, DEALLOCATE, EXPLAIN EXECUTE */
extern void PrepareQuery(PrepareStmt *stmt);
-extern void ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest,
- char *completionTag);
+extern void ExecuteQuery(ExecuteStmt *stmt, ParamListInfo params,
+ DestReceiver *dest, char *completionTag);
extern void DeallocateQuery(DeallocateStmt *stmt);
-extern void ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate);
+extern void ExplainExecuteQuery(ExplainStmt *stmt, ParamListInfo params,
+ TupOutputState *tstate);
/* Low-level access to stored prepared statements */
extern void StorePreparedStatement(const char *stmt_name,