diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-03-17 18:25:44 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-03-17 18:25:44 -0400 |
commit | d7b5c071dd6af2b81a7042dc60295061c7230cdc (patch) | |
tree | b74969bf121453b16364c34e65be4688a9b0c07b /src/backend/optimizer | |
parent | ec62cb0aac5ba31a82339606009ddbd7eb00e2ac (diff) | |
download | postgresql-d7b5c071dd6af2b81a7042dc60295061c7230cdc.tar.gz postgresql-d7b5c071dd6af2b81a7042dc60295061c7230cdc.zip |
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
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r-- | src/backend/optimizer/prep/prepjointree.c | 6 | ||||
-rw-r--r-- | src/backend/optimizer/util/var.c | 1 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/backend/optimizer/prep/prepjointree.c b/src/backend/optimizer/prep/prepjointree.c index 282589dec81..74823e8437a 100644 --- a/src/backend/optimizer/prep/prepjointree.c +++ b/src/backend/optimizer/prep/prepjointree.c @@ -2279,8 +2279,8 @@ pullup_replace_vars_callback(Var *var, * 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 * dropped columns. If the var is RECORD (ie, this is a JOIN), then - * omit dropped columns. Either way, attach column names to the - * RowExpr for use of ruleutils.c. + * omit dropped columns. In the latter case, attach column names to + * the RowExpr for use of the executor and ruleutils.c. * * In order to be able to cache the results, we always generate the * expansion with varlevelsup = 0, and then adjust if needed. @@ -2301,7 +2301,7 @@ pullup_replace_vars_callback(Var *var, rowexpr->args = fields; rowexpr->row_typeid = var->vartype; rowexpr->row_format = COERCE_IMPLICIT_CAST; - rowexpr->colnames = colnames; + rowexpr->colnames = (var->vartype == RECORDOID) ? colnames : NIL; rowexpr->location = var->location; newnode = (Node *) rowexpr; diff --git a/src/backend/optimizer/util/var.c b/src/backend/optimizer/util/var.c index a0543b7f47b..2b44ef3e176 100644 --- a/src/backend/optimizer/util/var.c +++ b/src/backend/optimizer/util/var.c @@ -809,6 +809,7 @@ flatten_join_alias_vars_mutator(Node *node, rowexpr->args = fields; rowexpr->row_typeid = var->vartype; rowexpr->row_format = COERCE_IMPLICIT_CAST; + /* vartype will always be RECORDOID, so we always need colnames */ rowexpr->colnames = colnames; rowexpr->location = var->location; |