currently support this because we must be able to build Vars referencing
join columns, and varattno is only 16 bits wide. Perhaps this should be
improved in future, but considering that it never came up before, I'm not
sure the problem is worth much effort. Per bug #4070 from Marcello
Ceschia.
The problem seems largely academic in 8.0 and 7.4, because they have
(different) O(N^2) performance issues with such wide joins, but
back-patch all the way anyway.
Alias *eref;
int numaliases;
+ /*
+ * Fail if join has too many columns --- we must be able to reference
+ * any of the columns with an AttrNumber.
+ */
+ if (list_length(aliasvars) > MaxAttrNumber)
+ ereport(ERROR,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("joins can have at most %d columns",
+ MaxAttrNumber)));
+
rte->rtekind = RTE_JOIN;
rte->relid = InvalidOid;
rte->subquery = NULL;
typedef int16 AttrNumber;
#define InvalidAttrNumber 0
+#define MaxAttrNumber 32767
/* ----------------
* support macros