81 while (
i < lena &&
i < lenb && *
a == *
b)
102 while (StopLow < StopHigh)
104 int StopMiddle = (StopLow + StopHigh) >> 1;
108 StopHigh = StopMiddle;
110 StopLow = StopMiddle + 1;
129 char *inStr =
NameStr(*inName);
130 int inSize = strlen(inStr);
131 char *prefixStr = NULL;
150 if (commonLen == prefixSize)
152 if (inSize - in->
level > commonLen)
153 nodeChar = *(
unsigned char *) (inStr + in->
level + commonLen);
180 if (prefixSize - commonLen == 1)
189 prefixSize - commonLen - 1);
195 else if (inSize > in->
level)
197 nodeChar = *(
unsigned char *) (inStr + in->
level);
217 levelAdd = commonLen;
221 if (inSize - in->
level - levelAdd > 0)
224 inSize - in->
level - levelAdd);
270 text *reconstructedValue;
273 text *prefixText = NULL;
292 Assert(reconstructedValue == NULL ? in->
level == 0 :
295 maxReconstrLen = in->
level + 1;
300 maxReconstrLen += prefixSize;
335 thisLen = maxReconstrLen - 1;
338 ((
unsigned char *)
VARDATA(reconstrText))[maxReconstrLen - 1] = nodeChar;
339 thisLen = maxReconstrLen;
352 inSize = strlen(inStr);
354 r = memcmp(
VARDATA(reconstrText), inStr,
355 Min(inSize, thisLen));
365 if (r != 0 || inSize < thisLen)
374 elog(
ERROR,
"unrecognized strategy number: %d",
403 int level = in->
level;
405 *reconstrValue = NULL;
420 Assert(reconstrValue == NULL ? level == 0 :
429 memcpy(fullValue,
VARDATA(reconstrValue),
435 memcpy(fullValue,
VARDATA(reconstrValue), level);
448 char *queryStr =
NameStr(*queryName);
449 int queryLen = strlen(queryStr);
453 r = memcmp(fullValue, queryStr,
Min(queryLen, fullLen));
457 if (queryLen > fullLen)
459 else if (queryLen < fullLen)
481 elog(
ERROR,
"unrecognized strategy number: %d",
499 char *inStr =
NameStr(*inName);
#define Assert(condition)
Datum datumCopy(Datum value, bool typByVal, int typLen)
static void PGresult * res
#define DatumGetTextPP(X)
#define PG_GETARG_POINTER(n)
#define PG_GETARG_NAME(n)
#define PG_RETURN_DATUM(x)
#define PG_RETURN_BOOL(x)
void * palloc0(Size size)
static Datum PointerGetDatum(const void *X)
static Name DatumGetName(Datum X)
static Datum Int16GetDatum(int16 X)
static Pointer DatumGetPointer(Datum X)
static int16 DatumGetInt16(Datum X)
PG_FUNCTION_INFO_V1(spgist_name_config)
Datum spgist_name_compress(PG_FUNCTION_ARGS)
Datum spgist_name_config(PG_FUNCTION_ARGS)
static int commonPrefix(const char *a, const char *b, int lena, int lenb)
static Datum formTextDatum(const char *data, int datalen)
Datum spgist_name_leaf_consistent(PG_FUNCTION_ARGS)
Datum spgist_name_inner_consistent(PG_FUNCTION_ARGS)
Datum spgist_name_choose(PG_FUNCTION_ARGS)
static bool searchChar(Datum *nodeLabels, int nNodes, int16 c, int *i)
#define BTGreaterStrategyNumber
#define BTLessStrategyNumber
#define BTEqualStrategyNumber
#define BTLessEqualStrategyNumber
#define BTGreaterEqualStrategyNumber
StrategyNumber sk_strategy
spgChooseResultType resultType
struct spgChooseOut::@51::@54 splitTuple
struct spgChooseOut::@51::@53 addNode
struct spgChooseOut::@51::@52 matchNode
union spgChooseOut::@51 result
Datum * reconstructedValues
#define SET_VARSIZE_SHORT(PTR, len)
#define SET_VARSIZE(PTR, len)
#define VARSIZE_ANY_EXHDR(PTR)