File tree Expand file tree Collapse file tree 4 files changed +14
-15
lines changed Expand file tree Collapse file tree 4 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -2279,8 +2279,8 @@ pullup_replace_vars_callback(Var *var,
22792279 * If generating an expansion for a var of a named rowtype (ie, this
22802280 * is a plain relation RTE), then we must include dummy items for
22812281 * dropped columns. If the var is RECORD (ie, this is a JOIN), then
2282- * omit dropped columns. Either way , attach column names to the
2283- * RowExpr for use of ruleutils.c.
2282+ * omit dropped columns. In the latter case , attach column names to
2283+ * the RowExpr for use of the executor and ruleutils.c.
22842284 *
22852285 * In order to be able to cache the results, we always generate the
22862286 * expansion with varlevelsup = 0, and then adjust if needed.
@@ -2301,7 +2301,7 @@ pullup_replace_vars_callback(Var *var,
23012301 rowexpr -> args = fields ;
23022302 rowexpr -> row_typeid = var -> vartype ;
23032303 rowexpr -> row_format = COERCE_IMPLICIT_CAST ;
2304- rowexpr -> colnames = colnames ;
2304+ rowexpr -> colnames = ( var -> vartype == RECORDOID ) ? colnames : NIL ;
23052305 rowexpr -> location = var -> location ;
23062306 newnode = (Node * ) rowexpr ;
23072307
Original file line number Diff line number Diff line change @@ -809,6 +809,7 @@ flatten_join_alias_vars_mutator(Node *node,
809809 rowexpr -> args = fields ;
810810 rowexpr -> row_typeid = var -> vartype ;
811811 rowexpr -> row_format = COERCE_IMPLICIT_CAST ;
812+ /* vartype will always be RECORDOID, so we always need colnames */
812813 rowexpr -> colnames = colnames ;
813814 rowexpr -> location = var -> location ;
814815
Original file line number Diff line number Diff line change @@ -1424,8 +1424,8 @@ ReplaceVarsFromTargetList_callback(Var *var,
14241424 * If generating an expansion for a var of a named rowtype (ie, this
14251425 * is a plain relation RTE), then we must include dummy items for
14261426 * dropped columns. If the var is RECORD (ie, this is a JOIN), then
1427- * omit dropped columns. Either way , attach column names to the
1428- * RowExpr for use of ruleutils.c.
1427+ * omit dropped columns. In the latter case , attach column names to
1428+ * the RowExpr for use of the executor and ruleutils.c.
14291429 */
14301430 expandRTE (rcon -> target_rte ,
14311431 var -> varno , var -> varlevelsup , var -> location ,
@@ -1438,7 +1438,7 @@ ReplaceVarsFromTargetList_callback(Var *var,
14381438 rowexpr -> args = fields ;
14391439 rowexpr -> row_typeid = var -> vartype ;
14401440 rowexpr -> row_format = COERCE_IMPLICIT_CAST ;
1441- rowexpr -> colnames = colnames ;
1441+ rowexpr -> colnames = ( var -> vartype == RECORDOID ) ? colnames : NIL ;
14421442 rowexpr -> location = var -> location ;
14431443
14441444 return (Node * ) rowexpr ;
Original file line number Diff line number Diff line change @@ -1052,15 +1052,13 @@ typedef struct ArrayExpr
10521052 * than vice versa.) It is important not to assume that length(args) is
10531053 * the same as the number of columns logically present in the rowtype.
10541054 *
1055- * colnames provides field names in cases where the names can't easily be
1056- * obtained otherwise. Names *must* be provided if row_typeid is RECORDOID.
1057- * If row_typeid identifies a known composite type, colnames can be NIL to
1058- * indicate the type's cataloged field names apply. Note that colnames can
1059- * be non-NIL even for a composite type, and typically is when the RowExpr
1060- * was created by expanding a whole-row Var. This is so that we can retain
1061- * the column alias names of the RTE that the Var referenced (which would
1062- * otherwise be very difficult to extract from the parsetree). Like the
1063- * args list, colnames is one-for-one with physical fields of the rowtype.
1055+ * colnames provides field names if the ROW() result is of type RECORD.
1056+ * Names *must* be provided if row_typeid is RECORDOID; but if it is a
1057+ * named composite type, colnames will be ignored in favor of using the
1058+ * type's cataloged field names, so colnames should be NIL. Like the
1059+ * args list, colnames is defined to be one-for-one with physical fields
1060+ * of the rowtype (although dropped columns shouldn't appear in the
1061+ * RECORD case, so this fine point is currently moot).
10641062 */
10651063typedef struct RowExpr
10661064{
You can’t perform that action at this time.
0 commit comments