summaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.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/commands/tablecmds.c
parent88177f77b17ef478da1dbca9acb5e3a61b346613 (diff)
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/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 09c60bdf3f9..2a1a2b4cf49 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.61 2002/12/15 16:17:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.62 2002/12/16 18:39:22 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -125,7 +125,6 @@ DefineRelation(CreateStmt *stmt, char relkind)
char relname[NAMEDATALEN];
Oid namespaceId;
List *schema = stmt->tableElts;
- int numberOfAttributes;
Oid relationId;
Relation rel;
TupleDesc descriptor;
@@ -174,10 +173,6 @@ DefineRelation(CreateStmt *stmt, char relkind)
stmt->relation->istemp,
&inheritOids, &old_constraints, &parentHasOids);
- numberOfAttributes = length(schema);
- if (numberOfAttributes <= 0)
- elog(ERROR, "DefineRelation: please inherit from a relation or define an attribute");
-
/*
* Create a relation descriptor from the relation schema and create
* the relation. Note that in this stage only inherited (pre-cooked)
@@ -1800,6 +1795,9 @@ AlterTableAddColumn(Oid myrelid,
typeTuple = typenameType(colDef->typename);
tform = (Form_pg_type) GETSTRUCT(typeTuple);
+ /* make sure datatype is legal for a column */
+ CheckAttributeType(colDef->colname, HeapTupleGetOid(typeTuple));
+
attributeTuple = heap_addheader(Natts_pg_attribute,
false,
ATTRIBUTE_TUPLE_SIZE,