Index: src/backend/tcop/postgres.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/tcop/postgres.c,v retrieving revision 1.457 diff -c -c -r1.457 postgres.c *** src/backend/tcop/postgres.c 11 Aug 2005 21:11:45 -0000 1.457 --- src/backend/tcop/postgres.c 5 Sep 2005 18:57:22 -0000 *************** *** 1681,1686 **** --- 1681,1687 ---- bool save_log_duration = log_duration; int save_log_min_duration_statement = log_min_duration_statement; bool save_log_statement_stats = log_statement_stats; + bool subsequent_fetch = false; /* Adjust destination to tell printtup.c what to do */ dest = whereToSendOutput; *************** *** 1693,1698 **** --- 1694,1707 ---- (errcode(ERRCODE_UNDEFINED_CURSOR), errmsg("portal \"%s\" does not exist", portal_name))); + /* + * 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 + */ + if (!portal->atEnd) + subsequent_fetch = true; + /* * If the original query was a null string, just return * EmptyQueryResponse. *************** *** 1704,1710 **** return; } ! if (portal->sourceText) { debug_query_string = portal->sourceText; pgstat_report_activity(portal->sourceText); --- 1713,1724 ---- return; } ! if (subsequent_fetch) ! { ! debug_query_string = "fetch message"; ! pgstat_report_activity(""); ! } ! else if (portal->sourceText) { debug_query_string = portal->sourceText; pgstat_report_activity(portal->sourceText); *************** *** 1730,1739 **** ResetUsage(); if (log_statement == LOGSTMT_ALL) ! /* We have the portal, so output the source query. */ ! ereport(LOG, (errmsg("statement: EXECUTE %s [PREPARE: %s]", portal_name, portal->sourceText ? portal->sourceText : ""))); BeginCommand(portal->commandTag, dest); --- 1744,1760 ---- ResetUsage(); if (log_statement == LOGSTMT_ALL) ! { ! if (subsequent_fetch) ! ereport(LOG, ! (errmsg("statement: FETCH %s ROWS %ld", portal_name, ! max_rows))); ! else ! /* We have the portal, so output the source query. */ ! ereport(LOG, (errmsg("statement: EXECUTE %s [PREPARE: %s]", portal_name, portal->sourceText ? portal->sourceText : ""))); + } BeginCommand(portal->commandTag, dest); *************** *** 1862,1874 **** if (save_log_min_duration_statement == 0 || (save_log_min_duration_statement > 0 && usecs >= save_log_min_duration_statement * 1000)) ! ereport(LOG, (errmsg("duration: %ld.%03ld ms statement: EXECUTE %s [PREPARE: %s]", (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + (stop_t.tv_usec - start_t.tv_usec) / 1000), (long) (stop_t.tv_usec - start_t.tv_usec) % 1000, portal_name, portal->sourceText ? portal->sourceText : ""))); } if (save_log_statement_stats) --- 1883,1906 ---- if (save_log_min_duration_statement == 0 || (save_log_min_duration_statement > 0 && usecs >= save_log_min_duration_statement * 1000)) ! { ! if (subsequent_fetch) ! ereport(LOG, ! (errmsg("duration: %ld.%03ld ms statement: FETCH %s ROWS %ld ", ! (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + ! (stop_t.tv_usec - start_t.tv_usec) / 1000), ! (long) (stop_t.tv_usec - start_t.tv_usec) % 1000, ! portal_name, ! max_rows))); ! else ! ereport(LOG, (errmsg("duration: %ld.%03ld ms statement: EXECUTE %s [PREPARE: %s]", (long) ((stop_t.tv_sec - start_t.tv_sec) * 1000 + (stop_t.tv_usec - start_t.tv_usec) / 1000), (long) (stop_t.tv_usec - start_t.tv_usec) % 1000, portal_name, portal->sourceText ? portal->sourceText : ""))); + } } if (save_log_statement_stats)