Rename jsonb - text[] operator to #- to avoid ambiguity.

Following recent discussion  on -hackers. The underlying function is
also renamed to jsonb_delete_path. The regression tests now don't need
ugly type casts to avoid the ambiguity, so they are also removed.

Catalog version bumped.
This commit is contained in:
Andrew Dunstan 2015-06-11 10:06:58 -04:00
parent 966c37fdb5
commit 908e234733
7 changed files with 59 additions and 59 deletions

View File

@ -10316,10 +10316,10 @@ table2-mapping
<entry><literal>'["a", "b"]'::jsonb - 1 </literal></entry>
</row>
<row>
<entry><literal>-</literal></entry>
<entry><literal>#-</literal></entry>
<entry><type>text[]</type></entry>
<entry>Delete the field or element with specified path</entry>
<entry><literal>'["a", {"b":1}]'::jsonb - '{1,b}'::text[] </literal></entry>
<entry><literal>'["a", {"b":1}]'::jsonb #- '{1,b}'</literal></entry>
</row>
</tbody>
</tgroup>

View File

@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 201505311
#define CATALOG_VERSION_NO 201506111
#endif

View File

@ -1816,11 +1816,11 @@ DESCR("is contained by");
DATA(insert OID = 3284 ( "||" PGNSP PGUID b f f 3802 3802 3802 0 0 jsonb_concat - - ));
DESCR("concatenate");
DATA(insert OID = 3285 ( "-" PGNSP PGUID b f f 3802 25 3802 0 0 3302 - - ));
DESCR("delete");
DESCR("delete object field");
DATA(insert OID = 3286 ( "-" PGNSP PGUID b f f 3802 23 3802 0 0 3303 - - ));
DESCR("delete");
DATA(insert OID = 3287 ( "-" PGNSP PGUID b f f 3802 1009 3802 0 0 3304 - - ));
DESCR("delete");
DESCR("delete array element");
DATA(insert OID = 3287 ( "#-" PGNSP PGUID b f f 3802 1009 3802 0 0 jsonb_delete_path - - ));
DESCR("delete path");
/*
* function prototypes

View File

@ -4858,7 +4858,7 @@ DESCR("GIN support");
DATA(insert OID = 3301 ( jsonb_concat PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 3802 "3802 3802" _null_ _null_ _null_ _null_ _null_ jsonb_concat _null_ _null_ _null_ ));
DATA(insert OID = 3302 ( jsonb_delete PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 3802 "3802 25" _null_ _null_ _null_ _null_ _null_ jsonb_delete _null_ _null_ _null_ ));
DATA(insert OID = 3303 ( jsonb_delete PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 3802 "3802 23" _null_ _null_ _null_ _null_ _null_ jsonb_delete_idx _null_ _null_ _null_ ));
DATA(insert OID = 3304 ( jsonb_delete PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 3802 "3802 1009" _null_ _null_ _null_ _null_ _null_ jsonb_delete_path _null_ _null_ _null_ ));
DATA(insert OID = 3304 ( jsonb_delete_path PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 3802 "3802 1009" _null_ _null_ _null_ _null_ _null_ jsonb_delete_path _null_ _null_ _null_ ));
DATA(insert OID = 3305 ( jsonb_set PGNSP PGUID 12 1 0 0 0 f f f f t f i 4 0 3802 "3802 1009 3802 16" _null_ _null_ _null_ _null_ _null_ jsonb_set _null_ _null_ _null_ ));
DESCR("Set part of a jsonb");
DATA(insert OID = 3306 ( jsonb_pretty PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 25 "3802" _null_ _null_ _null_ _null_ _null_ jsonb_pretty _null_ _null_ _null_ ));

View File

@ -2947,37 +2947,37 @@ select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'd');
{"a": 1, "b": 2, "c": 3}
(1 row)
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a'::text;
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a';
?column?
------------------
{"b": 2, "c": 3}
(1 row)
select '{"a":null , "b":2, "c":3}'::jsonb - 'a'::text;
select '{"a":null , "b":2, "c":3}'::jsonb - 'a';
?column?
------------------
{"b": 2, "c": 3}
(1 row)
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text;
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b';
?column?
------------------
{"a": 1, "c": 3}
(1 row)
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c'::text;
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c';
?column?
------------------
{"a": 1, "b": 2}
(1 row)
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd'::text;
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd';
?column?
--------------------------
{"a": 1, "b": 2, "c": 3}
(1 row)
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text) = pg_column_size('{"a":1, "b":2}'::jsonb);
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b') = pg_column_size('{"a":1, "b":2}'::jsonb);
?column?
----------
t
@ -3091,37 +3091,37 @@ select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::j
{"a": 1, "b": [1, {"f": "test"}], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
(1 row)
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}'::text[]);
jsonb_delete
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}');
jsonb_delete_path
----------------------------------------------------------
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
(1 row)
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}'::text[]);
jsonb_delete
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}');
jsonb_delete_path
------------------------------------------------------------------
{"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
(1 row)
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}'::text[]);
jsonb_delete
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}');
jsonb_delete_path
------------------------------------------------------------------
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
(1 row)
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{n}'::text[];
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{n}';
?column?
----------------------------------------------------------
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
(1 row)
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{b,-1}'::text[];
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{b,-1}';
?column?
------------------------------------------------------------------
{"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
(1 row)
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{d,1,0}'::text[];
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{d,1,0}';
?column?
------------------------------------------------------------------
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
@ -3152,15 +3152,15 @@ select '[]'::jsonb - 1;
[]
(1 row)
select '"a"'::jsonb - '{a}'::text[]; -- error
select '"a"'::jsonb #- '{a}'; -- error
ERROR: cannot delete path in scalar
select '{}'::jsonb - '{a}'::text[];
select '{}'::jsonb #- '{a}';
?column?
----------
{}
(1 row)
select '[]'::jsonb - '{a}'::text[];
select '[]'::jsonb #- '{a}';
?column?
----------
[]

View File

@ -2947,37 +2947,37 @@ select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'd');
{"a": 1, "b": 2, "c": 3}
(1 row)
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a'::text;
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a';
?column?
------------------
{"b": 2, "c": 3}
(1 row)
select '{"a":null , "b":2, "c":3}'::jsonb - 'a'::text;
select '{"a":null , "b":2, "c":3}'::jsonb - 'a';
?column?
------------------
{"b": 2, "c": 3}
(1 row)
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text;
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b';
?column?
------------------
{"a": 1, "c": 3}
(1 row)
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c'::text;
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c';
?column?
------------------
{"a": 1, "b": 2}
(1 row)
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd'::text;
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd';
?column?
--------------------------
{"a": 1, "b": 2, "c": 3}
(1 row)
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text) = pg_column_size('{"a":1, "b":2}'::jsonb);
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b') = pg_column_size('{"a":1, "b":2}'::jsonb);
?column?
----------
t
@ -3091,37 +3091,37 @@ select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::j
{"a": 1, "b": [1, {"f": "test"}], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
(1 row)
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}'::text[]);
jsonb_delete
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}');
jsonb_delete_path
----------------------------------------------------------
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
(1 row)
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}'::text[]);
jsonb_delete
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}');
jsonb_delete_path
------------------------------------------------------------------
{"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
(1 row)
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}'::text[]);
jsonb_delete
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}');
jsonb_delete_path
------------------------------------------------------------------
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
(1 row)
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{n}'::text[];
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{n}';
?column?
----------------------------------------------------------
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
(1 row)
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{b,-1}'::text[];
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{b,-1}';
?column?
------------------------------------------------------------------
{"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
(1 row)
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{d,1,0}'::text[];
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{d,1,0}';
?column?
------------------------------------------------------------------
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
@ -3152,15 +3152,15 @@ select '[]'::jsonb - 1;
[]
(1 row)
select '"a"'::jsonb - '{a}'::text[]; -- error
select '"a"'::jsonb #- '{a}'; -- error
ERROR: cannot delete path in scalar
select '{}'::jsonb - '{a}'::text[];
select '{}'::jsonb #- '{a}';
?column?
----------
{}
(1 row)
select '[]'::jsonb - '{a}'::text[];
select '[]'::jsonb #- '{a}';
?column?
----------
[]

View File

@ -722,12 +722,12 @@ select jsonb_delete('{"a":null , "b":2, "c":3}'::jsonb, 'a');
select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'b');
select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'c');
select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'd');
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a'::text;
select '{"a":null , "b":2, "c":3}'::jsonb - 'a'::text;
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text;
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c'::text;
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd'::text;
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text) = pg_column_size('{"a":1, "b":2}'::jsonb);
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a';
select '{"a":null , "b":2, "c":3}'::jsonb - 'a';
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b';
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c';
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd';
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b') = pg_column_size('{"a":1, "b":2}'::jsonb);
select '["a","b","c"]'::jsonb - 3;
select '["a","b","c"]'::jsonb - 2;
@ -751,13 +751,13 @@ select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::j
select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '"test"');
select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '{"f": "test"}');
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}'::text[]);
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}'::text[]);
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}'::text[]);
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}');
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}');
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}');
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{n}'::text[];
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{b,-1}'::text[];
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{d,1,0}'::text[];
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{n}';
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{b,-1}';
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{d,1,0}';
-- empty structure and error conditions for delete and replace
@ -768,9 +768,9 @@ select '[]'::jsonb - 'a';
select '"a"'::jsonb - 1; -- error
select '{}'::jsonb - 1; -- error
select '[]'::jsonb - 1;
select '"a"'::jsonb - '{a}'::text[]; -- error
select '{}'::jsonb - '{a}'::text[];
select '[]'::jsonb - '{a}'::text[];
select '"a"'::jsonb #- '{a}'; -- error
select '{}'::jsonb #- '{a}';
select '[]'::jsonb #- '{a}';
select jsonb_set('"a"','{a}','"b"'); --error
select jsonb_set('{}','{a}','"b"', false);
select jsonb_set('[]','{1}','"b"', false);