aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_relation.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-04-05 01:58:51 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-04-05 01:58:51 +0000
commitda2c44736188ad5517f0533772ed93e1556a2abb (patch)
tree09b7d3a3204e4c17c57f6f0e5b1bcc7c922c5f17 /src/backend/parser/parse_relation.c
parent2069940bc6c8d576f0bf628a38396bcb853f2c56 (diff)
downloadpostgresql-da2c44736188ad5517f0533772ed93e1556a2abb.tar.gz
postgresql-da2c44736188ad5517f0533772ed93e1556a2abb.zip
Defend against JOINs having more than 32K columns altogether. We cannot
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.
Diffstat (limited to 'src/backend/parser/parse_relation.c')
-rw-r--r--src/backend/parser/parse_relation.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 0145f86500c..d2039813bab 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.102.4.1 2005/05/29 17:10:35 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.102.4.2 2008/04/05 01:58:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1114,6 +1114,16 @@ addRangeTableEntryForJoin(ParseState *pstate,
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;