40 "Gin scan temporary context",
43 "Gin scan key context",
60 bool isPartialMatch,
Pointer extra_data)
116 scanEntry->
list = NULL;
117 scanEntry->
nlist = 0;
146 int i =
key->nentries++;
151 (
Datum) 0, queryCategory,
163 bool *partial_matches,
Pointer *extra_data)
169 key->nentries = nQueryValues;
170 key->nuserentries = nQueryValues;
179 key->queryValues = queryValues;
180 key->queryCategories = queryCategories;
181 key->extra_data = extra_data;
182 key->strategy = strategy;
183 key->searchMode = searchMode;
193 key->curItemMatches =
false;
194 key->recheckCurItem =
false;
195 key->isFinished =
false;
197 key->nadditional = 0;
198 key->requiredEntries = NULL;
199 key->additionalEntries = NULL;
204 for (
i = 0;
i < nQueryValues;
i++)
211 queryKey = queryValues[
i];
212 queryCategory = queryCategories[
i];
215 ? partial_matches[
i] :
false;
216 this_extra = (extra_data) ? extra_data[
i] : NULL;
219 strategy, searchMode,
220 queryKey, queryCategory,
221 isPartialMatch, this_extra);
243 if (so->
keys == NULL)
275 bool hasNullQuery =
false;
292 so->totalentries = 0;
293 so->allocentries = 32;
297 so->isVoidRes =
false;
299 for (
i = 0;
i < scan->numberOfKeys;
i++)
303 int32 nQueryValues = 0;
304 bool *partial_matches = NULL;
306 bool *nullFlags = NULL;
316 so->isVoidRes =
true;
321 queryValues = (
Datum *)
323 so->ginstate.supportCollation[skey->
sk_attno - 1],
348 if (queryValues == NULL || nQueryValues <= 0)
352 so->isVoidRes =
true;
368 for (
j = 0;
j < nQueryValues;
j++)
381 queryValues, categories,
382 partial_matches, extra_data);
386 attrHasNormalScan[skey->
sk_attno - 1] =
true;
398 for (
i = 0;
i < so->nkeys;
i++)
405 if (!attrHasNormalScan[
key->attnum - 1])
407 key->excludeOnly =
false;
409 attrHasNormalScan[
key->attnum - 1] =
true;
419 if (numExcludeOnly > 0)
426 Assert(numExcludeOnly < so->nkeys);
431 iExcludeOnly = so->nkeys - numExcludeOnly;
432 for (
i = 0;
i < so->nkeys;
i++)
436 if (
key->excludeOnly)
447 Assert(iNormalKey == so->nkeys - numExcludeOnly);
448 Assert(iExcludeOnly == so->nkeys);
458 if (so->nkeys == 0 && !so->isVoidRes)
464 NULL, NULL, NULL, NULL);
472 if (hasNullQuery && !so->isVoidRes)
479 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
480 errmsg(
"old GIN indexes do not support whole-index scans nor searches for nulls"),
481 errhint(
"To fix this, do REINDEX INDEX \"%s\".",
488 if (scan->instrument)
489 scan->instrument->nsearches++;
494 ScanKey orderbys,
int norderbys)
#define InvalidBlockNumber
void ReleaseBuffer(Buffer buffer)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Datum FunctionCall7Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7)
IndexScanDesc RelationGetIndexScan(Relation indexRelation, int nkeys, int norderbys)
#define GIN_SEARCH_MODE_ALL
#define GIN_SEARCH_MODE_EVERYTHING
#define GIN_SEARCH_MODE_DEFAULT
#define GIN_SEARCH_MODE_INCLUDE_EMPTY
struct GinScanKeyData GinScanKeyData
GinScanOpaqueData * GinScanOpaque
struct GinScanEntryData * GinScanEntry
struct GinScanKeyData * GinScanKey
#define GIN_CAT_EMPTY_ITEM
signed char GinNullCategory
#define ItemPointerSetMin(p)
#define GIN_CAT_EMPTY_QUERY
void ginInitConsistentFunction(GinState *ginstate, GinScanKey key)
IndexScanDesc ginbeginscan(Relation rel, int nkeys, int norderbys)
void ginFreeScanKeys(GinScanOpaque so)
static void ginFillScanKey(GinScanOpaque so, OffsetNumber attnum, StrategyNumber strategy, int32 searchMode, Datum query, uint32 nQueryValues, Datum *queryValues, GinNullCategory *queryCategories, bool *partial_matches, Pointer *extra_data)
void ginendscan(IndexScanDesc scan)
void ginNewScanKey(IndexScanDesc scan)
void ginrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys, ScanKey orderbys, int norderbys)
static void ginScanKeyAddHiddenEntry(GinScanOpaque so, GinScanKey key, GinNullCategory queryCategory)
static GinScanEntry ginFillScanEntry(GinScanOpaque so, OffsetNumber attnum, StrategyNumber strategy, int32 searchMode, Datum queryKey, GinNullCategory queryCategory, bool isPartialMatch, Pointer extra_data)
void ginGetStats(Relation index, GinStatsData *stats)
void initGinState(GinState *state, Relation index)
int ginCompareEntries(GinState *ginstate, OffsetNumber attnum, Datum a, GinNullCategory categorya, Datum b, GinNullCategory categoryb)
Assert(PointerIsAligned(start, uint64))
void MemoryContextReset(MemoryContext context)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define InvalidOffsetNumber
#define FirstOffsetNumber
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define pgstat_count_index_scan(rel)
static Datum PointerGetDatum(const void *X)
static Datum UInt16GetDatum(uint16 X)
static Pointer DatumGetPointer(Datum X)
#define RelationGetRelationName(relation)
TBMIterateResult matchResult
TBMPrivateIterator * matchIterator
GinNullCategory queryCategory
bool canPartialMatch[INDEX_MAX_KEYS]
struct ScanKeyData * keyData
StrategyNumber sk_strategy
void tbm_free(TIDBitmap *tbm)
void tbm_end_private_iterate(TBMPrivateIterator *iterator)