aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/parser/parse_relation.c12
-rw-r--r--src/include/access/attnum.h3
2 files changed, 13 insertions, 2 deletions
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 180ba985129..bc5c54d2801 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.90.2.2 2005/05/29 17:10:52 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.90.2.3 2008/04/05 01:59:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1072,6 +1072,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 (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;
diff --git a/src/include/access/attnum.h b/src/include/access/attnum.h
index 16d16f5a9df..25f0d4ee368 100644
--- a/src/include/access/attnum.h
+++ b/src/include/access/attnum.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: attnum.h,v 1.17 2003/08/04 02:40:10 momjian Exp $
+ * $Id: attnum.h,v 1.17.4.1 2008/04/05 01:59:01 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,6 +21,7 @@
typedef int16 AttrNumber;
#define InvalidAttrNumber 0
+#define MaxAttrNumber 32767
/* ----------------
* support macros