PostgreSQL Source Code  git master
jsonpath.h File Reference
#include "fmgr.h"
#include "utils/jsonb.h"
#include "nodes/pg_list.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 DatumGetJsonPathP(d)   ((JsonPath *) DatumGetPointer(PG_DETOAST_DATUM(d)))
 
#define DatumGetJsonPathPCopy(d)   ((JsonPath *) DatumGetPointer(PG_DETOAST_DATUM_COPY(d)))
 
#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

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)
 
int jspConvertRegexFlags (uint32 xflags)
 

Macro Definition Documentation

◆ DatumGetJsonPathP

#define DatumGetJsonPathP (   d)    ((JsonPath *) DatumGetPointer(PG_DETOAST_DATUM(d)))

Definition at line 32 of file jsonpath.h.

◆ DatumGetJsonPathPCopy

#define DatumGetJsonPathPCopy (   d)    ((JsonPath *) DatumGetPointer(PG_DETOAST_DATUM_COPY(d)))

Definition at line 33 of file jsonpath.h.

◆ JSONPATH_HDRSZ

#define JSONPATH_HDRSZ   (offsetof(JsonPath, data))

Definition at line 30 of file jsonpath.h.

Referenced by flattenJsonPathParseItem(), and jsonPathFromCstring().

◆ JSONPATH_LAX

#define JSONPATH_LAX   (0x80000000)

◆ JSONPATH_VERSION

#define JSONPATH_VERSION   (0x01)

Definition at line 28 of file jsonpath.h.

Referenced by jsonpath_recv(), jsonpath_send(), jsonPathFromCstring(), and jspInit().

◆ JSP_REGEX_DOTALL

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

Definition at line 92 of file jsonpath.h.

Referenced by printJsonPathItem().

◆ JSP_REGEX_ICASE

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

Definition at line 91 of file jsonpath.h.

Referenced by printJsonPathItem().

◆ JSP_REGEX_MLINE

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

Definition at line 93 of file jsonpath.h.

Referenced by printJsonPathItem().

◆ JSP_REGEX_QUOTE

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

Definition at line 95 of file jsonpath.h.

Referenced by printJsonPathItem().

◆ JSP_REGEX_WSPACE

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

Definition at line 94 of file jsonpath.h.

Referenced by printJsonPathItem().

◆ jspHasNext

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

◆ jspIsScalar

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

Definition at line 38 of file jsonpath.h.

Referenced by extract_jsp_bool_expr().

◆ PG_GETARG_JSONPATH_P

◆ PG_GETARG_JSONPATH_P_COPY

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

Definition at line 35 of file jsonpath.h.

Referenced by jsonb_path_query_internal().

◆ PG_RETURN_JSONPATH_P

#define PG_RETURN_JSONPATH_P (   p)    PG_RETURN_POINTER(p)

Definition at line 36 of file jsonpath.h.

Referenced by jsonPathFromCstring().

Typedef Documentation

◆ JsonPathItem

typedef struct JsonPathItem JsonPathItem

◆ JsonPathItemType

◆ JsonPathParseItem

Definition at line 184 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 43 of file jsonpath.h.

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

Function Documentation

◆ jspConvertRegexFlags()

int jspConvertRegexFlags ( uint32  xflags)

Referenced by executeLikeRegex().

◆ jspGetArg()

void jspGetArg ( JsonPathItem v,
JsonPathItem a 
)

Definition at line 923 of file jsonpath.c.

References 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().

924 {
925  Assert(v->type == jpiFilter ||
926  v->type == jpiNot ||
927  v->type == jpiIsUnknown ||
928  v->type == jpiExists ||
929  v->type == jpiPlus ||
930  v->type == jpiMinus ||
931  v->type == jpiDatetime);
932 
933  jspInitByBuffer(a, v->base, v->content.arg);
934 }
char * base
Definition: jsonpath.h:116
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:843
int32 arg
Definition: jsonpath.h:128
union JsonPathItem::@130 content
#define Assert(condition)
Definition: c.h:733
JsonPathItemType type
Definition: jsonpath.h:107

◆ jspGetArraySubscript()

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

Definition at line 1062 of file jsonpath.c.

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

Referenced by executeItemOptUnwrapTarget(), and printJsonPathItem().

1064 {
1065  Assert(v->type == jpiIndexArray);
1066 
1067  jspInitByBuffer(from, v->base, v->content.array.elems[i].from);
1068 
1069  if (!v->content.array.elems[i].to)
1070  return false;
1071 
1072  jspInitByBuffer(to, v->base, v->content.array.elems[i].to);
1073 
1074  return true;
1075 }
char * base
Definition: jsonpath.h:116
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:843
union JsonPathItem::@130 content
#define Assert(condition)
Definition: c.h:733
JsonPathItemType type
Definition: jsonpath.h:107
int i
struct JsonPathItem::@130::@132 array

◆ jspGetBool()

bool jspGetBool ( JsonPathItem v)

Definition at line 1034 of file jsonpath.c.

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

Referenced by getJsonPathItem(), and printJsonPathItem().

1035 {
1036  Assert(v->type == jpiBool);
1037 
1038  return (bool) *v->content.value.data;
1039 }
struct JsonPathItem::@130::@134 value
union JsonPathItem::@130 content
#define Assert(condition)
Definition: c.h:733
JsonPathItemType type
Definition: jsonpath.h:107

◆ jspGetLeftArg()

void jspGetLeftArg ( JsonPathItem v,
JsonPathItem a 
)

Definition at line 992 of file jsonpath.c.

References 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().

993 {
994  Assert(v->type == jpiAnd ||
995  v->type == jpiOr ||
996  v->type == jpiEqual ||
997  v->type == jpiNotEqual ||
998  v->type == jpiLess ||
999  v->type == jpiGreater ||
1000  v->type == jpiLessOrEqual ||
1001  v->type == jpiGreaterOrEqual ||
1002  v->type == jpiAdd ||
1003  v->type == jpiSub ||
1004  v->type == jpiMul ||
1005  v->type == jpiDiv ||
1006  v->type == jpiMod ||
1007  v->type == jpiStartsWith);
1008 
1009  jspInitByBuffer(a, v->base, v->content.args.left);
1010 }
Definition: jsonpath.h:50
char * base
Definition: jsonpath.h:116
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:843
union JsonPathItem::@130 content
#define Assert(condition)
Definition: c.h:733
JsonPathItemType type
Definition: jsonpath.h:107
struct JsonPathItem::@130::@131 args

◆ jspGetNext()

bool jspGetNext ( JsonPathItem v,
JsonPathItem a 
)

Definition at line 937 of file jsonpath.c.

References 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().

938 {
939  if (jspHasNext(v))
940  {
941  Assert(v->type == jpiString ||
942  v->type == jpiNumeric ||
943  v->type == jpiBool ||
944  v->type == jpiNull ||
945  v->type == jpiKey ||
946  v->type == jpiAny ||
947  v->type == jpiAnyArray ||
948  v->type == jpiAnyKey ||
949  v->type == jpiIndexArray ||
950  v->type == jpiFilter ||
951  v->type == jpiCurrent ||
952  v->type == jpiExists ||
953  v->type == jpiRoot ||
954  v->type == jpiVariable ||
955  v->type == jpiLast ||
956  v->type == jpiAdd ||
957  v->type == jpiSub ||
958  v->type == jpiMul ||
959  v->type == jpiDiv ||
960  v->type == jpiMod ||
961  v->type == jpiPlus ||
962  v->type == jpiMinus ||
963  v->type == jpiEqual ||
964  v->type == jpiNotEqual ||
965  v->type == jpiGreater ||
966  v->type == jpiGreaterOrEqual ||
967  v->type == jpiLess ||
968  v->type == jpiLessOrEqual ||
969  v->type == jpiAnd ||
970  v->type == jpiOr ||
971  v->type == jpiNot ||
972  v->type == jpiIsUnknown ||
973  v->type == jpiType ||
974  v->type == jpiSize ||
975  v->type == jpiAbs ||
976  v->type == jpiFloor ||
977  v->type == jpiCeiling ||
978  v->type == jpiDouble ||
979  v->type == jpiDatetime ||
980  v->type == jpiKeyValue ||
981  v->type == jpiStartsWith);
982 
983  if (a)
984  jspInitByBuffer(a, v->base, v->nextPos);
985  return true;
986  }
987 
988  return false;
989 }
Definition: jsonpath.h:50
char * base
Definition: jsonpath.h:116
#define jspHasNext(jsp)
Definition: jsonpath.h:164
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:843
#define Assert(condition)
Definition: c.h:733
JsonPathItemType type
Definition: jsonpath.h:107
int32 nextPos
Definition: jsonpath.h:110

◆ jspGetNumeric()

Numeric jspGetNumeric ( JsonPathItem v)

Definition at line 1042 of file jsonpath.c.

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

Referenced by getJsonPathItem(), and printJsonPathItem().

1043 {
1044  Assert(v->type == jpiNumeric);
1045 
1046  return (Numeric) v->content.value.data;
1047 }
struct JsonPathItem::@130::@134 value
union JsonPathItem::@130 content
#define Assert(condition)
Definition: c.h:733
JsonPathItemType type
Definition: jsonpath.h:107

◆ jspGetRightArg()

void jspGetRightArg ( JsonPathItem v,
JsonPathItem a 
)

Definition at line 1013 of file jsonpath.c.

References 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().

1014 {
1015  Assert(v->type == jpiAnd ||
1016  v->type == jpiOr ||
1017  v->type == jpiEqual ||
1018  v->type == jpiNotEqual ||
1019  v->type == jpiLess ||
1020  v->type == jpiGreater ||
1021  v->type == jpiLessOrEqual ||
1022  v->type == jpiGreaterOrEqual ||
1023  v->type == jpiAdd ||
1024  v->type == jpiSub ||
1025  v->type == jpiMul ||
1026  v->type == jpiDiv ||
1027  v->type == jpiMod ||
1028  v->type == jpiStartsWith);
1029 
1030  jspInitByBuffer(a, v->base, v->content.args.right);
1031 }
Definition: jsonpath.h:50
char * base
Definition: jsonpath.h:116
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:843
union JsonPathItem::@130 content
#define Assert(condition)
Definition: c.h:733
JsonPathItemType type
Definition: jsonpath.h:107
struct JsonPathItem::@130::@131 args

◆ jspGetString()

char* jspGetString ( JsonPathItem v,
int32 len 
)

Definition at line 1050 of file jsonpath.c.

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

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

1051 {
1052  Assert(v->type == jpiKey ||
1053  v->type == jpiString ||
1054  v->type == jpiVariable);
1055 
1056  if (len)
1057  *len = v->content.value.datalen;
1058  return v->content.value.data;
1059 }
struct JsonPathItem::@130::@134 value
union JsonPathItem::@130 content
#define Assert(condition)
Definition: c.h:733
JsonPathItemType type
Definition: jsonpath.h:107

◆ jspInit()

void jspInit ( JsonPathItem v,
JsonPath js 
)

Definition at line 833 of file jsonpath.c.

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

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

834 {
836  jspInitByBuffer(v, js->data, 0);
837 }
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:843
#define JSONPATH_LAX
Definition: jsonpath.h:29
#define JSONPATH_VERSION
Definition: jsonpath.h:28
#define Assert(condition)
Definition: c.h:733
char data[FLEXIBLE_ARRAY_MEMBER]
Definition: jsonpath.h:25
uint32 header
Definition: jsonpath.h:24

◆ jspInitByBuffer()

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

Definition at line 843 of file jsonpath.c.

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().

844 {
845  v->base = base + pos;
846 
847  read_byte(v->type, base, pos);
848  pos = INTALIGN((uintptr_t) (base + pos)) - (uintptr_t) base;
849  read_int32(v->nextPos, base, pos);
850 
851  switch (v->type)
852  {
853  case jpiNull:
854  case jpiRoot:
855  case jpiCurrent:
856  case jpiAnyArray:
857  case jpiAnyKey:
858  case jpiType:
859  case jpiSize:
860  case jpiAbs:
861  case jpiFloor:
862  case jpiCeiling:
863  case jpiDouble:
864  case jpiKeyValue:
865  case jpiLast:
866  break;
867  case jpiKey:
868  case jpiString:
869  case jpiVariable:
870  read_int32(v->content.value.datalen, base, pos);
871  /* FALLTHROUGH */
872  case jpiNumeric:
873  case jpiBool:
874  v->content.value.data = base + pos;
875  break;
876  case jpiAnd:
877  case jpiOr:
878  case jpiAdd:
879  case jpiSub:
880  case jpiMul:
881  case jpiDiv:
882  case jpiMod:
883  case jpiEqual:
884  case jpiNotEqual:
885  case jpiLess:
886  case jpiGreater:
887  case jpiLessOrEqual:
888  case jpiGreaterOrEqual:
889  case jpiStartsWith:
890  read_int32(v->content.args.left, base, pos);
891  read_int32(v->content.args.right, base, pos);
892  break;
893  case jpiLikeRegex:
894  read_int32(v->content.like_regex.flags, base, pos);
895  read_int32(v->content.like_regex.expr, base, pos);
896  read_int32(v->content.like_regex.patternlen, base, pos);
897  v->content.like_regex.pattern = base + pos;
898  break;
899  case jpiNot:
900  case jpiExists:
901  case jpiIsUnknown:
902  case jpiPlus:
903  case jpiMinus:
904  case jpiFilter:
905  case jpiDatetime:
906  read_int32(v->content.arg, base, pos);
907  break;
908  case jpiIndexArray:
909  read_int32(v->content.array.nelems, base, pos);
910  read_int32_n(v->content.array.elems, base, pos,
911  v->content.array.nelems * 2);
912  break;
913  case jpiAny:
914  read_int32(v->content.anybounds.first, base, pos);
915  read_int32(v->content.anybounds.last, base, pos);
916  break;
917  default:
918  elog(ERROR, "unrecognized jsonpath item type: %d", v->type);
919  }
920 }
struct JsonPathItem::@130::@134 value
#define read_int32(v, b, p)
Definition: jsonpath.c:819
Definition: jsonpath.h:50
struct JsonPathItem::@130::@133 anybounds
char * base
Definition: jsonpath.h:116
#define INTALIGN(LEN)
Definition: c.h:683
int32 arg
Definition: jsonpath.h:128
#define ERROR
Definition: elog.h:43
union JsonPathItem::@130 content
#define read_int32_n(v, b, p, n)
Definition: jsonpath.c:824
JsonPathItemType type
Definition: jsonpath.h:107
struct JsonPathItem::@130::@135 like_regex
#define elog(elevel,...)
Definition: elog.h:228
struct JsonPathItem::@130::@131 args
#define read_byte(v, b, p)
Definition: jsonpath.c:814
int32 nextPos
Definition: jsonpath.h:110
struct JsonPathItem::@130::@132 array

◆ jspOperationName()

const char* jspOperationName ( JsonPathItemType  type)

Definition at line 718 of file jsonpath.c.

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, and jpiType.

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

719 {
720  switch (type)
721  {
722  case jpiAnd:
723  return "&&";
724  case jpiOr:
725  return "||";
726  case jpiEqual:
727  return "==";
728  case jpiNotEqual:
729  return "!=";
730  case jpiLess:
731  return "<";
732  case jpiGreater:
733  return ">";
734  case jpiLessOrEqual:
735  return "<=";
736  case jpiGreaterOrEqual:
737  return ">=";
738  case jpiPlus:
739  case jpiAdd:
740  return "+";
741  case jpiMinus:
742  case jpiSub:
743  return "-";
744  case jpiMul:
745  return "*";
746  case jpiDiv:
747  return "/";
748  case jpiMod:
749  return "%";
750  case jpiStartsWith:
751  return "starts with";
752  case jpiLikeRegex:
753  return "like_regex";
754  case jpiType:
755  return "type";
756  case jpiSize:
757  return "size";
758  case jpiKeyValue:
759  return "keyvalue";
760  case jpiDouble:
761  return "double";
762  case jpiAbs:
763  return "abs";
764  case jpiFloor:
765  return "floor";
766  case jpiCeiling:
767  return "ceiling";
768  case jpiDatetime:
769  return "datetime";
770  default:
771  elog(ERROR, "unrecognized jsonpath item type: %d", type);
772  return NULL;
773  }
774 }
Definition: jsonpath.h:50
#define ERROR
Definition: elog.h:43
#define elog(elevel,...)
Definition: elog.h:228

◆ parsejsonpath()

JsonPathParseResult* parsejsonpath ( const char *  str,
int  len 
)

Referenced by jsonPathFromCstring().