77 * Portions Copyright (c) 1994, Regents of the University of California
88 *
99 * IDENTIFICATION
10- * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.152 2010/02/17 00:52:09 tgl Exp $
10+ * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.153 2010/02/17 16:54:06 tgl Exp $
1111 *
1212 *-------------------------------------------------------------------------
1313 */
@@ -1951,6 +1951,7 @@ asyncQueueReadAllNotifications(void)
19511951 * The function returns true once we have reached the stop position or an
19521952 * uncommitted notification, and false if we have finished with the page.
19531953 * In other words: once it returns true there is no need to look further.
1954+ * The QueuePosition *current is advanced past all processed messages.
19541955 */
19551956static bool
19561957asyncQueueProcessPageEntries (QueuePosition * current ,
@@ -1963,10 +1964,12 @@ asyncQueueProcessPageEntries(QueuePosition *current,
19631964
19641965 do
19651966 {
1966- if (QUEUE_POS_EQUAL (* current , stop ))
1967+ QueuePosition thisentry = * current ;
1968+
1969+ if (QUEUE_POS_EQUAL (thisentry , stop ))
19671970 break ;
19681971
1969- qe = (AsyncQueueEntry * ) (page_buffer + QUEUE_POS_OFFSET (* current ));
1972+ qe = (AsyncQueueEntry * ) (page_buffer + QUEUE_POS_OFFSET (thisentry ));
19701973
19711974 /*
19721975 * Advance *current over this message, possibly to the next page.
@@ -2002,8 +2005,14 @@ asyncQueueProcessPageEntries(QueuePosition *current,
20022005 {
20032006 /*
20042007 * The transaction has neither committed nor aborted so far,
2005- * so we can't process its message yet. Break out of the loop.
2008+ * so we can't process its message yet. Break out of the loop,
2009+ * but first back up *current so we will reprocess the message
2010+ * next time. (Note: it is unlikely but not impossible for
2011+ * TransactionIdDidCommit to fail, so we can't really avoid
2012+ * this advance-then-back-up behavior when dealing with an
2013+ * uncommitted message.)
20062014 */
2015+ * current = thisentry ;
20072016 reachedStop = true;
20082017 break ;
20092018 }
0 commit comments