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:
parent
918b158743
commit
b281ea8cf1
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user