40 "Gin scan temporary context",
43 "Gin scan key context",
60 bool isPartialMatch,
Pointer extra_data)
116 scanEntry->
list = NULL;
117 scanEntry->
nlist = 0;
145 int i =
key->nentries++;
150 (
Datum) 0, queryCategory,
162 bool *partial_matches,
Pointer *extra_data)
168 key->nentries = nQueryValues;
169 key->nuserentries = nQueryValues;
176 key->queryValues = queryValues;
177 key->queryCategories = queryCategories;
178 key->extra_data = extra_data;
179 key->strategy = strategy;
180 key->searchMode = searchMode;
190 key->curItemMatches =
false;
191 key->recheckCurItem =
false;
192 key->isFinished =
false;
194 key->nadditional = 0;
195 key->requiredEntries = NULL;
196 key->additionalEntries = NULL;
201 for (
i = 0;
i < nQueryValues;
i++)
208 queryKey = queryValues[
i];
209 queryCategory = queryCategories[
i];
212 ? partial_matches[
i] :
false;
213 this_extra = (extra_data) ? extra_data[
i] : NULL;
216 strategy, searchMode,
217 queryKey, queryCategory,
218 isPartialMatch, this_extra);
240 if (so->
keys == NULL)
272 bool hasNullQuery =
false;
289 so->totalentries = 0;
290 so->allocentries = 32;
294 so->isVoidRes =
false;
296 for (
i = 0;
i < scan->numberOfKeys;
i++)
300 int32 nQueryValues = 0;
301 bool *partial_matches = NULL;
303 bool *nullFlags = NULL;
313 so->isVoidRes =
true;
318 queryValues = (
Datum *)
320 so->ginstate.supportCollation[skey->
sk_attno - 1],
345 if (queryValues == NULL || nQueryValues <= 0)
349 so->isVoidRes =
true;
365 for (
j = 0;
j < nQueryValues;
j++)
378 queryValues, categories,
379 partial_matches, extra_data);
383 attrHasNormalScan[skey->
sk_attno - 1] =
true;
395 for (
i = 0;
i < so->nkeys;
i++)
402 if (!attrHasNormalScan[
key->attnum - 1])
404 key->excludeOnly =
false;
406 attrHasNormalScan[
key->attnum - 1] =
true;
416 if (numExcludeOnly > 0)
423 Assert(numExcludeOnly < so->nkeys);
428 iExcludeOnly = so->nkeys - numExcludeOnly;
429 for (
i = 0;
i < so->nkeys;
i++)
433 if (
key->excludeOnly)
444 Assert(iNormalKey == so->nkeys - numExcludeOnly);
445 Assert(iExcludeOnly == so->nkeys);
455 if (so->nkeys == 0 && !so->isVoidRes)
461 NULL, NULL, NULL, NULL);
469 if (hasNullQuery && !so->isVoidRes)
476 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
477 errmsg(
"old GIN indexes do not support whole-index scans nor searches for nulls"),
478 errhint(
"To fix this, do REINDEX INDEX \"%s\".",
485 if (scan->instrument)
486 scan->instrument->nsearches++;
491 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,...)
#define palloc_object(type)
#define repalloc_array(pointer, type, count)
#define palloc_array(type, count)
#define palloc0_array(type, count)
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 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 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)