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

Commit f6b45f1

Browse files
author
Nikita Glukhov
committed
Add missing json functions and operators
1 parent fb4ab66 commit f6b45f1

File tree

14 files changed

+623
-33
lines changed

14 files changed

+623
-33
lines changed

src/backend/catalog/system_views.sql

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,14 @@ LANGUAGE INTERNAL
14161416
STRICT IMMUTABLE PARALLEL SAFE
14171417
AS 'make_interval';
14181418

1419+
CREATE OR REPLACE FUNCTION
1420+
json_set(json_in json, path text[] , replacement json,
1421+
create_if_missing boolean DEFAULT true)
1422+
RETURNS json
1423+
LANGUAGE INTERNAL
1424+
STRICT IMMUTABLE PARALLEL SAFE
1425+
AS 'json_set';
1426+
14191427
CREATE OR REPLACE FUNCTION
14201428
jsonb_set(jsonb_in jsonb, path text[] , replacement jsonb,
14211429
create_if_missing boolean DEFAULT true)
@@ -1440,6 +1448,14 @@ LANGUAGE INTERNAL
14401448
STRICT IMMUTABLE PARALLEL SAFE
14411449
AS 'parse_ident';
14421450

1451+
CREATE OR REPLACE FUNCTION
1452+
json_insert(json_in json, path text[] , replacement json,
1453+
insert_after boolean DEFAULT false)
1454+
RETURNS json
1455+
LANGUAGE INTERNAL
1456+
STRICT IMMUTABLE PARALLEL SAFE
1457+
AS 'json_insert';
1458+
14431459
CREATE OR REPLACE FUNCTION
14441460
jsonb_insert(jsonb_in jsonb, path text[] , replacement jsonb,
14451461
insert_after boolean DEFAULT false)
@@ -1528,6 +1544,88 @@ LANGUAGE INTERNAL
15281544
STRICT STABLE PARALLEL SAFE
15291545
AS 'jsonb_path_query_first_tz';
15301546

1547+
1548+
CREATE OR REPLACE FUNCTION
1549+
json_path_exists(target json, path jsonpath, vars json DEFAULT '{}',
1550+
silent boolean DEFAULT false)
1551+
RETURNS boolean
1552+
LANGUAGE INTERNAL
1553+
STRICT IMMUTABLE PARALLEL SAFE
1554+
AS 'json_path_exists';
1555+
1556+
CREATE OR REPLACE FUNCTION
1557+
json_path_match(target json, path jsonpath, vars json DEFAULT '{}',
1558+
silent boolean DEFAULT false)
1559+
RETURNS boolean
1560+
LANGUAGE INTERNAL
1561+
STRICT IMMUTABLE PARALLEL SAFE
1562+
AS 'json_path_match';
1563+
1564+
CREATE OR REPLACE FUNCTION
1565+
json_path_query(target json, path jsonpath, vars json DEFAULT '{}',
1566+
silent boolean DEFAULT false)
1567+
RETURNS SETOF json
1568+
LANGUAGE INTERNAL
1569+
STRICT IMMUTABLE PARALLEL SAFE
1570+
AS 'json_path_query';
1571+
1572+
CREATE OR REPLACE FUNCTION
1573+
json_path_query_array(target json, path jsonpath, vars json DEFAULT '{}',
1574+
silent boolean DEFAULT false)
1575+
RETURNS json
1576+
LANGUAGE INTERNAL
1577+
STRICT IMMUTABLE PARALLEL SAFE
1578+
AS 'json_path_query_array';
1579+
1580+
CREATE OR REPLACE FUNCTION
1581+
json_path_query_first(target json, path jsonpath, vars json DEFAULT '{}',
1582+
silent boolean DEFAULT false)
1583+
RETURNS json
1584+
LANGUAGE INTERNAL
1585+
STRICT IMMUTABLE PARALLEL SAFE
1586+
AS 'json_path_query_first';
1587+
1588+
CREATE OR REPLACE FUNCTION
1589+
json_path_exists_tz(target json, path jsonpath, vars json DEFAULT '{}',
1590+
silent boolean DEFAULT false)
1591+
RETURNS boolean
1592+
LANGUAGE INTERNAL
1593+
STRICT STABLE PARALLEL SAFE
1594+
AS 'json_path_exists_tz';
1595+
1596+
CREATE OR REPLACE FUNCTION
1597+
json_path_match_tz(target json, path jsonpath, vars json DEFAULT '{}',
1598+
silent boolean DEFAULT false)
1599+
RETURNS boolean
1600+
LANGUAGE INTERNAL
1601+
STRICT STABLE PARALLEL SAFE
1602+
AS 'json_path_match_tz';
1603+
1604+
CREATE OR REPLACE FUNCTION
1605+
json_path_query_tz(target json, path jsonpath, vars json DEFAULT '{}',
1606+
silent boolean DEFAULT false)
1607+
RETURNS SETOF json
1608+
LANGUAGE INTERNAL
1609+
STRICT STABLE PARALLEL SAFE
1610+
AS 'json_path_query_tz';
1611+
1612+
CREATE OR REPLACE FUNCTION
1613+
json_path_query_array_tz(target json, path jsonpath, vars json DEFAULT '{}',
1614+
silent boolean DEFAULT false)
1615+
RETURNS json
1616+
LANGUAGE INTERNAL
1617+
STRICT STABLE PARALLEL SAFE
1618+
AS 'json_path_query_array_tz';
1619+
1620+
CREATE OR REPLACE FUNCTION
1621+
json_path_query_first_tz(target json, path jsonpath, vars json DEFAULT '{}',
1622+
silent boolean DEFAULT false)
1623+
RETURNS json
1624+
LANGUAGE INTERNAL
1625+
STRICT STABLE PARALLEL SAFE
1626+
AS 'json_path_query_first_tz';
1627+
1628+
15311629
-- default normalization form is NFC, per SQL standard
15321630
CREATE OR REPLACE FUNCTION
15331631
"normalize"(text, text DEFAULT 'NFC')

src/backend/utils/adt/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ OBJS = \
4646
int8.o \
4747
json.o \
4848
json_generic.o \
49+
json_gin.o \
50+
json_op.o \
4951
jsonb.o \
5052
jsonb_gin.o \
5153
jsonb_op.o \

src/backend/utils/adt/json_gin.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* json_gin.c
3+
*
4+
* Portions Copyright (c) 2016, PostgreSQL Global Development Group
5+
*
6+
* IDENTIFICATION
7+
* src/backend/utils/adt/json_gin.c
8+
*
9+
*/
10+
11+
#define gin_compare_jsonb gin_compare_json
12+
#define gin_extract_jsonb gin_extract_json
13+
#define gin_extract_jsonb_query gin_extract_json_query
14+
#define gin_consistent_jsonb gin_consistent_json
15+
#define gin_triconsistent_jsonb gin_triconsistent_json
16+
#define gin_extract_jsonb_path gin_extract_json_path
17+
#define gin_extract_jsonb_query_path gin_extract_json_query_path
18+
#define gin_consistent_jsonb_path gin_consistent_json_path
19+
#define gin_triconsistent_jsonb_path gin_triconsistent_json_path
20+
21+
#define JsonxContainerOps (&jsontContainerOps)
22+
#define JsonxGetDatum(json) JsontGetDatum(json)
23+
24+
#include "utils/json_generic.h"
25+
26+
#include "jsonb_gin.c"

src/backend/utils/adt/json_op.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* json_op.c
3+
*
4+
* Portions Copyright (c) 2016, PostgreSQL Global Development Group
5+
*
6+
* IDENTIFICATION
7+
* src/backend/utils/adt/json_op.c
8+
*
9+
*/
10+
11+
#define jsonb_exists json_exists
12+
#define jsonb_exists_any json_exists_any
13+
#define jsonb_exists_all json_exists_all
14+
#define jsonb_contains json_contains
15+
#define jsonb_contained json_contained
16+
#define jsonb_ne json_ne
17+
#define jsonb_lt json_lt
18+
#define jsonb_gt json_gt
19+
#define jsonb_le json_le
20+
#define jsonb_ge json_ge
21+
#define jsonb_eq json_eq
22+
#define jsonb_cmp json_cmp
23+
#define jsonb_hash json_hash
24+
#define jsonb_hash_extended json_hash_extended
25+
26+
#define JsonxContainerOps (&jsontContainerOps)
27+
#define JsonxGetDatum(json) JsontGetDatum(json)
28+
29+
#include "utils/json_generic.h"
30+
31+
#include "jsonb_op.c"

0 commit comments

Comments
 (0)