Due to an oversight in
de3600452b61, the ON EMPTY clause was
incorrectly allowed in the EXISTS column. Fix the grammar to prevent
this.
Discussion: https://postgr.es/m/CA%2BHiwqHh3YDXTpccgAo4CdfV9Mhy%2Bmg%3Doh6t8rfM5uLW1BJN4g%40mail.gmail.com
}
| ColId Typename
EXISTS json_table_column_path_clause_opt
- json_behavior_clause_opt
+ json_on_error_clause_opt
{
JsonTableColumn *n = makeNode(JsonTableColumn);
n->wrapper = JSW_NONE;
n->quotes = JS_QUOTES_UNSPEC;
n->pathspec = (JsonTablePathSpec *) $4;
- n->on_empty = (JsonBehavior *) linitial($5);
- n->on_error = (JsonBehavior *) lsecond($5);
+ n->on_empty = NULL;
+ n->on_error = (JsonBehavior *) $5;
n->location = @1;
$$ = (Node *) n;
}
) sub
DROP VIEW jsonb_table_view7;
DROP TABLE s;
+-- Prevent ON EMPTY specification on EXISTS columns
+SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty object on empty));
+ERROR: syntax error at or near "empty"
+LINE 1: ...sonb '1', '$' COLUMNS (a int exists empty object on empty));
+ ^
\sv jsonb_table_view7
DROP VIEW jsonb_table_view7;
DROP TABLE s;
+
+-- Prevent ON EMPTY specification on EXISTS columns
+SELECT * FROM JSON_TABLE(jsonb '1', '$' COLUMNS (a int exists empty object on empty));