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.
This commit is contained in:
Tom Lane 2003-12-08 18:19:58 +00:00
parent 918b158743
commit b281ea8cf1
1 changed files with 8 additions and 14 deletions

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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_SUBQUERY:
case RTE_FUNCTION: case RTE_FUNCTION:
/* Subquery or function --- need only set up attr range */ /* 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); rel->max_attr = length(rte->eref->colnames);
break; break;
default: default:
@ -170,18 +171,11 @@ make_base_rel(Query *root, int relid)
break; break;
} }
if (rel->max_attr >= rel->min_attr) Assert(rel->max_attr >= rel->min_attr);
{ rel->attr_needed = (Relids *)
rel->attr_needed = (Relids *) palloc0((rel->max_attr - rel->min_attr + 1) * sizeof(Relids));
palloc0((rel->max_attr - rel->min_attr + 1) * sizeof(Relids)); rel->attr_widths = (int32 *)
rel->attr_widths = (int32 *) palloc0((rel->max_attr - rel->min_attr + 1) * sizeof(int32));
palloc0((rel->max_attr - rel->min_attr + 1) * sizeof(int32));
}
else
{
rel->attr_needed = NULL;
rel->attr_widths = NULL;
}
return rel; return rel;
} }