49 elog(
ERROR,
"failed to add item to GiST index page, item %d out of %d, size %d bytes",
61 unsigned int size = freespace,
117 memmove(&itvec[*
len], additvec,
sizeof(
IndexTuple) * addlen);
135 for (
i = 0;
i < veclen;
i++)
138 ptr = ret =
palloc(*memlen);
140 for (
i = 0;
i < veclen;
i++)
156 Datum *attr,
bool *isnull)
236 Datum *dst,
bool *dstisnull)
249 if (isnull1 && isnull2)
256 if (isnull1 ==
false && isnull2 ==
false)
258 evec->
vector[0] = *entry1;
259 evec->
vector[1] = *entry2;
261 else if (isnull1 ==
false)
263 evec->
vector[0] = *entry1;
264 evec->
vector[1] = *entry1;
268 evec->
vector[0] = *entry2;
269 evec->
vector[1] = *entry2;
318 bool neednew =
false;
337 oldentries +
i, oldisnull[
i],
338 addentries +
i, addisnull[
i],
339 attr +
i, isnull +
i);
384 int keep_current_best;
405 best_penalty[0] = -1;
430 keep_current_best = -1;
459 &identry[
j], isnull[
j]);
461 zero_penalty =
false;
463 if (best_penalty[
j] < 0 || usize < best_penalty[
j])
474 best_penalty[
j] = usize;
477 best_penalty[
j + 1] = -1;
480 keep_current_best = -1;
482 else if (best_penalty[
j] == usize)
497 zero_penalty =
false;
508 if (keep_current_best == -1)
513 if (keep_current_best == 0)
518 keep_current_best = -1;
530 if (keep_current_best == -1)
535 if (keep_current_best == 1)
576 Datum *attdata,
bool *isnull,
bool isleaf)
597 Datum *attdata,
bool *isnull,
bool isleaf,
Datum *compatt)
623 compatt[
i] = cep->
key;
637 compatt[
i] = attdata[
i];
731 (isNullOrig ==
false && isNullAdd ==
false))
739 if (isnan(penalty) || penalty < 0.0)
742 else if (isNullOrig && isNullAdd)
797 (
errcode(ERRCODE_INDEX_CORRUPTED),
798 errmsg(
"index \"%s\" contains unexpected zero page at block %u",
801 errhint(
"Please REINDEX it.")));
808 (
errcode(ERRCODE_INDEX_CORRUPTED),
809 errmsg(
"index \"%s\" contains corrupted page at block %u",
812 errhint(
"Please REINDEX it.")));
944 bool *
res,
bool *isnull)
1027 if (rel->
rd_rel->relpersistence == RELPERSISTENCE_TEMP)
1064 Assert(rel->
rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED);
@ AMPROP_DISTANCE_ORDERABLE
#define InvalidBlockNumber
BlockNumber BufferGetBlockNumber(Buffer buffer)
bool ConditionalLockBuffer(Buffer buffer)
void ReleaseBuffer(Buffer buffer)
void LockBuffer(Buffer buffer, int mode)
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
#define BufferGetPage(buffer)
void PageInit(Page page, Size pageSize, Size specialSize)
Size PageGetFreeSpace(Page page)
#define PageGetSpecialSize(page)
#define PageGetMaxOffsetNumber(page)
#define PageGetItemId(page, offsetNumber)
#define PageIsEmpty(page)
#define PageGetItem(page, itemId)
#define PageAddItem(page, item, size, offsetNumber, overwrite, is_heap)
#define offsetof(type, field)
#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)
IndexTuple gistFormTuple(GISTSTATE *giststate, Relation r, Datum *attdata, bool *isnull, bool isleaf)
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)
Buffer gistNewBuffer(Relation r)
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 * 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)
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 gistCompressValues(GISTSTATE *giststate, Relation r, Datum *attdata, bool *isnull, bool isleaf, Datum *compatt)
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, BlockNumber blkno, FullTransactionId latestRemovedXid)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
BlockNumber GetFreeIndexPage(Relation rel)
IndexTuple index_form_tuple(TupleDesc tupleDescriptor, Datum *values, bool *isnull)
struct ItemIdData ItemIdData
#define ItemPointerSetOffsetNumber(pointer, offsetNumber)
#define index_getattr(tup, attnum, tupleDesc, isnull)
IndexTupleData * IndexTuple
#define IndexTupleSize(itup)
Assert(fmt[strlen(fmt) - 1] !='\n')
void LockRelationForExtension(Relation relation, LOCKMODE lockmode)
void UnlockRelationForExtension(Relation relation, LOCKMODE lockmode)
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
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
pg_prng_state pg_global_prng_state
bool pg_prng_bool(pg_prng_state *state)
#define DatumGetPointer(X)
#define ObjectIdGetDatum(X)
#define PointerGetDatum(X)
bool GlobalVisCheckRemovableFullXid(Relation rel, FullTransactionId fxid)
#define RELATION_IS_LOCAL(relation)
#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)
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