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)
274 bool hasNullQuery =
false;
291 so->totalentries = 0;
292 so->allocentries = 32;
296 so->isVoidRes =
false;
298 for (
i = 0;
i < scan->numberOfKeys;
i++)
302 int32 nQueryValues = 0;
303 bool *partial_matches = NULL;
305 bool *nullFlags = NULL;
315 so->isVoidRes =
true;
320 queryValues = (
Datum *)
322 so->ginstate.supportCollation[skey->
sk_attno - 1],
347 if (queryValues == NULL || nQueryValues <= 0)
351 so->isVoidRes =
true;
367 for (
j = 0;
j < nQueryValues;
j++)
380 queryValues, categories,
381 partial_matches, extra_data);
385 attrHasNormalScan[skey->
sk_attno - 1] =
true;
396 for (
i = 0;
i < so->nkeys;
i++)
403 if (!attrHasNormalScan[
key->attnum - 1])
405 key->excludeOnly =
false;
407 attrHasNormalScan[
key->attnum - 1] =
true;
415 if (so->nkeys == 0 && !so->isVoidRes)
421 NULL, NULL, NULL, NULL);
429 if (hasNullQuery && !so->isVoidRes)
436 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
437 errmsg(
"old GIN indexes do not support whole-index scans nor searches for nulls"),
438 errhint(
"To fix this, do REINDEX INDEX \"%s\".",
445 if (scan->instrument)
446 scan->instrument->nsearches++;
451 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)