1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +03:00

Infrastructure for I/O of composite types: arrange for the I/O routines

of a composite type to get that type's OID as their second parameter,
in place of typelem which is useless.  The actual changes are mostly
centralized in getTypeInputInfo and siblings, but I had to fix a few
places that were fetching pg_type.typelem for themselves instead of
using the lsyscache.c routines.  Also, I renamed all the related variables
from 'typelem' to 'typioparam' to discourage people from assuming that
they necessarily contain array element types.
This commit is contained in:
Tom Lane
2004-06-06 00:41:28 +00:00
parent c3a153afed
commit c541bb86e9
25 changed files with 332 additions and 382 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.117 2004/05/30 23:40:35 neilc Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.118 2004/06/06 00:41:26 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -356,14 +356,10 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
/*
* If input is an untyped string constant, assume we can convert
* it to anything except a class type.
* it to anything.
*/
if (inputTypeId == UNKNOWNOID)
{
if (ISCOMPLEX(targetTypeId))
return false;
continue;
}
/*
* If pg_cast shows that we can coerce, accept. This test now

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.68 2004/06/03 19:41:46 tgl Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.69 2004/06/06 00:41:26 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -323,83 +323,24 @@ typeTypeRelid(Type typ)
return typtup->typrelid;
}
#ifdef NOT_USED
Oid
typeTypElem(Type typ)
{
Form_pg_type typtup;
typtup = (Form_pg_type) GETSTRUCT(typ);
return typtup->typelem;
}
#endif
#ifdef NOT_USED
/* Given a type structure, return the in-conversion function of the type */
Oid
typeInfunc(Type typ)
{
Form_pg_type typtup;
typtup = (Form_pg_type) GETSTRUCT(typ);
return typtup->typinput;
}
#endif
#ifdef NOT_USED
/* Given a type structure, return the out-conversion function of the type */
Oid
typeOutfunc(Type typ)
{
Form_pg_type typtup;
typtup = (Form_pg_type) GETSTRUCT(typ);
return typtup->typoutput;
}
#endif
/* Given a type structure and a string, returns the internal form of
that string */
/*
* Given a type structure and a string, returns the internal representation
* of that string
*/
Datum
stringTypeDatum(Type tp, char *string, int32 atttypmod)
{
Oid op;
Oid typelem;
Oid typinput;
Oid typioparam;
op = ((Form_pg_type) GETSTRUCT(tp))->typinput;
typelem = ((Form_pg_type) GETSTRUCT(tp))->typelem; /* XXX - used for
* array_in */
return OidFunctionCall3(op,
typinput = ((Form_pg_type) GETSTRUCT(tp))->typinput;
typioparam = getTypeIOParam(tp);
return OidFunctionCall3(typinput,
CStringGetDatum(string),
ObjectIdGetDatum(typelem),
ObjectIdGetDatum(typioparam),
Int32GetDatum(atttypmod));
}
/* Given a type id, returns the out-conversion function of the type */
#ifdef NOT_USED
Oid
typeidOutfunc(Oid type_id)
{
HeapTuple typeTuple;
Form_pg_type type;
Oid outfunc;
typeTuple = SearchSysCache(TYPEOID,
ObjectIdGetDatum(type_id),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type_id);
type = (Form_pg_type) GETSTRUCT(typeTuple);
outfunc = type->typoutput;
ReleaseSysCache(typeTuple);
return outfunc;
}
#endif
/* given a typeid, return the type's typrelid (associated relation, if any) */
Oid
typeidTypeRelid(Oid type_id)