mirror of
https://github.com/postgres/postgres.git
synced 2025-11-28 11:44:57 +03:00
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.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.51 2002/11/02 22:02:08 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.51.2.1 2002/12/16 18:39:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -104,7 +104,6 @@ DefineRelation(CreateStmt *stmt, char relkind)
|
||||
char relname[NAMEDATALEN];
|
||||
Oid namespaceId;
|
||||
List *schema = stmt->tableElts;
|
||||
int numberOfAttributes;
|
||||
Oid relationId;
|
||||
Relation rel;
|
||||
TupleDesc descriptor;
|
||||
@@ -147,10 +146,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)
|
||||
@@ -1784,6 +1779,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,
|
||||
|
||||
Reference in New Issue
Block a user