diff options
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/parse_coerce.c | 35 | ||||
-rw-r--r-- | src/backend/parser/parse_type.c | 11 |
2 files changed, 20 insertions, 26 deletions
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index bcb8e0016df..5a343e768dd 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.135 2006/03/05 15:58:33 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.136 2006/04/04 19:35:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -166,26 +166,21 @@ coerce_type(ParseState *pstate, Node *node, newcon->constbyval = typeByVal(targetType); newcon->constisnull = con->constisnull; + /* + * We pass typmod -1 to the input routine, primarily because + * existing input routines follow implicit-coercion semantics for + * length checks, which is not always what we want here. Any + * length constraint will be applied later by our caller. + * + * We assume here that UNKNOWN's internal representation is the + * same as CSTRING. + */ if (!con->constisnull) - { - /* - * We assume here that UNKNOWN's internal representation is the - * same as CSTRING - */ - char *val = DatumGetCString(con->constvalue); - - /* - * We pass typmod -1 to the input routine, primarily because - * existing input routines follow implicit-coercion semantics for - * length checks, which is not always what we want here. Any - * length constraint will be applied later by our caller. - * - * Note that we call stringTypeDatum using the domain's pg_type - * row, if it's a domain. This works because the domain row has - * the same typinput and typelem as the base type --- ugly... - */ - newcon->constvalue = stringTypeDatum(targetType, val, -1); - } + newcon->constvalue = stringTypeDatum(targetType, + DatumGetCString(con->constvalue), + -1); + else + newcon->constvalue = stringTypeDatum(targetType, NULL, -1); result = (Node *) newcon; diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c index e88e6c37c1e..fec4552c9c4 100644 --- a/src/backend/parser/parse_type.c +++ b/src/backend/parser/parse_type.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.79 2006/03/14 22:48:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.80 2006/04/04 19:35:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -326,7 +326,8 @@ typeTypeRelid(Type typ) /* * Given a type structure and a string, returns the internal representation - * of that string + * of that string. The "string" can be NULL to perform conversion of a NULL + * (which might result in failure, if the input function rejects NULLs). */ Datum stringTypeDatum(Type tp, char *string, int32 atttypmod) @@ -336,10 +337,8 @@ stringTypeDatum(Type tp, char *string, int32 atttypmod) typinput = ((Form_pg_type) GETSTRUCT(tp))->typinput; typioparam = getTypeIOParam(tp); - return OidFunctionCall3(typinput, - CStringGetDatum(string), - ObjectIdGetDatum(typioparam), - Int32GetDatum(atttypmod)); + return OidInputFunctionCall(typinput, string, + typioparam, atttypmod); } /* given a typeid, return the type's typrelid (associated relation, if any) */ |