50 while (an > 0 && bn > 0)
57 return (al->
len - bl->
len) * 10 * (an + 1);
65 return res * 10 * (an + 1);
74 return (
a->numlevel -
b->numlevel) * 10 * (an + 1);
78 ltree *a = PG_GETARG_LTREE_P(0); \
79 ltree *b = PG_GETARG_LTREE_P(1); \
80 int res = ltree_compare(a,b); \
81 PG_FREE_IF_COPY(a,0); \
139 int an =
a->numlevel;
153 result = (result << 5) - result + levelHash;
170 int an =
a->numlevel;
189 result = (result << 5) - result + levelHash;
203 int res =
a->numlevel;
216 if (pn >
c->numlevel)
269 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
270 errmsg(
"invalid positions")));
275 start = end = (
char *) ptr;
279 start = (
char *) ptr;
332 end = (fcinfo->nargs == 3) ?
start : 0xffff;
344 int numlevel = (int)
a->numlevel +
b->numlevel;
348 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
349 errmsg(
"number of ltree levels (%d) exceeds the maximum allowed (%d)",
416 if (-
start >=
a->numlevel)
422 if (
a->numlevel - start < b->numlevel ||
a->numlevel == 0 ||
b->numlevel == 0)
430 for (
i = 0;
i <=
a->numlevel -
b->numlevel;
i++)
436 for (
j = 0;
j <
b->numlevel;
j++)
444 if (
j ==
b->numlevel)
506 if ((*a)->numlevel == 0)
510 num = (*a)->numlevel - 1;
514 while (ptr -
a <
len)
516 if ((*ptr)->numlevel == 0)
518 else if ((*ptr)->numlevel == 1)
524 tmp =
Min(num, (*ptr)->numlevel - 1);
526 for (
i = 0;
i < tmp;
i++)
543 for (
i = 0;
i < num;
i++)
557 for (
i = 0;
i < num;
i++)
575 for (
i = 0;
i < fcinfo->nargs;
i++)
578 for (
i = 0;
i < fcinfo->nargs;
i++)
624 memcpy(ptr, curlevel->
name, curlevel->
len);
625 ptr += curlevel->
len;
static void PGresult * res
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_FREE_IF_COPY(ptr, n)
#define PG_RETURN_UINT32(x)
#define PG_GETARG_TEXT_PP(n)
#define PG_RETURN_FLOAT8(x)
#define PG_GETARG_POINTER(n)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_INT64(n)
#define PG_RETURN_UINT64(x)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_RETURN_POINTER(x)
#define PG_RETURN_BOOL(x)
static Datum hash_any_extended(const unsigned char *k, int keylen, uint64 seed)
static Datum hash_any(const unsigned char *k, int keylen)
if(TABLE==NULL||TABLE_index==NULL)
#define PG_GETARG_LTREE_P(n)
PGDLLEXPORT Datum ltree_in(PG_FUNCTION_ARGS)
static ltree * inner_subltree(ltree *t, int32 startpos, int32 endpos)
Datum lca(PG_FUNCTION_ARGS)
bool inner_isparent(const ltree *c, const ltree *p)
Datum hash_ltree_extended(PG_FUNCTION_ARGS)
Datum ltree_index(PG_FUNCTION_ARGS)
Datum ltree_cmp(PG_FUNCTION_ARGS)
Datum subltree(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(ltree_cmp)
Datum ltree_gt(PG_FUNCTION_ARGS)
Datum nlevel(PG_FUNCTION_ARGS)
Datum ltree_textadd(PG_FUNCTION_ARGS)
int ltree_compare(const ltree *a, const ltree *b)
Datum ltreeparentsel(PG_FUNCTION_ARGS)
Datum ltree_eq(PG_FUNCTION_ARGS)
static ltree * ltree_concat(ltree *a, ltree *b)
Datum ltree_ge(PG_FUNCTION_ARGS)
Datum ltree_isparent(PG_FUNCTION_ARGS)
Datum ltree_addtext(PG_FUNCTION_ARGS)
Datum ltree_ne(PG_FUNCTION_ARGS)
Datum text2ltree(PG_FUNCTION_ARGS)
Datum ltree_risparent(PG_FUNCTION_ARGS)
Datum ltree2text(PG_FUNCTION_ARGS)
Datum hash_ltree(PG_FUNCTION_ARGS)
Datum ltree_le(PG_FUNCTION_ARGS)
Datum ltree_lt(PG_FUNCTION_ARGS)
Datum ltree_addltree(PG_FUNCTION_ARGS)
Datum subpath(PG_FUNCTION_ARGS)
ltree * lca_inner(ltree **a, int len)
void pfree(void *pointer)
void * palloc0(Size size)
static XLogRecPtr startpos
static uint32 DatumGetUInt32(Datum X)
static uint64 DatumGetUInt64(Datum X)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
double generic_restriction_selectivity(PlannerInfo *root, Oid oproid, Oid collation, List *args, int varRelid, double default_selectivity)
char name[FLEXIBLE_ARRAY_MEMBER]
#define SET_VARSIZE(PTR, len)
char * text_to_cstring(const text *t)