diff options
| author | Tom Lane | 2007-11-11 19:22:49 +0000 |
|---|---|---|
| committer | Tom Lane | 2007-11-11 19:22:49 +0000 |
| commit | 0bd4da23a4bee4fb3b6b61cb0fadc43c054c5ddb (patch) | |
| tree | 2a37c084e71feafe8e502758e7e01446192d9529 /src/include/parser | |
| parent | 6b8cc88268fcf33b5e2d3c230f097dff0541398f (diff) | |
Ensure that typmod decoration on a datatype name is validated in all cases,
even in code paths where we don't pay any subsequent attention to the typmod
value. This seems needed in view of the fact that 8.3's generalized typmod
support will accept a lot of bogus syntax, such as "timestamp(foo)" or
"record(int, 42)" --- if we allow such things to pass without comment,
users will get confused. Per a recent example from Greg Stark.
To implement this in a way that's not very vulnerable to future
bugs-of-omission, refactor the API of parse_type.c's TypeName lookup routines
so that typmod validation is folded into the base lookup operation. Callers
can still choose not to receive the encoded typmod, but we'll check the
decoration anyway if it's present.
Diffstat (limited to 'src/include/parser')
| -rw-r--r-- | src/include/parser/parse_type.h | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/include/parser/parse_type.h b/src/include/parser/parse_type.h index 3d07b08579..414dd09b91 100644 --- a/src/include/parser/parse_type.h +++ b/src/include/parser/parse_type.h @@ -1,13 +1,12 @@ /*------------------------------------------------------------------------- * * parse_type.h - * - * + * handle type operations for parser * * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/parser/parse_type.h,v 1.36 2007/04/02 03:49:41 tgl Exp $ + * $PostgreSQL: pgsql/src/include/parser/parse_type.h,v 1.37 2007/11/11 19:22:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -20,13 +19,15 @@ typedef HeapTuple Type; -extern Oid LookupTypeName(ParseState *pstate, const TypeName *typename); +extern Type LookupTypeName(ParseState *pstate, const TypeName *typename, + int32 *typmod_p); +extern Type typenameType(ParseState *pstate, const TypeName *typename, + int32 *typmod_p); +extern Oid typenameTypeId(ParseState *pstate, const TypeName *typename, + int32 *typmod_p); + extern char *TypeNameToString(const TypeName *typename); extern char *TypeNameListToString(List *typenames); -extern Oid typenameTypeId(ParseState *pstate, const TypeName *typename); -extern int32 typenameTypeMod(ParseState *pstate, const TypeName *typename, - Oid typeId); -extern Type typenameType(ParseState *pstate, const TypeName *typename); extern Type typeidType(Oid id); @@ -39,7 +40,7 @@ extern Datum stringTypeDatum(Type tp, char *string, int32 atttypmod); extern Oid typeidTypeRelid(Oid type_id); -extern void parseTypeString(const char *str, Oid *type_id, int32 *typmod); +extern void parseTypeString(const char *str, Oid *type_id, int32 *typmod_p); #define ISCOMPLEX(typeid) (typeidTypeRelid(typeid) != InvalidOid) |
