diff options
Diffstat (limited to 'src/backend/utils/adt/jsonpath.c')
-rw-r--r-- | src/backend/utils/adt/jsonpath.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/backend/utils/adt/jsonpath.c b/src/backend/utils/adt/jsonpath.c index 7f322485e7b..e683cbef7c6 100644 --- a/src/backend/utils/adt/jsonpath.c +++ b/src/backend/utils/adt/jsonpath.c @@ -337,12 +337,14 @@ flattenJsonPathParseItem(StringInfo buf, JsonPathParseItem *item, case jpiPlus: case jpiMinus: case jpiExists: + case jpiDatetime: { int32 arg = reserveSpaceForItemPointer(buf); - chld = flattenJsonPathParseItem(buf, item->value.arg, - nestingLevel + argNestingLevel, - insideArraySubscript); + chld = !item->value.arg ? pos : + flattenJsonPathParseItem(buf, item->value.arg, + nestingLevel + argNestingLevel, + insideArraySubscript); *(int32 *) (buf->data + arg) = chld - pos; } break; @@ -692,6 +694,15 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey, case jpiDouble: appendBinaryStringInfo(buf, ".double()", 9); break; + case jpiDatetime: + appendBinaryStringInfo(buf, ".datetime(", 10); + if (v->content.arg) + { + jspGetArg(v, &elem); + printJsonPathItem(buf, &elem, false, false); + } + appendStringInfoChar(buf, ')'); + break; case jpiKeyValue: appendBinaryStringInfo(buf, ".keyvalue()", 11); break; @@ -754,6 +765,8 @@ jspOperationName(JsonPathItemType type) return "floor"; case jpiCeiling: return "ceiling"; + case jpiDatetime: + return "datetime"; default: elog(ERROR, "unrecognized jsonpath item type: %d", type); return NULL; @@ -889,6 +902,7 @@ jspInitByBuffer(JsonPathItem *v, char *base, int32 pos) case jpiPlus: case jpiMinus: case jpiFilter: + case jpiDatetime: read_int32(v->content.arg, base, pos); break; case jpiIndexArray: @@ -913,7 +927,8 @@ jspGetArg(JsonPathItem *v, JsonPathItem *a) v->type == jpiIsUnknown || v->type == jpiExists || v->type == jpiPlus || - v->type == jpiMinus); + v->type == jpiMinus || + v->type == jpiDatetime); jspInitByBuffer(a, v->base, v->content.arg); } @@ -961,6 +976,7 @@ jspGetNext(JsonPathItem *v, JsonPathItem *a) v->type == jpiFloor || v->type == jpiCeiling || v->type == jpiDouble || + v->type == jpiDatetime || v->type == jpiKeyValue || v->type == jpiStartsWith); |