summaryrefslogtreecommitdiff
path: root/contrib/pgstattuple/pgstattuple.c
diff options
context:
space:
mode:
authorTom Lane2005-05-30 23:09:07 +0000
committerTom Lane2005-05-30 23:09:07 +0000
commit978129f28e0cba0b6364df672fbd1ae88e3397c4 (patch)
tree94dcfb1cb3494d7981dc9d09c10047129577db40 /contrib/pgstattuple/pgstattuple.c
parentb215fae891a7b0e9bcd7126f3aab1c477d4947b1 (diff)
Document get_call_result_type() and friends; mark TypeGetTupleDesc()
and RelationNameGetTupleDesc() as deprecated; remove uses of the latter in the contrib library. Along the way, clean up crosstab() code and documentation a little.
Diffstat (limited to 'contrib/pgstattuple/pgstattuple.c')
-rw-r--r--contrib/pgstattuple/pgstattuple.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c
index db4b37def0e..3056bd8978e 100644
--- a/contrib/pgstattuple/pgstattuple.c
+++ b/contrib/pgstattuple/pgstattuple.c
@@ -1,5 +1,5 @@
/*
- * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.18 2005/05/27 00:57:49 neilc Exp $
+ * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.19 2005/05/30 23:09:06 tgl Exp $
*
* Copyright (c) 2001,2002 Tatsuo Ishii
*
@@ -38,7 +38,8 @@ PG_FUNCTION_INFO_V1(pgstattuplebyid);
extern Datum pgstattuple(PG_FUNCTION_ARGS);
extern Datum pgstattuplebyid(PG_FUNCTION_ARGS);
-static Datum pgstattuple_real(Relation rel);
+static Datum pgstattuple_real(Relation rel, FunctionCallInfo fcinfo);
+
/* ----------
* pgstattuple:
@@ -50,7 +51,6 @@ static Datum pgstattuple_real(Relation rel);
* ----------
*/
-#define DUMMY_TUPLE "public.pgstattuple_type"
#define NCOLUMNS 9
#define NCHARS 32
@@ -66,7 +66,7 @@ pgstattuple(PG_FUNCTION_ARGS)
relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname));
rel = heap_openrv(relrv, AccessShareLock);
- result = pgstattuple_real(rel);
+ result = pgstattuple_real(rel, fcinfo);
PG_RETURN_DATUM(result);
}
@@ -81,7 +81,7 @@ pgstattuplebyid(PG_FUNCTION_ARGS)
/* open relation */
rel = heap_open(relid, AccessShareLock);
- result = pgstattuple_real(rel);
+ result = pgstattuple_real(rel, fcinfo);
PG_RETURN_DATUM(result);
}
@@ -92,7 +92,7 @@ pgstattuplebyid(PG_FUNCTION_ARGS)
* The real work occurs here
*/
static Datum
-pgstattuple_real(Relation rel)
+pgstattuple_real(Relation rel, FunctionCallInfo fcinfo)
{
HeapScanDesc scan;
HeapTuple tuple;
@@ -115,10 +115,12 @@ pgstattuple_real(Relation rel)
int i;
Datum result;
- /*
- * Build a tuple description for a pgstattupe_type tuple
- */
- tupdesc = RelationNameGetTupleDesc(DUMMY_TUPLE);
+ /* Build a tuple descriptor for our result type */
+ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
+ elog(ERROR, "return type must be a row type");
+
+ /* make sure we have a persistent copy of the tupdesc */
+ tupdesc = CreateTupleDescCopy(tupdesc);
/*
* Generate attribute metadata needed later to produce tuples from raw