@@ -683,6 +683,18 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
683
683
json_table_formatted_column_definition
684
684
json_table_exists_column_definition
685
685
json_table_nested_columns
686
+ json_table_plan_clause_opt
687
+ json_table_specific_plan
688
+ json_table_plan
689
+ json_table_plan_simple
690
+ json_table_plan_parent_child
691
+ json_table_plan_outer
692
+ json_table_plan_inner
693
+ json_table_plan_sibling
694
+ json_table_plan_union
695
+ json_table_plan_cross
696
+ json_table_plan_primary
697
+ json_table_default_plan
686
698
687
699
%type <list> json_name_and_value_list
688
700
json_value_expr_list
@@ -698,6 +710,9 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
698
710
699
711
%type <ival> json_encoding
700
712
json_encoding_clause_opt
713
+ json_table_default_plan_choices
714
+ json_table_default_plan_inner_outer
715
+ json_table_default_plan_union_cross
701
716
json_wrapper_clause_opt
702
717
json_wrapper_behavior
703
718
json_conditional_or_unconditional_opt
@@ -812,7 +827,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
812
827
ORDER ORDINALITY OTHERS OUT_P OUTER_P
813
828
OVER OVERLAPS OVERLAY OVERRIDING OWNED OWNER
814
829
815
- PARALLEL PARSER PARTIAL PARTITION PASSING PASSWORD PATH PLACING PLANS POLICY
830
+ PARALLEL PARSER PARTIAL PARTITION PASSING PASSWORD PATH PLACING PLAN PLANS POLICY
816
831
POSITION PRECEDING PRECISION PRESERVE PREPARE PREPARED PRIMARY
817
832
PRIOR PRIVILEGES PROCEDURAL PROCEDURE PROCEDURES PROGRAM PUBLICATION
818
833
@@ -15928,13 +15943,15 @@ json_table:
15928
15943
JSON_TABLE ' ('
15929
15944
json_api_common_syntax
15930
15945
json_table_columns_clause
15946
+ json_table_plan_clause_opt
15931
15947
json_table_error_clause_opt
15932
15948
' )'
15933
15949
{
15934
15950
JsonTable *n = makeNode (JsonTable);
15935
15951
n->common = (JsonCommon *) $3 ;
15936
15952
n->columns = $4 ;
15937
- n->on_error = $5 ;
15953
+ n->plan = (JsonTablePlan *) $5 ;
15954
+ n->on_error = $6 ;
15938
15955
n->location = @1 ;
15939
15956
$$ = (Node *) n;
15940
15957
}
@@ -16055,12 +16072,15 @@ json_table_formatted_column_definition:
16055
16072
;
16056
16073
16057
16074
json_table_nested_columns:
16058
- NESTED path_opt Sconst json_table_columns_clause
16075
+ NESTED path_opt Sconst
16076
+ json_as_path_name_clause_opt
16077
+ json_table_columns_clause
16059
16078
{
16060
16079
JsonTableColumn *n = makeNode (JsonTableColumn);
16061
16080
n->coltype = JTC_NESTED;
16062
16081
n->pathspec = $3 ;
16063
- n->columns = $4 ;
16082
+ n->pathname = $4 ;
16083
+ n->columns = $5 ;
16064
16084
n->location = @1 ;
16065
16085
$$ = (Node *) n;
16066
16086
}
@@ -16071,6 +16091,106 @@ path_opt:
16071
16091
| /* EMPTY */ { }
16072
16092
;
16073
16093
16094
+ json_table_plan_clause_opt:
16095
+ json_table_specific_plan { $$ = $1 ; }
16096
+ | json_table_default_plan { $$ = $1 ; }
16097
+ | /* EMPTY */ { $$ = NULL ; }
16098
+ ;
16099
+
16100
+ json_table_specific_plan:
16101
+ PLAN ' (' json_table_plan ' )' { $$ = $3 ; }
16102
+ ;
16103
+
16104
+ json_table_plan:
16105
+ json_table_plan_simple
16106
+ | json_table_plan_parent_child
16107
+ | json_table_plan_sibling
16108
+ ;
16109
+
16110
+ json_table_plan_simple:
16111
+ json_table_path_name
16112
+ {
16113
+ JsonTablePlan *n = makeNode (JsonTablePlan);
16114
+ n->plan_type = JSTP_SIMPLE;
16115
+ n->pathname = $1 ;
16116
+ n->location = @1 ;
16117
+ $$ = (Node *) n;
16118
+ }
16119
+ ;
16120
+
16121
+ json_table_plan_parent_child:
16122
+ json_table_plan_outer
16123
+ | json_table_plan_inner
16124
+ ;
16125
+
16126
+ json_table_plan_outer:
16127
+ json_table_plan_simple OUTER_P json_table_plan_primary
16128
+ { $$ = makeJsonTableJoinedPlan (JSTPJ_OUTER, $1 , $3 , @1 ); }
16129
+ ;
16130
+
16131
+ json_table_plan_inner:
16132
+ json_table_plan_simple INNER_P json_table_plan_primary
16133
+ { $$ = makeJsonTableJoinedPlan (JSTPJ_INNER, $1 , $3 , @1 ); }
16134
+ ;
16135
+
16136
+ json_table_plan_sibling:
16137
+ json_table_plan_union
16138
+ | json_table_plan_cross
16139
+ ;
16140
+
16141
+ json_table_plan_union:
16142
+ json_table_plan_primary UNION json_table_plan_primary
16143
+ { $$ = makeJsonTableJoinedPlan (JSTPJ_UNION, $1 , $3 , @1 ); }
16144
+ | json_table_plan_union UNION json_table_plan_primary
16145
+ { $$ = makeJsonTableJoinedPlan (JSTPJ_UNION, $1 , $3 , @1 ); }
16146
+ ;
16147
+
16148
+ json_table_plan_cross:
16149
+ json_table_plan_primary CROSS json_table_plan_primary
16150
+ { $$ = makeJsonTableJoinedPlan (JSTPJ_CROSS, $1 , $3 , @1 ); }
16151
+ | json_table_plan_cross CROSS json_table_plan_primary
16152
+ { $$ = makeJsonTableJoinedPlan (JSTPJ_CROSS, $1 , $3 , @1 ); }
16153
+ ;
16154
+
16155
+ json_table_plan_primary:
16156
+ json_table_plan_simple { $$ = $1 ; }
16157
+ | ' (' json_table_plan ' )'
16158
+ {
16159
+ castNode (JsonTablePlan, $2 )->location = @1 ;
16160
+ $$ = $2 ;
16161
+ }
16162
+ ;
16163
+
16164
+ json_table_default_plan:
16165
+ PLAN DEFAULT ' (' json_table_default_plan_choices ' )'
16166
+ {
16167
+ JsonTablePlan *n = makeNode (JsonTablePlan);
16168
+ n->plan_type = JSTP_DEFAULT;
16169
+ n->join_type = $4 ;
16170
+ n->location = @1 ;
16171
+ $$ = (Node *) n;
16172
+ }
16173
+ ;
16174
+
16175
+ json_table_default_plan_choices:
16176
+ json_table_default_plan_inner_outer { $$ = $1 | JSTPJ_UNION; }
16177
+ | json_table_default_plan_inner_outer ' ,'
16178
+ json_table_default_plan_union_cross { $$ = $1 | $3 ; }
16179
+ | json_table_default_plan_union_cross { $$ = $1 | JSTPJ_OUTER; }
16180
+ | json_table_default_plan_union_cross ' ,'
16181
+ json_table_default_plan_inner_outer { $$ = $1 | $3 ; }
16182
+ ;
16183
+
16184
+ json_table_default_plan_inner_outer:
16185
+ INNER_P { $$ = JSTPJ_INNER; }
16186
+ | OUTER_P { $$ = JSTPJ_OUTER; }
16187
+ ;
16188
+
16189
+ json_table_default_plan_union_cross:
16190
+ UNION { $$ = JSTPJ_UNION; }
16191
+ | CROSS { $$ = JSTPJ_CROSS; }
16192
+ ;
16193
+
16074
16194
json_returning_clause_opt:
16075
16195
RETURNING Typename
16076
16196
{
@@ -16951,6 +17071,7 @@ unreserved_keyword:
16951
17071
| PASSING
16952
17072
| PASSWORD
16953
17073
| PATH
17074
+ | PLAN
16954
17075
| PLANS
16955
17076
| POLICY
16956
17077
| PRECEDING
@@ -17568,6 +17689,7 @@ bare_label_keyword:
17568
17689
| PASSWORD
17569
17690
| PATH
17570
17691
| PLACING
17692
+ | PLAN
17571
17693
| PLANS
17572
17694
| POLICY
17573
17695
| POSITION
0 commit comments