mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Include a pointer to the query's source text in QueryDesc structs. This is
practically free given prior 8.4 changes in plancache and portal management, and it makes it a lot easier for ExecutorStart/Run/End hooks to get at the query text. Extracted from Itagaki Takahiro's pg_stat_statements patch, with minor editorialization.
This commit is contained in:
@ -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.183 2009/01/01 17:23:37 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.184 2009/01/02 20:42:00 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -172,7 +172,7 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, const char *queryString,
|
||||
plan = pg_plan_query(query, 0, params);
|
||||
|
||||
/* run it (if needed) and produce output */
|
||||
ExplainOnePlan(plan, params, stmt, tstate);
|
||||
ExplainOnePlan(plan, stmt, queryString, params, tstate);
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,8 +218,9 @@ ExplainOneUtility(Node *utilityStmt, ExplainStmt *stmt,
|
||||
* to call it.
|
||||
*/
|
||||
void
|
||||
ExplainOnePlan(PlannedStmt *plannedstmt, ParamListInfo params,
|
||||
ExplainStmt *stmt, TupOutputState *tstate)
|
||||
ExplainOnePlan(PlannedStmt *plannedstmt, ExplainStmt *stmt,
|
||||
const char *queryString, ParamListInfo params,
|
||||
TupOutputState *tstate)
|
||||
{
|
||||
QueryDesc *queryDesc;
|
||||
instr_time starttime;
|
||||
@ -234,7 +235,7 @@ ExplainOnePlan(PlannedStmt *plannedstmt, ParamListInfo params,
|
||||
PushUpdatedSnapshot(GetActiveSnapshot());
|
||||
|
||||
/* Create a QueryDesc requesting no output */
|
||||
queryDesc = CreateQueryDesc(plannedstmt,
|
||||
queryDesc = CreateQueryDesc(plannedstmt, queryString,
|
||||
GetActiveSnapshot(), InvalidSnapshot,
|
||||
None_Receiver, params,
|
||||
stmt->analyze);
|
||||
|
Reference in New Issue
Block a user