From c541bb86e9ec8fed37b23df6a0df703d0bde4dfa Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 6 Jun 2004 00:41:28 +0000 Subject: 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. --- src/backend/utils/adt/ruleutils.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'src/backend/utils/adt/ruleutils.c') diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 8614e73d534..ef58e99dac9 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * back to source text * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.169 2004/05/30 23:40:36 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.170 2004/06/06 00:41:27 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -3445,8 +3445,9 @@ static void get_const_expr(Const *constval, deparse_context *context) { StringInfo buf = context->buf; - HeapTuple typetup; - Form_pg_type typeStruct; + Oid typoutput; + Oid typioparam; + bool typIsVarlena; char *extval; char *valptr; bool isfloat = false; @@ -3463,17 +3464,12 @@ get_const_expr(Const *constval, deparse_context *context) return; } - typetup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(constval->consttype), - 0, 0, 0); - if (!HeapTupleIsValid(typetup)) - elog(ERROR, "cache lookup failed for type %u", constval->consttype); - - typeStruct = (Form_pg_type) GETSTRUCT(typetup); + getTypeOutputInfo(constval->consttype, + &typoutput, &typioparam, &typIsVarlena); - extval = DatumGetCString(OidFunctionCall3(typeStruct->typoutput, + extval = DatumGetCString(OidFunctionCall3(typoutput, constval->constvalue, - ObjectIdGetDatum(typeStruct->typelem), + ObjectIdGetDatum(typioparam), Int32GetDatum(-1))); switch (constval->consttype) @@ -3570,8 +3566,6 @@ get_const_expr(Const *constval, deparse_context *context) if (needlabel) appendStringInfo(buf, "::%s", format_type_with_typemod(constval->consttype, -1)); - - ReleaseSysCache(typetup); } -- cgit v1.2.3