aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/lsyscache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/cache/lsyscache.c')
-rw-r--r--src/backend/utils/cache/lsyscache.c86
1 files changed, 85 insertions, 1 deletions
diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c
index 095c5e6a8aa..a4fcd3fc286 100644
--- a/src/backend/utils/cache/lsyscache.c
+++ b/src/backend/utils/cache/lsyscache.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.96 2003/06/22 22:04:54 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.97 2003/06/24 23:14:46 momjian Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
@@ -719,6 +719,40 @@ get_func_rettype(Oid funcid)
}
/*
+ * get_func_argtypes
+ * Given procedure id, return the function's argument types.
+ * Also pass back the number of arguments.
+ */
+Oid *
+get_func_argtypes(Oid funcid, int *nargs)
+{
+ HeapTuple tp;
+ Form_pg_proc procstruct;
+ Oid *result = NULL;
+ int i;
+
+ tp = SearchSysCache(PROCOID,
+ ObjectIdGetDatum(funcid),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(tp))
+ elog(ERROR, "Function OID %u does not exist", funcid);
+
+ procstruct = (Form_pg_proc) GETSTRUCT(tp);
+ *nargs = (int) procstruct->pronargs;
+
+ if (*nargs > 0)
+ {
+ result = (Oid *) palloc(*nargs * sizeof(Oid));
+
+ for (i = 0; i < *nargs; i++)
+ result[i] = procstruct->proargtypes[i];
+ }
+
+ ReleaseSysCache(tp);
+ return result;
+}
+
+/*
* get_func_retset
* Given procedure id, return the function's proretset flag.
*/
@@ -1090,6 +1124,56 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
ReleaseSysCache(tp);
}
+/*
+ * get_type_metadata
+ *
+ * A six-fer: given the type OID, return typlen, typbyval, typalign,
+ * typdelim, typelem, IO function Oid. The IO function
+ * returned is controlled by IOFuncSelector
+ */
+void
+get_type_metadata(Oid element_type,
+ IOFuncSelector which_func,
+ int *typlen,
+ bool *typbyval,
+ char *typdelim,
+ Oid *typelem,
+ Oid *proc,
+ char *typalign)
+{
+ HeapTuple typeTuple;
+ Form_pg_type typeStruct;
+
+ typeTuple = SearchSysCache(TYPEOID,
+ ObjectIdGetDatum(element_type),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(typeTuple))
+ elog(ERROR, "cache lookup failed for type %u", element_type);
+ typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
+
+ *typlen = typeStruct->typlen;
+ *typbyval = typeStruct->typbyval;
+ *typdelim = typeStruct->typdelim;
+ *typelem = typeStruct->typelem;
+ *typalign = typeStruct->typalign;
+ switch (which_func)
+ {
+ case IOFunc_input:
+ *proc = typeStruct->typinput;
+ break;
+ case IOFunc_output:
+ *proc = typeStruct->typoutput;
+ break;
+ case IOFunc_receive:
+ *proc = typeStruct->typreceive;
+ break;
+ case IOFunc_send:
+ *proc = typeStruct->typsend;
+ break;
+ }
+ ReleaseSysCache(typeTuple);
+}
+
#ifdef NOT_USED
char
get_typalign(Oid typid)