56 for (
i = 0;
i < gsvp->
len;
i++)
61 cleanedItVec[cleanedLen++] = itvec[gsvp->
entries[
i] - 1];
132 float penalty =
gistpenalty(giststate, attno, &entry,
false,
148 float penalty =
gistpenalty(giststate, attno, &entry,
false,
174 origlen = newlen = *
len;
176 for (
i = 0;
i < origlen;
i++)
180 if (dontcare[ai] ==
false)
218 identry + attno, isnull[attno]);
221 identry + attno, isnull[attno]);
223 if (lpenalty != rpenalty)
225 if (lpenalty > rpenalty)
237#define SWAPVAR( s, d, t ) \
261 bool leaveOnLeft =
true,
278 penalty1 =
gistpenalty(giststate, attno, &entryL,
false, &entrySL,
false) +
279 gistpenalty(giststate, attno, &entryR,
false, &entrySR,
false);
280 penalty2 =
gistpenalty(giststate, attno, &entryL,
false, &entrySR,
false) +
281 gistpenalty(giststate, attno, &entryR,
false, &entrySL,
false);
283 if (penalty1 > penalty2)
302 penalty1 =
gistpenalty(giststate, attno, entry1,
false, &entrySL,
false);
303 penalty2 =
gistpenalty(giststate, attno, entry1,
false, &entrySR,
false);
305 if (penalty1 < penalty2)
311 if (leaveOnLeft ==
false)
351 maxoff = entryvec->
n - 1;
445 (
errcode(ERRCODE_INTERNAL_ERROR),
446 errmsg(
"picksplit method for column %d of index \"%s\" failed",
448 errhint(
"The index is not optimal. To optimize it, contact a developer, or try to use the column as the second one in the CREATE INDEX command.")));
545 if (NumDontCare == 1)
562 Assert(toMove < entryvec->n);
565 placeOne(r, giststate, v, itup[toMove - 1], toMove, attno + 1);
592 for (
i = 1;
i <=
len;
i++)
628 int nOffNullTuples = 0;
634 entryvec->
n =
len + 1;
637 for (
i = 1;
i <=
len;
i++)
648 offNullTuples[nOffNullTuples++] =
i;
651 if (nOffNullTuples ==
len)
665 else if (nOffNullTuples > 0)
679 for (
i = 1;
i <=
len;
i++)
680 if (j < v->splitVector.spl_nright && offNullTuples[
j] ==
i)
728 newitup[newlen] = itup[
i];
747 gistSplitByKey(r, page, newitup, newlen, giststate, v, attno + 1);
#define Assert(condition)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
#define gistentryinit(e, k, r, pg, o, l)
static void removeDontCares(OffsetNumber *a, int *len, const bool *dontcare)
static void supportSecondarySplit(Relation r, GISTSTATE *giststate, int attno, GIST_SPLITVEC *sv, Datum oldL, Datum oldR)
static void genericPickSplit(GISTSTATE *giststate, GistEntryVector *entryvec, GIST_SPLITVEC *v, int attno)
static void placeOne(Relation r, GISTSTATE *giststate, GistSplitVector *v, IndexTuple itup, OffsetNumber off, int attno)
static void gistunionsubkey(GISTSTATE *giststate, IndexTuple *itvec, GistSplitVector *spl)
void gistSplitByKey(Relation r, Page page, IndexTuple *itup, int len, GISTSTATE *giststate, GistSplitVector *v, int attno)
static bool gistUserPicksplit(Relation r, GistEntryVector *entryvec, int attno, GistSplitVector *v, IndexTuple *itup, int len, GISTSTATE *giststate)
static int findDontCares(Relation r, GISTSTATE *giststate, GISTENTRY *valvec, GistSplitVector *spl, int attno)
static void gistunionsubkeyvec(GISTSTATE *giststate, IndexTuple *itvec, GistSplitUnion *gsvp)
static void gistSplitHalf(GIST_SPLITVEC *v, int len)
void gistDeCompressAtt(GISTSTATE *giststate, Relation r, IndexTuple tuple, Page p, OffsetNumber o, GISTENTRY *attdata, bool *isnull)
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 gistKeyIsEQ(GISTSTATE *giststate, int attno, Datum a, Datum b)
void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, Datum k, Relation r, Page pg, OffsetNumber o, bool l, bool isNull)
float gistpenalty(GISTSTATE *giststate, int attno, GISTENTRY *orig, bool isNullOrig, GISTENTRY *add, bool isNullAdd)
static Datum index_getattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
void pfree(void *pointer)
void * palloc0(Size size)
#define InvalidOffsetNumber
#define OffsetNumberNext(offsetNumber)
#define FirstOffsetNumber
static Datum PointerGetDatum(const void *X)
#define RelationGetRelationName(relation)
Oid supportCollation[INDEX_MAX_KEYS]
FmgrInfo unionFn[INDEX_MAX_KEYS]
FmgrInfo picksplitFn[INDEX_MAX_KEYS]
GISTENTRY vector[FLEXIBLE_ARRAY_MEMBER]
GIST_SPLITVEC splitVector
Datum spl_lattr[INDEX_MAX_KEYS]
bool spl_lisnull[INDEX_MAX_KEYS]
Datum spl_rattr[INDEX_MAX_KEYS]
bool spl_risnull[INDEX_MAX_KEYS]