mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
Don't bother to attach column name lists to RowExprs of named types.
If a RowExpr is marked as returning a named composite type, we aren't going to consult its colnames list; we'll use the attribute names shown for the type in pg_attribute. Hence, skip storing that list, to save a few nanoseconds when copying the expression tree around. Discussion: https://postgr.es/m/2950001.1638729947@sss.pgh.pa.us
This commit is contained in:
parent
ec62cb0aac
commit
d7b5c071dd
@ -2279,8 +2279,8 @@ pullup_replace_vars_callback(Var *var,
|
|||||||
* If generating an expansion for a var of a named rowtype (ie, this
|
* If generating an expansion for a var of a named rowtype (ie, this
|
||||||
* is a plain relation RTE), then we must include dummy items for
|
* is a plain relation RTE), then we must include dummy items for
|
||||||
* dropped columns. If the var is RECORD (ie, this is a JOIN), then
|
* dropped columns. If the var is RECORD (ie, this is a JOIN), then
|
||||||
* omit dropped columns. Either way, attach column names to the
|
* omit dropped columns. In the latter case, attach column names to
|
||||||
* RowExpr for use of ruleutils.c.
|
* the RowExpr for use of the executor and ruleutils.c.
|
||||||
*
|
*
|
||||||
* In order to be able to cache the results, we always generate the
|
* In order to be able to cache the results, we always generate the
|
||||||
* expansion with varlevelsup = 0, and then adjust if needed.
|
* expansion with varlevelsup = 0, and then adjust if needed.
|
||||||
@ -2301,7 +2301,7 @@ pullup_replace_vars_callback(Var *var,
|
|||||||
rowexpr->args = fields;
|
rowexpr->args = fields;
|
||||||
rowexpr->row_typeid = var->vartype;
|
rowexpr->row_typeid = var->vartype;
|
||||||
rowexpr->row_format = COERCE_IMPLICIT_CAST;
|
rowexpr->row_format = COERCE_IMPLICIT_CAST;
|
||||||
rowexpr->colnames = colnames;
|
rowexpr->colnames = (var->vartype == RECORDOID) ? colnames : NIL;
|
||||||
rowexpr->location = var->location;
|
rowexpr->location = var->location;
|
||||||
newnode = (Node *) rowexpr;
|
newnode = (Node *) rowexpr;
|
||||||
|
|
||||||
|
@ -809,6 +809,7 @@ flatten_join_alias_vars_mutator(Node *node,
|
|||||||
rowexpr->args = fields;
|
rowexpr->args = fields;
|
||||||
rowexpr->row_typeid = var->vartype;
|
rowexpr->row_typeid = var->vartype;
|
||||||
rowexpr->row_format = COERCE_IMPLICIT_CAST;
|
rowexpr->row_format = COERCE_IMPLICIT_CAST;
|
||||||
|
/* vartype will always be RECORDOID, so we always need colnames */
|
||||||
rowexpr->colnames = colnames;
|
rowexpr->colnames = colnames;
|
||||||
rowexpr->location = var->location;
|
rowexpr->location = var->location;
|
||||||
|
|
||||||
|
@ -1424,8 +1424,8 @@ ReplaceVarsFromTargetList_callback(Var *var,
|
|||||||
* If generating an expansion for a var of a named rowtype (ie, this
|
* If generating an expansion for a var of a named rowtype (ie, this
|
||||||
* is a plain relation RTE), then we must include dummy items for
|
* is a plain relation RTE), then we must include dummy items for
|
||||||
* dropped columns. If the var is RECORD (ie, this is a JOIN), then
|
* dropped columns. If the var is RECORD (ie, this is a JOIN), then
|
||||||
* omit dropped columns. Either way, attach column names to the
|
* omit dropped columns. In the latter case, attach column names to
|
||||||
* RowExpr for use of ruleutils.c.
|
* the RowExpr for use of the executor and ruleutils.c.
|
||||||
*/
|
*/
|
||||||
expandRTE(rcon->target_rte,
|
expandRTE(rcon->target_rte,
|
||||||
var->varno, var->varlevelsup, var->location,
|
var->varno, var->varlevelsup, var->location,
|
||||||
@ -1438,7 +1438,7 @@ ReplaceVarsFromTargetList_callback(Var *var,
|
|||||||
rowexpr->args = fields;
|
rowexpr->args = fields;
|
||||||
rowexpr->row_typeid = var->vartype;
|
rowexpr->row_typeid = var->vartype;
|
||||||
rowexpr->row_format = COERCE_IMPLICIT_CAST;
|
rowexpr->row_format = COERCE_IMPLICIT_CAST;
|
||||||
rowexpr->colnames = colnames;
|
rowexpr->colnames = (var->vartype == RECORDOID) ? colnames : NIL;
|
||||||
rowexpr->location = var->location;
|
rowexpr->location = var->location;
|
||||||
|
|
||||||
return (Node *) rowexpr;
|
return (Node *) rowexpr;
|
||||||
|
@ -1052,15 +1052,13 @@ typedef struct ArrayExpr
|
|||||||
* than vice versa.) It is important not to assume that length(args) is
|
* than vice versa.) It is important not to assume that length(args) is
|
||||||
* the same as the number of columns logically present in the rowtype.
|
* the same as the number of columns logically present in the rowtype.
|
||||||
*
|
*
|
||||||
* colnames provides field names in cases where the names can't easily be
|
* colnames provides field names if the ROW() result is of type RECORD.
|
||||||
* obtained otherwise. Names *must* be provided if row_typeid is RECORDOID.
|
* Names *must* be provided if row_typeid is RECORDOID; but if it is a
|
||||||
* If row_typeid identifies a known composite type, colnames can be NIL to
|
* named composite type, colnames will be ignored in favor of using the
|
||||||
* indicate the type's cataloged field names apply. Note that colnames can
|
* type's cataloged field names, so colnames should be NIL. Like the
|
||||||
* be non-NIL even for a composite type, and typically is when the RowExpr
|
* args list, colnames is defined to be one-for-one with physical fields
|
||||||
* was created by expanding a whole-row Var. This is so that we can retain
|
* of the rowtype (although dropped columns shouldn't appear in the
|
||||||
* the column alias names of the RTE that the Var referenced (which would
|
* RECORD case, so this fine point is currently moot).
|
||||||
* otherwise be very difficult to extract from the parsetree). Like the
|
|
||||||
* args list, colnames is one-for-one with physical fields of the rowtype.
|
|
||||||
*/
|
*/
|
||||||
typedef struct RowExpr
|
typedef struct RowExpr
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user