25#define LTPRS_WAITNAME 0
26#define LTPRS_WAITDELIM 1
50#define UNCHAR ereturn(escontext, NULL,\
51 errcode(ERRCODE_SYNTAX_ERROR), \
52 errmsg("ltree syntax error at character %d", \
67 errmsg(
"number of ltree labels (%d) exceeds the maximum allowed (%d)",
100 elog(
ERROR,
"internal error in ltree parser");
118 errmsg(
"ltree syntax error"),
239 elog(
ERROR,
"unsupported ltree version number %d", version);
249#define LQPRS_WAITLEVEL 0
250#define LQPRS_WAITDELIM 1
251#define LQPRS_WAITOPEN 2
252#define LQPRS_WAITFNUM 3
253#define LQPRS_WAITSNUM 4
254#define LQPRS_WAITND 5
255#define LQPRS_WAITCLOSE 6
256#define LQPRS_WAITEND 7
257#define LQPRS_WAITVAR 8
260#define GETVAR(x) ( *((nodeitem**)LQL_FIRST(x)) )
261#define ITEMSIZE MAXALIGN(LQL_HDRSIZE+sizeof(nodeitem*))
262#define NEXTLEV(x) ( (lquery_level*)( ((char*)(x)) + ITEMSIZE) )
287#define UNCHAR ereturn(escontext, NULL,\
288 errcode(ERRCODE_SYNTAX_ERROR), \
289 errmsg("lquery syntax error at character %d", \
299 else if (
t_iseq(ptr,
'|'))
309 errmsg(
"number of lquery items (%d) exceeds the maximum allowed (%d)",
327 else if (
t_iseq(ptr,
'!'))
330 lptr->start = ptr + 1;
337 else if (
t_iseq(ptr,
'*'))
351 errmsg(
"lquery level has too many variants"),
352 errdetail(
"Number of variants exceeds the maximum allowed (%d).",
364 else if (
t_iseq(ptr,
'*'))
369 else if (
t_iseq(ptr,
'%'))
374 else if (
t_iseq(ptr,
'|'))
380 else if (
t_iseq(ptr,
'{'))
387 else if (
t_iseq(ptr,
'.'))
406 else if (
t_iseq(ptr,
'.'))
420 else if (
isdigit((
unsigned char) *ptr))
427 errmsg(
"lquery syntax error"),
428 errdetail(
"Low limit (%d) exceeds the maximum allowed (%d), at character %d.",
438 if (
isdigit((
unsigned char) *ptr))
440 int high =
atoi(ptr);
445 errmsg(
"lquery syntax error"),
446 errdetail(
"High limit (%d) exceeds the maximum allowed (%d), at character %d.",
451 errmsg(
"lquery syntax error"),
452 errdetail(
"Low limit (%d) is greater than high limit (%d), at character %d.",
458 else if (
t_iseq(ptr,
'}'))
469 else if (!
isdigit((
unsigned char) *ptr))
478 else if (
t_iseq(ptr,
','))
480 else if (!
isdigit((
unsigned char) *ptr))
493 elog(
ERROR,
"internal error in lquery parser");
512 errmsg(
"lquery syntax error"),
556 errmsg(
"lquery level is too large"),
557 errdetail(
"Total size of level exceeds the maximum allowed (%d bytes).",
569 if (
cur->numvar > 1 ||
cur->flag != 0)
601 struct Node *escontext)
625 errmsg(
"lquery syntax error at character %d", pos) :
626 errmsg(
"ltree syntax error at character %d", pos),
627 errdetail(
"Empty labels are not allowed.")));
631 errmsg(
"label string is too long"),
632 errdetail(
"Label length is %d, must be at most %d, at character %d.",
660 totallen += 2 * 11 + 3;
663 totallen += 2 * 11 + 4;
823 elog(
ERROR,
"unsupported lquery version number %d", version);
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
unsigned int ltree_crc32_sz(const char *buf, int size)
int errcode(int sqlerrcode)
#define ereturn(context, dummy_value,...)
int errdetail(const char *fmt,...) pg_attribute_printf(1
#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)
static bool pg_add_u16_overflow(uint16 a, uint16 b, uint16 *result)
#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_cstr(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)