diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2006-10-19 19:52:22 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2006-10-19 19:52:22 +0000 |
commit | 681892208fe41459acf89ade0d91a78e55f1089a (patch) | |
tree | a3be01aa37a64a7c2f76b44810d7db52b3e334c9 /src/backend/tcop/postgres.c | |
parent | def651f48f6e8e8e2bc8bb604d443f4c10136d5f (diff) | |
download | postgresql-681892208fe41459acf89ade0d91a78e55f1089a.tar.gz postgresql-681892208fe41459acf89ade0d91a78e55f1089a.zip |
Make sure that debug_query_string contains the original query text,
if available (which it usually should be), during processing of Bind
and Execute protocol messages. This improves usefulness of
log_min_error_statement logging for extended query protocol.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 599bb8aa863..d019864fea4 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.515 2006/10/08 17:45:50 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.516 2006/10/19 19:52:22 tgl Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -1326,9 +1326,9 @@ exec_bind_message(StringInfo input_message) /* * Report query to various monitoring facilities. */ - debug_query_string = "bind message"; + debug_query_string = pstmt->query_string ? pstmt->query_string : "<BIND>"; - pgstat_report_activity(pstmt->query_string ? pstmt->query_string : "<BIND>"); + pgstat_report_activity(debug_query_string); set_ps_display("BIND", false); @@ -1680,37 +1680,17 @@ exec_execute_message(const char *portal_name, long max_rows) return; } - /* - * Report query to various monitoring facilities. - */ - debug_query_string = "execute message"; - - pgstat_report_activity(portal->sourceText ? portal->sourceText : "<EXECUTE>"); - - set_ps_display(portal->commandTag, false); - - if (save_log_statement_stats) - ResetUsage(); - /* Does the portal contain a transaction command? */ is_xact_command = IsTransactionStmtList(portal->parseTrees); /* - * If we re-issue an Execute protocol request against an existing portal, - * then we are only fetching more rows rather than completely re-executing - * the query from the start. atStart is never reset for a v3 portal, so we - * are safe to use this check. - */ - execute_is_fetch = !portal->atStart; - - /* * We must copy the sourceText and prepStmtName into MessageContext in * case the portal is destroyed during finish_xact_command. Can avoid the * copy if it's not an xact command, though. */ if (is_xact_command) { - sourceText = pstrdup(portal->sourceText); + sourceText = portal->sourceText ? pstrdup(portal->sourceText) : NULL; if (portal->prepStmtName) prepStmtName = pstrdup(portal->prepStmtName); else @@ -1732,6 +1712,18 @@ exec_execute_message(const char *portal_name, long max_rows) portalParams = portal->portalParams; } + /* + * Report query to various monitoring facilities. + */ + debug_query_string = sourceText ? sourceText : "<EXECUTE>"; + + pgstat_report_activity(debug_query_string); + + set_ps_display(portal->commandTag, false); + + if (save_log_statement_stats) + ResetUsage(); + BeginCommand(portal->commandTag, dest); /* @@ -1746,6 +1738,14 @@ exec_execute_message(const char *portal_name, long max_rows) */ start_xact_command(); + /* + * If we re-issue an Execute protocol request against an existing portal, + * then we are only fetching more rows rather than completely re-executing + * the query from the start. atStart is never reset for a v3 portal, so we + * are safe to use this check. + */ + execute_is_fetch = !portal->atStart; + /* Log immediately if dictated by log_statement */ if (check_log_statement_cooked(portal->parseTrees)) { |