24#define LTPRS_WAITNAME 0
25#define LTPRS_WAITDELIM 1
49#define UNCHAR ereturn(escontext, NULL,\
50 errcode(ERRCODE_SYNTAX_ERROR), \
51 errmsg("ltree syntax error at character %d", \
66 errmsg(
"number of ltree labels (%d) exceeds the maximum allowed (%d)",
99 elog(
ERROR,
"internal error in ltree parser");
117 errmsg(
"ltree syntax error"),
238 elog(
ERROR,
"unsupported ltree version number %d", version);
248#define LQPRS_WAITLEVEL 0
249#define LQPRS_WAITDELIM 1
250#define LQPRS_WAITOPEN 2
251#define LQPRS_WAITFNUM 3
252#define LQPRS_WAITSNUM 4
253#define LQPRS_WAITND 5
254#define LQPRS_WAITCLOSE 6
255#define LQPRS_WAITEND 7
256#define LQPRS_WAITVAR 8
259#define GETVAR(x) ( *((nodeitem**)LQL_FIRST(x)) )
260#define ITEMSIZE MAXALIGN(LQL_HDRSIZE+sizeof(nodeitem*))
261#define NEXTLEV(x) ( (lquery_level*)( ((char*)(x)) + ITEMSIZE) )
286#define UNCHAR ereturn(escontext, NULL,\
287 errcode(ERRCODE_SYNTAX_ERROR), \
288 errmsg("lquery syntax error at character %d", \
298 else if (
t_iseq(ptr,
'|'))
308 errmsg(
"number of lquery items (%d) exceeds the maximum allowed (%d)",
326 else if (
t_iseq(ptr,
'!'))
329 lptr->start = ptr + 1;
336 else if (
t_iseq(ptr,
'*'))
358 else if (
t_iseq(ptr,
'*'))
363 else if (
t_iseq(ptr,
'%'))
368 else if (
t_iseq(ptr,
'|'))
374 else if (
t_iseq(ptr,
'{'))
381 else if (
t_iseq(ptr,
'.'))
400 else if (
t_iseq(ptr,
'.'))
414 else if (
isdigit((
unsigned char) *ptr))
421 errmsg(
"lquery syntax error"),
422 errdetail(
"Low limit (%d) exceeds the maximum allowed (%d), at character %d.",
432 if (
isdigit((
unsigned char) *ptr))
434 int high =
atoi(ptr);
439 errmsg(
"lquery syntax error"),
440 errdetail(
"High limit (%d) exceeds the maximum allowed (%d), at character %d.",
445 errmsg(
"lquery syntax error"),
446 errdetail(
"Low limit (%d) is greater than high limit (%d), at character %d.",
452 else if (
t_iseq(ptr,
'}'))
463 else if (!
isdigit((
unsigned char) *ptr))
472 else if (
t_iseq(ptr,
','))
474 else if (!
isdigit((
unsigned char) *ptr))
487 elog(
ERROR,
"internal error in lquery parser");
506 errmsg(
"lquery syntax error"),
554 if (
cur->numvar > 1 ||
cur->flag != 0)
586 struct Node *escontext)
610 errmsg(
"lquery syntax error at character %d", pos) :
611 errmsg(
"ltree syntax error at character %d", pos),
612 errdetail(
"Empty labels are not allowed.")));
616 errmsg(
"label string is too long"),
617 errdetail(
"Label length is %d, must be at most %d, at character %d.",
645 totallen += 2 * 11 + 3;
648 totallen += 2 * 11 + 4;
808 elog(
ERROR,
"unsupported lquery version number %d", version);
unsigned int ltree_crc32_sz(const char *buf, int size)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
#define palloc_array(type, count)
#define palloc0_array(type, count)
#define PG_RETURN_BYTEA_P(x)
#define PG_GETARG_POINTER(n)
#define PG_FUNCTION_INFO_V1(funcname)
#define PG_RETURN_POINTER(x)
#define PG_GETARG_LQUERY_P(n)
#define LQUERY_MAX_LEVELS
#define LTREE_LABEL_MAX_CHARS
#define PG_GETARG_LTREE_P(n)
static ltree * parse_ltree(const char *buf, struct Node *escontext)
Datum ltree_recv(PG_FUNCTION_ARGS)
Datum lquery_out(PG_FUNCTION_ARGS)
Datum lquery_in(PG_FUNCTION_ARGS)
Datum ltree_in(PG_FUNCTION_ARGS)
Datum ltree_send(PG_FUNCTION_ARGS)
Datum lquery_send(PG_FUNCTION_ARGS)
static bool finish_nodeitem(nodeitem *lptr, const char *ptr, bool is_lquery, int pos, struct Node *escontext)
static char * deparse_ltree(const ltree *in)
Datum lquery_recv(PG_FUNCTION_ARGS)
static lquery * parse_lquery(const char *buf, struct Node *escontext)
static char * deparse_lquery(const lquery *in)
Datum ltree_out(PG_FUNCTION_ARGS)
int pg_mblen(const char *mbstr)
void pfree(void *pointer)
void * palloc0(Size size)
static char buf[DEFAULT_XLOG_SEG_SIZE]
struct StringInfoData * StringInfo
static Size VARSIZE(const void *PTR)
static void SET_VARSIZE(void *PTR, Size len)