Update parser changes between PostgreSQL 16 BETA1 and 16 RC1.
authorChen Ningwei <chen@sraoss.co.jp>
Mon, 30 Oct 2023 03:00:12 +0000 (12:00 +0900)
committerChen Ningwei <chen@sraoss.co.jp>
Mon, 30 Oct 2023 03:00:12 +0000 (12:00 +0900)
src/include/parser/makefuncs.h
src/include/parser/parsenodes.h
src/include/parser/primnodes.h
src/parser/gram.y
src/parser/gram_minimal.y
src/parser/gram_template.y
src/parser/makefuncs.c

index dd20b129707c2a64832b3f1e9df90e226680d99a..922122ca03e28ead1049b5527a1dfaf0d9dfee24 100644 (file)
@@ -92,7 +92,8 @@ extern VacuumRelation *makeVacuumRelation(RangeVar *relation, Oid oid, List *va_
 
 extern JsonFormat *makeJsonFormat(JsonFormatType type, JsonEncoding encoding,
                                                                  int location);
-extern JsonValueExpr *makeJsonValueExpr(Expr *expr, JsonFormat *format);
+extern JsonValueExpr *makeJsonValueExpr(Expr *raw_expr, Expr *formatted_expr,
+                                                                               JsonFormat *format);
 extern Node *makeJsonKeyValue(Node *key, Node *value);
 extern Node *makeJsonIsPredicate(Node *expr, JsonFormat *format,
                                                                 JsonValueType item_type, bool unique_keys,
index ae29425bf4271496f77f899c6bbc3621a6b9b706..727012209d235d832439541d4b9945d9ab24fdb1 100644 (file)
@@ -92,8 +92,7 @@ typedef uint64 AclMode;                       /* a bitmask of privilege bits */
 #define ACL_CONNECT            (1<<11) /* for databases */
 #define ACL_SET                        (1<<12) /* for configuration parameters */
 #define ACL_ALTER_SYSTEM (1<<13)       /* for configuration parameters */
-#define ACL_MAINTAIN           (1<<14) /* for relations */
-#define N_ACL_RIGHTS   15              /* 1 plus the last 1<<x */
+#define N_ACL_RIGHTS   14              /* 1 plus the last 1<<x */
 #define ACL_NO_RIGHTS  0
 /* Currently, SELECT ... FOR [KEY] UPDATE/SHARE requires UPDATE privileges */
 #define ACL_SELECT_FOR_UPDATE  ACL_UPDATE
@@ -1061,13 +1060,13 @@ typedef struct RangeTblEntry
         * this RTE in the containing struct's list of same; 0 if permissions need
         * not be checked for this RTE.
         *
-        * As a special case, relid, rellockmode, and perminfoindex can also be
-        * set (nonzero) in an RTE_SUBQUERY RTE.  This occurs when we convert an
-        * RTE_RELATION RTE naming a view into an RTE_SUBQUERY containing the
-        * view's query.  We still need to perform run-time locking and permission
-        * checks on the view, even though it's not directly used in the query
-        * anymore, and the most expedient way to do that is to retain these
-        * fields from the old state of the RTE.
+        * As a special case, relid, relkind, rellockmode, and perminfoindex can
+        * also be set (nonzero) in an RTE_SUBQUERY RTE.  This occurs when we
+        * convert an RTE_RELATION RTE naming a view into an RTE_SUBQUERY
+        * containing the view's query.  We still need to perform run-time locking
+        * and permission checks on the view, even though it's not directly used
+        * in the query anymore, and the most expedient way to do that is to
+        * retain these fields from the old state of the RTE.
         *
         * As a special case, RTE_NAMEDTUPLESTORE can also set relid to indicate
         * that the tuple format of the tuplestore is the same as the referenced
index d75e1880bf20de5a89841dc01b594c29939707b0..cb37d33e3a4c085665f53c24175c3294f47318e3 100644 (file)
@@ -1284,6 +1284,8 @@ typedef struct CaseWhen
  *       see build_coercion_expression().
  *     * Nested FieldStore/SubscriptingRef assignment expressions in INSERT/UPDATE;
  *       see transformAssignmentIndirection().
+ *     * Placeholder for intermediate results in some SQL/JSON expression nodes,
+ *       such as JsonConstructorExpr.
  *
  * The uses in CaseExpr and ArrayCoerceExpr are safe only to the extent that
  * there is not any other CaseExpr or ArrayCoerceExpr between the value source
@@ -1613,12 +1615,16 @@ typedef struct JsonReturning
 /*
  * JsonValueExpr -
  *             representation of JSON value expression (expr [FORMAT JsonFormat])
+ *
+ * The actual value is obtained by evaluating formatted_expr.  raw_expr is
+ * only there for displaying the original user-written expression and is not
+ * evaluated by ExecInterpExpr() and eval_const_exprs_mutator().
  */
 typedef struct JsonValueExpr
 {
        NodeTag         type;
        Expr       *raw_expr;           /* raw expression */
-       Expr       *formatted_expr; /* formatted expression or NULL */
+       Expr       *formatted_expr; /* formatted expression */
        JsonFormat *format;                     /* FORMAT clause, if specified */
 } JsonValueExpr;
 
index ae2c43a49b06560c9b59feda70745eea56619489..e672ae1e01544a12184a232b129874aa500d62ba 100644 (file)
@@ -678,23 +678,20 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
 %type <list>           hash_partbound
 %type <defelt>         hash_partbound_elem
 
+%type <node>   json_format_clause_opt
+                               json_value_expr
+                               json_output_clause_opt
+                               json_name_and_value
+                               json_aggregate_func
+%type <list>   json_name_and_value_list
+                               json_value_expr_list
+                               json_array_aggregate_order_by_clause_opt
+%type <ival>   json_encoding_clause_opt
+                               json_predicate_type_constraint
+%type <boolean>        json_key_uniqueness_constraint_opt
+                               json_object_constructor_null_clause_opt
+                               json_array_constructor_null_clause_opt
 
-%type <node>           json_format_clause_opt
-                                       json_value_expr
-                                       json_output_clause_opt
-                                       json_name_and_value
-                                       json_aggregate_func
-
-%type <list>           json_name_and_value_list
-                                       json_value_expr_list
-                                       json_array_aggregate_order_by_clause_opt
-
-%type <ival>           json_encoding_clause_opt
-                                       json_predicate_type_constraint
-
-%type <boolean>                json_key_uniqueness_constraint_opt
-                                       json_object_constructor_null_clause_opt
-                                       json_array_constructor_null_clause_opt
 
 /*
  * Non-keyword token types.  These are hard-wired into the "flex" lexer.
@@ -16414,7 +16411,9 @@ opt_asymmetric: ASYMMETRIC
 json_value_expr:
                        a_expr json_format_clause_opt
                        {
-                               $$ = (Node *) makeJsonValueExpr((Expr *) $1, castNode(JsonFormat, $2));
+                               /* formatted_expr will be set during parse-analysis. */
+                               $$ = (Node *) makeJsonValueExpr((Expr *) $1, NULL,
+                                                                                               castNode(JsonFormat, $2));
                        }
                ;
 
index 56ed0390d420094b0c72962121017fbec1510739..e897f373a639c94c74bd44c21d8172f1a2bea49b 100644 (file)
@@ -680,23 +680,20 @@ UpdateStmtShort
 %type <list>           hash_partbound
 %type <defelt>         hash_partbound_elem
 
+%type <node>   json_format_clause_opt
+                               json_value_expr
+                               json_output_clause_opt
+                               json_name_and_value
+                               json_aggregate_func
+%type <list>   json_name_and_value_list
+                               json_value_expr_list
+                               json_array_aggregate_order_by_clause_opt
+%type <ival>   json_encoding_clause_opt
+                               json_predicate_type_constraint
+%type <boolean>        json_key_uniqueness_constraint_opt
+                               json_object_constructor_null_clause_opt
+                               json_array_constructor_null_clause_opt
 
-%type <node>           json_format_clause_opt
-                                       json_value_expr
-                                       json_output_clause_opt
-                                       json_name_and_value
-                                       json_aggregate_func
-
-%type <list>           json_name_and_value_list
-                                       json_value_expr_list
-                                       json_array_aggregate_order_by_clause_opt
-
-%type <ival>           json_encoding_clause_opt
-                                       json_predicate_type_constraint
-
-%type <boolean>                json_key_uniqueness_constraint_opt
-                                       json_object_constructor_null_clause_opt
-                                       json_array_constructor_null_clause_opt
 
 /*
  * Non-keyword token types.  These are hard-wired into the "flex" lexer.
@@ -16444,7 +16441,9 @@ opt_asymmetric: ASYMMETRIC
 json_value_expr:
                        a_expr json_format_clause_opt
                        {
-                               $$ = (Node *) makeJsonValueExpr((Expr *) $1, castNode(JsonFormat, $2));
+                               /* formatted_expr will be set during parse-analysis. */
+                               $$ = (Node *) makeJsonValueExpr((Expr *) $1, NULL,
+                                                                                               castNode(JsonFormat, $2));
                        }
                ;
 
index 6334b8ed54babca1aa87c6d8248c10599484440f..c542cf75d05133d4211c4dd72e460e166d8efd73 100644 (file)
@@ -693,23 +693,20 @@ UpdateStmtShort
 %type <list>           hash_partbound
 %type <defelt>         hash_partbound_elem
 
+%type <node>   json_format_clause_opt
+                               json_value_expr
+                               json_output_clause_opt
+                               json_name_and_value
+                               json_aggregate_func
+%type <list>   json_name_and_value_list
+                               json_value_expr_list
+                               json_array_aggregate_order_by_clause_opt
+%type <ival>   json_encoding_clause_opt
+                               json_predicate_type_constraint
+%type <boolean>        json_key_uniqueness_constraint_opt
+                               json_object_constructor_null_clause_opt
+                               json_array_constructor_null_clause_opt
 
-%type <node>           json_format_clause_opt
-                                       json_value_expr
-                                       json_output_clause_opt
-                                       json_name_and_value
-                                       json_aggregate_func
-
-%type <list>           json_name_and_value_list
-                                       json_value_expr_list
-                                       json_array_aggregate_order_by_clause_opt
-
-%type <ival>           json_encoding_clause_opt
-                                       json_predicate_type_constraint
-
-%type <boolean>                json_key_uniqueness_constraint_opt
-                                       json_object_constructor_null_clause_opt
-                                       json_array_constructor_null_clause_opt
 
 /*
  * Non-keyword token types.  These are hard-wired into the "flex" lexer.
@@ -16469,7 +16466,9 @@ opt_asymmetric: ASYMMETRIC
 json_value_expr:
                        a_expr json_format_clause_opt
                        {
-                               $$ = (Node *) makeJsonValueExpr((Expr *) $1, castNode(JsonFormat, $2));
+                               /* formatted_expr will be set during parse-analysis. */
+                               $$ = (Node *) makeJsonValueExpr((Expr *) $1, NULL,
+                                                                                               castNode(JsonFormat, $2));
                        }
                ;
 
index 5fabf614dea6159fd8cc3b082d32082ba25e3b9f..c8b806939eb18c2ed6834559256c2fbaa8e61977 100644 (file)
@@ -654,12 +654,13 @@ makeJsonFormat(JsonFormatType type, JsonEncoding encoding, int location)
  *   *    creates a JsonValueExpr node
  *    */
 JsonValueExpr *
-makeJsonValueExpr(Expr *expr, JsonFormat *format)
+makeJsonValueExpr(Expr *raw_expr, Expr *formatted_expr,
+                                 JsonFormat *format)
 {
     JsonValueExpr *jve = makeNode(JsonValueExpr);
 
-    jve->raw_expr = expr;
-    jve->formatted_expr = NULL;
+    jve->raw_expr = raw_expr;
+    jve->formatted_expr = formatted_expr;
     jve->format = format;
 
     return jve;