Skip to content

Commit 908e234

Browse files
committed
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.
1 parent 966c37f commit 908e234

File tree

7 files changed

+59
-59
lines changed

7 files changed

+59
-59
lines changed

doc/src/sgml/func.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10316,10 +10316,10 @@ table2-mapping
1031610316
<entry><literal>'["a", "b"]'::jsonb - 1 </literal></entry>
1031710317
</row>
1031810318
<row>
10319-
<entry><literal>-</literal></entry>
10319+
<entry><literal>#-</literal></entry>
1032010320
<entry><type>text[]</type></entry>
1032110321
<entry>Delete the field or element with specified path</entry>
10322-
<entry><literal>'["a", {"b":1}]'::jsonb - '{1,b}'::text[] </literal></entry>
10322+
<entry><literal>'["a", {"b":1}]'::jsonb #- '{1,b}'</literal></entry>
1032310323
</row>
1032410324
</tbody>
1032510325
</tgroup>

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201505311
56+
#define CATALOG_VERSION_NO 201506111
5757

5858
#endif

src/include/catalog/pg_operator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,11 +1816,11 @@ DESCR("is contained by");
18161816
DATA(insert OID = 3284 ( "||" PGNSP PGUID b f f 3802 3802 3802 0 0 jsonb_concat - - ));
18171817
DESCR("concatenate");
18181818
DATA(insert OID = 3285 ( "-" PGNSP PGUID b f f 3802 25 3802 0 0 3302 - - ));
1819-
DESCR("delete");
1819+
DESCR("delete object field");
18201820
DATA(insert OID = 3286 ( "-" PGNSP PGUID b f f 3802 23 3802 0 0 3303 - - ));
1821-
DESCR("delete");
1822-
DATA(insert OID = 3287 ( "-" PGNSP PGUID b f f 3802 1009 3802 0 0 3304 - - ));
1823-
DESCR("delete");
1821+
DESCR("delete array element");
1822+
DATA(insert OID = 3287 ( "#-" PGNSP PGUID b f f 3802 1009 3802 0 0 jsonb_delete_path - - ));
1823+
DESCR("delete path");
18241824

18251825
/*
18261826
* function prototypes

src/include/catalog/pg_proc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4858,7 +4858,7 @@ DESCR("GIN support");
48584858
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_ ));
48594859
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_ ));
48604860
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_ ));
4861-
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_ ));
4861+
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_ ));
48624862
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_ ));
48634863
DESCR("Set part of a jsonb");
48644864
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_ ));

src/test/regress/expected/jsonb.out

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,37 +2947,37 @@ select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'd');
29472947
{"a": 1, "b": 2, "c": 3}
29482948
(1 row)
29492949

2950-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a'::text;
2950+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a';
29512951
?column?
29522952
------------------
29532953
{"b": 2, "c": 3}
29542954
(1 row)
29552955

2956-
select '{"a":null , "b":2, "c":3}'::jsonb - 'a'::text;
2956+
select '{"a":null , "b":2, "c":3}'::jsonb - 'a';
29572957
?column?
29582958
------------------
29592959
{"b": 2, "c": 3}
29602960
(1 row)
29612961

2962-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text;
2962+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b';
29632963
?column?
29642964
------------------
29652965
{"a": 1, "c": 3}
29662966
(1 row)
29672967

2968-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c'::text;
2968+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c';
29692969
?column?
29702970
------------------
29712971
{"a": 1, "b": 2}
29722972
(1 row)
29732973

2974-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd'::text;
2974+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd';
29752975
?column?
29762976
--------------------------
29772977
{"a": 1, "b": 2, "c": 3}
29782978
(1 row)
29792979

2980-
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text) = pg_column_size('{"a":1, "b":2}'::jsonb);
2980+
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b') = pg_column_size('{"a":1, "b":2}'::jsonb);
29812981
?column?
29822982
----------
29832983
t
@@ -3091,37 +3091,37 @@ select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::j
30913091
{"a": 1, "b": [1, {"f": "test"}], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
30923092
(1 row)
30933093

3094-
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}'::text[]);
3095-
jsonb_delete
3094+
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}');
3095+
jsonb_delete_path
30963096
----------------------------------------------------------
30973097
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
30983098
(1 row)
30993099

3100-
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}'::text[]);
3101-
jsonb_delete
3100+
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}');
3101+
jsonb_delete_path
31023102
------------------------------------------------------------------
31033103
{"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
31043104
(1 row)
31053105

3106-
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}'::text[]);
3107-
jsonb_delete
3106+
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}');
3107+
jsonb_delete_path
31083108
------------------------------------------------------------------
31093109
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
31103110
(1 row)
31113111

3112-
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{n}'::text[];
3112+
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{n}';
31133113
?column?
31143114
----------------------------------------------------------
31153115
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
31163116
(1 row)
31173117

3118-
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{b,-1}'::text[];
3118+
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{b,-1}';
31193119
?column?
31203120
------------------------------------------------------------------
31213121
{"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
31223122
(1 row)
31233123

3124-
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{d,1,0}'::text[];
3124+
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{d,1,0}';
31253125
?column?
31263126
------------------------------------------------------------------
31273127
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
@@ -3152,15 +3152,15 @@ select '[]'::jsonb - 1;
31523152
[]
31533153
(1 row)
31543154

3155-
select '"a"'::jsonb - '{a}'::text[]; -- error
3155+
select '"a"'::jsonb #- '{a}'; -- error
31563156
ERROR: cannot delete path in scalar
3157-
select '{}'::jsonb - '{a}'::text[];
3157+
select '{}'::jsonb #- '{a}';
31583158
?column?
31593159
----------
31603160
{}
31613161
(1 row)
31623162

3163-
select '[]'::jsonb - '{a}'::text[];
3163+
select '[]'::jsonb #- '{a}';
31643164
?column?
31653165
----------
31663166
[]

src/test/regress/expected/jsonb_1.out

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,37 +2947,37 @@ select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'd');
29472947
{"a": 1, "b": 2, "c": 3}
29482948
(1 row)
29492949

2950-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a'::text;
2950+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a';
29512951
?column?
29522952
------------------
29532953
{"b": 2, "c": 3}
29542954
(1 row)
29552955

2956-
select '{"a":null , "b":2, "c":3}'::jsonb - 'a'::text;
2956+
select '{"a":null , "b":2, "c":3}'::jsonb - 'a';
29572957
?column?
29582958
------------------
29592959
{"b": 2, "c": 3}
29602960
(1 row)
29612961

2962-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text;
2962+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b';
29632963
?column?
29642964
------------------
29652965
{"a": 1, "c": 3}
29662966
(1 row)
29672967

2968-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c'::text;
2968+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c';
29692969
?column?
29702970
------------------
29712971
{"a": 1, "b": 2}
29722972
(1 row)
29732973

2974-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd'::text;
2974+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd';
29752975
?column?
29762976
--------------------------
29772977
{"a": 1, "b": 2, "c": 3}
29782978
(1 row)
29792979

2980-
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text) = pg_column_size('{"a":1, "b":2}'::jsonb);
2980+
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b') = pg_column_size('{"a":1, "b":2}'::jsonb);
29812981
?column?
29822982
----------
29832983
t
@@ -3091,37 +3091,37 @@ select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::j
30913091
{"a": 1, "b": [1, {"f": "test"}], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
30923092
(1 row)
30933093

3094-
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}'::text[]);
3095-
jsonb_delete
3094+
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}');
3095+
jsonb_delete_path
30963096
----------------------------------------------------------
30973097
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
30983098
(1 row)
30993099

3100-
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}'::text[]);
3101-
jsonb_delete
3100+
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}');
3101+
jsonb_delete_path
31023102
------------------------------------------------------------------
31033103
{"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
31043104
(1 row)
31053105

3106-
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}'::text[]);
3107-
jsonb_delete
3106+
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}');
3107+
jsonb_delete_path
31083108
------------------------------------------------------------------
31093109
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
31103110
(1 row)
31113111

3112-
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{n}'::text[];
3112+
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{n}';
31133113
?column?
31143114
----------------------------------------------------------
31153115
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
31163116
(1 row)
31173117

3118-
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{b,-1}'::text[];
3118+
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{b,-1}';
31193119
?column?
31203120
------------------------------------------------------------------
31213121
{"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
31223122
(1 row)
31233123

3124-
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{d,1,0}'::text[];
3124+
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{d,1,0}';
31253125
?column?
31263126
------------------------------------------------------------------
31273127
{"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
@@ -3152,15 +3152,15 @@ select '[]'::jsonb - 1;
31523152
[]
31533153
(1 row)
31543154

3155-
select '"a"'::jsonb - '{a}'::text[]; -- error
3155+
select '"a"'::jsonb #- '{a}'; -- error
31563156
ERROR: cannot delete path in scalar
3157-
select '{}'::jsonb - '{a}'::text[];
3157+
select '{}'::jsonb #- '{a}';
31583158
?column?
31593159
----------
31603160
{}
31613161
(1 row)
31623162

3163-
select '[]'::jsonb - '{a}'::text[];
3163+
select '[]'::jsonb #- '{a}';
31643164
?column?
31653165
----------
31663166
[]

src/test/regress/sql/jsonb.sql

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -722,12 +722,12 @@ select jsonb_delete('{"a":null , "b":2, "c":3}'::jsonb, 'a');
722722
select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'b');
723723
select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'c');
724724
select jsonb_delete('{"a":1 , "b":2, "c":3}'::jsonb, 'd');
725-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a'::text;
726-
select '{"a":null , "b":2, "c":3}'::jsonb - 'a'::text;
727-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text;
728-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c'::text;
729-
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd'::text;
730-
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b'::text) = pg_column_size('{"a":1, "b":2}'::jsonb);
725+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'a';
726+
select '{"a":null , "b":2, "c":3}'::jsonb - 'a';
727+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'b';
728+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'c';
729+
select '{"a":1 , "b":2, "c":3}'::jsonb - 'd';
730+
select pg_column_size('{"a":1 , "b":2, "c":3}'::jsonb - 'b') = pg_column_size('{"a":1, "b":2}'::jsonb);
731731

732732
select '["a","b","c"]'::jsonb - 3;
733733
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
751751
select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '"test"');
752752
select jsonb_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb, '{b,-1}', '{"f": "test"}');
753753

754-
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}'::text[]);
755-
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}'::text[]);
756-
select jsonb_delete('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}'::text[]);
754+
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}');
755+
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}');
756+
select jsonb_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}');
757757

758-
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{n}'::text[];
759-
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{b,-1}'::text[];
760-
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb - '{d,1,0}'::text[];
758+
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{n}';
759+
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{b,-1}';
760+
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::jsonb #- '{d,1,0}';
761761

762762

763763
-- empty structure and error conditions for delete and replace
@@ -768,9 +768,9 @@ select '[]'::jsonb - 'a';
768768
select '"a"'::jsonb - 1; -- error
769769
select '{}'::jsonb - 1; -- error
770770
select '[]'::jsonb - 1;
771-
select '"a"'::jsonb - '{a}'::text[]; -- error
772-
select '{}'::jsonb - '{a}'::text[];
773-
select '[]'::jsonb - '{a}'::text[];
771+
select '"a"'::jsonb #- '{a}'; -- error
772+
select '{}'::jsonb #- '{a}';
773+
select '[]'::jsonb #- '{a}';
774774
select jsonb_set('"a"','{a}','"b"'); --error
775775
select jsonb_set('{}','{a}','"b"', false);
776776
select jsonb_set('[]','{1}','"b"', false);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy