Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 94650f7

Browse files
author
Nikita Glukhov
committed
Add jsonpath item methods
1 parent f3fd502 commit 94650f7

File tree

7 files changed

+590
-17
lines changed

7 files changed

+590
-17
lines changed

src/backend/utils/adt/jsonpath.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ flattenJsonPathParseItem(StringInfo buf, JsonPathParseItem *item,
163163
(char*)&item->value.anybounds.last,
164164
sizeof(item->value.anybounds.last));
165165
break;
166+
case jpiType:
167+
case jpiSize:
168+
case jpiAbs:
169+
case jpiFloor:
170+
case jpiCeiling:
171+
case jpiDouble:
172+
case jpiDatetime:
173+
case jpiKeyValue:
174+
break;
166175
default:
167176
elog(ERROR, "Unknown jsonpath item type: %d", item->type);
168177
}
@@ -398,6 +407,30 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey, bool printBracket
398407
appendStringInfo(buf, "**{%u,%u}", v->content.anybounds.first,
399408
v->content.anybounds.last);
400409
break;
410+
case jpiType:
411+
appendBinaryStringInfo(buf, ".type()", 7);
412+
break;
413+
case jpiSize:
414+
appendBinaryStringInfo(buf, ".size()", 7);
415+
break;
416+
case jpiAbs:
417+
appendBinaryStringInfo(buf, ".abs()", 6);
418+
break;
419+
case jpiFloor:
420+
appendBinaryStringInfo(buf, ".floor()", 8);
421+
break;
422+
case jpiCeiling:
423+
appendBinaryStringInfo(buf, ".ceiling()", 10);
424+
break;
425+
case jpiDouble:
426+
appendBinaryStringInfo(buf, ".double()", 9);
427+
break;
428+
case jpiDatetime:
429+
appendBinaryStringInfo(buf, ".datetime()", 11);
430+
break;
431+
case jpiKeyValue:
432+
appendBinaryStringInfo(buf, ".keyvalue()", 11);
433+
break;
401434
default:
402435
elog(ERROR, "Unknown jsonpath item type: %d", v->type);
403436
}
@@ -483,6 +516,14 @@ jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
483516
case jpiCurrent:
484517
case jpiAnyArray:
485518
case jpiAnyKey:
519+
case jpiType:
520+
case jpiSize:
521+
case jpiAbs:
522+
case jpiFloor:
523+
case jpiCeiling:
524+
case jpiDouble:
525+
case jpiDatetime:
526+
case jpiKeyValue:
486527
break;
487528
case jpiKey:
488529
case jpiString:
@@ -559,7 +600,15 @@ jspGetNext(JsonPathItem *v, JsonPathItem *a)
559600
v->type == jpiFilter ||
560601
v->type == jpiCurrent ||
561602
v->type == jpiExists ||
562-
v->type == jpiRoot
603+
v->type == jpiRoot ||
604+
v->type == jpiType ||
605+
v->type == jpiSize ||
606+
v->type == jpiAbs ||
607+
v->type == jpiFloor ||
608+
v->type == jpiCeiling ||
609+
v->type == jpiDouble ||
610+
v->type == jpiDatetime ||
611+
v->type == jpiKeyValue
563612
);
564613

565614
if (a)

0 commit comments

Comments
 (0)