aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_clause.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-12-16 18:39:22 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-12-16 18:39:22 +0000
commit260faf0b633716d02e30103bd5e94eb40f06bf27 (patch)
tree578a60809421acd51066b5290fc3be05b778cb9e /src/backend/parser/parse_clause.c
parent88177f77b17ef478da1dbca9acb5e3a61b346613 (diff)
downloadpostgresql-260faf0b633716d02e30103bd5e94eb40f06bf27.tar.gz
postgresql-260faf0b633716d02e30103bd5e94eb40f06bf27.zip
Fix ALTER TABLE ADD COLUMN to disallow the same column types that are
disallowed by CREATE TABLE (eg, pseudo-types); also disallow these types from being introduced by the range-function syntax. While at it, allow CREATE TABLE to create zero-column tables, per recent pghackers discussion. I am back-patching this into 7.3 since failure to disallow pseudo-types is arguably a security hole.
Diffstat (limited to 'src/backend/parser/parse_clause.c')
-rw-r--r--src/backend/parser/parse_clause.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c
index 71375f62c97..5d729216751 100644
--- a/src/backend/parser/parse_clause.c
+++ b/src/backend/parser/parse_clause.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.102 2002/12/12 20:35:13 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.103 2002/12/16 18:39:22 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,6 +16,7 @@
#include "postgres.h"
#include "access/heapam.h"
+#include "catalog/heap.h"
#include "nodes/makefuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/tlist.h"
@@ -503,6 +504,18 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r)
}
/*
+ * If a coldeflist is supplied, ensure it defines a legal set of names
+ * (no duplicates) and datatypes (no pseudo-types, for instance).
+ */
+ if (r->coldeflist)
+ {
+ TupleDesc tupdesc;
+
+ tupdesc = BuildDescForRelation(r->coldeflist);
+ CheckAttributeNamesTypes(tupdesc, RELKIND_COMPOSITE_TYPE);
+ }
+
+ /*
* OK, build an RTE for the function.
*/
rte = addRangeTableEntryForFunction(pstate, funcname, funcexpr,