68 #define SPGIST_MAX_PREFIX_LENGTH Max((int) (BLCKSZ - 258 * 16 - 100), 32)
80 #define SPG_STRATEGY_ADDITION (10)
81 #define SPG_IS_COLLATION_AWARE_STRATEGY(s) ((s) > SPG_STRATEGY_ADDITION \
82 && (s) != RTPrefixStrategyNumber)
140 while (
i < lena &&
i < lenb && *
a == *
b)
161 while (StopLow < StopHigh)
163 int StopMiddle = (StopLow + StopHigh) >> 1;
167 StopHigh = StopMiddle;
169 StopLow = StopMiddle + 1;
189 char *prefixStr = NULL;
208 if (commonLen == prefixSize)
210 if (inSize - in->
level > commonLen)
211 nodeChar = *(
unsigned char *) (inStr + in->
level + commonLen);
238 if (prefixSize - commonLen == 1)
247 prefixSize - commonLen - 1);
253 else if (inSize > in->
level)
255 nodeChar = *(
unsigned char *) (inStr + in->
level);
275 levelAdd = commonLen;
279 if (inSize - in->
level - levelAdd > 0)
282 inSize - in->
level - levelAdd);
327 return aa->
c - bb->
c;
342 for (
i = 1;
i < in->
nTuples && commonLen > 0;
i++)
379 nodes[
i].
c = *(
unsigned char *) (
VARDATA_ANY(texti) + commonLen);
404 if (
i == 0 || nodes[
i].
c != nodes[
i - 1].
c)
429 text *reconstructedValue;
432 text *prefixText = NULL;
448 Assert(reconstructedValue == NULL ? in->
level == 0 :
451 maxReconstrLen = in->
level + 1;
456 maxReconstrLen += prefixSize;
491 thisLen = maxReconstrLen - 1;
494 ((
unsigned char *)
VARDATA(reconstrText))[maxReconstrLen - 1] = nodeChar;
495 thisLen = maxReconstrLen;
525 Min(inSize, thisLen));
535 if (r != 0 || inSize < thisLen)
548 elog(
ERROR,
"unrecognized strategy number: %d",
576 int level = in->
level;
578 *reconstrValue = NULL;
593 Assert(reconstrValue == NULL ? level == 0 :
600 fullValue =
VARDATA(reconstrValue);
610 memcpy(fullValue,
VARDATA(reconstrValue), level);
632 res = (level >= queryLen) ||
659 r = memcmp(fullValue,
VARDATA_ANY(query),
Min(queryLen, fullLen));
663 if (queryLen > fullLen)
665 else if (queryLen < fullLen)
688 elog(
ERROR,
"unrecognized strategy number: %d",
Datum datumCopy(Datum value, bool typByVal, int typLen)
static void PGresult * res
Datum DirectFunctionCall2Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2)
#define DatumGetTextPP(X)
#define PG_GETARG_POINTER(n)
#define PG_GET_COLLATION()
#define PG_RETURN_BOOL(x)
Assert(fmt[strlen(fmt) - 1] !='\n')
bool pg_verifymbstr(const char *mbstr, int len, bool noError)
bool lc_collate_is_c(Oid collation)
#define qsort(a, b, c, d)
#define SET_VARSIZE_SHORT(PTR, len)
#define DatumGetPointer(X)
#define SET_VARSIZE(PTR, len)
#define PointerGetDatum(X)
#define VARSIZE_ANY_EXHDR(PTR)
Datum spg_text_config(PG_FUNCTION_ARGS)
static int commonPrefix(const char *a, const char *b, int lena, int lenb)
#define SPG_IS_COLLATION_AWARE_STRATEGY(s)
static int cmpNodePtr(const void *a, const void *b)
#define SPGIST_MAX_PREFIX_LENGTH
struct spgNodePtr spgNodePtr
#define SPG_STRATEGY_ADDITION
Datum spg_text_leaf_consistent(PG_FUNCTION_ARGS)
Datum spg_text_inner_consistent(PG_FUNCTION_ARGS)
static Datum formTextDatum(const char *data, int datalen)
Datum spg_text_choose(PG_FUNCTION_ARGS)
static bool searchChar(Datum *nodeLabels, int nNodes, int16 c, int *i)
Datum spg_text_picksplit(PG_FUNCTION_ARGS)
#define RTPrefixStrategyNumber
#define BTGreaterStrategyNumber
#define BTLessStrategyNumber
#define BTEqualStrategyNumber
#define BTLessEqualStrategyNumber
#define BTGreaterEqualStrategyNumber
StrategyNumber sk_strategy
spgChooseResultType resultType
struct spgChooseOut::@48::@50 addNode
union spgChooseOut::@48 result
struct spgChooseOut::@48::@49 matchNode
struct spgChooseOut::@48::@51 splitTuple
Datum * reconstructedValues
int varstr_cmp(const char *arg1, int len1, const char *arg2, int len2, Oid collid)
Datum text_starts_with(PG_FUNCTION_ARGS)