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

Commite3c1393

Browse files
committed
SQL/JSON: Prevent ON EMPTY for EXISTS columns in JSON_TABLE()
Due to an oversight inde36004, the ON EMPTY clause wasincorrectly allowed in the EXISTS column. Fix the grammar to preventthis.Discussion:https://postgr.es/m/CA%2BHiwqHh3YDXTpccgAo4CdfV9Mhy%2Bmg%3Doh6t8rfM5uLW1BJN4g%40mail.gmail.com
1 parent0ad8153 commite3c1393

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

‎src/backend/parser/gram.y

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14265,7 +14265,7 @@ json_table_column_definition:
1426514265
}
1426614266
|ColIdTypename
1426714267
EXISTSjson_table_column_path_clause_opt
14268-
json_behavior_clause_opt
14268+
json_on_error_clause_opt
1426914269
{
1427014270
JsonTableColumn *n = makeNode(JsonTableColumn);
1427114271

@@ -14276,8 +14276,8 @@ json_table_column_definition:
1427614276
n->wrapper = JSW_NONE;
1427714277
n->quotes = JS_QUOTES_UNSPEC;
1427814278
n->pathspec = (JsonTablePathSpec *)$4;
14279-
n->on_empty =(JsonBehavior *) linitial($5);
14280-
n->on_error = (JsonBehavior *)lsecond($5);
14279+
n->on_empty =NULL;
14280+
n->on_error = (JsonBehavior *)$5;
1428114281
n->location =@1;
1428214282
$$ = (Node *) n;
1428314283
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,3 +1067,8 @@ CREATE OR REPLACE VIEW public.jsonb_table_view7 AS
10671067
) sub
10681068
DROP VIEW jsonb_table_view7;
10691069
DROP TABLE s;
1070+
-- Prevent ON EMPTY specification on EXISTS columns
1071+
SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty object on empty));
1072+
ERROR: syntax error at or near "empty"
1073+
LINE 1: ...sonb '1', '$' COLUMNS (a int exists empty object on empty));
1074+
^

‎src/test/regress/sql/sqljson_jsontable.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,6 @@ SELECT sub.* FROM s,
518518
\sv jsonb_table_view7
519519
DROPVIEW jsonb_table_view7;
520520
DROPTABLE s;
521+
522+
-- Prevent ON EMPTY specification on EXISTS columns
523+
SELECT*FROM JSON_TABLE(jsonb'1','$' COLUMNS (aint exists empty objecton empty));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp