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

Commit7273902

Browse files
committed
Log protocol-excute fetch operatation as fetch, rather than execute,
adjusted from a patch by Simon.
1 parent8892259 commit7273902

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

‎src/backend/tcop/postgres.c

Lines changed: 23 additions & 4 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.462 2005/09/24 17:53:15 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.463 2005/09/26 15:51:12 momjian Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1466,6 +1466,7 @@ exec_bind_message(StringInfo input_message)
14661466
else
14671467
portal=CreatePortal(portal_name, false, false);
14681468

1469+
/* We need to output the parameter values someday */
14691470
if (log_statement==LOGSTMT_ALL)
14701471
ereport(LOG,
14711472
(errmsg("statement: <BIND> %s",portal_name)));
@@ -1681,6 +1682,7 @@ exec_execute_message(const char *portal_name, long max_rows)
16811682
boolsave_log_duration=log_duration;
16821683
intsave_log_min_duration_statement=log_min_duration_statement;
16831684
boolsave_log_statement_stats=log_statement_stats;
1685+
boolexecute_is_fetch= false;
16841686

16851687
/* Adjust destination to tell printtup.c what to do */
16861688
dest=whereToSendOutput;
@@ -1693,6 +1695,15 @@ exec_execute_message(const char *portal_name, long max_rows)
16931695
(errcode(ERRCODE_UNDEFINED_CURSOR),
16941696
errmsg("portal \"%s\" does not exist",portal_name)));
16951697

1698+
/*
1699+
* If we re-issue an Execute protocol request against an existing
1700+
* portal, then we are only fetching more rows rather than
1701+
* completely re-executing the query from the start. atStart is never
1702+
* reset for a v3 portal, so we are safe to use this check.
1703+
*/
1704+
if (!portal->atStart)
1705+
execute_is_fetch= true;
1706+
16961707
/*
16971708
* If the original query was a null string, just return
16981709
* EmptyQueryResponse.
@@ -1704,7 +1715,13 @@ exec_execute_message(const char *portal_name, long max_rows)
17041715
return;
17051716
}
17061717

1707-
if (portal->sourceText)
1718+
/* Should we display the portal names here? */
1719+
if (execute_is_fetch)
1720+
{
1721+
debug_query_string="fetch message";
1722+
pgstat_report_activity("<FETCH>");
1723+
}
1724+
elseif (portal->sourceText)
17081725
{
17091726
debug_query_string=portal->sourceText;
17101727
pgstat_report_activity(portal->sourceText);
@@ -1732,7 +1749,8 @@ exec_execute_message(const char *portal_name, long max_rows)
17321749
if (log_statement==LOGSTMT_ALL)
17331750
/* We have the portal, so output the source query. */
17341751
ereport(LOG,
1735-
(errmsg("statement: EXECUTE %s [PREPARE: %s]",
1752+
(errmsg("statement: %sEXECUTE %s [PREPARE: %s]",
1753+
(execute_is_fetch) ?"FETCH from " :"",
17361754
(*portal_name!='\0') ?portal_name :"<unnamed>",
17371755
portal->sourceText ?portal->sourceText :"")));
17381756

@@ -1864,10 +1882,11 @@ exec_execute_message(const char *portal_name, long max_rows)
18641882
(save_log_min_duration_statement>0&&
18651883
usecs >=save_log_min_duration_statement*1000))
18661884
ereport(LOG,
1867-
(errmsg("duration: %ld.%03ld ms statement:EXECUTE %s [PREPARE: %s]",
1885+
(errmsg("duration: %ld.%03ld ms statement:%sEXECUTE %s [PREPARE: %s]",
18681886
(long) ((stop_t.tv_sec-start_t.tv_sec)*1000+
18691887
(stop_t.tv_usec-start_t.tv_usec) /1000),
18701888
(long) (stop_t.tv_usec-start_t.tv_usec) %1000,
1889+
(execute_is_fetch) ?"FETCH from " :"",
18711890
(*portal_name!='\0') ?portal_name :"<unnamed>",
18721891
portal->sourceText ?portal->sourceText :"")));
18731892
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp