Commit b281ea8c authored by Tom Lane's avatar Tom Lane

Whole-row references were broken for subqueries and functions, because

attr_needed/attr_widths optimization failed to allow for Vars with attno
zero in this case.  Per report from Tatsuo Ishii.
parent 918b1587
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.53 2003/11/29 19:51:51 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.54 2003/12/08 18:19:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -161,7 +161,8 @@ make_base_rel(Query *root, int relid)
case RTE_SUBQUERY:
case RTE_FUNCTION:
/* Subquery or function --- need only set up attr range */
rel->min_attr = 1;
/* Note: 0 is included in range to support whole-row Vars */
rel->min_attr = 0;
rel->max_attr = length(rte->eref->colnames);
break;
default:
......@@ -170,18 +171,11 @@ make_base_rel(Query *root, int relid)
break;
}
if (rel->max_attr >= rel->min_attr)
{
rel->attr_needed = (Relids *)
palloc0((rel->max_attr - rel->min_attr + 1) * sizeof(Relids));
rel->attr_widths = (int32 *)
palloc0((rel->max_attr - rel->min_attr + 1) * sizeof(int32));
}
else
{
rel->attr_needed = NULL;
rel->attr_widths = NULL;
}
Assert(rel->max_attr >= rel->min_attr);
rel->attr_needed = (Relids *)
palloc0((rel->max_attr - rel->min_attr + 1) * sizeof(Relids));
rel->attr_widths = (int32 *)
palloc0((rel->max_attr - rel->min_attr + 1) * sizeof(int32));
return rel;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment