aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2004-11-16 23:34:26 +0000
committerNeil Conway <neilc@samurai.com>2004-11-16 23:34:26 +0000
commite1bf6527f60a53f1d4abfb9fa6ad71e8694218b3 (patch)
tree0361e04f6944a4a77cc709978b41d9751b9e21a8 /src/backend/parser
parent8a1821ab5b27a2bfc491881207f595a5157236ab (diff)
downloadpostgresql-e1bf6527f60a53f1d4abfb9fa6ad71e8694218b3.tar.gz
postgresql-e1bf6527f60a53f1d4abfb9fa6ad71e8694218b3.zip
Prevent a backend crash when processing CREATE TABLE commands with
more than 65K columns, or when the created table has more than 65K columns due to adding inherited columns from parent relations. Fix a similar crash when processing SELECT queries with more than 65K target list entries. In all three cases we would eventually detect the error and elog, but the check was being made too late.
Diffstat (limited to 'src/backend/parser')
-rw-r--r--src/backend/parser/analyze.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index c3b547dd5b7..b68f28f8556 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.312 2004/09/27 04:12:02 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.313 2004/11/16 23:34:26 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -396,6 +396,18 @@ transformStmt(ParseState *pstate, Node *parseTree,
result->querySource = QSRC_ORIGINAL;
result->canSetTag = true;
+ /*
+ * Check that we did not produce too many resnos; at the very
+ * least we cannot allow more than 2^16, since that would exceed
+ * the range of a AttrNumber. It seems safest to use
+ * MaxTupleAttributeNumber.
+ */
+ if (pstate->p_next_resno - 1 > MaxTupleAttributeNumber)
+ ereport(ERROR,
+ (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
+ errmsg("target lists can have at most %d entries",
+ MaxTupleAttributeNumber)));
+
return result;
}