/* Look up nodeChar in the node label array */ if (searchChar(in->nodeLabels, in->nNodes, nodeChar, &i))
{ /* *Descendtoexistingnode.(Ifin->allTheSame,thecorecodewill *ignoreournodeNspecificationhere,butthat'sOK.Westillhave *toprovidethecorrectlevelAddandrestDatumvalues,andthoseare *thesameregardlessofwhichnodegetschosenbycore.)
*/ int levelAdd;
/* The picksplit function is identical to the core opclass, so just use that */
PG_FUNCTION_INFO_V1(spgist_name_inner_consistent);
Datum
spgist_name_inner_consistent(PG_FUNCTION_ARGS)
{
spgInnerConsistentIn *in = (spgInnerConsistentIn *) PG_GETARG_POINTER(0);
spgInnerConsistentOut *out = (spgInnerConsistentOut *) PG_GETARG_POINTER(1);
text *reconstructedValue;
text *reconstrText; int maxReconstrLen;
text *prefixText = NULL; int prefixSize = 0; int i;
if (in->level)
memcpy(VARDATA(reconstrText),
VARDATA(reconstructedValue),
in->level); if (prefixSize)
memcpy(((char *) VARDATA(reconstrText)) + in->level,
VARDATA_ANY(prefixText),
prefixSize); /* last byte of reconstrText will be filled in below */
for (i = 0; i < in->nNodes; i++)
{
int16 nodeChar = DatumGetInt16(in->nodeLabels[i]); int thisLen; bool res = true; int j;
/* If nodeChar is a dummy value, don't include it in data */ if (nodeChar <= 0)
thisLen = maxReconstrLen - 1; else
{
((unsignedchar *) VARDATA(reconstrText))[maxReconstrLen - 1] = nodeChar;
thisLen = maxReconstrLen;
}
for (j = 0; j < in->nkeys; j++)
{
StrategyNumber strategy = in->scankeys[j].sk_strategy;
Name inName; char *inStr; int inSize; int r;
r = memcmp(VARDATA(reconstrText), inStr,
Min(inSize, thisLen));
switch (strategy)
{ case BTLessStrategyNumber: case BTLessEqualStrategyNumber: if (r > 0)
res = false; break; case BTEqualStrategyNumber: if (r != 0 || inSize < thisLen)
res = false; break; case BTGreaterEqualStrategyNumber: case BTGreaterStrategyNumber: if (r < 0)
res = false; break; default:
elog(ERROR, "unrecognized strategy number: %d",
in->scankeys[j].sk_strategy); break;
}
if (!res) break; /* no need to consider remaining conditions */
}
/* Reconstruct the Name represented by this leaf tuple */
fullValue = palloc0(NAMEDATALEN);
fullLen = level + VARSIZE_ANY_EXHDR(leafValue);
Assert(fullLen < NAMEDATALEN); if (VARSIZE_ANY_EXHDR(leafValue) == 0 && level > 0)
{
memcpy(fullValue, VARDATA(reconstrValue),
VARSIZE_ANY_EXHDR(reconstrValue));
} else
{ if (level)
memcpy(fullValue, VARDATA(reconstrValue), level); if (VARSIZE_ANY_EXHDR(leafValue) > 0)
memcpy(fullValue + level, VARDATA_ANY(leafValue),
VARSIZE_ANY_EXHDR(leafValue));
}
out->leafValue = PointerGetDatum(fullValue);
/* Perform the required comparison(s) */
res = true; for (j = 0; j < in->nkeys; j++)
{
StrategyNumber strategy = in->scankeys[j].sk_strategy;
Name queryName = DatumGetName(in->scankeys[j].sk_argument); char *queryStr = NameStr(*queryName); int queryLen = strlen(queryStr); int r;
/* Non-collation-aware comparison */
r = memcmp(fullValue, queryStr, Min(queryLen, fullLen));
if (r == 0)
{ if (queryLen > fullLen)
r = -1; elseif (queryLen < fullLen)
r = 1;
}
switch (strategy)
{ case BTLessStrategyNumber:
res = (r < 0); break; case BTLessEqualStrategyNumber:
res = (r <= 0); break; case BTEqualStrategyNumber:
res = (r == 0); break; case BTGreaterEqualStrategyNumber:
res = (r >= 0); break; case BTGreaterStrategyNumber:
res = (r > 0); break; default:
elog(ERROR, "unrecognized strategy number: %d",
in->scankeys[j].sk_strategy);
res = false; break;
}
if (!res) break; /* no need to consider remaining conditions */
}
PG_RETURN_BOOL(res);
}
PG_FUNCTION_INFO_V1(spgist_name_compress);
Datum
spgist_name_compress(PG_FUNCTION_ARGS)
{
Name inName = PG_GETARG_NAME(0); char *inStr = NameStr(*inName);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.