File tree 4 files changed +14
-15
lines changed
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,
2279
2279
* If generating an expansion for a var of a named rowtype (ie, this
2280
2280
* is a plain relation RTE), then we must include dummy items for
2281
2281
* 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.
2284
2284
*
2285
2285
* In order to be able to cache the results, we always generate the
2286
2286
* expansion with varlevelsup = 0, and then adjust if needed.
@@ -2301,7 +2301,7 @@ pullup_replace_vars_callback(Var *var,
2301
2301
rowexpr -> args = fields ;
2302
2302
rowexpr -> row_typeid = var -> vartype ;
2303
2303
rowexpr -> row_format = COERCE_IMPLICIT_CAST ;
2304
- rowexpr -> colnames = colnames ;
2304
+ rowexpr -> colnames = ( var -> vartype == RECORDOID ) ? colnames : NIL ;
2305
2305
rowexpr -> location = var -> location ;
2306
2306
newnode = (Node * ) rowexpr ;
2307
2307
Original file line number Diff line number Diff line change @@ -809,6 +809,7 @@ flatten_join_alias_vars_mutator(Node *node,
809
809
rowexpr -> args = fields ;
810
810
rowexpr -> row_typeid = var -> vartype ;
811
811
rowexpr -> row_format = COERCE_IMPLICIT_CAST ;
812
+ /* vartype will always be RECORDOID, so we always need colnames */
812
813
rowexpr -> colnames = colnames ;
813
814
rowexpr -> location = var -> location ;
814
815
Original file line number Diff line number Diff line change @@ -1424,8 +1424,8 @@ ReplaceVarsFromTargetList_callback(Var *var,
1424
1424
* If generating an expansion for a var of a named rowtype (ie, this
1425
1425
* is a plain relation RTE), then we must include dummy items for
1426
1426
* 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.
1429
1429
*/
1430
1430
expandRTE (rcon -> target_rte ,
1431
1431
var -> varno , var -> varlevelsup , var -> location ,
@@ -1438,7 +1438,7 @@ ReplaceVarsFromTargetList_callback(Var *var,
1438
1438
rowexpr -> args = fields ;
1439
1439
rowexpr -> row_typeid = var -> vartype ;
1440
1440
rowexpr -> row_format = COERCE_IMPLICIT_CAST ;
1441
- rowexpr -> colnames = colnames ;
1441
+ rowexpr -> colnames = ( var -> vartype == RECORDOID ) ? colnames : NIL ;
1442
1442
rowexpr -> location = var -> location ;
1443
1443
1444
1444
return (Node * ) rowexpr ;
Original file line number Diff line number Diff line change @@ -1052,15 +1052,13 @@ typedef struct ArrayExpr
1052
1052
* than vice versa.) It is important not to assume that length(args) is
1053
1053
* the same as the number of columns logically present in the rowtype.
1054
1054
*
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).
1064
1062
*/
1065
1063
typedef struct RowExpr
1066
1064
{
You can’t perform that action at this time.
0 commit comments