PostgreSQL Source Code  git master
jsonpath.c File Reference
#include "postgres.h"
#include "funcapi.h"
#include "lib/stringinfo.h"
#include "libpq/pqformat.h"
#include "nodes/miscnodes.h"
#include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/json.h"
#include "utils/jsonpath.h"
Include dependency graph for jsonpath.c:

Go to the source code of this file.

Macros

#define read_byte(v, b, p)
 
#define read_int32(v, b, p)
 
#define read_int32_n(v, b, p, n)
 

Functions

static Datum jsonPathFromCstring (char *in, int len, struct Node *escontext)
 
static char * jsonPathToCstring (StringInfo out, JsonPath *in, int estimated_len)
 
static bool flattenJsonPathParseItem (StringInfo buf, int *result, struct Node *escontext, JsonPathParseItem *item, int nestingLevel, bool insideArraySubscript)
 
static void alignStringInfoInt (StringInfo buf)
 
static int32 reserveSpaceForItemPointer (StringInfo buf)
 
static void printJsonPathItem (StringInfo buf, JsonPathItem *v, bool inKey, bool printBracketes)
 
static int operationPriority (JsonPathItemType op)
 
Datum jsonpath_in (PG_FUNCTION_ARGS)
 
Datum jsonpath_recv (PG_FUNCTION_ARGS)
 
Datum jsonpath_out (PG_FUNCTION_ARGS)
 
Datum jsonpath_send (PG_FUNCTION_ARGS)
 
const char * jspOperationName (JsonPathItemType type)
 
void jspInit (JsonPathItem *v, JsonPath *js)
 
void jspInitByBuffer (JsonPathItem *v, char *base, int32 pos)
 
void jspGetArg (JsonPathItem *v, JsonPathItem *a)
 
bool jspGetNext (JsonPathItem *v, JsonPathItem *a)
 
void jspGetLeftArg (JsonPathItem *v, JsonPathItem *a)
 
void jspGetRightArg (JsonPathItem *v, JsonPathItem *a)
 
bool jspGetBool (JsonPathItem *v)
 
Numeric jspGetNumeric (JsonPathItem *v)
 
char * jspGetString (JsonPathItem *v, int32 *len)
 
bool jspGetArraySubscript (JsonPathItem *v, JsonPathItem *from, JsonPathItem *to, int i)
 

Macro Definition Documentation

◆ read_byte

#define read_byte (   v,
  b,
 
)
Value:
do { \
(v) = *(uint8*)((b) + (p)); \
(p) += 1; \
} while(0) \
unsigned char uint8
Definition: c.h:488
int b
Definition: isn.c:70

Definition at line 850 of file jsonpath.c.

◆ read_int32

#define read_int32 (   v,
  b,
 
)
Value:
do { \
(v) = *(uint32*)((b) + (p)); \
(p) += sizeof(int32); \
} while(0) \
unsigned int uint32
Definition: c.h:490
signed int int32
Definition: c.h:478

Definition at line 855 of file jsonpath.c.

◆ read_int32_n

#define read_int32_n (   v,
  b,
  p,
 
)
Value:
do { \
(v) = (void *)((b) + (p)); \
(p) += sizeof(int32) * (n); \
} while(0) \

Definition at line 860 of file jsonpath.c.

Function Documentation

◆ alignStringInfoInt()

static void alignStringInfoInt ( StringInfo  buf)
static

Definition at line 471 of file jsonpath.c.

472 {
473  switch (INTALIGN(buf->len) - buf->len)
474  {
475  case 3:
477  /* FALLTHROUGH */
478  case 2:
480  /* FALLTHROUGH */
481  case 1:
483  /* FALLTHROUGH */
484  default:
485  break;
486  }
487 }
#define INTALIGN(LEN)
Definition: c.h:792
static char * buf
Definition: pg_test_fsync.c:67
#define appendStringInfoCharMacro(str, ch)
Definition: stringinfo.h:128

References appendStringInfoCharMacro, buf, and INTALIGN.

Referenced by flattenJsonPathParseItem().

◆ flattenJsonPathParseItem()

static bool flattenJsonPathParseItem ( StringInfo  buf,
int *  result,
struct Node escontext,
JsonPathParseItem item,
int  nestingLevel,
bool  insideArraySubscript 
)
static

Definition at line 237 of file jsonpath.c.

240 {
241  /* position from beginning of jsonpath data */
242  int32 pos = buf->len - JSONPATH_HDRSZ;
243  int32 chld;
244  int32 next;
245  int argNestingLevel = 0;
246 
249 
250  appendStringInfoChar(buf, (char) (item->type));
251 
252  /*
253  * We align buffer to int32 because a series of int32 values often goes
254  * after the header, and we want to read them directly by dereferencing
255  * int32 pointer (see jspInitByBuffer()).
256  */
258 
259  /*
260  * Reserve space for next item pointer. Actual value will be recorded
261  * later, after next and children items processing.
262  */
264 
265  switch (item->type)
266  {
267  case jpiString:
268  case jpiVariable:
269  case jpiKey:
271  sizeof(item->value.string.len));
273  item->value.string.len);
274  appendStringInfoChar(buf, '\0');
275  break;
276  case jpiNumeric:
278  VARSIZE(item->value.numeric));
279  break;
280  case jpiBool:
282  sizeof(item->value.boolean));
283  break;
284  case jpiAnd:
285  case jpiOr:
286  case jpiEqual:
287  case jpiNotEqual:
288  case jpiLess:
289  case jpiGreater:
290  case jpiLessOrEqual:
291  case jpiGreaterOrEqual:
292  case jpiAdd:
293  case jpiSub:
294  case jpiMul:
295  case jpiDiv:
296  case jpiMod:
297  case jpiStartsWith:
298  {
299  /*
300  * First, reserve place for left/right arg's positions, then
301  * record both args and sets actual position in reserved
302  * places.
303  */
306 
307  if (!item->value.args.left)
308  chld = pos;
309  else if (!flattenJsonPathParseItem(buf, &chld, escontext,
310  item->value.args.left,
311  nestingLevel + argNestingLevel,
312  insideArraySubscript))
313  return false;
314  *(int32 *) (buf->data + left) = chld - pos;
315 
316  if (!item->value.args.right)
317  chld = pos;
318  else if (!flattenJsonPathParseItem(buf, &chld, escontext,
319  item->value.args.right,
320  nestingLevel + argNestingLevel,
321  insideArraySubscript))
322  return false;
323  *(int32 *) (buf->data + right) = chld - pos;
324  }
325  break;
326  case jpiLikeRegex:
327  {
328  int32 offs;
329 
331  &item->value.like_regex.flags,
332  sizeof(item->value.like_regex.flags));
335  &item->value.like_regex.patternlen,
336  sizeof(item->value.like_regex.patternlen));
338  item->value.like_regex.patternlen);
339  appendStringInfoChar(buf, '\0');
340 
341  if (!flattenJsonPathParseItem(buf, &chld, escontext,
342  item->value.like_regex.expr,
343  nestingLevel,
344  insideArraySubscript))
345  return false;
346  *(int32 *) (buf->data + offs) = chld - pos;
347  }
348  break;
349  case jpiFilter:
350  argNestingLevel++;
351  /* FALLTHROUGH */
352  case jpiIsUnknown:
353  case jpiNot:
354  case jpiPlus:
355  case jpiMinus:
356  case jpiExists:
357  case jpiDatetime:
358  {
360 
361  if (!item->value.arg)
362  chld = pos;
363  else if (!flattenJsonPathParseItem(buf, &chld, escontext,
364  item->value.arg,
365  nestingLevel + argNestingLevel,
366  insideArraySubscript))
367  return false;
368  *(int32 *) (buf->data + arg) = chld - pos;
369  }
370  break;
371  case jpiNull:
372  break;
373  case jpiRoot:
374  break;
375  case jpiAnyArray:
376  case jpiAnyKey:
377  break;
378  case jpiCurrent:
379  if (nestingLevel <= 0)
380  ereturn(escontext, false,
381  (errcode(ERRCODE_SYNTAX_ERROR),
382  errmsg("@ is not allowed in root expressions")));
383  break;
384  case jpiLast:
385  if (!insideArraySubscript)
386  ereturn(escontext, false,
387  (errcode(ERRCODE_SYNTAX_ERROR),
388  errmsg("LAST is allowed only in array subscripts")));
389  break;
390  case jpiIndexArray:
391  {
392  int32 nelems = item->value.array.nelems;
393  int offset;
394  int i;
395 
396  appendBinaryStringInfo(buf, &nelems, sizeof(nelems));
397 
398  offset = buf->len;
399 
400  appendStringInfoSpaces(buf, sizeof(int32) * 2 * nelems);
401 
402  for (i = 0; i < nelems; i++)
403  {
404  int32 *ppos;
405  int32 topos;
406  int32 frompos;
407 
408  if (!flattenJsonPathParseItem(buf, &frompos, escontext,
409  item->value.array.elems[i].from,
410  nestingLevel, true))
411  return false;
412  frompos -= pos;
413 
414  if (item->value.array.elems[i].to)
415  {
416  if (!flattenJsonPathParseItem(buf, &topos, escontext,
417  item->value.array.elems[i].to,
418  nestingLevel, true))
419  return false;
420  topos -= pos;
421  }
422  else
423  topos = 0;
424 
425  ppos = (int32 *) &buf->data[offset + i * 2 * sizeof(int32)];
426 
427  ppos[0] = frompos;
428  ppos[1] = topos;
429  }
430  }
431  break;
432  case jpiAny:
434  &item->value.anybounds.first,
435  sizeof(item->value.anybounds.first));
437  &item->value.anybounds.last,
438  sizeof(item->value.anybounds.last));
439  break;
440  case jpiType:
441  case jpiSize:
442  case jpiAbs:
443  case jpiFloor:
444  case jpiCeiling:
445  case jpiDouble:
446  case jpiKeyValue:
447  break;
448  default:
449  elog(ERROR, "unrecognized jsonpath item type: %d", item->type);
450  }
451 
452  if (item->next)
453  {
454  if (!flattenJsonPathParseItem(buf, &chld, escontext,
455  item->next, nestingLevel,
456  insideArraySubscript))
457  return false;
458  chld -= pos;
459  *(int32 *) (buf->data + next) = chld;
460  }
461 
462  if (result)
463  *result = pos;
464  return true;
465 }
static int32 next
Definition: blutils.c:219
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ereturn(context, dummy_value,...)
Definition: elog.h:276
#define ERROR
Definition: elog.h:39
int i
Definition: isn.c:73
static void alignStringInfoInt(StringInfo buf)
Definition: jsonpath.c:471
static bool flattenJsonPathParseItem(StringInfo buf, int *result, struct Node *escontext, JsonPathParseItem *item, int nestingLevel, bool insideArraySubscript)
Definition: jsonpath.c:237
static int32 reserveSpaceForItemPointer(StringInfo buf)
Definition: jsonpath.c:494
@ jpiAdd
Definition: jsonpath.h:69
@ jpiString
Definition: jsonpath.h:56
@ jpiAbs
Definition: jsonpath.h:88
@ jpiIndexArray
Definition: jsonpath.h:78
@ jpiAny
Definition: jsonpath.h:79
@ jpiDatetime
Definition: jsonpath.h:92
@ jpiBool
Definition: jsonpath.h:58
@ jpiType
Definition: jsonpath.h:86
@ jpiFloor
Definition: jsonpath.h:89
@ jpiAnyArray
Definition: jsonpath.h:76
@ jpiExists
Definition: jsonpath.h:85
@ jpiSize
Definition: jsonpath.h:87
@ jpiSub
Definition: jsonpath.h:70
@ jpiNotEqual
Definition: jsonpath.h:64
@ jpiMul
Definition: jsonpath.h:71
@ jpiVariable
Definition: jsonpath.h:83
@ jpiNot
Definition: jsonpath.h:61
@ jpiGreaterOrEqual
Definition: jsonpath.h:68
@ jpiPlus
Definition: jsonpath.h:74
@ jpiDouble
Definition: jsonpath.h:91
@ jpiGreater
Definition: jsonpath.h:66
@ jpiAnd
Definition: jsonpath.h:59
@ jpiStartsWith
Definition: jsonpath.h:96
@ jpiOr
Definition: jsonpath.h:60
@ jpiMod
Definition: jsonpath.h:73
@ jpiLikeRegex
Definition: jsonpath.h:97
@ jpiRoot
Definition: jsonpath.h:82
@ jpiFilter
Definition: jsonpath.h:84
@ jpiNull
Definition: jsonpath.h:55
@ jpiLess
Definition: jsonpath.h:65
@ jpiCurrent
Definition: jsonpath.h:81
@ jpiEqual
Definition: jsonpath.h:63
@ jpiKey
Definition: jsonpath.h:80
@ jpiDiv
Definition: jsonpath.h:72
@ jpiLast
Definition: jsonpath.h:95
@ jpiMinus
Definition: jsonpath.h:75
@ jpiLessOrEqual
Definition: jsonpath.h:67
@ jpiCeiling
Definition: jsonpath.h:90
@ jpiIsUnknown
Definition: jsonpath.h:62
@ jpiKeyValue
Definition: jsonpath.h:93
@ jpiNumeric
Definition: jsonpath.h:57
@ jpiAnyKey
Definition: jsonpath.h:77
#define JSONPATH_HDRSZ
Definition: jsonpath.h:30
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:121
void * arg
void check_stack_depth(void)
Definition: postgres.c:3508
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
Definition: stringinfo.c:227
void appendStringInfoSpaces(StringInfo str, int count)
Definition: stringinfo.c:206
void appendStringInfoChar(StringInfo str, char ch)
Definition: stringinfo.c:188
JsonPathParseItem * arg
Definition: jsonpath.h:212
struct JsonPathParseItem::@137::@141 like_regex
struct JsonPathParseItem::@137::@138 args
struct JsonPathParseItem::@137::@140 anybounds
struct JsonPathParseItem::@137::@139 array
JsonPathParseItem * next
Definition: jsonpath.h:199
Numeric numeric
Definition: jsonpath.h:241
JsonPathItemType type
Definition: jsonpath.h:198
struct JsonPathParseItem::@137::@142 string
union JsonPathParseItem::@137 value
#define VARSIZE(PTR)
Definition: varatt.h:279

References alignStringInfoInt(), JsonPathParseItem::anybounds, appendBinaryStringInfo(), appendStringInfoChar(), appendStringInfoSpaces(), arg, JsonPathParseItem::arg, JsonPathParseItem::args, JsonPathParseItem::array, JsonPathParseItem::boolean, buf, CHECK_FOR_INTERRUPTS, check_stack_depth(), elog(), ereturn, errcode(), errmsg(), ERROR, i, jpiAbs, jpiAdd, jpiAnd, jpiAny, jpiAnyArray, jpiAnyKey, jpiBool, jpiCeiling, jpiCurrent, jpiDatetime, jpiDiv, jpiDouble, jpiEqual, jpiExists, jpiFilter, jpiFloor, jpiGreater, jpiGreaterOrEqual, jpiIndexArray, jpiIsUnknown, jpiKey, jpiKeyValue, jpiLast, jpiLess, jpiLessOrEqual, jpiLikeRegex, jpiMinus, jpiMod, jpiMul, jpiNot, jpiNotEqual, jpiNull, jpiNumeric, jpiOr, jpiPlus, jpiRoot, jpiSize, jpiStartsWith, jpiString, jpiSub, jpiType, jpiVariable, JSONPATH_HDRSZ, JsonPathParseItem::like_regex, next, JsonPathParseItem::next, JsonPathParseItem::numeric, reserveSpaceForItemPointer(), JsonPathParseItem::string, JsonPathParseItem::type, JsonPathParseItem::value, and VARSIZE.

Referenced by jsonPathFromCstring().

◆ jsonpath_in()

Datum jsonpath_in ( PG_FUNCTION_ARGS  )

Definition at line 96 of file jsonpath.c.

97 {
98  char *in = PG_GETARG_CSTRING(0);
99  int len = strlen(in);
100 
101  return jsonPathFromCstring(in, len, fcinfo->context);
102 }
#define PG_GETARG_CSTRING(n)
Definition: fmgr.h:277
static Datum jsonPathFromCstring(char *in, int len, struct Node *escontext)
Definition: jsonpath.c:171
const void size_t len

References jsonPathFromCstring(), len, and PG_GETARG_CSTRING.

◆ jsonpath_out()

Datum jsonpath_out ( PG_FUNCTION_ARGS  )

Definition at line 132 of file jsonpath.c.

133 {
135 
137 }
#define PG_RETURN_CSTRING(x)
Definition: fmgr.h:362
static char * jsonPathToCstring(StringInfo out, JsonPath *in, int estimated_len)
Definition: jsonpath.c:211
#define PG_GETARG_JSONPATH_P(x)
Definition: jsonpath.h:44

References jsonPathToCstring(), PG_GETARG_JSONPATH_P, PG_RETURN_CSTRING, and VARSIZE.

◆ jsonpath_recv()

Datum jsonpath_recv ( PG_FUNCTION_ARGS  )

Definition at line 113 of file jsonpath.c.

114 {
116  int version = pq_getmsgint(buf, 1);
117  char *str;
118  int nbytes;
119 
120  if (version == JSONPATH_VERSION)
121  str = pq_getmsgtext(buf, buf->len - buf->cursor, &nbytes);
122  else
123  elog(ERROR, "unsupported jsonpath version number: %d", version);
124 
125  return jsonPathFromCstring(str, nbytes, NULL);
126 }
#define PG_GETARG_POINTER(n)
Definition: fmgr.h:276
#define JSONPATH_VERSION
Definition: jsonpath.h:28
unsigned int pq_getmsgint(StringInfo msg, int b)
Definition: pqformat.c:418
char * pq_getmsgtext(StringInfo msg, int rawbytes, int *nbytes)
Definition: pqformat.c:549
StringInfoData * StringInfo
Definition: stringinfo.h:44

References buf, elog(), ERROR, JSONPATH_VERSION, jsonPathFromCstring(), PG_GETARG_POINTER, pq_getmsgint(), pq_getmsgtext(), and generate_unaccent_rules::str.

◆ jsonpath_send()

Datum jsonpath_send ( PG_FUNCTION_ARGS  )

Definition at line 145 of file jsonpath.c.

146 {
149  StringInfoData jtext;
150  int version = JSONPATH_VERSION;
151 
152  initStringInfo(&jtext);
153  (void) jsonPathToCstring(&jtext, in, VARSIZE(in));
154 
156  pq_sendint8(&buf, version);
157  pq_sendtext(&buf, jtext.data, jtext.len);
158  pfree(jtext.data);
159 
161 }
#define PG_RETURN_BYTEA_P(x)
Definition: fmgr.h:371
void pfree(void *pointer)
Definition: mcxt.c:1456
void pq_sendtext(StringInfo buf, const char *str, int slen)
Definition: pqformat.c:175
void pq_begintypsend(StringInfo buf)
Definition: pqformat.c:329
bytea * pq_endtypsend(StringInfo buf)
Definition: pqformat.c:349
static void pq_sendint8(StringInfo buf, uint8 i)
Definition: pqformat.h:129
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59

References buf, StringInfoData::data, initStringInfo(), JSONPATH_VERSION, jsonPathToCstring(), StringInfoData::len, pfree(), PG_GETARG_JSONPATH_P, PG_RETURN_BYTEA_P, pq_begintypsend(), pq_endtypsend(), pq_sendint8(), pq_sendtext(), and VARSIZE.

◆ jsonPathFromCstring()

static Datum jsonPathFromCstring ( char *  in,
int  len,
struct Node escontext 
)
static

Definition at line 171 of file jsonpath.c.

172 {
173  JsonPathParseResult *jsonpath = parsejsonpath(in, len, escontext);
174  JsonPath *res;
176 
177  if (SOFT_ERROR_OCCURRED(escontext))
178  return (Datum) 0;
179 
180  if (!jsonpath)
181  ereturn(escontext, (Datum) 0,
182  (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
183  errmsg("invalid input syntax for type %s: \"%s\"", "jsonpath",
184  in)));
185 
187  enlargeStringInfo(&buf, 4 * len /* estimation */ );
188 
190 
191  if (!flattenJsonPathParseItem(&buf, NULL, escontext,
192  jsonpath->expr, 0, false))
193  return (Datum) 0;
194 
195  res = (JsonPath *) buf.data;
196  SET_VARSIZE(res, buf.len);
197  res->header = JSONPATH_VERSION;
198  if (jsonpath->lax)
199  res->header |= JSONPATH_LAX;
200 
202 }
#define PG_RETURN_JSONPATH_P(p)
Definition: jsonpath.h:46
JsonPathParseResult * parsejsonpath(const char *str, int len, struct Node *escontext)
#define JSONPATH_LAX
Definition: jsonpath.h:29
#define SOFT_ERROR_OCCURRED(escontext)
Definition: miscnodes.h:52
uintptr_t Datum
Definition: postgres.h:64
void enlargeStringInfo(StringInfo str, int needed)
Definition: stringinfo.c:283
JsonPathParseItem * expr
Definition: jsonpath.h:253
#define SET_VARSIZE(PTR, len)
Definition: varatt.h:305

References appendStringInfoSpaces(), buf, enlargeStringInfo(), ereturn, errcode(), errmsg(), JsonPathParseResult::expr, flattenJsonPathParseItem(), initStringInfo(), JSONPATH_HDRSZ, JSONPATH_LAX, JSONPATH_VERSION, JsonPathParseResult::lax, len, parsejsonpath(), PG_RETURN_JSONPATH_P, res, SET_VARSIZE, and SOFT_ERROR_OCCURRED.

Referenced by jsonpath_in(), and jsonpath_recv().

◆ jsonPathToCstring()

static char * jsonPathToCstring ( StringInfo  out,
JsonPath in,
int  estimated_len 
)
static

Definition at line 211 of file jsonpath.c.

212 {
214  JsonPathItem v;
215 
216  if (!out)
217  {
218  out = &buf;
219  initStringInfo(out);
220  }
221  enlargeStringInfo(out, estimated_len);
222 
223  if (!(in->header & JSONPATH_LAX))
224  appendStringInfoString(out, "strict ");
225 
226  jspInit(&v, in);
227  printJsonPathItem(out, &v, false, true);
228 
229  return out->data;
230 }
void jspInit(JsonPathItem *v, JsonPath *js)
Definition: jsonpath.c:869
static void printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey, bool printBracketes)
Definition: jsonpath.c:508
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
uint32 header
Definition: jsonpath.h:24

References appendStringInfoString(), buf, StringInfoData::data, enlargeStringInfo(), JsonPath::header, initStringInfo(), JSONPATH_LAX, jspInit(), and printJsonPathItem().

Referenced by jsonpath_out(), and jsonpath_send().

◆ jspGetArg()

void jspGetArg ( JsonPathItem v,
JsonPathItem a 
)

Definition at line 959 of file jsonpath.c.

960 {
961  Assert(v->type == jpiFilter ||
962  v->type == jpiNot ||
963  v->type == jpiIsUnknown ||
964  v->type == jpiExists ||
965  v->type == jpiPlus ||
966  v->type == jpiMinus ||
967  v->type == jpiDatetime);
968 
969  jspInitByBuffer(a, v->base, v->content.arg);
970 }
int a
Definition: isn.c:69
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:879
Assert(fmt[strlen(fmt) - 1] !='\n')
char * base
Definition: jsonpath.h:126
int32 arg
Definition: jsonpath.h:138
JsonPathItemType type
Definition: jsonpath.h:117
union JsonPathItem::@130 content

References a, JsonPathItem::arg, Assert(), JsonPathItem::base, JsonPathItem::content, jpiDatetime, jpiExists, jpiFilter, jpiIsUnknown, jpiMinus, jpiNot, jpiPlus, jspInitByBuffer(), and JsonPathItem::type.

Referenced by executeBoolItem(), executeDateTimeMethod(), executeItemOptUnwrapTarget(), executeUnaryArithmExpr(), extract_jsp_bool_expr(), extract_jsp_path_expr_nodes(), and printJsonPathItem().

◆ jspGetArraySubscript()

bool jspGetArraySubscript ( JsonPathItem v,
JsonPathItem from,
JsonPathItem to,
int  i 
)

Definition at line 1098 of file jsonpath.c.

1100 {
1101  Assert(v->type == jpiIndexArray);
1102 
1103  jspInitByBuffer(from, v->base, v->content.array.elems[i].from);
1104 
1105  if (!v->content.array.elems[i].to)
1106  return false;
1107 
1108  jspInitByBuffer(to, v->base, v->content.array.elems[i].to);
1109 
1110  return true;
1111 }
struct JsonPathItem::@130::@132 array

References JsonPathItem::array, Assert(), JsonPathItem::base, JsonPathItem::content, i, jpiIndexArray, jspInitByBuffer(), and JsonPathItem::type.

Referenced by executeItemOptUnwrapTarget(), and printJsonPathItem().

◆ jspGetBool()

bool jspGetBool ( JsonPathItem v)

Definition at line 1070 of file jsonpath.c.

1071 {
1072  Assert(v->type == jpiBool);
1073 
1074  return (bool) *v->content.value.data;
1075 }
struct JsonPathItem::@130::@134 value

References Assert(), JsonPathItem::content, jpiBool, JsonPathItem::type, and JsonPathItem::value.

Referenced by getJsonPathItem(), and printJsonPathItem().

◆ jspGetLeftArg()

void jspGetLeftArg ( JsonPathItem v,
JsonPathItem a 
)

Definition at line 1028 of file jsonpath.c.

1029 {
1030  Assert(v->type == jpiAnd ||
1031  v->type == jpiOr ||
1032  v->type == jpiEqual ||
1033  v->type == jpiNotEqual ||
1034  v->type == jpiLess ||
1035  v->type == jpiGreater ||
1036  v->type == jpiLessOrEqual ||
1037  v->type == jpiGreaterOrEqual ||
1038  v->type == jpiAdd ||
1039  v->type == jpiSub ||
1040  v->type == jpiMul ||
1041  v->type == jpiDiv ||
1042  v->type == jpiMod ||
1043  v->type == jpiStartsWith);
1044 
1045  jspInitByBuffer(a, v->base, v->content.args.left);
1046 }
struct JsonPathItem::@130::@131 args

References a, JsonPathItem::args, Assert(), JsonPathItem::base, JsonPathItem::content, jpiAdd, jpiAnd, jpiDiv, jpiEqual, jpiGreater, jpiGreaterOrEqual, jpiLess, jpiLessOrEqual, jpiMod, jpiMul, jpiNotEqual, jpiOr, jpiStartsWith, jpiSub, jspInitByBuffer(), and JsonPathItem::type.

Referenced by executeBinaryArithmExpr(), executeBoolItem(), extract_jsp_bool_expr(), and printJsonPathItem().

◆ jspGetNext()

bool jspGetNext ( JsonPathItem v,
JsonPathItem a 
)

Definition at line 973 of file jsonpath.c.

974 {
975  if (jspHasNext(v))
976  {
977  Assert(v->type == jpiString ||
978  v->type == jpiNumeric ||
979  v->type == jpiBool ||
980  v->type == jpiNull ||
981  v->type == jpiKey ||
982  v->type == jpiAny ||
983  v->type == jpiAnyArray ||
984  v->type == jpiAnyKey ||
985  v->type == jpiIndexArray ||
986  v->type == jpiFilter ||
987  v->type == jpiCurrent ||
988  v->type == jpiExists ||
989  v->type == jpiRoot ||
990  v->type == jpiVariable ||
991  v->type == jpiLast ||
992  v->type == jpiAdd ||
993  v->type == jpiSub ||
994  v->type == jpiMul ||
995  v->type == jpiDiv ||
996  v->type == jpiMod ||
997  v->type == jpiPlus ||
998  v->type == jpiMinus ||
999  v->type == jpiEqual ||
1000  v->type == jpiNotEqual ||
1001  v->type == jpiGreater ||
1002  v->type == jpiGreaterOrEqual ||
1003  v->type == jpiLess ||
1004  v->type == jpiLessOrEqual ||
1005  v->type == jpiAnd ||
1006  v->type == jpiOr ||
1007  v->type == jpiNot ||
1008  v->type == jpiIsUnknown ||
1009  v->type == jpiType ||
1010  v->type == jpiSize ||
1011  v->type == jpiAbs ||
1012  v->type == jpiFloor ||
1013  v->type == jpiCeiling ||
1014  v->type == jpiDouble ||
1015  v->type == jpiDatetime ||
1016  v->type == jpiKeyValue ||
1017  v->type == jpiStartsWith);
1018 
1019  if (a)
1020  jspInitByBuffer(a, v->base, v->nextPos);
1021  return true;
1022  }
1023 
1024  return false;
1025 }
#define jspHasNext(jsp)
Definition: jsonpath.h:174
int32 nextPos
Definition: jsonpath.h:120

References a, Assert(), JsonPathItem::base, jpiAbs, jpiAdd, jpiAnd, jpiAny, jpiAnyArray, jpiAnyKey, jpiBool, jpiCeiling, jpiCurrent, jpiDatetime, jpiDiv, jpiDouble, jpiEqual, jpiExists, jpiFilter, jpiFloor, jpiGreater, jpiGreaterOrEqual, jpiIndexArray, jpiIsUnknown, jpiKey, jpiKeyValue, jpiLast, jpiLess, jpiLessOrEqual, jpiMinus, jpiMod, jpiMul, jpiNot, jpiNotEqual, jpiNull, jpiNumeric, jpiOr, jpiPlus, jpiRoot, jpiSize, jpiStartsWith, jpiString, jpiSub, jpiType, jpiVariable, jspHasNext, jspInitByBuffer(), JsonPathItem::nextPos, and JsonPathItem::type.

Referenced by appendBoolResult(), executeBinaryArithmExpr(), executeDateTimeMethod(), executeItemOptUnwrapTarget(), executeKeyValueMethod(), executeNextItem(), executeNumericItemMethod(), executeUnaryArithmExpr(), extract_jsp_path_expr_nodes(), and printJsonPathItem().

◆ jspGetNumeric()

Numeric jspGetNumeric ( JsonPathItem v)

Definition at line 1078 of file jsonpath.c.

1079 {
1080  Assert(v->type == jpiNumeric);
1081 
1082  return (Numeric) v->content.value.data;
1083 }

References Assert(), JsonPathItem::content, jpiNumeric, JsonPathItem::type, and JsonPathItem::value.

Referenced by getJsonPathItem(), and printJsonPathItem().

◆ jspGetRightArg()

void jspGetRightArg ( JsonPathItem v,
JsonPathItem a 
)

Definition at line 1049 of file jsonpath.c.

1050 {
1051  Assert(v->type == jpiAnd ||
1052  v->type == jpiOr ||
1053  v->type == jpiEqual ||
1054  v->type == jpiNotEqual ||
1055  v->type == jpiLess ||
1056  v->type == jpiGreater ||
1057  v->type == jpiLessOrEqual ||
1058  v->type == jpiGreaterOrEqual ||
1059  v->type == jpiAdd ||
1060  v->type == jpiSub ||
1061  v->type == jpiMul ||
1062  v->type == jpiDiv ||
1063  v->type == jpiMod ||
1064  v->type == jpiStartsWith);
1065 
1066  jspInitByBuffer(a, v->base, v->content.args.right);
1067 }

References a, JsonPathItem::args, Assert(), JsonPathItem::base, JsonPathItem::content, jpiAdd, jpiAnd, jpiDiv, jpiEqual, jpiGreater, jpiGreaterOrEqual, jpiLess, jpiLessOrEqual, jpiMod, jpiMul, jpiNotEqual, jpiOr, jpiStartsWith, jpiSub, jspInitByBuffer(), and JsonPathItem::type.

Referenced by executeBinaryArithmExpr(), executeBoolItem(), extract_jsp_bool_expr(), and printJsonPathItem().

◆ jspGetString()

char* jspGetString ( JsonPathItem v,
int32 len 
)

Definition at line 1086 of file jsonpath.c.

1087 {
1088  Assert(v->type == jpiKey ||
1089  v->type == jpiString ||
1090  v->type == jpiVariable);
1091 
1092  if (len)
1093  *len = v->content.value.datalen;
1094  return v->content.value.data;
1095 }

References Assert(), JsonPathItem::content, jpiKey, jpiString, jpiVariable, len, JsonPathItem::type, and JsonPathItem::value.

Referenced by executeDateTimeMethod(), executeItemOptUnwrapTarget(), getJsonPathItem(), getJsonPathVariable(), jsonb_ops__add_path_item(), jsonb_path_ops__add_path_item(), and printJsonPathItem().

◆ jspInit()

void jspInit ( JsonPathItem v,
JsonPath js 
)

Definition at line 869 of file jsonpath.c.

870 {
872  jspInitByBuffer(v, js->data, 0);
873 }
char data[FLEXIBLE_ARRAY_MEMBER]
Definition: jsonpath.h:25

References Assert(), JsonPath::data, JsonPath::header, JSONPATH_LAX, JSONPATH_VERSION, and jspInitByBuffer().

Referenced by executeJsonPath(), extract_jsp_query(), and jsonPathToCstring().

◆ jspInitByBuffer()

void jspInitByBuffer ( JsonPathItem v,
char *  base,
int32  pos 
)

Definition at line 879 of file jsonpath.c.

880 {
881  v->base = base + pos;
882 
883  read_byte(v->type, base, pos);
884  pos = INTALIGN((uintptr_t) (base + pos)) - (uintptr_t) base;
885  read_int32(v->nextPos, base, pos);
886 
887  switch (v->type)
888  {
889  case jpiNull:
890  case jpiRoot:
891  case jpiCurrent:
892  case jpiAnyArray:
893  case jpiAnyKey:
894  case jpiType:
895  case jpiSize:
896  case jpiAbs:
897  case jpiFloor:
898  case jpiCeiling:
899  case jpiDouble:
900  case jpiKeyValue:
901  case jpiLast:
902  break;
903  case jpiKey:
904  case jpiString:
905  case jpiVariable:
906  read_int32(v->content.value.datalen, base, pos);
907  /* FALLTHROUGH */
908  case jpiNumeric:
909  case jpiBool:
910  v->content.value.data = base + pos;
911  break;
912  case jpiAnd:
913  case jpiOr:
914  case jpiAdd:
915  case jpiSub:
916  case jpiMul:
917  case jpiDiv:
918  case jpiMod:
919  case jpiEqual:
920  case jpiNotEqual:
921  case jpiLess:
922  case jpiGreater:
923  case jpiLessOrEqual:
924  case jpiGreaterOrEqual:
925  case jpiStartsWith:
926  read_int32(v->content.args.left, base, pos);
927  read_int32(v->content.args.right, base, pos);
928  break;
929  case jpiLikeRegex:
930  read_int32(v->content.like_regex.flags, base, pos);
931  read_int32(v->content.like_regex.expr, base, pos);
932  read_int32(v->content.like_regex.patternlen, base, pos);
933  v->content.like_regex.pattern = base + pos;
934  break;
935  case jpiNot:
936  case jpiExists:
937  case jpiIsUnknown:
938  case jpiPlus:
939  case jpiMinus:
940  case jpiFilter:
941  case jpiDatetime:
942  read_int32(v->content.arg, base, pos);
943  break;
944  case jpiIndexArray:
945  read_int32(v->content.array.nelems, base, pos);
946  read_int32_n(v->content.array.elems, base, pos,
947  v->content.array.nelems * 2);
948  break;
949  case jpiAny:
950  read_int32(v->content.anybounds.first, base, pos);
951  read_int32(v->content.anybounds.last, base, pos);
952  break;
953  default:
954  elog(ERROR, "unrecognized jsonpath item type: %d", v->type);
955  }
956 }
#define read_byte(v, b, p)
Definition: jsonpath.c:850
#define read_int32_n(v, b, p, n)
Definition: jsonpath.c:860
#define read_int32(v, b, p)
Definition: jsonpath.c:855
struct JsonPathItem::@130::@135 like_regex
struct JsonPathItem::@130::@133 anybounds

References JsonPathItem::anybounds, JsonPathItem::arg, JsonPathItem::args, JsonPathItem::array, JsonPathItem::base, JsonPathItem::content, elog(), ERROR, INTALIGN, jpiAbs, jpiAdd, jpiAnd, jpiAny, jpiAnyArray, jpiAnyKey, jpiBool, jpiCeiling, jpiCurrent, jpiDatetime, jpiDiv, jpiDouble, jpiEqual, jpiExists, jpiFilter, jpiFloor, jpiGreater, jpiGreaterOrEqual, jpiIndexArray, jpiIsUnknown, jpiKey, jpiKeyValue, jpiLast, jpiLess, jpiLessOrEqual, jpiLikeRegex, jpiMinus, jpiMod, jpiMul, jpiNot, jpiNotEqual, jpiNull, jpiNumeric, jpiOr, jpiPlus, jpiRoot, jpiSize, jpiStartsWith, jpiString, jpiSub, jpiType, jpiVariable, JsonPathItem::like_regex, JsonPathItem::nextPos, read_byte, read_int32, read_int32_n, JsonPathItem::type, and JsonPathItem::value.

Referenced by executeBoolItem(), jspGetArg(), jspGetArraySubscript(), jspGetLeftArg(), jspGetNext(), jspGetRightArg(), jspInit(), and printJsonPathItem().

◆ jspOperationName()

const char* jspOperationName ( JsonPathItemType  type)

Definition at line 754 of file jsonpath.c.

755 {
756  switch (type)
757  {
758  case jpiAnd:
759  return "&&";
760  case jpiOr:
761  return "||";
762  case jpiEqual:
763  return "==";
764  case jpiNotEqual:
765  return "!=";
766  case jpiLess:
767  return "<";
768  case jpiGreater:
769  return ">";
770  case jpiLessOrEqual:
771  return "<=";
772  case jpiGreaterOrEqual:
773  return ">=";
774  case jpiPlus:
775  case jpiAdd:
776  return "+";
777  case jpiMinus:
778  case jpiSub:
779  return "-";
780  case jpiMul:
781  return "*";
782  case jpiDiv:
783  return "/";
784  case jpiMod:
785  return "%";
786  case jpiStartsWith:
787  return "starts with";
788  case jpiLikeRegex:
789  return "like_regex";
790  case jpiType:
791  return "type";
792  case jpiSize:
793  return "size";
794  case jpiKeyValue:
795  return "keyvalue";
796  case jpiDouble:
797  return "double";
798  case jpiAbs:
799  return "abs";
800  case jpiFloor:
801  return "floor";
802  case jpiCeiling:
803  return "ceiling";
804  case jpiDatetime:
805  return "datetime";
806  default:
807  elog(ERROR, "unrecognized jsonpath item type: %d", type);
808  return NULL;
809  }
810 }

References elog(), ERROR, jpiAbs, jpiAdd, jpiAnd, jpiCeiling, jpiDatetime, jpiDiv, jpiDouble, jpiEqual, jpiFloor, jpiGreater, jpiGreaterOrEqual, jpiKeyValue, jpiLess, jpiLessOrEqual, jpiLikeRegex, jpiMinus, jpiMod, jpiMul, jpiNotEqual, jpiOr, jpiPlus, jpiSize, jpiStartsWith, jpiSub, jpiType, and generate_unaccent_rules::type.

Referenced by executeBinaryArithmExpr(), executeDateTimeMethod(), executeItemOptUnwrapTarget(), executeKeyValueMethod(), executeNumericItemMethod(), executeUnaryArithmExpr(), and printJsonPathItem().

◆ operationPriority()

static int operationPriority ( JsonPathItemType  op)
static

Definition at line 813 of file jsonpath.c.

814 {
815  switch (op)
816  {
817  case jpiOr:
818  return 0;
819  case jpiAnd:
820  return 1;
821  case jpiEqual:
822  case jpiNotEqual:
823  case jpiLess:
824  case jpiGreater:
825  case jpiLessOrEqual:
826  case jpiGreaterOrEqual:
827  case jpiStartsWith:
828  return 2;
829  case jpiAdd:
830  case jpiSub:
831  return 3;
832  case jpiMul:
833  case jpiDiv:
834  case jpiMod:
835  return 4;
836  case jpiPlus:
837  case jpiMinus:
838  return 5;
839  default:
840  return 6;
841  }
842 }

References jpiAdd, jpiAnd, jpiDiv, jpiEqual, jpiGreater, jpiGreaterOrEqual, jpiLess, jpiLessOrEqual, jpiMinus, jpiMod, jpiMul, jpiNotEqual, jpiOr, jpiPlus, jpiStartsWith, and jpiSub.

Referenced by printJsonPathItem().

◆ printJsonPathItem()

static void printJsonPathItem ( StringInfo  buf,
JsonPathItem v,
bool  inKey,
bool  printBracketes 
)
static

Definition at line 508 of file jsonpath.c.

510 {
511  JsonPathItem elem;
512  int i;
513 
516 
517  switch (v->type)
518  {
519  case jpiNull:
520  appendStringInfoString(buf, "null");
521  break;
522  case jpiKey:
523  if (inKey)
525  escape_json(buf, jspGetString(v, NULL));
526  break;
527  case jpiString:
528  escape_json(buf, jspGetString(v, NULL));
529  break;
530  case jpiVariable:
532  escape_json(buf, jspGetString(v, NULL));
533  break;
534  case jpiNumeric:
535  if (jspHasNext(v))
540  if (jspHasNext(v))
542  break;
543  case jpiBool:
544  if (jspGetBool(v))
545  appendStringInfoString(buf, "true");
546  else
547  appendStringInfoString(buf, "false");
548  break;
549  case jpiAnd:
550  case jpiOr:
551  case jpiEqual:
552  case jpiNotEqual:
553  case jpiLess:
554  case jpiGreater:
555  case jpiLessOrEqual:
556  case jpiGreaterOrEqual:
557  case jpiAdd:
558  case jpiSub:
559  case jpiMul:
560  case jpiDiv:
561  case jpiMod:
562  case jpiStartsWith:
563  if (printBracketes)
565  jspGetLeftArg(v, &elem);
566  printJsonPathItem(buf, &elem, false,
567  operationPriority(elem.type) <=
568  operationPriority(v->type));
572  jspGetRightArg(v, &elem);
573  printJsonPathItem(buf, &elem, false,
574  operationPriority(elem.type) <=
575  operationPriority(v->type));
576  if (printBracketes)
578  break;
579  case jpiLikeRegex:
580  if (printBracketes)
582 
583  jspInitByBuffer(&elem, v->base, v->content.like_regex.expr);
584  printJsonPathItem(buf, &elem, false,
585  operationPriority(elem.type) <=
586  operationPriority(v->type));
587 
588  appendStringInfoString(buf, " like_regex ");
589 
590  escape_json(buf, v->content.like_regex.pattern);
591 
592  if (v->content.like_regex.flags)
593  {
594  appendStringInfoString(buf, " flag \"");
595 
596  if (v->content.like_regex.flags & JSP_REGEX_ICASE)
598  if (v->content.like_regex.flags & JSP_REGEX_DOTALL)
600  if (v->content.like_regex.flags & JSP_REGEX_MLINE)
602  if (v->content.like_regex.flags & JSP_REGEX_WSPACE)
604  if (v->content.like_regex.flags & JSP_REGEX_QUOTE)
606 
608  }
609 
610  if (printBracketes)
612  break;
613  case jpiPlus:
614  case jpiMinus:
615  if (printBracketes)
617  appendStringInfoChar(buf, v->type == jpiPlus ? '+' : '-');
618  jspGetArg(v, &elem);
619  printJsonPathItem(buf, &elem, false,
620  operationPriority(elem.type) <=
621  operationPriority(v->type));
622  if (printBracketes)
624  break;
625  case jpiFilter:
627  jspGetArg(v, &elem);
628  printJsonPathItem(buf, &elem, false, false);
630  break;
631  case jpiNot:
633  jspGetArg(v, &elem);
634  printJsonPathItem(buf, &elem, false, false);
636  break;
637  case jpiIsUnknown:
639  jspGetArg(v, &elem);
640  printJsonPathItem(buf, &elem, false, false);
641  appendStringInfoString(buf, ") is unknown");
642  break;
643  case jpiExists:
644  appendStringInfoString(buf, "exists (");
645  jspGetArg(v, &elem);
646  printJsonPathItem(buf, &elem, false, false);
648  break;
649  case jpiCurrent:
650  Assert(!inKey);
652  break;
653  case jpiRoot:
654  Assert(!inKey);
656  break;
657  case jpiLast:
658  appendStringInfoString(buf, "last");
659  break;
660  case jpiAnyArray:
661  appendStringInfoString(buf, "[*]");
662  break;
663  case jpiAnyKey:
664  if (inKey)
667  break;
668  case jpiIndexArray:
670  for (i = 0; i < v->content.array.nelems; i++)
671  {
672  JsonPathItem from;
673  JsonPathItem to;
674  bool range = jspGetArraySubscript(v, &from, &to, i);
675 
676  if (i)
678 
679  printJsonPathItem(buf, &from, false, false);
680 
681  if (range)
682  {
683  appendStringInfoString(buf, " to ");
684  printJsonPathItem(buf, &to, false, false);
685  }
686  }
688  break;
689  case jpiAny:
690  if (inKey)
692 
693  if (v->content.anybounds.first == 0 &&
694  v->content.anybounds.last == PG_UINT32_MAX)
696  else if (v->content.anybounds.first == v->content.anybounds.last)
697  {
698  if (v->content.anybounds.first == PG_UINT32_MAX)
699  appendStringInfoString(buf, "**{last}");
700  else
701  appendStringInfo(buf, "**{%u}",
702  v->content.anybounds.first);
703  }
704  else if (v->content.anybounds.first == PG_UINT32_MAX)
705  appendStringInfo(buf, "**{last to %u}",
706  v->content.anybounds.last);
707  else if (v->content.anybounds.last == PG_UINT32_MAX)
708  appendStringInfo(buf, "**{%u to last}",
709  v->content.anybounds.first);
710  else
711  appendStringInfo(buf, "**{%u to %u}",
712  v->content.anybounds.first,
713  v->content.anybounds.last);
714  break;
715  case jpiType:
716  appendStringInfoString(buf, ".type()");
717  break;
718  case jpiSize:
719  appendStringInfoString(buf, ".size()");
720  break;
721  case jpiAbs:
722  appendStringInfoString(buf, ".abs()");
723  break;
724  case jpiFloor:
725  appendStringInfoString(buf, ".floor()");
726  break;
727  case jpiCeiling:
728  appendStringInfoString(buf, ".ceiling()");
729  break;
730  case jpiDouble:
731  appendStringInfoString(buf, ".double()");
732  break;
733  case jpiDatetime:
734  appendStringInfoString(buf, ".datetime(");
735  if (v->content.arg)
736  {
737  jspGetArg(v, &elem);
738  printJsonPathItem(buf, &elem, false, false);
739  }
741  break;
742  case jpiKeyValue:
743  appendStringInfoString(buf, ".keyvalue()");
744  break;
745  default:
746  elog(ERROR, "unrecognized jsonpath item type: %d", v->type);
747  }
748 
749  if (jspGetNext(v, &elem))
750  printJsonPathItem(buf, &elem, true, true);
751 }
Datum numeric_out(PG_FUNCTION_ARGS)
Definition: numeric.c:806
#define PG_UINT32_MAX
Definition: c.h:574
#define DirectFunctionCall1(func, arg1)
Definition: fmgr.h:642
void escape_json(StringInfo buf, const char *str)
Definition: json.c:1627
void jspGetLeftArg(JsonPathItem *v, JsonPathItem *a)
Definition: jsonpath.c:1028
void jspGetArg(JsonPathItem *v, JsonPathItem *a)
Definition: jsonpath.c:959
bool jspGetBool(JsonPathItem *v)
Definition: jsonpath.c:1070
const char * jspOperationName(JsonPathItemType type)
Definition: jsonpath.c:754
Numeric jspGetNumeric(JsonPathItem *v)
Definition: jsonpath.c:1078
bool jspGetArraySubscript(JsonPathItem *v, JsonPathItem *from, JsonPathItem *to, int i)
Definition: jsonpath.c:1098
bool jspGetNext(JsonPathItem *v, JsonPathItem *a)
Definition: jsonpath.c:973
static int operationPriority(JsonPathItemType op)
Definition: jsonpath.c:813
void jspGetRightArg(JsonPathItem *v, JsonPathItem *a)
Definition: jsonpath.c:1049
char * jspGetString(JsonPathItem *v, int32 *len)
Definition: jsonpath.c:1086
#define JSP_REGEX_WSPACE
Definition: jsonpath.h:104
#define JSP_REGEX_MLINE
Definition: jsonpath.h:103
#define JSP_REGEX_ICASE
Definition: jsonpath.h:101
#define JSP_REGEX_DOTALL
Definition: jsonpath.h:102
#define JSP_REGEX_QUOTE
Definition: jsonpath.h:105
static Datum NumericGetDatum(Numeric X)
Definition: numeric.h:72
static char * DatumGetCString(Datum X)
Definition: postgres.h:335
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
Definition: regc_locale.c:412
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91

References JsonPathItem::anybounds, appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), JsonPathItem::arg, JsonPathItem::array, Assert(), JsonPathItem::base, buf, CHECK_FOR_INTERRUPTS, check_stack_depth(), JsonPathItem::content, DatumGetCString(), DirectFunctionCall1, elog(), ERROR, escape_json(), i, jpiAbs, jpiAdd, jpiAnd, jpiAny, jpiAnyArray, jpiAnyKey, jpiBool, jpiCeiling, jpiCurrent, jpiDatetime, jpiDiv, jpiDouble, jpiEqual, jpiExists, jpiFilter, jpiFloor, jpiGreater, jpiGreaterOrEqual, jpiIndexArray, jpiIsUnknown, jpiKey, jpiKeyValue, jpiLast, jpiLess, jpiLessOrEqual, jpiLikeRegex, jpiMinus, jpiMod, jpiMul, jpiNot, jpiNotEqual, jpiNull, jpiNumeric, jpiOr, jpiPlus, jpiRoot, jpiSize, jpiStartsWith, jpiString, jpiSub, jpiType, jpiVariable, JSP_REGEX_DOTALL, JSP_REGEX_ICASE, JSP_REGEX_MLINE, JSP_REGEX_QUOTE, JSP_REGEX_WSPACE, jspGetArg(), jspGetArraySubscript(), jspGetBool(), jspGetLeftArg(), jspGetNext(), jspGetNumeric(), jspGetRightArg(), jspGetString(), jspHasNext, jspInitByBuffer(), jspOperationName(), JsonPathItem::like_regex, numeric_out(), NumericGetDatum(), operationPriority(), PG_UINT32_MAX, range(), and JsonPathItem::type.

Referenced by jsonPathToCstring().

◆ reserveSpaceForItemPointer()

static int32 reserveSpaceForItemPointer ( StringInfo  buf)
static

Definition at line 494 of file jsonpath.c.

495 {
496  int32 pos = buf->len;
497  int32 ptr = 0;
498 
499  appendBinaryStringInfo(buf, &ptr, sizeof(ptr));
500 
501  return pos;
502 }

References appendBinaryStringInfo(), and buf.

Referenced by flattenJsonPathParseItem().