48 elog(
ERROR,
"failed to add item to GiST index page, item %d out of %d, size %d bytes",
60 unsigned int size = freespace,
116 memmove(&itvec[*
len], additvec,
sizeof(
IndexTuple) * addlen);
134 for (
i = 0;
i < veclen;
i++)
137 ptr = ret =
palloc(*memlen);
139 for (
i = 0;
i < veclen;
i++)
155 Datum *attr,
bool *isnull)
235 Datum *dst,
bool *dstisnull)
248 if (isnull1 && isnull2)
255 if (isnull1 ==
false && isnull2 ==
false)
257 evec->
vector[0] = *entry1;
258 evec->
vector[1] = *entry2;
260 else if (isnull1 ==
false)
262 evec->
vector[0] = *entry1;
263 evec->
vector[1] = *entry1;
267 evec->
vector[0] = *entry2;
268 evec->
vector[1] = *entry2;
317 bool neednew =
false;
336 oldentries +
i, oldisnull[
i],
337 addentries +
i, addisnull[
i],
338 attr +
i, isnull +
i);
383 int keep_current_best;
404 best_penalty[0] = -1;
429 keep_current_best = -1;
458 &identry[
j], isnull[
j]);
460 zero_penalty =
false;
462 if (best_penalty[
j] < 0 || usize < best_penalty[
j])
473 best_penalty[
j] = usize;
476 best_penalty[
j + 1] = -1;
479 keep_current_best = -1;
481 else if (best_penalty[
j] == usize)
496 zero_penalty =
false;
507 if (keep_current_best == -1)
512 if (keep_current_best == 0)
517 keep_current_best = -1;
529 if (keep_current_best == -1)
534 if (keep_current_best == 1)
575 const Datum *attdata,
const bool *isnull,
bool isleaf)
596 const Datum *attdata,
const bool *isnull,
bool isleaf,
Datum *compatt)
622 compatt[
i] = cep->
key;
636 compatt[
i] = attdata[
i];
730 (isNullOrig ==
false && isNullAdd ==
false))
738 if (isnan(penalty) || penalty < 0.0)
741 else if (isNullOrig && isNullAdd)
796 (
errcode(ERRCODE_INDEX_CORRUPTED),
797 errmsg(
"index \"%s\" contains unexpected zero page at block %u",
800 errhint(
"Please REINDEX it.")));
807 (
errcode(ERRCODE_INDEX_CORRUPTED),
808 errmsg(
"index \"%s\" contains corrupted page at block %u",
811 errhint(
"Please REINDEX it.")));
934 bool *
res,
bool *isnull)
1017 if (rel->
rd_rel->relpersistence == RELPERSISTENCE_TEMP)
1054 Assert(rel->
rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED);
@ AMPROP_DISTANCE_ORDERABLE
#define InvalidBlockNumber
BlockNumber BufferGetBlockNumber(Buffer buffer)
Buffer ExtendBufferedRel(BufferManagerRelation bmr, ForkNumber forkNum, BufferAccessStrategy strategy, uint32 flags)
bool ConditionalLockBuffer(Buffer buffer)
void ReleaseBuffer(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
static Page BufferGetPage(Buffer buffer)
void PageInit(Page page, Size pageSize, Size specialSize)
Size PageGetFreeSpace(Page page)
static bool PageIsEmpty(Page page)
static Item PageGetItem(Page page, ItemId itemId)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static bool PageIsNew(Page page)
static OffsetNumber PageGetMaxOffsetNumber(Page page)
#define PageAddItem(page, item, size, offsetNumber, overwrite, is_heap)
static uint16 PageGetSpecialSize(Page page)
#define Assert(condition)
#define OidIsValid(objectId)
static void PGresult * res
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
static float4 get_float4_infinity(void)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Datum FunctionCall3Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3)
Datum FunctionCall1Coll(FmgrInfo *flinfo, Oid collation, Datum arg1)
struct GISTENTRY GISTENTRY
#define GIST_COMPRESS_PROC
#define GistPageIsLeaf(page)
#define GIST_DISTANCE_PROC
static FullTransactionId GistPageGetDeleteXid(Page page)
#define GistPageIsDeleted(page)
#define GistPageGetOpaque(page)
#define gistentryinit(e, k, r, pg, o, l)
void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, OffsetNumber o, GISTENTRY *attdata, bool *isnull)
Buffer gistNewBuffer(Relation r, Relation heaprel)
bool gistproperty(Oid index_oid, int attno, IndexAMProperty prop, const char *propname, bool *res, bool *isnull)
bool gistPageRecyclable(Page page)
void gistMakeUnionKey(GISTSTATE *giststate, int attno, GISTENTRY *entry1, bool isnull1, GISTENTRY *entry2, bool isnull2, Datum *dst, bool *dstisnull)
void gistMakeUnionItVec(GISTSTATE *giststate, IndexTuple *itvec, int len, Datum *attr, bool *isnull)
bool gistnospace(Page page, IndexTuple *itvec, int len, OffsetNumber todelete, Size freespace)
HeapTuple gistFetchTuple(GISTSTATE *giststate, Relation r, IndexTuple tuple)
bool gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)
static Datum gistFetchAtt(GISTSTATE *giststate, int nkey, Datum k, Relation r)
void gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)
IndexTuple gistFormTuple(GISTSTATE *giststate, Relation r, const Datum *attdata, const bool *isnull, bool isleaf)
IndexTuple * gistextractpage(Page page, int *len)
void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, bool l, bool isNull)
bool gistfitpage(IndexTuple *itvec, int len)
IndexTuple gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *giststate)
OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, GISTSTATE *giststate)
XLogRecPtr gistGetFakeLSN(Relation rel)
void gistCompressValues(GISTSTATE *giststate, Relation r, const Datum *attdata, const bool *isnull, bool isleaf, Datum *compatt)
IndexTuple * gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen)
void gistinitpage(Page page, uint32 f)
bytea * gistoptions(Datum reloptions, bool validate)
IndexTuple gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate)
void GISTInitBuffer(Buffer b, uint32 f)
IndexTupleData * gistfillitupvec(IndexTuple *vec, int veclen, int *memlen)
void gistcheckpage(Relation rel, Buffer buf)
float gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *orig, bool isNullOrig, GISTENTRY *add, bool isNullAdd)
XLogRecPtr gistXLogAssignLSN(void)
void gistXLogPageReuse(Relation rel, Relation heaprel, BlockNumber blkno, FullTransactionId deleteXid)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
BlockNumber GetFreeIndexPage(Relation rel)
IndexTuple index_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
struct ItemIdData ItemIdData
static void ItemPointerSetOffsetNumber(ItemPointerData *pointer, OffsetNumber offsetNumber)
IndexTupleData * IndexTuple
#define IndexTupleSize(itup)
static Datum index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
bool get_opclass_opfamily_and_input_type(Oid opclass, Oid *opfamily, Oid *opcintype)
Oid get_index_column_opclass(Oid index_oid, int attno)
void * repalloc(void *pointer, Size size)
#define InvalidOffsetNumber
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
pg_prng_state pg_global_prng_state
bool pg_prng_bool(pg_prng_state *state)
static Datum PointerGetDatum(const void *X)
static Datum Int16GetDatum(int16 X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
bool GlobalVisCheckRemovableFullXid(Relation rel, FullTransactionId fxid)
MemoryContextSwitchTo(old_ctx)
#define RelationGetRelationName(relation)
#define RelationNeedsWAL(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
#define RelationIsPermanent(relation)
void * build_reloptions(Datum reloptions, bool validate, relopt_kind kind, Size relopt_struct_size, const relopt_parse_elt *relopt_elems, int num_relopt_elems)
static pg_noinline void Size size
FmgrInfo fetchFn[INDEX_MAX_KEYS]
FmgrInfo penaltyFn[INDEX_MAX_KEYS]
Oid supportCollation[INDEX_MAX_KEYS]
FmgrInfo decompressFn[INDEX_MAX_KEYS]
FmgrInfo compressFn[INDEX_MAX_KEYS]
FmgrInfo equalFn[INDEX_MAX_KEYS]
FmgrInfo unionFn[INDEX_MAX_KEYS]
GISTENTRY vector[FLEXIBLE_ARRAY_MEMBER]
#define SearchSysCacheExists4(cacheId, key1, key2, key3, key4)
XLogRecPtr GetXLogInsertRecPtr(void)
XLogRecPtr GetFakeLSNForUnloggedRel(void)
#define XLogStandbyInfoActive()
#define FirstNormalUnloggedLSN
#define XLogRecPtrIsInvalid(r)
#define InvalidXLogRecPtr