summaryrefslogtreecommitdiff
path: root/src/backend/libpq
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-05-28 17:56:29 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-05-28 17:56:29 +0000
commit0a7fb4e9184539afcb6fed0f1d2bc0abddc2b0a6 (patch)
treeaffcce1c5b6367468fb6dcfd2790585f2e967629 /src/backend/libpq
parent5005bb060b3f3a82cd1bd662c7f8946c9be59db5 (diff)
downloadpostgresql-0a7fb4e9184539afcb6fed0f1d2bc0abddc2b0a6.tar.gz
First round of changes for new fmgr interface. fmgr itself and the
key call sites are changed, but most called functions are still oldstyle. An exception is that the PL managers are updated (so, for example, NULL handling now behaves as expected in plperl and plpgsql functions). NOTE initdb is forced due to added column in pg_proc.
Diffstat (limited to 'src/backend/libpq')
-rw-r--r--src/backend/libpq/Makefile7
-rw-r--r--src/backend/libpq/be-pqexec.c41
2 files changed, 25 insertions, 23 deletions
diff --git a/src/backend/libpq/Makefile b/src/backend/libpq/Makefile
index 656fbdb480..50f5f1b720 100644
--- a/src/backend/libpq/Makefile
+++ b/src/backend/libpq/Makefile
@@ -4,7 +4,7 @@
# Makefile for libpq subsystem (backend half of libpq interface)
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.17 2000/01/19 02:58:52 petere Exp $
+# $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.18 2000/05/28 17:55:56 tgl Exp $
#
#-------------------------------------------------------------------------
@@ -29,11 +29,6 @@ all: SUBSYS.o
SUBSYS.o: $(OBJS)
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
-be-dumpdata.o be-pqexec.o: ../fmgr.h
-
-../fmgr.h:
- $(MAKE) -C .. fmgr.h
-
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
diff --git a/src/backend/libpq/be-pqexec.c b/src/backend/libpq/be-pqexec.c
index 0c29ea2518..42d48281e0 100644
--- a/src/backend/libpq/be-pqexec.c
+++ b/src/backend/libpq/be-pqexec.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.31 2000/03/17 02:36:08 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.32 2000/05/28 17:55:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -42,11 +42,11 @@ static char *strmake(char *str, int len);
* result_buf : pointer to result buffer (&int if integer)
* result_len : length of return value.
* result_is_int : If the result is an integer, this must be non-zero
- * args : pointer to a NULL terminated arg array.
+ * args : pointer to an array of PQArgBlock items.
* (length, if integer, and result-pointer)
* nargs : # of arguments in args array.
*
- * This code scavanged from HandleFunctionRequest() in tcop/fastpath.h
+ * This code scavenged from HandleFunctionRequest() in tcop/fastpath.h
* ----------------
*/
char *
@@ -57,46 +57,53 @@ PQfn(int fnid,
PQArgBlock *args,
int nargs)
{
- char *retval; /* XXX - should be datum, maybe ? */
- char *arg[FUNC_MAX_ARGS];
- bool isNull;
- int i;
+ FmgrInfo flinfo;
+ FunctionCallInfoData fcinfo;
+ Datum retval;
+ int i;
- /* ----------------
- * fill args[] array
- * ----------------
- */
if (nargs > FUNC_MAX_ARGS)
elog(ERROR, "functions cannot have more than %d arguments",
FUNC_MAX_ARGS);
+
+ /* ----------------
+ * set up the argument block for the function manager
+ * ----------------
+ */
+ fmgr_info((Oid) fnid, &flinfo);
+
+ MemSet(&fcinfo, 0, sizeof(fcinfo));
+ fcinfo.flinfo = &flinfo;
+ fcinfo.nargs = nargs;
+
for (i = 0; i < nargs; i++)
{
if (args[i].len == VAR_LENGTH_ARG)
- arg[i] = (char *) args[i].u.ptr;
+ fcinfo.arg[i] = (Datum) args[i].u.ptr;
else if ((Size) args[i].len > sizeof(int4))
elog(ERROR, "arg_length of argument %d too long", i);
else
- arg[i] = (char *) args[i].u.integer;
+ fcinfo.arg[i] = (Datum) args[i].u.integer;
}
/* ----------------
* call the postgres function manager
* ----------------
*/
- retval = fmgr_array_args(fnid, nargs, arg, &isNull);
+ retval = FunctionCallInvoke(&fcinfo);
/* ----------------
* put the result in the buffer the user specified and
* return the proper code.
* ----------------
*/
- if (isNull) /* void retval */
+ if (fcinfo.isnull) /* void retval */
return "0";
if (result_is_int)
- *result_buf = (int) retval;
+ *result_buf = DatumGetInt32(retval);
else
- memmove(result_buf, retval, result_len);
+ memmove(result_buf, DatumGetPointer(retval), result_len);
return "G";
}