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)
14661466else
14671467portal = CreatePortal (portal_name , false, false);
14681468
1469+ /* We need to output the parameter values someday */
14691470if (log_statement == LOGSTMT_ALL )
14701471ereport (LOG ,
14711472(errmsg ("statement: <BIND> %s" ,portal_name )));
@@ -1681,6 +1682,7 @@ exec_execute_message(const char *portal_name, long max_rows)
16811682bool save_log_duration = log_duration ;
16821683int save_log_min_duration_statement = log_min_duration_statement ;
16831684bool save_log_statement_stats = log_statement_stats ;
1685+ bool execute_is_fetch = false;
16841686
16851687/* Adjust destination to tell printtup.c what to do */
16861688dest = whereToSendOutput ;
@@ -1693,6 +1695,15 @@ exec_execute_message(const char *portal_name, long max_rows)
16931695(errcode (ERRCODE_UNDEFINED_CURSOR ),
16941696errmsg ("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)
17041715return ;
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+ else if (portal -> sourceText )
17081725{
17091726debug_query_string = portal -> sourceText ;
17101727pgstat_report_activity (portal -> sourceText );
@@ -1732,7 +1749,8 @@ exec_execute_message(const char *portal_name, long max_rows)
17321749if (log_statement == LOGSTMT_ALL )
17331750/* We have the portal, so output the source query. */
17341751ereport (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>" ,
17371755portal -> 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 &&
18651883usecs >=save_log_min_duration_statement * 1000 ))
18661884ereport (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>" ,
18721891portal -> sourceText ?portal -> sourceText :"" )));
18731892}