Skip to content

Commit f26c21e

Browse files
author
Nikita Glukhov
committed
Add jsonbc_get_dict_id() user function
1 parent 951a923 commit f26c21e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/backend/utils/adt/jsonbc_util.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,3 +1502,16 @@ jsonbc_handler(PG_FUNCTION_ARGS)
15021502

15031503
PG_RETURN_POINTER(cmr);
15041504
}
1505+
1506+
PG_FUNCTION_INFO_V1(jsonbc_get_dict_id);
1507+
1508+
Datum
1509+
jsonbc_get_dict_id(PG_FUNCTION_ARGS)
1510+
{
1511+
Json *json = DatumGetJsont(PG_GETARG_DATUM(0));
1512+
1513+
if (json->root.ops == &jsonbcContainerOps)
1514+
PG_RETURN_INT32(jsonbcGetDictId(JsonRoot(json)));
1515+
else
1516+
PG_RETURN_NULL();
1517+
}

src/include/catalog/pg_proc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4529,6 +4529,8 @@ DATA(insert OID = 3421 ( jsonbc_get_id_by_name PGNSP PGUID 12 1 0 0 0 f f f
45294529
DESCR("get name id from jsonbc dictionary");
45304530
DATA(insert OID = 3998 ( jsonbc_get_name_by_id PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 25 "26 23" _null_ _null_ _null_ _null_ _null_ jsonbc_get_name_by_id _null_ _null_ _null_ ));
45314531
DESCR("get name id from jsonbc dictionary");
4532+
DATA(insert OID = 4001 ( jsonbc_get_dict_id PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 26 "114" _null_ _null_ _null_ _null_ _null_ jsonbc_get_dict_id _null_ _null_ _null_ ));
4533+
DESCR("get jsonbc dictionary id from a json object");
45324534

45334535
/* uuid */
45344536
DATA(insert OID = 2952 ( uuid_in PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 2950 "2275" _null_ _null_ _null_ _null_ _null_ uuid_in _null_ _null_ _null_ ));

0 commit comments

Comments
 (0)