index 272fb32c58f232456878e20b0a53ed6779b95a21..1f6edf6cafa1f0078b17f357b5eb7ec10a2ab2e1 100644 (file)
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.275 2009年05月12日 16:43:32 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.276 2009年06月10日 18:54:16 tgl Exp $
*
*
* INTERFACE ROUTINES
@@ -93,7 +93,7 @@ static bool HeapSatisfiesHOTUpdate(Relation relation, Bitmapset *hot_attrs,
* ----------------
*/
static void
-initscan(HeapScanDesc scan, ScanKey key)
+initscan(HeapScanDesc scan, ScanKey key, bool is_rescan)
{
bool allow_strat;
bool allow_sync;
scan->rs_strategy = NULL;
}
- if (allow_sync && synchronize_seqscans)
+ if (is_rescan)
+ {
+ /*
+ * If rescan, keep the previous startblock setting so that rewinding
+ * a cursor doesn't generate surprising results. Reset the syncscan
+ * setting, though.
+ */
+ scan->rs_syncscan = (allow_sync && synchronize_seqscans);
+ }
+ else if (allow_sync && synchronize_seqscans)
{
scan->rs_syncscan = true;
scan->rs_startblock = ss_get_location(scan->rs_rd, scan->rs_nblocks);
@@ -1218,7 +1227,7 @@ heap_beginscan_internal(Relation relation, Snapshot snapshot,
else
scan->rs_key = NULL;
- initscan(scan, key);
+ initscan(scan, key, false);
return scan;
}
/*
* reinitialize scan descriptor
*/
- initscan(scan, key);
+ initscan(scan, key, true);
}
/* ----------------