@@ -645,16 +645,16 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
645
645
%type <list> hash_partbound
646
646
%type <defelt> hash_partbound_elem
647
647
648
- %type <node> json_format_clause_opt
648
+ %type <node> json_format_clause
649
+ json_format_clause_opt
649
650
json_value_expr
650
651
json_returning_clause_opt
651
652
json_name_and_value
652
653
json_aggregate_func
653
654
%type <list> json_name_and_value_list
654
655
json_value_expr_list
655
656
json_array_aggregate_order_by_clause_opt
656
- %type <ival> json_encoding_clause_opt
657
- json_predicate_type_constraint
657
+ %type <ival> json_predicate_type_constraint
658
658
%type <boolean> json_key_uniqueness_constraint_opt
659
659
json_object_constructor_null_clause_opt
660
660
json_array_constructor_null_clause_opt
@@ -14962,12 +14962,11 @@ a_expr: c_expr { $$ = $1; }
14962
14962
/*
14963
14963
* Required by SQL/JSON, but there are conflicts
14964
14964
| a_expr
14965
- FORMAT_LA JSON json_encoding_clause_opt
14965
+ json_format_clause
14966
14966
IS json_predicate_type_constraint
14967
14967
json_key_uniqueness_constraint_opt %prec IS
14968
14968
{
14969
- $3.location = @2;
14970
- $$ = makeJsonIsPredicate($1, $3, $5, $6, @1);
14969
+ $$ = makeJsonIsPredicate($1, $2, $4, $5, @1);
14971
14970
}
14972
14971
*/
14973
14972
| a_expr IS NOT
@@ -14981,13 +14980,12 @@ a_expr: c_expr { $$ = $1; }
14981
14980
/*
14982
14981
* Required by SQL/JSON, but there are conflicts
14983
14982
| a_expr
14984
- FORMAT_LA JSON json_encoding_clause_opt
14983
+ json_format_clause
14985
14984
IS NOT
14986
14985
json_predicate_type_constraint
14987
14986
json_key_uniqueness_constraint_opt %prec IS
14988
14987
{
14989
- $3.location = @2;
14990
- $$ = makeNotExpr(makeJsonIsPredicate($1, $3, $6, $7, @1), @1);
14988
+ $$ = makeNotExpr(makeJsonIsPredicate($1, $2, $5, $6, @1), @1);
14991
14989
}
14992
14990
*/
14993
14991
| DEFAULT
@@ -16503,22 +16501,41 @@ json_value_expr:
16503
16501
}
16504
16502
;
16505
16503
16504
+ json_format_clause:
16505
+ FORMAT_LA JSON ENCODING name
16506
+ {
16507
+ int encoding;
16508
+
16509
+ if (!pg_strcasecmp ($4 , " utf8" ))
16510
+ encoding = JS_ENC_UTF8;
16511
+ else if (!pg_strcasecmp ($4 , " utf16" ))
16512
+ encoding = JS_ENC_UTF16;
16513
+ else if (!pg_strcasecmp ($4 , " utf32" ))
16514
+ encoding = JS_ENC_UTF32;
16515
+ else
16516
+ ereport (ERROR,
16517
+ errcode (ERRCODE_INVALID_PARAMETER_VALUE),
16518
+ errmsg (" unrecognized JSON encoding: %s" , $4 ));
16519
+
16520
+ $$ = (Node *) makeJsonFormat (JS_FORMAT_JSON, encoding, @1 );
16521
+ }
16522
+ | FORMAT_LA JSON
16523
+ {
16524
+ $$ = (Node *) makeJsonFormat (JS_FORMAT_JSON, JS_ENC_DEFAULT, @1 );
16525
+ }
16526
+ ;
16527
+
16506
16528
json_format_clause_opt:
16507
- FORMAT_LA JSON json_encoding_clause_opt
16529
+ json_format_clause
16508
16530
{
16509
- $$ = (Node *) makeJsonFormat (JS_FORMAT_JSON, $ 3 , @ 1 ) ;
16531
+ $$ = $ 1 ;
16510
16532
}
16511
16533
| /* EMPTY */
16512
16534
{
16513
16535
$$ = (Node *) makeJsonFormat (JS_FORMAT_DEFAULT, JS_ENC_DEFAULT, -1 );
16514
16536
}
16515
16537
;
16516
16538
16517
- json_encoding_clause_opt:
16518
- ENCODING name { $$ = makeJsonEncoding ($2 ); }
16519
- | /* EMPTY */ { $$ = JS_ENC_DEFAULT; }
16520
- ;
16521
-
16522
16539
json_returning_clause_opt:
16523
16540
RETURNING Typename json_format_clause_opt
16524
16541
{
0 commit comments