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, 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 91 of file jsonpath.h.

Referenced by printJsonPathItem().

◆ JSP_REGEX_ICASE

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

Definition at line 90 of file jsonpath.h.

Referenced by printJsonPathItem().

◆ JSP_REGEX_MLINE

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

Definition at line 92 of file jsonpath.h.

Referenced by printJsonPathItem().

◆ JSP_REGEX_QUOTE

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

Definition at line 94 of file jsonpath.h.

Referenced by printJsonPathItem().

◆ JSP_REGEX_WSPACE

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

Definition at line 93 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().

◆ 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 183 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 
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  jpiKeyValue, /* .keyvalue() item method */
83  jpiSubscript, /* array subscript: 'expr' or 'expr TO expr' */
84  jpiLast, /* LAST array subscript */
85  jpiStartsWith, /* STARTS WITH predicate */
86  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 909 of file jsonpath.c.

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

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

910 {
911  Assert(v->type == jpiFilter ||
912  v->type == jpiNot ||
913  v->type == jpiIsUnknown ||
914  v->type == jpiExists ||
915  v->type == jpiPlus ||
916  v->type == jpiMinus);
917 
918  jspInitByBuffer(a, v->base, v->content.arg);
919 }
char * base
Definition: jsonpath.h:115
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:830
int32 arg
Definition: jsonpath.h:127
union JsonPathItem::@129 content
#define Assert(condition)
Definition: c.h:732
JsonPathItemType type
Definition: jsonpath.h:106

◆ jspGetArraySubscript()

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

Definition at line 1046 of file jsonpath.c.

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

Referenced by executeItemOptUnwrapTarget(), and printJsonPathItem().

1048 {
1049  Assert(v->type == jpiIndexArray);
1050 
1051  jspInitByBuffer(from, v->base, v->content.array.elems[i].from);
1052 
1053  if (!v->content.array.elems[i].to)
1054  return false;
1055 
1056  jspInitByBuffer(to, v->base, v->content.array.elems[i].to);
1057 
1058  return true;
1059 }
char * base
Definition: jsonpath.h:115
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:830
struct JsonPathItem::@129::@131 array
union JsonPathItem::@129 content
#define Assert(condition)
Definition: c.h:732
JsonPathItemType type
Definition: jsonpath.h:106
int i

◆ jspGetBool()

bool jspGetBool ( JsonPathItem v)

Definition at line 1018 of file jsonpath.c.

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

Referenced by getJsonPathItem(), and printJsonPathItem().

1019 {
1020  Assert(v->type == jpiBool);
1021 
1022  return (bool) *v->content.value.data;
1023 }
union JsonPathItem::@129 content
#define Assert(condition)
Definition: c.h:732
JsonPathItemType type
Definition: jsonpath.h:106
struct JsonPathItem::@129::@133 value

◆ jspGetLeftArg()

void jspGetLeftArg ( JsonPathItem v,
JsonPathItem a 
)

Definition at line 976 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().

977 {
978  Assert(v->type == jpiAnd ||
979  v->type == jpiOr ||
980  v->type == jpiEqual ||
981  v->type == jpiNotEqual ||
982  v->type == jpiLess ||
983  v->type == jpiGreater ||
984  v->type == jpiLessOrEqual ||
985  v->type == jpiGreaterOrEqual ||
986  v->type == jpiAdd ||
987  v->type == jpiSub ||
988  v->type == jpiMul ||
989  v->type == jpiDiv ||
990  v->type == jpiMod ||
991  v->type == jpiStartsWith);
992 
993  jspInitByBuffer(a, v->base, v->content.args.left);
994 }
Definition: jsonpath.h:50
char * base
Definition: jsonpath.h:115
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:830
struct JsonPathItem::@129::@130 args
union JsonPathItem::@129 content
#define Assert(condition)
Definition: c.h:732
JsonPathItemType type
Definition: jsonpath.h:106

◆ jspGetNext()

bool jspGetNext ( JsonPathItem v,
JsonPathItem a 
)

Definition at line 922 of file jsonpath.c.

References Assert, JsonPathItem::base, jpiAbs, jpiAdd, jpiAnd, jpiAny, jpiAnyArray, jpiAnyKey, jpiBool, jpiCeiling, jpiCurrent, 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(), executeItemOptUnwrapTarget(), executeKeyValueMethod(), executeNextItem(), executeNumericItemMethod(), executeUnaryArithmExpr(), extract_jsp_path_expr_nodes(), and printJsonPathItem().

923 {
924  if (jspHasNext(v))
925  {
926  Assert(v->type == jpiString ||
927  v->type == jpiNumeric ||
928  v->type == jpiBool ||
929  v->type == jpiNull ||
930  v->type == jpiKey ||
931  v->type == jpiAny ||
932  v->type == jpiAnyArray ||
933  v->type == jpiAnyKey ||
934  v->type == jpiIndexArray ||
935  v->type == jpiFilter ||
936  v->type == jpiCurrent ||
937  v->type == jpiExists ||
938  v->type == jpiRoot ||
939  v->type == jpiVariable ||
940  v->type == jpiLast ||
941  v->type == jpiAdd ||
942  v->type == jpiSub ||
943  v->type == jpiMul ||
944  v->type == jpiDiv ||
945  v->type == jpiMod ||
946  v->type == jpiPlus ||
947  v->type == jpiMinus ||
948  v->type == jpiEqual ||
949  v->type == jpiNotEqual ||
950  v->type == jpiGreater ||
951  v->type == jpiGreaterOrEqual ||
952  v->type == jpiLess ||
953  v->type == jpiLessOrEqual ||
954  v->type == jpiAnd ||
955  v->type == jpiOr ||
956  v->type == jpiNot ||
957  v->type == jpiIsUnknown ||
958  v->type == jpiType ||
959  v->type == jpiSize ||
960  v->type == jpiAbs ||
961  v->type == jpiFloor ||
962  v->type == jpiCeiling ||
963  v->type == jpiDouble ||
964  v->type == jpiKeyValue ||
965  v->type == jpiStartsWith);
966 
967  if (a)
968  jspInitByBuffer(a, v->base, v->nextPos);
969  return true;
970  }
971 
972  return false;
973 }
Definition: jsonpath.h:50
char * base
Definition: jsonpath.h:115
#define jspHasNext(jsp)
Definition: jsonpath.h:163
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:830
#define Assert(condition)
Definition: c.h:732
JsonPathItemType type
Definition: jsonpath.h:106
int32 nextPos
Definition: jsonpath.h:109

◆ jspGetNumeric()

Numeric jspGetNumeric ( JsonPathItem v)

Definition at line 1026 of file jsonpath.c.

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

Referenced by getJsonPathItem(), and printJsonPathItem().

1027 {
1028  Assert(v->type == jpiNumeric);
1029 
1030  return (Numeric) v->content.value.data;
1031 }
union JsonPathItem::@129 content
#define Assert(condition)
Definition: c.h:732
JsonPathItemType type
Definition: jsonpath.h:106
struct JsonPathItem::@129::@133 value

◆ jspGetRightArg()

void jspGetRightArg ( JsonPathItem v,
JsonPathItem a 
)

Definition at line 997 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().

998 {
999  Assert(v->type == jpiAnd ||
1000  v->type == jpiOr ||
1001  v->type == jpiEqual ||
1002  v->type == jpiNotEqual ||
1003  v->type == jpiLess ||
1004  v->type == jpiGreater ||
1005  v->type == jpiLessOrEqual ||
1006  v->type == jpiGreaterOrEqual ||
1007  v->type == jpiAdd ||
1008  v->type == jpiSub ||
1009  v->type == jpiMul ||
1010  v->type == jpiDiv ||
1011  v->type == jpiMod ||
1012  v->type == jpiStartsWith);
1013 
1014  jspInitByBuffer(a, v->base, v->content.args.right);
1015 }
Definition: jsonpath.h:50
char * base
Definition: jsonpath.h:115
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:830
struct JsonPathItem::@129::@130 args
union JsonPathItem::@129 content
#define Assert(condition)
Definition: c.h:732
JsonPathItemType type
Definition: jsonpath.h:106

◆ jspGetString()

char* jspGetString ( JsonPathItem v,
int32 len 
)

Definition at line 1034 of file jsonpath.c.

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

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

1035 {
1036  Assert(v->type == jpiKey ||
1037  v->type == jpiString ||
1038  v->type == jpiVariable);
1039 
1040  if (len)
1041  *len = v->content.value.datalen;
1042  return v->content.value.data;
1043 }
union JsonPathItem::@129 content
#define Assert(condition)
Definition: c.h:732
JsonPathItemType type
Definition: jsonpath.h:106
struct JsonPathItem::@129::@133 value

◆ jspInit()

void jspInit ( JsonPathItem v,
JsonPath js 
)

Definition at line 820 of file jsonpath.c.

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

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

821 {
823  jspInitByBuffer(v, js->data, 0);
824 }
void jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
Definition: jsonpath.c:830
#define JSONPATH_LAX
Definition: jsonpath.h:29
#define JSONPATH_VERSION
Definition: jsonpath.h:28
#define Assert(condition)
Definition: c.h:732
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 830 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, 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().

831 {
832  v->base = base + pos;
833 
834  read_byte(v->type, base, pos);
835  pos = INTALIGN((uintptr_t) (base + pos)) - (uintptr_t) base;
836  read_int32(v->nextPos, base, pos);
837 
838  switch (v->type)
839  {
840  case jpiNull:
841  case jpiRoot:
842  case jpiCurrent:
843  case jpiAnyArray:
844  case jpiAnyKey:
845  case jpiType:
846  case jpiSize:
847  case jpiAbs:
848  case jpiFloor:
849  case jpiCeiling:
850  case jpiDouble:
851  case jpiKeyValue:
852  case jpiLast:
853  break;
854  case jpiKey:
855  case jpiString:
856  case jpiVariable:
857  read_int32(v->content.value.datalen, base, pos);
858  /* FALLTHROUGH */
859  case jpiNumeric:
860  case jpiBool:
861  v->content.value.data = base + pos;
862  break;
863  case jpiAnd:
864  case jpiOr:
865  case jpiAdd:
866  case jpiSub:
867  case jpiMul:
868  case jpiDiv:
869  case jpiMod:
870  case jpiEqual:
871  case jpiNotEqual:
872  case jpiLess:
873  case jpiGreater:
874  case jpiLessOrEqual:
875  case jpiGreaterOrEqual:
876  case jpiStartsWith:
877  read_int32(v->content.args.left, base, pos);
878  read_int32(v->content.args.right, base, pos);
879  break;
880  case jpiLikeRegex:
881  read_int32(v->content.like_regex.flags, base, pos);
882  read_int32(v->content.like_regex.expr, base, pos);
883  read_int32(v->content.like_regex.patternlen, base, pos);
884  v->content.like_regex.pattern = base + pos;
885  break;
886  case jpiNot:
887  case jpiExists:
888  case jpiIsUnknown:
889  case jpiPlus:
890  case jpiMinus:
891  case jpiFilter:
892  read_int32(v->content.arg, base, pos);
893  break;
894  case jpiIndexArray:
895  read_int32(v->content.array.nelems, base, pos);
896  read_int32_n(v->content.array.elems, base, pos,
897  v->content.array.nelems * 2);
898  break;
899  case jpiAny:
900  read_int32(v->content.anybounds.first, base, pos);
901  read_int32(v->content.anybounds.last, base, pos);
902  break;
903  default:
904  elog(ERROR, "unrecognized jsonpath item type: %d", v->type);
905  }
906 }
#define read_int32(v, b, p)
Definition: jsonpath.c:806
Definition: jsonpath.h:50
char * base
Definition: jsonpath.h:115
#define INTALIGN(LEN)
Definition: c.h:682
int32 arg
Definition: jsonpath.h:127
#define ERROR
Definition: elog.h:43
struct JsonPathItem::@129::@131 array
struct JsonPathItem::@129::@130 args
struct JsonPathItem::@129::@132 anybounds
struct JsonPathItem::@129::@134 like_regex
union JsonPathItem::@129 content
#define read_int32_n(v, b, p, n)
Definition: jsonpath.c:811
JsonPathItemType type
Definition: jsonpath.h:106
#define elog(elevel,...)
Definition: elog.h:226
#define read_byte(v, b, p)
Definition: jsonpath.c:801
struct JsonPathItem::@129::@133 value
int32 nextPos
Definition: jsonpath.h:109

◆ jspOperationName()

const char* jspOperationName ( JsonPathItemType  type)

Definition at line 707 of file jsonpath.c.

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

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

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

◆ parsejsonpath()

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

Referenced by jsonPathFromCstring().