177#define BRINSORTTUPLE_SIZE(len) (offsetof(BrinSortTuple, tuple) + (len))
183 Oid *sortOperators,
Oid *sortCollations,
199 "begin tuple sort: nkeys = %d, workMem = %d, randomAccess = %c",
222 for (
i = 0;
i < nkeys;
i++)
230 sortKey->ssup_collation = sortCollations[
i];
274 "begin tuple sort: nkeys = %d, workMem = %d, randomAccess = %c",
301 if (
arg->indexInfo->ii_IndexAttrNumbers[0] == 0)
306 arg->tupDesc = tupDesc;
310 if (
arg->indexInfo->ii_Expressions !=
NULL)
363 bool uniqueNullsNotDistinct,
381 "begin index sort: unique = %c, workMem = %d, randomAccess = %c",
382 enforceUnique ?
't' :
'f',
402 arg->index.heapRel = heapRel;
403 arg->index.indexRel = indexRel;
404 arg->enforceUnique = enforceUnique;
405 arg->uniqueNullsNotDistinct = uniqueNullsNotDistinct;
462 "begin index sort: high_mask = 0x%x, low_mask = 0x%x, "
463 "max_buckets = 0x%x, workMem = %d, randomAccess = %c",
480 arg->index.heapRel = heapRel;
481 arg->index.indexRel = indexRel;
483 arg->high_mask = high_mask;
484 arg->low_mask = low_mask;
485 arg->max_buckets = max_buckets;
511 "begin index sort: workMem = %d, randomAccess = %c",
524 arg->index.heapRel = heapRel;
525 arg->index.indexRel = indexRel;
526 arg->enforceUnique =
false;
527 arg->uniqueNullsNotDistinct =
false;
539 sortKey->ssup_nulls_first =
false;
566 "begin index sort: workMem = %d, randomAccess = %c",
600 "begin index sort: workMem = %d, randomAccess = %c",
624 sortKey->ssup_nulls_first =
false;
647 errmsg(
"could not identify a comparison function for type %s",
686 "begin datum sort: workMem = %d, randomAccess = %c",
706 arg->datumType = datumType;
710 arg->datumTypeLen = typlen;
781 !
stup.isnull1, tuplen);
811 arg->indexInfo->ii_IndexAttrNumbers[0],
825 !
stup.isnull1, tuplen);
848 tuple->
t_tid = *self;
864 !
stup.isnull1, tuplen);
882 bstup->tuplen = size;
887 stup.isnull1 =
false;
898 !
stup.isnull1, tuplen);
918 stup.isnull1 =
false;
929 !
stup.isnull1, tuplen);
959 if (isNull || !base->
tuples)
966 stup.isnull1 = isNull;
971 stup.isnull1 =
false;
1020 *abbrev =
stup.datum1;
1103 return &
btup->tuple;
1173 *abbrev =
stup.datum1;
1178 *isNull =
stup.isnull1;
1205 for (
i = 0;
i < count;
i++)
1230 b->datum1,
b->isnull1,
1261 if (
sortKey->abbrev_converter)
1324 tuple->
t_len = tuplen;
1328 stup->tuple = tuple;
1350 for (
i = 0;
i < count;
i++)
1356 arg->indexInfo->ii_IndexAttrNumbers[0],
1374 b->datum1,
b->isnull1,
1402 tupDesc =
arg->tupDesc;
1407 if (
sortKey->abbrev_converter)
1430 if (
arg->indexInfo->ii_Expressions ==
NULL)
1517 tuple->
t_len = t_len;
1525 stup->tuple = tuple;
1529 arg->indexInfo->ii_IndexAttrNumbers[0],
1565 for (
i = 0;
i < count;
i++)
1592 b->datum1,
b->isnull1,
1622 keysz = base->
nKeys;
1625 if (
sortKey->abbrev_converter)
1688 errmsg(
"could not create unique index \"%s\"",
1743 arg->max_buckets,
arg->high_mask,
1747 arg->max_buckets,
arg->high_mask,
1813 unsigned int tuplen;
1828 unsigned int tuplen =
len -
sizeof(
unsigned int);
1834 stup->tuple = tuple;
1851 for (
i = 0;
i < count;
i++)
1881 unsigned int tuplen = tuple->
tuplen;
1883 tuplen = tuplen +
sizeof(tuplen);
1896 unsigned int tuplen =
len -
sizeof(
unsigned int);
1910 stup->tuple = tuple;
1924 elog(
ERROR,
"removeabbrev_index_gin not implemented");
1945 unsigned int tuplen = tuple->
tuplen;
1947 tuplen = tuplen +
sizeof(tuplen);
1960 unsigned int tuplen =
len -
sizeof(
unsigned int);
1973 stup->tuple = tuple;
1988 for (
i = 0;
i < count;
i++)
1999 b->datum1,
b->isnull1,
2028 unsigned int tuplen;
2039 tuplen =
sizeof(
Datum);
2061 unsigned int tuplen =
len -
sizeof(
unsigned int);
2067 stup->isnull1 =
true;
2074 stup->isnull1 =
false;
2083 stup->isnull1 =
false;
2084 stup->tuple = raddr;
static Datum values[MAXATTR]
#define Assert(condition)
#define OidIsValid(objectId)
Datum datumCopy(Datum value, bool typByVal, int typLen)
Size datumGetSize(Datum value, bool typByVal, int typLen)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
TupleTableSlot * ExecStoreMinimalTuple(MinimalTuple mtup, TupleTableSlot *slot, bool shouldFree)
const TupleTableSlotOps TTSOpsHeapTuple
TupleTableSlot * ExecStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
void FreeExecutorState(EState *estate)
EState * CreateExecutorState(void)
#define ResetPerTupleExprContext(estate)
#define GetPerTupleExprContext(estate)
#define palloc_object(type)
#define palloc0_object(type)
char * BuildIndexValueDescription(Relation indexRelation, const Datum *values, const bool *isnull)
static int compare(const void *arg1, const void *arg2)
int _gin_compare_tuples(GinTuple *a, GinTuple *b, SortSupport ssup)
Bucket _hash_hashkey2bucket(uint32 hashkey, uint32 maxbucket, uint32 highmask, uint32 lowmask)
HeapTuple heap_copytuple(HeapTuple tuple)
MinimalTuple heap_copy_minimal_tuple(MinimalTuple mtup, Size extra)
HeapTupleData * HeapTuple
MinimalTupleData * MinimalTuple
HeapTupleHeaderData * HeapTupleHeader
#define MINIMAL_TUPLE_OFFSET
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
#define MINIMAL_TUPLE_DATA_OFFSET
IndexInfo * BuildIndexInfo(Relation index)
void FormIndexDatum(IndexInfo *indexInfo, TupleTableSlot *slot, EState *estate, Datum *values, bool *isnull)
RegProcedure index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum)
void index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor, Datum *values, bool *isnull)
IndexTuple index_form_tuple_context(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull, MemoryContext context)
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
IndexTupleData * IndexTuple
static Datum index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
static Size IndexTupleSize(const IndexTupleData *itup)
void LogicalTapeWrite(LogicalTape *lt, const void *ptr, size_t size)
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
void pfree(void *pointer)
Size GetMemoryChunkSpace(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
#define SK_BT_NULLS_FIRST
BTScanInsert _bt_mkscankey(Relation rel, IndexTuple itup)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
FormData_pg_attribute * Form_pg_attribute
static uint32 DatumGetUInt32(Datum X)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
static Datum UInt32GetDatum(uint32 X)
#define RelationGetDescr(relation)
#define RelationGetNumberOfAttributes(relation)
#define RelationGetRelationName(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
int errtableconstraint(Relation rel, const char *conname)
void PrepareSortSupportFromGistIndexRel(Relation indexRel, SortSupport ssup)
void PrepareSortSupportComparisonShim(Oid cmpFunc, SortSupport ssup)
void PrepareSortSupportFromIndexRel(Relation indexRel, bool reverse, SortSupport ssup)
void PrepareSortSupportFromOrderingOp(Oid orderingOp, SortSupport ssup)
static int ApplySortAbbrevFullComparator(Datum datum1, bool isNull1, Datum datum2, bool isNull2, SortSupport ssup)
struct SortSupportData * SortSupport
static int ApplySortComparator(Datum datum1, bool isNull1, Datum datum2, bool isNull2, SortSupport ssup)
TupleTableSlot * ecxt_scantuple
Datum(* abbrev_converter)(Datum original, SortSupport ssup)
bool uniqueNullsNotDistinct
MemoryContext maincontext
void(* writetup)(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
void(* removeabbrev)(Tuplesortstate *state, SortTuple *stups, int count)
void(* freestate)(Tuplesortstate *state)
MemoryContext tuplecontext
MemoryContext sortcontext
void(* readtup)(Tuplesortstate *state, SortTuple *stup, LogicalTape *tape, unsigned int len)
SortTupleComparator comparetup
SortTupleComparator comparetup_tiebreak
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
struct TupleDescData * TupleDesc
Tuplesortstate * tuplesort_begin_common(int workMem, SortCoordinate coordinate, int sortopt)
void tuplesort_puttuple_common(Tuplesortstate *state, SortTuple *tuple, bool useAbbrev, Size tuplen)
bool tuplesort_gettuple_common(Tuplesortstate *state, bool forward, SortTuple *stup)
void * tuplesort_readtup_alloc(Tuplesortstate *state, Size tuplen)
#define TupleSortUseBumpTupleCxt(opt)
#define PARALLEL_SORT(coordinate)
#define TUPLESORT_RANDOMACCESS
#define LogicalTapeReadExact(tape, ptr, len)
#define TuplesortstateGetPublic(state)
IndexTuple tuplesort_getindextuple(Tuplesortstate *state, bool forward)
static void writetup_index_brin(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
Tuplesortstate * tuplesort_begin_index_gin(Relation heapRel, Relation indexRel, int workMem, SortCoordinate coordinate, int sortopt)
HeapTuple tuplesort_getheaptuple(Tuplesortstate *state, bool forward)
static void removeabbrev_datum(Tuplesortstate *state, SortTuple *stups, int count)
static int comparetup_index_btree_tiebreak(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
void tuplesort_putdatum(Tuplesortstate *state, Datum val, bool isNull)
static int comparetup_index_btree(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
GinTuple * tuplesort_getgintuple(Tuplesortstate *state, Size *len, bool forward)
static void readtup_index(Tuplesortstate *state, SortTuple *stup, LogicalTape *tape, unsigned int len)
static int comparetup_cluster_tiebreak(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
static void writetup_index_gin(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
void tuplesort_puttupleslot(Tuplesortstate *state, TupleTableSlot *slot)
static int comparetup_datum(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
Tuplesortstate * tuplesort_begin_index_brin(int workMem, SortCoordinate coordinate, int sortopt)
Tuplesortstate * tuplesort_begin_heap(TupleDesc tupDesc, int nkeys, AttrNumber *attNums, Oid *sortOperators, Oid *sortCollations, bool *nullsFirstFlags, int workMem, SortCoordinate coordinate, int sortopt)
Tuplesortstate * tuplesort_begin_cluster(TupleDesc tupDesc, Relation indexRel, int workMem, SortCoordinate coordinate, int sortopt)
BrinTuple * tuplesort_getbrintuple(Tuplesortstate *state, Size *len, bool forward)
static void removeabbrev_index(Tuplesortstate *state, SortTuple *stups, int count)
Tuplesortstate * tuplesort_begin_index_btree(Relation heapRel, Relation indexRel, bool enforceUnique, bool uniqueNullsNotDistinct, int workMem, SortCoordinate coordinate, int sortopt)
static int comparetup_datum_tiebreak(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
static void readtup_datum(Tuplesortstate *state, SortTuple *stup, LogicalTape *tape, unsigned int len)
static void readtup_heap(Tuplesortstate *state, SortTuple *stup, LogicalTape *tape, unsigned int len)
static void readtup_cluster(Tuplesortstate *state, SortTuple *stup, LogicalTape *tape, unsigned int tuplen)
Tuplesortstate * tuplesort_begin_index_gist(Relation heapRel, Relation indexRel, int workMem, SortCoordinate coordinate, int sortopt)
static void writetup_datum(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
void tuplesort_putindextuplevalues(Tuplesortstate *state, Relation rel, const ItemPointerData *self, const Datum *values, const bool *isnull)
static int comparetup_heap(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
bool tuplesort_gettupleslot(Tuplesortstate *state, bool forward, bool copy, TupleTableSlot *slot, Datum *abbrev)
static void removeabbrev_index_brin(Tuplesortstate *state, SortTuple *stups, int count)
#define BRINSORTTUPLE_SIZE(len)
void tuplesort_putgintuple(Tuplesortstate *state, GinTuple *tuple, Size size)
static int comparetup_index_hash(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
static void readtup_index_brin(Tuplesortstate *state, SortTuple *stup, LogicalTape *tape, unsigned int len)
Tuplesortstate * tuplesort_begin_datum(Oid datumType, Oid sortOperator, Oid sortCollation, bool nullsFirstFlag, int workMem, SortCoordinate coordinate, int sortopt)
void tuplesort_putbrintuple(Tuplesortstate *state, BrinTuple *tuple, Size size)
static void writetup_heap(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
static void writetup_index(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
static void readtup_index_gin(Tuplesortstate *state, SortTuple *stup, LogicalTape *tape, unsigned int len)
static void removeabbrev_index_gin(Tuplesortstate *state, SortTuple *stups, int count)
Tuplesortstate * tuplesort_begin_index_hash(Relation heapRel, Relation indexRel, uint32 high_mask, uint32 low_mask, uint32 max_buckets, int workMem, SortCoordinate coordinate, int sortopt)
static int comparetup_heap_tiebreak(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
static void freestate_cluster(Tuplesortstate *state)
static void removeabbrev_heap(Tuplesortstate *state, SortTuple *stups, int count)
void tuplesort_putheaptuple(Tuplesortstate *state, HeapTuple tup)
static int comparetup_cluster(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
static int comparetup_index_brin(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
static int comparetup_index_hash_tiebreak(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
bool tuplesort_getdatum(Tuplesortstate *state, bool forward, bool copy, Datum *val, bool *isNull, Datum *abbrev)
static void writetup_cluster(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
static void removeabbrev_cluster(Tuplesortstate *state, SortTuple *stups, int count)
static int comparetup_index_gin(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
static MinimalTuple ExecCopySlotMinimalTuple(TupleTableSlot *slot)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_CMP_PROC_FINFO