mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Revise the TIDBitmap API to support multiple concurrent iterations over a
bitmap. This is extracted from Greg Stark's posix_fadvise patch; it seems worth committing separately, since it's potentially useful independently of posix_fadvise.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.21 2009/01/01 17:23:34 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/gin/ginget.c,v 1.22 2009/01/10 21:08:36 tgl Exp $
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -290,6 +290,7 @@ startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry)
|
||||
entry->list = NULL;
|
||||
entry->nlist = 0;
|
||||
entry->partialMatch = NULL;
|
||||
entry->partialMatchIterator = NULL;
|
||||
entry->partialMatchResult = NULL;
|
||||
entry->reduceResult = FALSE;
|
||||
entry->predictNumberResult = 0;
|
||||
@@ -311,6 +312,9 @@ startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry)
|
||||
*/
|
||||
if ( entry->partialMatch )
|
||||
{
|
||||
if (entry->partialMatchIterator)
|
||||
tbm_end_iterate(entry->partialMatchIterator);
|
||||
entry->partialMatchIterator = NULL;
|
||||
tbm_free( entry->partialMatch );
|
||||
entry->partialMatch = NULL;
|
||||
}
|
||||
@@ -323,7 +327,7 @@ startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry)
|
||||
|
||||
if ( entry->partialMatch && !tbm_is_empty(entry->partialMatch) )
|
||||
{
|
||||
tbm_begin_iterate(entry->partialMatch);
|
||||
entry->partialMatchIterator = tbm_begin_iterate(entry->partialMatch);
|
||||
entry->isFinished = FALSE;
|
||||
}
|
||||
}
|
||||
@@ -534,11 +538,13 @@ entryGetItem(Relation index, GinScanEntry entry)
|
||||
{
|
||||
if ( entry->partialMatchResult == NULL || entry->offset >= entry->partialMatchResult->ntuples )
|
||||
{
|
||||
entry->partialMatchResult = tbm_iterate( entry->partialMatch );
|
||||
entry->partialMatchResult = tbm_iterate( entry->partialMatchIterator );
|
||||
|
||||
if ( entry->partialMatchResult == NULL )
|
||||
{
|
||||
ItemPointerSet(&entry->curItem, InvalidBlockNumber, InvalidOffsetNumber);
|
||||
tbm_end_iterate(entry->partialMatchIterator);
|
||||
entry->partialMatchIterator = NULL;
|
||||
entry->isFinished = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/gin/ginscan.c,v 1.20 2009/01/01 17:23:34 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/gin/ginscan.c,v 1.21 2009/01/10 21:08:36 tgl Exp $
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@@ -61,6 +61,8 @@ fillScanKey(GinState *ginstate, GinScanKey key, OffsetNumber attnum, Datum query
|
||||
key->scanEntry[i].offset = InvalidOffsetNumber;
|
||||
key->scanEntry[i].buffer = InvalidBuffer;
|
||||
key->scanEntry[i].partialMatch = NULL;
|
||||
key->scanEntry[i].partialMatchIterator = NULL;
|
||||
key->scanEntry[i].partialMatchResult = NULL;
|
||||
key->scanEntry[i].strategy = strategy;
|
||||
key->scanEntry[i].list = NULL;
|
||||
key->scanEntry[i].nlist = 0;
|
||||
@@ -107,6 +109,7 @@ resetScanKeys(GinScanKey keys, uint32 nkeys)
|
||||
key->scanEntry[j].list = NULL;
|
||||
key->scanEntry[j].nlist = 0;
|
||||
key->scanEntry[j].partialMatch = NULL;
|
||||
key->scanEntry[j].partialMatchIterator = NULL;
|
||||
key->scanEntry[j].partialMatchResult = NULL;
|
||||
}
|
||||
}
|
||||
@@ -132,6 +135,8 @@ freeScanKeys(GinScanKey keys, uint32 nkeys)
|
||||
ReleaseBuffer(key->scanEntry[j].buffer);
|
||||
if (key->scanEntry[j].list)
|
||||
pfree(key->scanEntry[j].list);
|
||||
if (key->scanEntry[j].partialMatchIterator)
|
||||
tbm_end_iterate(key->scanEntry[j].partialMatchIterator);
|
||||
if (key->scanEntry[j].partialMatch)
|
||||
tbm_free(key->scanEntry[j].partialMatch);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user