88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.128 2009/01/01 17:23:48 momjian Exp $
11+ * $PostgreSQL: pgsql/src/backend/tcop/pquery.c,v 1.129 2009/01/02 20:42:00 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -36,6 +36,7 @@ PortalActivePortal = NULL;
3636
3737
3838static void ProcessQuery (PlannedStmt * plan ,
39+ const char * sourceText ,
3940ParamListInfo params ,
4041DestReceiver * dest ,
4142char * completionTag );
@@ -61,6 +62,7 @@ static void DoPortalRewind(Portal portal);
6162 */
6263QueryDesc *
6364CreateQueryDesc (PlannedStmt * plannedstmt ,
65+ const char * sourceText ,
6466Snapshot snapshot ,
6567Snapshot crosscheck_snapshot ,
6668DestReceiver * dest ,
@@ -72,6 +74,7 @@ CreateQueryDesc(PlannedStmt *plannedstmt,
7274qd -> operation = plannedstmt -> commandType ;/* operation */
7375qd -> plannedstmt = plannedstmt ;/* plan */
7476qd -> utilitystmt = plannedstmt -> utilityStmt ;/* in case DECLARE CURSOR */
77+ qd -> sourceText = sourceText ;/* query text */
7578qd -> snapshot = RegisterSnapshot (snapshot );/* snapshot */
7679/* RI check snapshot */
7780qd -> crosscheck_snapshot = RegisterSnapshot (crosscheck_snapshot );
@@ -93,6 +96,7 @@ CreateQueryDesc(PlannedStmt *plannedstmt,
9396 */
9497QueryDesc *
9598CreateUtilityQueryDesc (Node * utilitystmt ,
99+ const char * sourceText ,
96100Snapshot snapshot ,
97101DestReceiver * dest ,
98102ParamListInfo params )
@@ -102,6 +106,7 @@ CreateUtilityQueryDesc(Node *utilitystmt,
102106qd -> operation = CMD_UTILITY ;/* operation */
103107qd -> plannedstmt = NULL ;
104108qd -> utilitystmt = utilitystmt ;/* utility command */
109+ qd -> sourceText = sourceText ;/* query text */
105110qd -> snapshot = RegisterSnapshot (snapshot );/* snapshot */
106111qd -> crosscheck_snapshot = InvalidSnapshot ;/* RI check snapshot */
107112qd -> dest = dest ;/* output dest */
@@ -141,6 +146,7 @@ FreeQueryDesc(QueryDesc *qdesc)
141146 *or PORTAL_ONE_RETURNING portal
142147 *
143148 *plan: the plan tree for the query
149+ *sourceText: the source text of the query
144150 *params: any parameters needed
145151 *dest: where to send results
146152 *completionTag: points to a buffer of size COMPLETION_TAG_BUFSIZE
@@ -153,6 +159,7 @@ FreeQueryDesc(QueryDesc *qdesc)
153159 */
154160static void
155161ProcessQuery (PlannedStmt * plan ,
162+ const char * sourceText ,
156163ParamListInfo params ,
157164DestReceiver * dest ,
158165char * completionTag )
@@ -169,7 +176,7 @@ ProcessQuery(PlannedStmt *plan,
169176/*
170177 * Create the QueryDesc object
171178 */
172- queryDesc = CreateQueryDesc (plan ,
179+ queryDesc = CreateQueryDesc (plan ,sourceText ,
173180GetActiveSnapshot (),InvalidSnapshot ,
174181dest ,params , false);
175182
@@ -503,6 +510,7 @@ PortalStart(Portal portal, ParamListInfo params, Snapshot snapshot)
503510 * the destination to DestNone.
504511 */
505512queryDesc = CreateQueryDesc ((PlannedStmt * )linitial (portal -> stmts ),
513+ portal -> sourceText ,
506514GetActiveSnapshot (),
507515InvalidSnapshot ,
508516None_Receiver ,
@@ -1258,13 +1266,15 @@ PortalRunMulti(Portal portal, bool isTopLevel,
12581266{
12591267/* statement can set tag string */
12601268ProcessQuery (pstmt ,
1269+ portal -> sourceText ,
12611270portal -> portalParams ,
12621271dest ,completionTag );
12631272}
12641273else
12651274{
12661275/* stmt added by rewrite cannot set tag */
12671276ProcessQuery (pstmt ,
1277+ portal -> sourceText ,
12681278portal -> portalParams ,
12691279altdest ,NULL );
12701280}