aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-06-06 00:41:28 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-06-06 00:41:28 +0000
commitc541bb86e9ec8fed37b23df6a0df703d0bde4dfa (patch)
treeb4cff96eecc86e338274ec5d7355918efe9c149e /src/backend/utils/adt/ruleutils.c
parentc3a153afed84e29dac664bdc6123724a9e3a906f (diff)
downloadpostgresql-c541bb86e9ec8fed37b23df6a0df703d0bde4dfa.tar.gz
postgresql-c541bb86e9ec8fed37b23df6a0df703d0bde4dfa.zip
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.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c22
1 files changed, 8 insertions, 14 deletions
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);
}