mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
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.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.222 2007/10/29 19:40:40 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.223 2007/11/11 19:22:49 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -829,7 +829,7 @@ transformAExprOf(ParseState *pstate, A_Expr *a)
|
||||
ltype = exprType(lexpr);
|
||||
foreach(telem, (List *) a->rexpr)
|
||||
{
|
||||
rtype = typenameTypeId(pstate, lfirst(telem));
|
||||
rtype = typenameTypeId(pstate, lfirst(telem), NULL);
|
||||
matched = (rtype == ltype);
|
||||
if (matched)
|
||||
break;
|
||||
@ -1550,8 +1550,7 @@ transformXmlSerialize(ParseState *pstate, XmlSerialize *xs)
|
||||
XMLOID,
|
||||
"XMLSERIALIZE"));
|
||||
|
||||
targetType = typenameTypeId(pstate, xs->typename);
|
||||
targetTypmod = typenameTypeMod(pstate, xs->typename, targetType);
|
||||
targetType = typenameTypeId(pstate, xs->typename, &targetTypmod);
|
||||
|
||||
xexpr->xmloption = xs->xmloption;
|
||||
/* We actually only need these to be able to parse back the expression. */
|
||||
@ -2227,8 +2226,7 @@ typecast_expression(ParseState *pstate, Node *expr, TypeName *typename)
|
||||
Oid targetType;
|
||||
int32 targetTypmod;
|
||||
|
||||
targetType = typenameTypeId(pstate, typename);
|
||||
targetTypmod = typenameTypeMod(pstate, typename, targetType);
|
||||
targetType = typenameTypeId(pstate, typename, &targetTypmod);
|
||||
|
||||
if (inputType == InvalidOid)
|
||||
return expr; /* do nothing if NULL input */
|
||||
|
Reference in New Issue
Block a user