diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-05 02:30:50 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-05 02:30:50 +0000 |
| commit | 07f9682de43ce53fcd6d86744f610cacfabc60bb (patch) | |
| tree | 2415db60be54912154c9c8f8834fb94f33fa5bca /src/backend/catalog | |
| parent | ac1a3dcf24e182a1cc9a136246b7f18a8a64bbd5 (diff) | |
| download | postgresql-07f9682de43ce53fcd6d86744f610cacfabc60bb.tar.gz | |
Preliminary code review for anonymous-composite-types patch: fix breakage
of functions returning domain types, update documentation for typtype,
move get_typtype to lsyscache.c (actually, resurrect the old version),
add defense against creating pseudo-typed table columns, fix some
bogus list-parsing in grammar. Issues remain with respect to alias
handling and type checking; Joe is on those.
Diffstat (limited to 'src/backend/catalog')
| -rw-r--r-- | src/backend/catalog/heap.c | 36 | ||||
| -rw-r--r-- | src/backend/catalog/pg_proc.c | 7 |
2 files changed, 26 insertions, 17 deletions
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index cb1248caaa..65f7dc097a 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.216 2002/08/02 21:54:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.217 2002/08/05 02:30:50 tgl Exp $ * * * INTERFACE ROUTINES @@ -370,18 +370,6 @@ CheckAttributeNames(TupleDesc tupdesc, bool relhasoids, char relkind) } /* - * also, warn user if attribute to be created has an unknown typid - * (usually as a result of a 'retrieve into' - jolly - */ - for (i = 0; i < natts; i++) - { - if (tupdesc->attrs[i]->atttypid == UNKNOWNOID) - elog(WARNING, "Attribute '%s' has an unknown type" - "\n\tProceeding with relation creation anyway", - NameStr(tupdesc->attrs[i]->attname)); - } - - /* * next check for repeated attribute names */ for (i = 1; i < natts; i++) @@ -394,6 +382,28 @@ CheckAttributeNames(TupleDesc tupdesc, bool relhasoids, char relkind) NameStr(tupdesc->attrs[j]->attname)); } } + + /* + * We also do some checking of the attribute types here. + * + * Warn user, but don't fail, if column to be created has UNKNOWN type + * (usually as a result of a 'retrieve into' - jolly) + * + * Refuse any attempt to create a pseudo-type column. + */ + for (i = 0; i < natts; i++) + { + Oid att_type = tupdesc->attrs[i]->atttypid; + + if (att_type == UNKNOWNOID) + elog(WARNING, "Attribute \"%s\" has an unknown type" + "\n\tProceeding with relation creation anyway", + NameStr(tupdesc->attrs[i]->attname)); + if (get_typtype(att_type) == 'p') + elog(ERROR, "Attribute \"%s\" has pseudo-type %s", + NameStr(tupdesc->attrs[i]->attname), + format_type_be(att_type)); + } } /* -------------------------------- diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index c8f769db30..5cc863249b 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.86 2002/08/05 00:21:27 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.87 2002/08/05 02:30:50 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,6 @@ #include "miscadmin.h" #include "parser/parse_coerce.h" #include "parser/parse_expr.h" -#include "parser/parse_relation.h" #include "parser/parse_type.h" #include "tcop/tcopprot.h" #include "utils/builtins.h" @@ -370,7 +369,7 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList) typerelid = typeidTypeRelid(rettype); - if (fn_typtype == 'b') + if (fn_typtype == 'b' || fn_typtype == 'd') { /* Shouldn't have a typerelid */ Assert(typerelid == InvalidOid); @@ -592,7 +591,7 @@ fmgr_sql_validator(PG_FUNCTION_ARGS) prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp)); /* check typtype to see if we have a predetermined return type */ - functyptype = typeid_get_typtype(proc->prorettype); + functyptype = get_typtype(proc->prorettype); querytree_list = pg_parse_and_rewrite(prosrc, proc->proargtypes, proc->pronargs); checkretval(proc->prorettype, functyptype, querytree_list); |
