Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit641fde2

Browse files
committed
Remove ambiguity for jsonb_path_match() and jsonb_path_exists()
There are 2-arguments and 4-arguments versions of jsonb_path_match() andjsonb_path_exists(). But 4-arguments versions have optional 3rd and 4tharguments, that leads to ambiguity. In the same time 2-arguments versions areneeded only for @@ and @? operators. So, rename 2-arguments versions toremove the ambiguity.Catversion is bumped.
1 parent1f39a1c commit641fde2

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

‎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-
#defineCATALOG_VERSION_NO201903161
56+
#defineCATALOG_VERSION_NO201903201
5757

5858
#endif

‎src/include/catalog/pg_operator.dat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,11 +3257,11 @@
32573257
oprresult => 'jsonb', oprcode => 'jsonb_delete_path' },
32583258
{ oid => '4012', descr => 'jsonpath exists',
32593259
oprname => '@?', oprleft => 'jsonb', oprright => 'jsonpath',
3260-
oprresult => 'bool', oprcode => 'jsonb_path_exists(jsonb,jsonpath)',
3260+
oprresult => 'bool', oprcode => 'jsonb_path_exists_opr(jsonb,jsonpath)',
32613261
oprrest => 'contsel', oprjoin => 'contjoinsel' },
32623262
{ oid => '4013', descr => 'jsonpath match',
32633263
oprname => '@@', oprleft => 'jsonb', oprright => 'jsonpath',
3264-
oprresult => 'bool', oprcode => 'jsonb_path_match(jsonb,jsonpath)',
3264+
oprresult => 'bool', oprcode => 'jsonb_path_match_opr(jsonb,jsonpath)',
32653265
oprrest => 'contsel', oprjoin => 'contjoinsel' },
32663266

32673267
]

‎src/include/catalog/pg_proc.dat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9249,10 +9249,10 @@
92499249
prosrc => 'jsonb_path_match' },
92509250

92519251
{ oid => '4010', descr => 'implementation of @? operator',
9252-
proname => 'jsonb_path_exists', prorettype => 'bool',
9252+
proname => 'jsonb_path_exists_opr', prorettype => 'bool',
92539253
proargtypes => 'jsonb jsonpath', prosrc => 'jsonb_path_exists_opr' },
92549254
{ oid => '4011', descr => 'implementation of @@ operator',
9255-
proname => 'jsonb_path_match', prorettype => 'bool',
9255+
proname => 'jsonb_path_match_opr', prorettype => 'bool',
92569256
proargtypes => 'jsonb jsonpath', prosrc => 'jsonb_path_match_opr' },
92579257

92589258
# txid

‎src/test/regress/expected/jsonb_jsonpath.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,6 +1751,12 @@ SELECT jsonb '[{"a": 1}, {"a": 2}]' @? '$[*] ? (@.a > 2)';
17511751
f
17521752
(1 row)
17531753

1754+
SELECT jsonb_path_exists('[{"a": 1}, {"a": 2}]', '$[*].a ? (@ > 1)');
1755+
jsonb_path_exists
1756+
-------------------
1757+
t
1758+
(1 row)
1759+
17541760
SELECT jsonb_path_exists('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*] ? (@.a > $min && @.a < $max)', vars => '{"min": 1, "max": 4}');
17551761
jsonb_path_exists
17561762
-------------------
@@ -1775,3 +1781,9 @@ SELECT jsonb '[{"a": 1}, {"a": 2}]' @@ '$[*].a > 2';
17751781
f
17761782
(1 row)
17771783

1784+
SELECT jsonb_path_match('[{"a": 1}, {"a": 2}]', '$[*].a > 1');
1785+
jsonb_path_match
1786+
------------------
1787+
t
1788+
(1 row)
1789+

‎src/test/regress/sql/jsonb_jsonpath.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,10 @@ SELECT jsonb_path_query_first('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]', '$[*].
362362

363363
SELECT jsonb'[{"a": 1}, {"a": 2}]' @?'$[*].a ? (@ > 1)';
364364
SELECT jsonb'[{"a": 1}, {"a": 2}]' @?'$[*] ? (@.a > 2)';
365+
SELECT jsonb_path_exists('[{"a": 1}, {"a": 2}]','$[*].a ? (@ > 1)');
365366
SELECT jsonb_path_exists('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]','$[*] ? (@.a > $min && @.a < $max)', vars=>'{"min": 1, "max": 4}');
366367
SELECT jsonb_path_exists('[{"a": 1}, {"a": 2}, {"a": 3}, {"a": 5}]','$[*] ? (@.a > $min && @.a < $max)', vars=>'{"min": 3, "max": 4}');
367368

368369
SELECT jsonb'[{"a": 1}, {"a": 2}]' @@'$[*].a > 1';
369370
SELECT jsonb'[{"a": 1}, {"a": 2}]' @@'$[*].a > 2';
371+
SELECT jsonb_path_match('[{"a": 1}, {"a": 2}]','$[*].a > 1');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp