1996-07-09 06:22:35 +00:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-13 23:22:53 +00:00
|
|
|
* fastpath.c
|
1997-09-07 05:04:48 +00:00
|
|
|
* routines to handle function requests from the frontend
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
2002-06-20 20:29:54 +00:00
|
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
2000-01-26 05:58:53 +00:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2003-05-05 00:44:56 +00:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.61 2003/05/05 00:44:56 tgl Exp $
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
* NOTES
|
1997-09-07 05:04:48 +00:00
|
|
|
* This cruft is the server side of PQfn.
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* - jolly 07/11/95:
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* no longer rely on return sizes provided by the frontend. Always
|
|
|
|
* use the true lengths for the catalogs. Assume that the frontend
|
|
|
|
* has allocated enough space to handle the result value returned.
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* trust that the user knows what he is doing with the args. If the
|
|
|
|
* sys catalog says it is a varlena, assume that the user is only sending
|
|
|
|
* down VARDATA and that the argsize is the VARSIZE. If the arg is
|
|
|
|
* fixed len, assume that the argsize given by the user is correct.
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* if the function returns by value, then only send 4 bytes value
|
|
|
|
* back to the frontend. If the return returns by reference,
|
|
|
|
* send down only the data portion and set the return size appropriately.
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
|
|
|
2003-04-19 00:02:30 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
1999-07-16 03:14:30 +00:00
|
|
|
#include "access/xact.h"
|
1996-07-09 06:22:35 +00:00
|
|
|
#include "catalog/pg_proc.h"
|
1999-07-16 05:00:38 +00:00
|
|
|
#include "libpq/libpq.h"
|
|
|
|
#include "libpq/pqformat.h"
|
2003-01-09 18:00:24 +00:00
|
|
|
#include "miscadmin.h"
|
1999-07-16 05:00:38 +00:00
|
|
|
#include "tcop/fastpath.h"
|
2003-01-01 21:57:05 +00:00
|
|
|
#include "utils/acl.h"
|
2001-06-01 15:45:42 +00:00
|
|
|
#include "utils/lsyscache.h"
|
1999-07-16 05:00:38 +00:00
|
|
|
#include "utils/syscache.h"
|
2003-01-01 21:57:05 +00:00
|
|
|
#include "utils/tqual.h"
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
|
2003-04-19 00:02:30 +00:00
|
|
|
/* ----------------
|
|
|
|
* GetOldFunctionMessage
|
|
|
|
*
|
|
|
|
* In pre-3.0 protocol, there is no length word on the message, so we have
|
|
|
|
* to have code that understands the message layout to absorb the message
|
|
|
|
* into a buffer. We want to do this before we start execution, so that
|
|
|
|
* we do not lose sync with the frontend if there's an error.
|
|
|
|
*
|
|
|
|
* The caller should already have initialized buf to empty.
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
GetOldFunctionMessage(StringInfo buf)
|
|
|
|
{
|
|
|
|
int32 ibuf;
|
|
|
|
int nargs;
|
|
|
|
|
|
|
|
/* Dummy string argument */
|
|
|
|
if (pq_getstring(buf))
|
|
|
|
return EOF;
|
|
|
|
/* Function OID */
|
|
|
|
if (pq_getbytes((char *) &ibuf, 4))
|
|
|
|
return EOF;
|
|
|
|
appendBinaryStringInfo(buf, (char *) &ibuf, 4);
|
|
|
|
/* Number of arguments */
|
|
|
|
if (pq_getbytes((char *) &ibuf, 4))
|
|
|
|
return EOF;
|
|
|
|
appendBinaryStringInfo(buf, (char *) &ibuf, 4);
|
|
|
|
nargs = ntohl(ibuf);
|
|
|
|
/* For each argument ... */
|
|
|
|
while (nargs-- > 0)
|
|
|
|
{
|
|
|
|
int argsize;
|
|
|
|
|
|
|
|
/* argsize */
|
|
|
|
if (pq_getbytes((char *) &ibuf, 4))
|
|
|
|
return EOF;
|
|
|
|
appendBinaryStringInfo(buf, (char *) &ibuf, 4);
|
|
|
|
argsize = ntohl(ibuf);
|
|
|
|
if (argsize < 0)
|
|
|
|
{
|
|
|
|
/* FATAL here since no hope of regaining message sync */
|
|
|
|
elog(FATAL, "HandleFunctionRequest: bogus argsize %d",
|
|
|
|
argsize);
|
|
|
|
}
|
|
|
|
/* and arg contents */
|
|
|
|
if (argsize > 0)
|
|
|
|
{
|
|
|
|
/* Allocate space for arg */
|
|
|
|
enlargeStringInfo(buf, argsize);
|
|
|
|
/* And grab it */
|
|
|
|
if (pq_getbytes(buf->data + buf->len, argsize))
|
|
|
|
return EOF;
|
|
|
|
buf->len += argsize;
|
|
|
|
/* Place a trailing null per StringInfo convention */
|
|
|
|
buf->data[buf->len] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
/* ----------------
|
1997-09-07 05:04:48 +00:00
|
|
|
* SendFunctionResult
|
2002-08-24 15:00:47 +00:00
|
|
|
*
|
|
|
|
* retlen is 0 if returning NULL, else the typlen according to the catalogs
|
1996-07-09 06:22:35 +00:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static void
|
2002-08-24 15:00:47 +00:00
|
|
|
SendFunctionResult(Datum retval, bool retbyval, int retlen)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1999-04-25 03:19:27 +00:00
|
|
|
StringInfoData buf;
|
|
|
|
|
2003-04-22 00:08:07 +00:00
|
|
|
pq_beginmessage(&buf, 'V');
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
if (retlen != 0)
|
|
|
|
{
|
1999-04-25 03:19:27 +00:00
|
|
|
pq_sendbyte(&buf, 'G');
|
1997-09-07 05:04:48 +00:00
|
|
|
if (retbyval)
|
|
|
|
{ /* by-value */
|
1999-04-25 03:19:27 +00:00
|
|
|
pq_sendint(&buf, retlen, 4);
|
2000-05-28 17:56:29 +00:00
|
|
|
pq_sendint(&buf, DatumGetInt32(retval), retlen);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* by-reference ... */
|
2002-08-24 15:00:47 +00:00
|
|
|
if (retlen == -1)
|
1997-09-07 05:04:48 +00:00
|
|
|
{ /* ... varlena */
|
2003-01-07 22:32:10 +00:00
|
|
|
struct varlena *v = PG_DETOAST_DATUM(retval);
|
2000-05-28 17:56:29 +00:00
|
|
|
|
|
|
|
pq_sendint(&buf, VARSIZE(v) - VARHDRSZ, VARHDRSZ);
|
|
|
|
pq_sendbytes(&buf, VARDATA(v), VARSIZE(v) - VARHDRSZ);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* ... fixed */
|
1999-04-25 03:19:27 +00:00
|
|
|
pq_sendint(&buf, retlen, 4);
|
2000-05-28 17:56:29 +00:00
|
|
|
pq_sendbytes(&buf, DatumGetPointer(retval), retlen);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
}
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1999-04-25 03:19:27 +00:00
|
|
|
pq_sendbyte(&buf, '0');
|
|
|
|
pq_endmessage(&buf);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-06-01 15:45:42 +00:00
|
|
|
* Formerly, this code attempted to cache the function and type info
|
|
|
|
* looked up by fetch_fp_info, but only for the duration of a single
|
|
|
|
* transaction command (since in theory the info could change between
|
|
|
|
* commands). This was utterly useless, because postgres.c executes
|
|
|
|
* each fastpath call as a separate transaction command, and so the
|
|
|
|
* cached data could never actually have been reused. If it had worked
|
|
|
|
* as intended, it would have had problems anyway with dangling references
|
2001-10-25 05:50:21 +00:00
|
|
|
* in the FmgrInfo struct. So, forget about caching and just repeat the
|
|
|
|
* syscache fetches on each usage. They're not *that* expensive.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
1997-09-07 05:04:48 +00:00
|
|
|
struct fp_info
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
Oid funcid;
|
2000-05-28 17:56:29 +00:00
|
|
|
FmgrInfo flinfo; /* function lookup info for funcid */
|
2001-06-01 15:45:42 +00:00
|
|
|
int16 arglen[FUNC_MAX_ARGS];
|
2000-01-10 17:14:46 +00:00
|
|
|
bool argbyval[FUNC_MAX_ARGS];
|
2001-06-01 15:45:42 +00:00
|
|
|
int16 retlen;
|
1997-09-08 02:41:22 +00:00
|
|
|
bool retbyval;
|
1996-07-09 06:22:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2001-06-01 15:45:42 +00:00
|
|
|
* fetch_fp_info
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
* Performs catalog lookups to load a struct fp_info 'fip' for the
|
|
|
|
* function 'func_id'.
|
|
|
|
*/
|
|
|
|
static void
|
2001-06-01 15:45:42 +00:00
|
|
|
fetch_fp_info(Oid func_id, struct fp_info * fip)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
2000-01-10 16:13:23 +00:00
|
|
|
Oid *argtypes; /* an oidvector */
|
1997-09-08 02:41:22 +00:00
|
|
|
Oid rettype;
|
2001-06-01 15:45:42 +00:00
|
|
|
HeapTuple func_htp;
|
1997-09-08 02:41:22 +00:00
|
|
|
Form_pg_proc pp;
|
|
|
|
int i;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
Assert(OidIsValid(func_id));
|
|
|
|
Assert(fip != (struct fp_info *) NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since the validity of this structure is determined by whether the
|
|
|
|
* funcid is OK, we clear the funcid here. It must not be set to the
|
|
|
|
* correct value until we are about to return with a good struct
|
1998-01-07 21:07:04 +00:00
|
|
|
* fp_info, since we can be interrupted (i.e., with an elog(ERROR,
|
2001-06-01 15:45:42 +00:00
|
|
|
* ...)) at any time. [No longer really an issue since we don't save
|
2001-10-25 05:50:21 +00:00
|
|
|
* the struct fp_info across transactions anymore, but keep it
|
|
|
|
* anyway.]
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
2001-06-01 15:45:42 +00:00
|
|
|
MemSet((char *) fip, 0, sizeof(struct fp_info));
|
1997-09-07 05:04:48 +00:00
|
|
|
fip->funcid = InvalidOid;
|
|
|
|
|
2001-06-01 15:45:42 +00:00
|
|
|
fmgr_info(func_id, &fip->flinfo);
|
|
|
|
|
2000-11-16 22:30:52 +00:00
|
|
|
func_htp = SearchSysCache(PROCOID,
|
|
|
|
ObjectIdGetDatum(func_id),
|
|
|
|
0, 0, 0);
|
1997-09-07 05:04:48 +00:00
|
|
|
if (!HeapTupleIsValid(func_htp))
|
2001-06-01 15:45:42 +00:00
|
|
|
elog(ERROR, "fetch_fp_info: cache lookup for function %u failed",
|
1997-09-07 05:04:48 +00:00
|
|
|
func_id);
|
|
|
|
pp = (Form_pg_proc) GETSTRUCT(func_htp);
|
|
|
|
rettype = pp->prorettype;
|
|
|
|
argtypes = pp->proargtypes;
|
|
|
|
|
2001-06-01 15:45:42 +00:00
|
|
|
for (i = 0; i < pp->pronargs; ++i)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
2002-08-24 15:00:47 +00:00
|
|
|
get_typlenbyval(argtypes[i], &fip->arglen[i], &fip->argbyval[i]);
|
|
|
|
/* We don't support cstring in fastpath protocol */
|
|
|
|
if (fip->arglen[i] == -2)
|
|
|
|
elog(ERROR, "CSTRING not supported in fastpath protocol");
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
|
2002-08-24 15:00:47 +00:00
|
|
|
get_typlenbyval(rettype, &fip->retlen, &fip->retbyval);
|
|
|
|
if (fip->retlen == -2)
|
|
|
|
elog(ERROR, "CSTRING not supported in fastpath protocol");
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-11-16 22:30:52 +00:00
|
|
|
ReleaseSysCache(func_htp);
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
|
|
|
* This must be last!
|
|
|
|
*/
|
|
|
|
fip->funcid = func_id;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* HandleFunctionRequest
|
|
|
|
*
|
|
|
|
* Server side of PQfn (fastpath function calls from the frontend).
|
|
|
|
* This corresponds to the libpq protocol symbol "F".
|
|
|
|
*
|
2003-04-19 00:02:30 +00:00
|
|
|
* INPUT:
|
|
|
|
* In protocol version 3, postgres.c has already read the message body
|
|
|
|
* and will pass it in msgBuf.
|
|
|
|
* In old protocol, the passed msgBuf is empty and we must read the
|
|
|
|
* message here.
|
|
|
|
*
|
1996-07-09 06:22:35 +00:00
|
|
|
* RETURNS:
|
1999-07-22 02:40:07 +00:00
|
|
|
* 0 if successful completion, EOF if frontend connection lost.
|
|
|
|
*
|
|
|
|
* Note: All ordinary errors result in elog(ERROR,...). However,
|
|
|
|
* if we lose the frontend connection there is no one to elog to,
|
|
|
|
* and no use in proceeding...
|
2000-10-24 20:59:35 +00:00
|
|
|
*
|
|
|
|
* Note: palloc()s done here and in the called function do not need to be
|
|
|
|
* cleaned up explicitly. We are called from PostgresMain() in the
|
2003-05-02 20:54:36 +00:00
|
|
|
* MessageContext memory context, which will be automatically reset when
|
2000-10-24 20:59:35 +00:00
|
|
|
* control returns to PostgresMain.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
|
|
|
int
|
2003-04-19 00:02:30 +00:00
|
|
|
HandleFunctionRequest(StringInfo msgBuf)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
Oid fid;
|
|
|
|
int nargs;
|
2003-01-01 21:57:05 +00:00
|
|
|
AclResult aclresult;
|
2000-05-28 17:56:29 +00:00
|
|
|
FunctionCallInfoData fcinfo;
|
|
|
|
Datum retval;
|
1997-09-08 02:41:22 +00:00
|
|
|
int i;
|
2001-06-01 15:45:42 +00:00
|
|
|
struct fp_info my_fp;
|
1997-09-07 05:04:48 +00:00
|
|
|
struct fp_info *fip;
|
|
|
|
|
2000-10-24 20:59:35 +00:00
|
|
|
/*
|
2003-04-19 00:02:30 +00:00
|
|
|
* Read message contents if not already done.
|
2000-10-24 20:59:35 +00:00
|
|
|
*/
|
2003-04-19 00:02:30 +00:00
|
|
|
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
|
|
|
|
{
|
|
|
|
if (GetOldFunctionMessage(msgBuf))
|
|
|
|
{
|
|
|
|
elog(COMMERROR, "unexpected EOF on client connection");
|
|
|
|
return EOF;
|
|
|
|
}
|
|
|
|
}
|
2000-10-24 20:59:35 +00:00
|
|
|
|
2003-04-19 00:02:30 +00:00
|
|
|
/*
|
|
|
|
* Now that we've eaten the input message, check to see if we actually
|
|
|
|
* want to do the function call or not. It's now safe to elog(); we won't
|
|
|
|
* lose sync with the frontend.
|
|
|
|
*/
|
|
|
|
if (IsAbortedTransactionBlockState())
|
|
|
|
elog(ERROR, "current transaction is aborted, "
|
|
|
|
"queries ignored until end of transaction block");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse the buffer contents.
|
|
|
|
*/
|
|
|
|
(void) pq_getmsgstring(msgBuf); /* dummy string */
|
|
|
|
fid = (Oid) pq_getmsgint(msgBuf, 4); /* function oid */
|
|
|
|
nargs = pq_getmsgint(msgBuf, 4); /* # of arguments */
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
2001-10-25 05:50:21 +00:00
|
|
|
* There used to be a lame attempt at caching lookup info here. Now we
|
|
|
|
* just do the lookups on every call.
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
2001-06-01 15:45:42 +00:00
|
|
|
fip = &my_fp;
|
|
|
|
fetch_fp_info(fid, fip);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2003-04-19 00:02:30 +00:00
|
|
|
/* Check permission to call function */
|
|
|
|
aclresult = pg_proc_aclcheck(fid, GetUserId(), ACL_EXECUTE);
|
|
|
|
if (aclresult != ACLCHECK_OK)
|
|
|
|
aclcheck_error(aclresult, get_func_name(fid));
|
|
|
|
|
2003-05-05 00:44:56 +00:00
|
|
|
/*
|
|
|
|
* Set up a query snapshot in case function needs one.
|
|
|
|
*/
|
|
|
|
SetQuerySnapshot();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prepare function call info block.
|
|
|
|
*/
|
2000-05-28 17:56:29 +00:00
|
|
|
if (fip->flinfo.fn_nargs != nargs || nargs > FUNC_MAX_ARGS)
|
1998-01-07 21:07:04 +00:00
|
|
|
elog(ERROR, "HandleFunctionRequest: actual arguments (%d) != registered arguments (%d)",
|
2000-05-28 17:56:29 +00:00
|
|
|
nargs, fip->flinfo.fn_nargs);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-05-28 17:56:29 +00:00
|
|
|
MemSet(&fcinfo, 0, sizeof(fcinfo));
|
|
|
|
fcinfo.flinfo = &fip->flinfo;
|
|
|
|
fcinfo.nargs = nargs;
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
2000-05-28 17:56:29 +00:00
|
|
|
* Copy supplied arguments into arg vector. Note there is no way for
|
2003-04-19 00:02:30 +00:00
|
|
|
* frontend to specify a NULL argument --- this protocol is misdesigned.
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
2000-05-28 17:56:29 +00:00
|
|
|
for (i = 0; i < nargs; ++i)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
2003-04-19 00:02:30 +00:00
|
|
|
int argsize;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
argsize = pq_getmsgint(msgBuf, 4);
|
2000-05-28 17:56:29 +00:00
|
|
|
if (fip->argbyval[i])
|
|
|
|
{ /* by-value */
|
|
|
|
if (argsize < 1 || argsize > 4)
|
|
|
|
elog(ERROR, "HandleFunctionRequest: bogus argsize %d",
|
|
|
|
argsize);
|
|
|
|
/* XXX should we demand argsize == fip->arglen[i] ? */
|
2003-04-19 00:02:30 +00:00
|
|
|
fcinfo.arg[i] = (Datum) pq_getmsgint(msgBuf, argsize);
|
2000-05-28 17:56:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* by-reference ... */
|
2002-08-24 15:00:47 +00:00
|
|
|
if (fip->arglen[i] == -1)
|
2000-05-28 17:56:29 +00:00
|
|
|
{ /* ... varlena */
|
|
|
|
if (argsize < 0)
|
|
|
|
elog(ERROR, "HandleFunctionRequest: bogus argsize %d",
|
|
|
|
argsize);
|
2003-04-19 00:02:30 +00:00
|
|
|
p = palloc(argsize + VARHDRSZ);
|
2000-07-03 23:10:14 +00:00
|
|
|
VARATT_SIZEP(p) = argsize + VARHDRSZ;
|
2003-04-19 00:02:30 +00:00
|
|
|
pq_copymsgbytes(msgBuf, VARDATA(p), argsize);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
1997-09-07 05:04:48 +00:00
|
|
|
else
|
2000-05-28 17:56:29 +00:00
|
|
|
{ /* ... fixed */
|
|
|
|
if (argsize != fip->arglen[i])
|
|
|
|
elog(ERROR, "HandleFunctionRequest: bogus argsize %d, should be %d",
|
|
|
|
argsize, fip->arglen[i]);
|
2001-03-22 04:01:46 +00:00
|
|
|
p = palloc(argsize + 1); /* +1 in case argsize is 0 */
|
2003-04-19 00:02:30 +00:00
|
|
|
pq_copymsgbytes(msgBuf, p, argsize);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
2000-05-28 17:56:29 +00:00
|
|
|
fcinfo.arg[i] = PointerGetDatum(p);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
2003-05-05 00:44:56 +00:00
|
|
|
/* Verify we reached the end of the message where expected. */
|
|
|
|
pq_getmsgend(msgBuf);
|
2003-01-01 21:57:05 +00:00
|
|
|
|
2000-05-28 17:56:29 +00:00
|
|
|
#ifdef NO_FASTPATH
|
|
|
|
/* force a NULL return */
|
|
|
|
retval = (Datum) 0;
|
|
|
|
fcinfo.isnull = true;
|
1996-07-09 06:22:35 +00:00
|
|
|
#else
|
2000-05-28 17:56:29 +00:00
|
|
|
retval = FunctionCallInvoke(&fcinfo);
|
2001-11-05 17:46:40 +00:00
|
|
|
#endif /* NO_FASTPATH */
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-05-28 17:56:29 +00:00
|
|
|
if (fcinfo.isnull)
|
|
|
|
SendFunctionResult(retval, fip->retbyval, 0);
|
|
|
|
else
|
|
|
|
SendFunctionResult(retval, fip->retbyval, fip->retlen);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return 0;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|