summaryrefslogtreecommitdiff
path: root/src/include/funcapi.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-03-31 22:46:33 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-03-31 22:46:33 +0000
commit47888fe84227aaf3decffc7204554bdec54d2b29 (patch)
tree73703aa272d2b9899626002190f0fbd3b1e579fb /src/include/funcapi.h
parentfb13881f423193a8342e0fe098f581e511b09d67 (diff)
downloadpostgresql-47888fe84227aaf3decffc7204554bdec54d2b29.tar.gz
First phase of OUT-parameters project. We can now define and use SQL
functions with OUT parameters. The various PLs still need work, as does pg_dump. Rudimentary docs and regression tests included.
Diffstat (limited to 'src/include/funcapi.h')
-rw-r--r--src/include/funcapi.h55
1 files changed, 52 insertions, 3 deletions
diff --git a/src/include/funcapi.h b/src/include/funcapi.h
index 00549897d5..c4d1809948 100644
--- a/src/include/funcapi.h
+++ b/src/include/funcapi.h
@@ -9,7 +9,7 @@
*
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/funcapi.h,v 1.15 2005/01/01 05:43:08 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/funcapi.h,v 1.16 2005/03/31 22:46:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -124,7 +124,57 @@ typedef struct FuncCallContext
} FuncCallContext;
/*----------
- * Support to ease writing Functions returning composite types
+ * Support to ease writing functions returning composite types
+ *
+ * External declarations:
+ * get_call_result_type:
+ * Given a function's call info record, determine the kind of datatype
+ * it is supposed to return. If resultTypeId isn't NULL, *resultTypeId
+ * receives the actual datatype OID (this is mainly useful for scalar
+ * result types). If resultTupleDesc isn't NULL, *resultTupleDesc
+ * receives a pointer to a TupleDesc when the result is of a composite
+ * type, or NULL when it's a scalar result or the rowtype could not be
+ * determined. NB: the tupledesc should be copied if it is to be
+ * accessed over a long period.
+ * get_expr_result_type:
+ * Given an expression node, return the same info as for
+ * get_call_result_type. Note: the cases in which rowtypes cannot be
+ * determined are different from the cases for get_call_result_type.
+ * get_func_result_type:
+ * Given only a function's OID, return the same info as for
+ * get_call_result_type. Note: the cases in which rowtypes cannot be
+ * determined are different from the cases for get_call_result_type.
+ * Do *not* use this if you can use one of the others.
+ *----------
+ */
+
+/* Type categories for get_call_result_type and siblings */
+typedef enum TypeFuncClass
+{
+ TYPEFUNC_SCALAR, /* scalar result type */
+ TYPEFUNC_COMPOSITE, /* determinable rowtype result */
+ TYPEFUNC_RECORD, /* indeterminate rowtype result */
+ TYPEFUNC_OTHER /* bogus type, eg pseudotype */
+} TypeFuncClass;
+
+extern TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo,
+ Oid *resultTypeId,
+ TupleDesc *resultTupleDesc);
+extern TypeFuncClass get_expr_result_type(Node *expr,
+ Oid *resultTypeId,
+ TupleDesc *resultTupleDesc);
+extern TypeFuncClass get_func_result_type(Oid functionId,
+ Oid *resultTypeId,
+ TupleDesc *resultTupleDesc);
+
+extern TupleDesc build_function_result_tupdesc_d(Datum proallargtypes,
+ Datum proargmodes,
+ Datum proargnames);
+extern TupleDesc build_function_result_tupdesc_t(HeapTuple procTuple);
+
+
+/*----------
+ * Support to ease writing functions returning composite types
*
* External declarations:
* TupleDesc RelationNameGetTupleDesc(const char *relname) - Use to get a
@@ -160,7 +210,6 @@ typedef struct FuncCallContext
/* obsolete version of above */
#define TupleGetDatum(_slot, _tuple) PointerGetDatum((_tuple)->t_data)
-/* from tupdesc.c */
extern TupleDesc RelationNameGetTupleDesc(const char *relname);
extern TupleDesc TypeGetTupleDesc(Oid typeoid, List *colaliases);