69 #define SPGIST_MAX_PREFIX_LENGTH Max((int) (BLCKSZ - 258 * 16 - 100), 32)
81 #define SPG_STRATEGY_ADDITION (10)
82 #define SPG_IS_COLLATION_AWARE_STRATEGY(s) ((s) > SPG_STRATEGY_ADDITION \
83 && (s) != RTPrefixStrategyNumber)
141 while (
i < lena &&
i < lenb && *
a == *
b)
162 while (StopLow < StopHigh)
164 int StopMiddle = (StopLow + StopHigh) >> 1;
168 StopHigh = StopMiddle;
170 StopLow = StopMiddle + 1;
190 char *prefixStr = NULL;
209 if (commonLen == prefixSize)
211 if (inSize - in->
level > commonLen)
212 nodeChar = *(
unsigned char *) (inStr + in->
level + commonLen);
239 if (prefixSize - commonLen == 1)
248 prefixSize - commonLen - 1);
254 else if (inSize > in->
level)
256 nodeChar = *(
unsigned char *) (inStr + in->
level);
276 levelAdd = commonLen;
280 if (inSize - in->
level - levelAdd > 0)
283 inSize - in->
level - levelAdd);
328 return aa->
c - bb->
c;
343 for (
i = 1;
i < in->
nTuples && commonLen > 0;
i++)
380 nodes[
i].
c = *(
unsigned char *) (
VARDATA_ANY(texti) + commonLen);
405 if (
i == 0 || nodes[
i].
c != nodes[
i - 1].
c)
430 text *reconstructedValue;
433 text *prefixText = NULL;
449 Assert(reconstructedValue == NULL ? in->
level == 0 :
452 maxReconstrLen = in->
level + 1;
457 maxReconstrLen += prefixSize;
492 thisLen = maxReconstrLen - 1;
495 ((
unsigned char *)
VARDATA(reconstrText))[maxReconstrLen - 1] = nodeChar;
496 thisLen = maxReconstrLen;
526 Min(inSize, thisLen));
536 if (r != 0 || inSize < thisLen)
549 elog(
ERROR,
"unrecognized strategy number: %d",
577 int level = in->
level;
579 *reconstrValue = NULL;
594 Assert(reconstrValue == NULL ? level == 0 :
601 fullValue =
VARDATA(reconstrValue);
611 memcpy(fullValue,
VARDATA(reconstrValue), level);
633 res = (level >= queryLen) ||
660 r = memcmp(fullValue,
VARDATA_ANY(query),
Min(queryLen, fullLen));
664 if (queryLen > fullLen)
666 else if (queryLen < fullLen)
689 elog(
ERROR,
"unrecognized strategy number: %d",
Datum datumCopy(Datum value, bool typByVal, int typLen)
static void PGresult * res
elog(ERROR, "%s: %s", p2, msg)
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)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum Int16GetDatum(int16 X)
static Pointer DatumGetPointer(Datum X)
static int16 DatumGetInt16(Datum X)
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
struct spgChooseOut::@47::@49 addNode
spgChooseResultType resultType
union spgChooseOut::@47 result
struct spgChooseOut::@47::@50 splitTuple
struct spgChooseOut::@47::@48 matchNode
Datum * reconstructedValues
#define SET_VARSIZE_SHORT(PTR, len)
#define SET_VARSIZE(PTR, len)
#define VARSIZE_ANY_EXHDR(PTR)
int varstr_cmp(const char *arg1, int len1, const char *arg2, int len2, Oid collid)
Datum text_starts_with(PG_FUNCTION_ARGS)