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/nodes/print.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/backend/nodes/print.c') diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c index 4934c09e2b3..035bb7aa65e 100644 --- a/src/backend/nodes/print.c +++ b/src/backend/nodes/print.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.68 2004/05/30 23:40:27 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.69 2004/06/06 00:41:26 tgl Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -20,7 +20,6 @@ #include "postgres.h" #include "access/printtup.h" -#include "catalog/pg_type.h" #include "lib/stringinfo.h" #include "nodes/print.h" #include "optimizer/clauses.h" @@ -345,9 +344,9 @@ print_expr(Node *expr, List *rtable) else if (IsA(expr, Const)) { Const *c = (Const *) expr; - HeapTuple typeTup; Oid typoutput; - Oid typelem; + Oid typioparam; + bool typIsVarlena; char *outputstr; if (c->constisnull) @@ -356,18 +355,12 @@ print_expr(Node *expr, List *rtable) return; } - typeTup = SearchSysCache(TYPEOID, - ObjectIdGetDatum(c->consttype), - 0, 0, 0); - if (!HeapTupleIsValid(typeTup)) - elog(ERROR, "cache lookup failed for type %u", c->consttype); - typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput; - typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem; - ReleaseSysCache(typeTup); + getTypeOutputInfo(c->consttype, + &typoutput, &typioparam, &typIsVarlena); outputstr = DatumGetCString(OidFunctionCall3(typoutput, c->constvalue, - ObjectIdGetDatum(typelem), + ObjectIdGetDatum(typioparam), Int32GetDatum(-1))); printf("%s", outputstr); pfree(outputstr); -- cgit v1.2.3