From f599d56f5196f25cc128c7fabe9f087773b9c390 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 16 Dec 2002 18:39:57 +0000 Subject: 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. --- src/backend/parser/parse_clause.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/backend/parser') diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 245c0ba422b..c88ce186e41 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.98 2002/09/18 21:35:22 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.98.2.1 2002/12/16 18:39:56 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" @@ -502,6 +503,18 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) elog(ERROR, "cannot use aggregate function in FROM function expression"); } + /* + * 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); + } + /* * Insist we have a bare function call (explain.c is the only place * that depends on this, I think). If this fails, it's probably -- cgit v1.2.3