PostgreSQL Source Code  git master
jsonpath.h File Reference
#include "fmgr.h"
#include "nodes/pg_list.h"
#include "utils/jsonb.h"
Include dependency graph for jsonpath.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  JsonPath
 
struct  JsonPathItem
 
struct  JsonPathParseItem
 
struct  JsonPathParseResult
 

Macros

#define JSONPATH_VERSION   (0x01)
 
#define JSONPATH_LAX   (0x80000000)
 
#define JSONPATH_HDRSZ   (offsetof(JsonPath, data))
 
#define PG_GETARG_JSONPATH_P(x)   DatumGetJsonPathP(PG_GETARG_DATUM(x))
 
#define PG_GETARG_JSONPATH_P_COPY(x)   DatumGetJsonPathPCopy(PG_GETARG_DATUM(x))
 
#define PG_RETURN_JSONPATH_P(p)   PG_RETURN_POINTER(p)
 
#define jspIsScalar(type)   ((type) >= jpiNull && (type) <= jpiBool)
 
#define JSP_REGEX_ICASE   0x01 /* i flag, case insensitive */
 
#define JSP_REGEX_DOTALL   0x02 /* s flag, dot matches newline */
 
#define JSP_REGEX_MLINE   0x04 /* m flag, ^/$ match at newlines */
 
#define JSP_REGEX_WSPACE   0x08 /* x flag, ignore whitespace in pattern */
 
#define JSP_REGEX_QUOTE   0x10 /* q flag, no special characters */
 
#define jspHasNext(jsp)   ((jsp)->nextPos > 0)
 

Typedefs

typedef enum JsonPathItemType JsonPathItemType
 
typedef struct JsonPathItem JsonPathItem
 
typedef struct JsonPathParseItem JsonPathParseItem
 
typedef struct JsonPathParseResult JsonPathParseResult
 

Enumerations

enum  JsonPathItemType {
  jpiNull = jbvNull , jpiString = jbvString , jpiNumeric = jbvNumeric , jpiBool = jbvBool ,
  jpiAnd , jpiOr , jpiNot , jpiIsUnknown ,
  jpiEqual , jpiNotEqual , jpiLess , jpiGreater ,
  jpiLessOrEqual , jpiGreaterOrEqual , jpiAdd , jpiSub ,
  jpiMul , jpiDiv , jpiMod , jpiPlus ,
  jpiMinus , jpiAnyArray , jpiAnyKey , jpiIndexArray ,
  jpiAny , jpiKey , jpiCurrent , jpiRoot ,
  jpiVariable , jpiFilter , jpiExists , jpiType ,
  jpiSize , jpiAbs , jpiFloor , jpiCeiling ,
  jpiDouble , jpiDatetime , jpiKeyValue , jpiSubscript ,
  jpiLast , jpiStartsWith , jpiLikeRegex
}
 

Functions

static JsonPathDatumGetJsonPathP (Datum d)
 
static JsonPathDatumGetJsonPathPCopy (Datum d)
 
void jspInit (JsonPathItem *v, JsonPath *js)
 
void jspInitByBuffer (JsonPathItem *v, char *base, int32 pos)
 
bool jspGetNext (JsonPathItem *v, JsonPathItem *a)
 
void jspGetArg (JsonPathItem *v, JsonPathItem *a)
 
void jspGetLeftArg (JsonPathItem *v, JsonPathItem *a)
 
void jspGetRightArg (JsonPathItem *v, JsonPathItem *a)
 
Numeric jspGetNumeric (JsonPathItem *v)
 
bool jspGetBool (JsonPathItem *v)
 
char * jspGetString (JsonPathItem *v, int32 *len)
 
bool jspGetArraySubscript (JsonPathItem *v, JsonPathItem *from, JsonPathItem *to, int i)
 
const char * jspOperationName (JsonPathItemType type)
 
JsonPathParseResultparsejsonpath (const char *str, int len, struct Node *escontext)
 
bool jspConvertRegexFlags (uint32 xflags, int *result, struct Node *escontext)
 

Macro Definition Documentation

◆ JSONPATH_HDRSZ

#define JSONPATH_HDRSZ   (offsetof(JsonPath, data))

Definition at line 30 of file jsonpath.h.

◆ JSONPATH_LAX

#define JSONPATH_LAX   (0x80000000)

Definition at line 29 of file jsonpath.h.

◆ JSONPATH_VERSION

#define JSONPATH_VERSION   (0x01)

Definition at line 28 of file jsonpath.h.

◆ JSP_REGEX_DOTALL

#define JSP_REGEX_DOTALL   0x02 /* s flag, dot matches newline */

Definition at line 102 of file jsonpath.h.

◆ JSP_REGEX_ICASE

#define JSP_REGEX_ICASE   0x01 /* i flag, case insensitive */

Definition at line 101 of file jsonpath.h.

◆ JSP_REGEX_MLINE

#define JSP_REGEX_MLINE   0x04 /* m flag, ^/$ match at newlines */

Definition at line 103 of file jsonpath.h.

◆ JSP_REGEX_QUOTE

#define JSP_REGEX_QUOTE   0x10 /* q flag, no special characters */

Definition at line 105 of file jsonpath.h.

◆ JSP_REGEX_WSPACE

#define JSP_REGEX_WSPACE   0x08 /* x flag, ignore whitespace in pattern */

Definition at line 104 of file jsonpath.h.

◆ jspHasNext

#define jspHasNext (   jsp)    ((jsp)->nextPos > 0)

Definition at line 174 of file jsonpath.h.

◆ jspIsScalar

#define jspIsScalar (   type)    ((type) >= jpiNull && (type) <= jpiBool)

Definition at line 48 of file jsonpath.h.

◆ PG_GETARG_JSONPATH_P

#define PG_GETARG_JSONPATH_P (   x)    DatumGetJsonPathP(PG_GETARG_DATUM(x))

Definition at line 44 of file jsonpath.h.

◆ PG_GETARG_JSONPATH_P_COPY

#define PG_GETARG_JSONPATH_P_COPY (   x)    DatumGetJsonPathPCopy(PG_GETARG_DATUM(x))

Definition at line 45 of file jsonpath.h.

◆ PG_RETURN_JSONPATH_P

#define PG_RETURN_JSONPATH_P (   p)    PG_RETURN_POINTER(p)

Definition at line 46 of file jsonpath.h.

Typedef Documentation

◆ JsonPathItem

typedef struct JsonPathItem JsonPathItem

◆ JsonPathItemType

◆ JsonPathParseItem

Definition at line 188 of file jsonpath.h.

◆ JsonPathParseResult

Enumeration Type Documentation

◆ JsonPathItemType

Enumerator
jpiNull 
jpiString 
jpiNumeric 
jpiBool 
jpiAnd 
jpiOr 
jpiNot 
jpiIsUnknown 
jpiEqual 
jpiNotEqual 
jpiLess 
jpiGreater 
jpiLessOrEqual 
jpiGreaterOrEqual 
jpiAdd 
jpiSub 
jpiMul 
jpiDiv 
jpiMod 
jpiPlus 
jpiMinus 
jpiAnyArray 
jpiAnyKey 
jpiIndexArray 
jpiAny 
jpiKey 
jpiCurrent 
jpiRoot 
jpiVariable 
jpiFilter 
jpiExists 
jpiType 
jpiSize 
jpiAbs 
jpiFloor 
jpiCeiling 
jpiDouble 
jpiDatetime 
jpiKeyValue 
jpiSubscript 
jpiLast 
jpiStartsWith 
jpiLikeRegex 

Definition at line 53 of file jsonpath.h.

54 {
55  jpiNull = jbvNull, /* NULL literal */
56  jpiString = jbvString, /* string literal */
57  jpiNumeric = jbvNumeric, /* numeric literal */
58  jpiBool = jbvBool, /* boolean literal: TRUE or FALSE */
59  jpiAnd, /* predicate && predicate */
60  jpiOr, /* predicate || predicate */
61  jpiNot, /* ! predicate */
62  jpiIsUnknown, /* (predicate) IS UNKNOWN */
63  jpiEqual, /* expr == expr */
64  jpiNotEqual, /* expr != expr */
65  jpiLess, /* expr < expr */
66  jpiGreater, /* expr > expr */
67  jpiLessOrEqual, /* expr <= expr */
68  jpiGreaterOrEqual, /* expr >= expr */
69  jpiAdd, /* expr + expr */
70  jpiSub, /* expr - expr */
71  jpiMul, /* expr * expr */
72  jpiDiv, /* expr / expr */
73  jpiMod, /* expr % expr */
74  jpiPlus, /* + expr */
75  jpiMinus, /* - expr */
76  jpiAnyArray, /* [*] */
77  jpiAnyKey, /* .* */
78  jpiIndexArray, /* [subscript, ...] */
79  jpiAny, /* .** */
80  jpiKey, /* .key */
81  jpiCurrent, /* @ */
82  jpiRoot, /* $ */
83  jpiVariable, /* $variable */
84  jpiFilter, /* ? (predicate) */
85  jpiExists, /* EXISTS (expr) predicate */
86  jpiType, /* .type() item method */
87  jpiSize, /* .size() item method */
88  jpiAbs, /* .abs() item method */
89  jpiFloor, /* .floor() item method */
90  jpiCeiling, /* .ceiling() item method */
91  jpiDouble, /* .double() item method */
92  jpiDatetime, /* .datetime() item method */
93  jpiKeyValue, /* .keyvalue() item method */
94  jpiSubscript, /* array subscript: 'expr' or 'expr TO expr' */
95  jpiLast, /* LAST array subscript */
96  jpiStartsWith, /* STARTS WITH predicate */
97  jpiLikeRegex, /* LIKE_REGEX predicate */
@ jbvNumeric
Definition: jsonb.h:230
@ jbvBool
Definition: jsonb.h:231
@ jbvNull
Definition: jsonb.h:228
@ jbvString
Definition: jsonb.h:229
JsonPathItemType
Definition: jsonpath.h:54
@ 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
@ jpiSubscript
Definition: jsonpath.h:94
@ 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

Function Documentation

◆ DatumGetJsonPathP()

static JsonPath* DatumGetJsonPathP ( Datum  d)
inlinestatic

Definition at line 33 of file jsonpath.h.

34 {
35  return (JsonPath *) PG_DETOAST_DATUM(d);
36 }
#define PG_DETOAST_DATUM(datum)
Definition: fmgr.h:240

References PG_DETOAST_DATUM.

◆ DatumGetJsonPathPCopy()

static JsonPath* DatumGetJsonPathPCopy ( Datum  d)
inlinestatic

Definition at line 39 of file jsonpath.h.

40 {
41  return (JsonPath *) PG_DETOAST_DATUM_COPY(d);
42 }
#define PG_DETOAST_DATUM_COPY(datum)
Definition: fmgr.h:242

References PG_DETOAST_DATUM_COPY.

◆ jspConvertRegexFlags()

bool jspConvertRegexFlags ( uint32  xflags,
int *  result,
struct Node escontext 
)

Referenced by executeLikeRegex().

◆ 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
union JsonPathItem::@126 content
JsonPathItemType type
Definition: jsonpath.h:117

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 }
int i
Definition: isn.c:73
struct JsonPathItem::@126::@128 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::@126::@130 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::@126::@127 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 }
const void size_t len

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 }
#define JSONPATH_VERSION
Definition: jsonpath.h:28
#define JSONPATH_LAX
Definition: jsonpath.h:29
char data[FLEXIBLE_ARRAY_MEMBER]
Definition: jsonpath.h:25
uint32 header
Definition: jsonpath.h:24

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 INTALIGN(LEN)
Definition: c.h:792
#define ERROR
Definition: elog.h:39
#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::@126::@131 like_regex
struct JsonPathItem::@126::@129 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().

◆ parsejsonpath()

JsonPathParseResult* parsejsonpath ( const char *  str,
int  len,
struct Node escontext 
)

Referenced by jsonPathFromCstring().