@@ -220,6 +220,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
220
220
JoinType jtype;
221
221
DropBehavior dbehavior;
222
222
OnCommitAction oncommit;
223
+ JsonFormat jsformat;
223
224
List *list;
224
225
Node *node;
225
226
Value *value;
@@ -599,6 +600,15 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
599
600
%type <list> hash_partbound
600
601
%type <defelt> hash_partbound_elem
601
602
603
+ %type <node> json_value_expr
604
+ json_output_clause_opt
605
+
606
+ %type <ival> json_encoding
607
+ json_encoding_clause_opt
608
+
609
+ %type <jsformat> json_format_clause_opt
610
+ json_representation
611
+
602
612
/*
603
613
* Non-keyword token types. These are hard-wired into the "flex" lexer.
604
614
* They must be listed first so that their numeric codes do not depend on
@@ -650,7 +660,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
650
660
EXTENSION EXTERNAL EXTRACT
651
661
652
662
FALSE_P FAMILY FETCH FILTER FIRST_P FLOAT_P FOLLOWING FOR
653
- FORCE FOREIGN FORWARD FREEZE FROM FULL FUNCTION FUNCTIONS
663
+ FORCE FOREIGN FORMAT FORWARD FREEZE FROM FULL FUNCTION FUNCTIONS
654
664
655
665
GENERATED GLOBAL GRANT GRANTED GREATEST GROUP_P GROUPING GROUPS
656
666
@@ -661,7 +671,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
661
671
INNER_P INOUT INPUT_P INSENSITIVE INSERT INSTEAD INT_P INTEGER
662
672
INTERSECT INTERVAL INTO INVOKER IS ISNULL ISOLATION
663
673
664
- JOIN
674
+ JOIN JSON
665
675
666
676
KEY
667
677
@@ -729,9 +739,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
729
739
*/
730
740
%token NOT_LA NULLS_LA WITH_LA
731
741
732
-
733
742
/* Precedence: lowest to highest */
734
743
%nonassoc SET /* see relation_expr_opt_alias */
744
+ %right FORMAT
735
745
%left UNION EXCEPT
736
746
%left INTERSECT
737
747
%left OR
@@ -14635,6 +14645,58 @@ opt_asymmetric: ASYMMETRIC
14635
14645
| /* EMPTY*/
14636
14646
;
14637
14647
14648
+ /* SQL/JSON support */
14649
+
14650
+ json_value_expr:
14651
+ a_expr json_format_clause_opt
14652
+ {
14653
+ $$ = (Node *) makeJsonValueExpr ((Expr *) $1 , $2 );
14654
+ }
14655
+ ;
14656
+
14657
+ json_format_clause_opt:
14658
+ FORMAT json_representation
14659
+ {
14660
+ $$ = $2 ;
14661
+ $$.location = @1 ;
14662
+ }
14663
+ | /* EMPTY */
14664
+ {
14665
+ $$.type = JS_FORMAT_DEFAULT;
14666
+ $$.encoding = JS_ENC_DEFAULT;
14667
+ $$.location = -1 ;
14668
+ }
14669
+ ;
14670
+
14671
+ json_representation:
14672
+ JSON json_encoding_clause_opt
14673
+ {
14674
+ $$.type = JS_FORMAT_JSON;
14675
+ $$.encoding = $2 ;
14676
+ $$.location = @1 ;
14677
+ }
14678
+ /* | implementation_defined_JSON_representation_option (BSON, AVRO etc) */
14679
+ ;
14680
+
14681
+ json_encoding_clause_opt:
14682
+ ENCODING json_encoding { $$ = $2 ; }
14683
+ | /* EMPTY */ { $$ = JS_ENC_DEFAULT; }
14684
+ ;
14685
+
14686
+ json_encoding:
14687
+ name { $$ = makeJsonEncoding ($1 ); }
14688
+ ;
14689
+
14690
+ json_output_clause_opt:
14691
+ RETURNING Typename json_format_clause_opt
14692
+ {
14693
+ JsonOutput *n = makeNode (JsonOutput);
14694
+ n->typeName = $2 ;
14695
+ n->returning .format = $3 ;
14696
+ $$ = (Node *) n;
14697
+ }
14698
+ | /* EMPTY */ { $$ = NULL ; }
14699
+ ;
14638
14700
14639
14701
/* ****************************************************************************
14640
14702
*
@@ -15113,6 +15175,7 @@ unreserved_keyword:
15113
15175
| FIRST_P
15114
15176
| FOLLOWING
15115
15177
| FORCE
15178
+ | FORMAT
15116
15179
| FORWARD
15117
15180
| FUNCTION
15118
15181
| FUNCTIONS
@@ -15144,6 +15207,7 @@ unreserved_keyword:
15144
15207
| INSTEAD
15145
15208
| INVOKER
15146
15209
| ISOLATION
15210
+ | JSON
15147
15211
| KEY
15148
15212
| LABEL
15149
15213
| LANGUAGE
0 commit comments