Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6818922

Browse files
committed
Make sure that debug_query_string contains the original query text,
if available (which it usually should be), during processing of Bindand Execute protocol messages. This improves usefulness oflog_min_error_statement logging for extended query protocol.
1 parentdef651f commit6818922

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

‎src/backend/tcop/postgres.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
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

13331333
set_ps_display("BIND", false);
13341334

@@ -1680,37 +1680,17 @@ exec_execute_message(const char *portal_name, long max_rows)
16801680
return;
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? */
16961684
is_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
*/
17111691
if (is_xact_command)
17121692
{
1713-
sourceText=pstrdup(portal->sourceText);
1693+
sourceText=portal->sourceText ?pstrdup(portal->sourceText) :NULL;
17141694
if (portal->prepStmtName)
17151695
prepStmtName=pstrdup(portal->prepStmtName);
17161696
else
@@ -1732,6 +1712,18 @@ exec_execute_message(const char *portal_name, long max_rows)
17321712
portalParams=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+
17351727
BeginCommand(portal->commandTag,dest);
17361728

17371729
/*
@@ -1746,6 +1738,14 @@ exec_execute_message(const char *portal_name, long max_rows)
17461738
*/
17471739
start_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 */
17501750
if (check_log_statement_cooked(portal->parseTrees))
17511751
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp