88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.515 2006/10/08 17:45:50 momjian Exp $
11+ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.516 2006/10/19 19:52:22 tgl Exp $
1212 *
1313 * NOTES
1414 * this is the "main" module of the postgres backend and
@@ -1326,9 +1326,9 @@ exec_bind_message(StringInfo input_message)
13261326/*
13271327 * Report query to various monitoring facilities.
13281328 */
1329- debug_query_string = "bind message " ;
1329+ debug_query_string = pstmt -> query_string ? pstmt -> query_string : "<BIND> " ;
13301330
1331- pgstat_report_activity (pstmt -> query_string ? pstmt -> query_string : "<BIND>" );
1331+ pgstat_report_activity (debug_query_string );
13321332
13331333set_ps_display ("BIND" , false);
13341334
@@ -1680,37 +1680,17 @@ exec_execute_message(const char *portal_name, long max_rows)
16801680return ;
16811681}
16821682
1683- /*
1684- * Report query to various monitoring facilities.
1685- */
1686- debug_query_string = "execute message" ;
1687-
1688- pgstat_report_activity (portal -> sourceText ?portal -> sourceText :"<EXECUTE>" );
1689-
1690- set_ps_display (portal -> commandTag , false);
1691-
1692- if (save_log_statement_stats )
1693- ResetUsage ();
1694-
16951683/* Does the portal contain a transaction command? */
16961684is_xact_command = IsTransactionStmtList (portal -> parseTrees );
16971685
1698- /*
1699- * If we re-issue an Execute protocol request against an existing portal,
1700- * then we are only fetching more rows rather than completely re-executing
1701- * the query from the start. atStart is never reset for a v3 portal, so we
1702- * are safe to use this check.
1703- */
1704- execute_is_fetch = !portal -> atStart ;
1705-
17061686/*
17071687 * We must copy the sourceText and prepStmtName into MessageContext in
17081688 * case the portal is destroyed during finish_xact_command. Can avoid the
17091689 * copy if it's not an xact command, though.
17101690 */
17111691if (is_xact_command )
17121692{
1713- sourceText = pstrdup (portal -> sourceText );
1693+ sourceText = portal -> sourceText ? pstrdup (portal -> sourceText ) : NULL ;
17141694if (portal -> prepStmtName )
17151695prepStmtName = pstrdup (portal -> prepStmtName );
17161696else
@@ -1732,6 +1712,18 @@ exec_execute_message(const char *portal_name, long max_rows)
17321712portalParams = portal -> portalParams ;
17331713}
17341714
1715+ /*
1716+ * Report query to various monitoring facilities.
1717+ */
1718+ debug_query_string = sourceText ?sourceText :"<EXECUTE>" ;
1719+
1720+ pgstat_report_activity (debug_query_string );
1721+
1722+ set_ps_display (portal -> commandTag , false);
1723+
1724+ if (save_log_statement_stats )
1725+ ResetUsage ();
1726+
17351727BeginCommand (portal -> commandTag ,dest );
17361728
17371729/*
@@ -1746,6 +1738,14 @@ exec_execute_message(const char *portal_name, long max_rows)
17461738 */
17471739start_xact_command ();
17481740
1741+ /*
1742+ * If we re-issue an Execute protocol request against an existing portal,
1743+ * then we are only fetching more rows rather than completely re-executing
1744+ * the query from the start. atStart is never reset for a v3 portal, so we
1745+ * are safe to use this check.
1746+ */
1747+ execute_is_fetch = !portal -> atStart ;
1748+
17491749/* Log immediately if dictated by log_statement */
17501750if (check_log_statement_cooked (portal -> parseTrees ))
17511751{