diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index 17b06faf4b5867e980703e72926675fdd6617e32..9e0e77b051b6ac7a794653e9ea7b9f65a192bb10 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.16 1999/05/25 16:10:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.17 1999/05/29 03:17:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -39,6 +39,7 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, int32 atttypmod) { Node *result = NULL; + Type targetType; Oid infunc; Datum val; @@ -79,10 +80,11 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, Const *con = (Const *) node; val = (Datum) textout((struct varlena *) con->constvalue); - infunc = typeidInfunc(targetTypeId); + targetType = typeidType(targetTypeId); + infunc = typeInfunc(targetType); con = makeNode(Const); con->consttype = targetTypeId; - con->constlen = typeLen(typeidType(targetTypeId)); + con->constlen = typeLen(targetType); /* * Use "-1" for varchar() type. For char(), we need to pad @@ -92,10 +94,10 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, */ con->constvalue = (Datum) fmgr(infunc, val, - typeidTypElem(targetTypeId), + typeTypElem(targetType), (targetTypeId != BPCHAROID) ? -1 : atttypmod); con->constisnull = false; - con->constbyval = typeByVal(typeidType(targetTypeId)); + con->constbyval = typeByVal(targetType); con->constisset = false; result = (Node *) con; } diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 1b821606f573cd41bfa8fdd8de9c1b723beba53b..563a48e1b4eaae8077d670b996db6a38e84f3e62 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.40 1999/05/25 16:10:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.41 1999/05/29 03:17:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -241,7 +241,7 @@ MakeTargetEntryExpr(ParseState *pstate, Oid typelem; if (arrayRef && !(((A_Indices *) lfirst(arrayRef))->lidx)) - typelem = typeidTypElem(attrtype); + typelem = typeTypElem(typeidType(attrtype)); else typelem = attrtype; diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c index cdec9d9aeac365545ca05afd57dbf9c2c189be3f..7ced7111cb81f7228317d159bb63d3c33cd18986 100644 --- a/src/backend/parser/parse_type.c +++ b/src/backend/parser/parse_type.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.21 1999/05/25 16:10:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.22 1999/05/29 03:17:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -58,7 +58,7 @@ typeidTypeName(Oid id) return (typetuple->typname).data; } -/* return a Type structure, given an typid */ +/* return a Type structure, given a type id */ Type typeidType(Oid id) { @@ -180,7 +180,6 @@ typeidTypeRelid(Oid type_id) { HeapTuple typeTuple; Form_pg_type type; - Oid infunc; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type_id), @@ -189,8 +188,7 @@ typeidTypeRelid(Oid type_id) elog(ERROR, "typeidTypeRelid: Invalid type - oid = %u", type_id); type = (Form_pg_type) GETSTRUCT(typeTuple); - infunc = type->typrelid; - return infunc; + return type->typrelid; } Oid @@ -204,18 +202,13 @@ typeTypeRelid(Type typ) } Oid -typeidTypElem(Oid type_id) +typeTypElem(Type typ) { - HeapTuple typeTuple; - Form_pg_type type; + Form_pg_type typtup; - if (!(typeTuple = SearchSysCacheTuple(TYPOID, - ObjectIdGetDatum(type_id), - 0, 0, 0))) - elog(ERROR, "type id lookup of %u failed", type_id); - type = (Form_pg_type) GETSTRUCT(typeTuple); + typtup = (Form_pg_type) GETSTRUCT(typ); - return type->typelem; + return typtup->typelem; } /* Given the attribute type of an array return the attribute type of @@ -247,21 +240,13 @@ GetArrayElementType(Oid typearray) return type_struct_array->typelem; } -/* Given a type id, returns the in-conversion function of the type */ +/* Given a type structure, return the in-conversion function of the type */ Oid -typeidInfunc(Oid type_id) +typeInfunc(Type typ) { - HeapTuple typeTuple; - Form_pg_type type; - Oid infunc; + Form_pg_type typtup; - typeTuple = SearchSysCacheTuple(TYPOID, - ObjectIdGetDatum(type_id), - 0, 0, 0); - if (!HeapTupleIsValid(typeTuple)) - elog(ERROR, "typeidInfunc: Invalid type - oid = %u", type_id); + typtup = (Form_pg_type) GETSTRUCT(typ); - type = (Form_pg_type) GETSTRUCT(typeTuple); - infunc = type->typinput; - return infunc; + return typtup->typinput; } diff --git a/src/include/parser/parse_type.h b/src/include/parser/parse_type.h index bc906090b0f00dead721515540afc2bfa0b1cba3..5ca8f9b34c558db5964b3abac5dd91930e77f29c 100644 --- a/src/include/parser/parse_type.h +++ b/src/include/parser/parse_type.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: parse_type.h,v 1.9 1998/10/08 18:30:39 momjian Exp $ + * $Id: parse_type.h,v 1.10 1999/05/29 03:17:19 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -29,8 +29,8 @@ extern char typeTypeFlag(Type t); extern char *stringTypeString(Type tp, char *string, int32 atttypmod); extern Oid typeidTypeRelid(Oid type_id); extern Oid typeTypeRelid(Type typ); -extern Oid typeidTypElem(Oid type_id); +extern Oid typeTypElem(Type typ); extern Oid GetArrayElementType(Oid typearray); -extern Oid typeidInfunc(Oid type_id); +extern Oid typeInfunc(Type typ); #endif /* PARSE_TYPE_H */