1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* fastpath.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* routines to handle function requests from the frontend
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2000-05-30 09:09:23 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.40 2000/05/30 07:09:23 tgl Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* NOTES
|
1997-09-07 07:04:48 +02:00
|
|
|
* This cruft is the server side of PQfn.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* - jolly 07/11/95:
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02: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 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02: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 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02: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 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* OLD COMMENTS FOLLOW
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
1997-09-07 07:04:48 +02:00
|
|
|
* The VAR_LENGTH_{ARGS,RESULT} stuff is limited to MAX_STRING_LENGTH
|
|
|
|
* (see src/backend/tmp/fastpath.h) for no obvious reason. Since its
|
|
|
|
* primary use (for us) is for Inversion path names, it should probably
|
|
|
|
* be increased to 256 (MAXPATHLEN for Inversion, hidden in pg_type
|
|
|
|
* as well as utils/adt/filename.c).
|
|
|
|
*
|
|
|
|
* Quoth PMA on 08/15/93:
|
|
|
|
*
|
|
|
|
* This code has been almost completely rewritten with an eye to
|
|
|
|
* keeping it as compatible as possible with the previous (broken)
|
|
|
|
* implementation.
|
|
|
|
*
|
|
|
|
* The previous implementation would assume (1) that any value of
|
|
|
|
* length <= 4 bytes was passed-by-value, and that any other value
|
|
|
|
* was a struct varlena (by-reference). There was NO way to pass a
|
1998-04-26 06:12:15 +02:00
|
|
|
* fixed-length by-reference argument (like name) or a struct
|
1997-09-07 07:04:48 +02:00
|
|
|
* varlena of size <= 4 bytes.
|
|
|
|
*
|
|
|
|
* The new implementation checks the catalogs to determine whether
|
|
|
|
* a value is by-value (type "0" is null-delimited character string,
|
|
|
|
* as it is for, e.g., the parser). The only other item obtained
|
|
|
|
* from the catalogs is whether or not the value should be placed in
|
|
|
|
* a struct varlena or not. Otherwise, the size given by the
|
|
|
|
* frontend is assumed to be correct (probably a bad decision, but
|
|
|
|
* we do strange things in the name of compatibility).
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1996-11-08 07:02:30 +01:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "postgres.h"
|
|
|
|
|
1999-07-16 05:14:30 +02:00
|
|
|
#include "access/xact.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "catalog/pg_proc.h"
|
|
|
|
#include "catalog/pg_type.h"
|
1999-07-16 07:00:38 +02:00
|
|
|
#include "libpq/libpq.h"
|
|
|
|
#include "libpq/pqformat.h"
|
|
|
|
#include "tcop/fastpath.h"
|
|
|
|
#include "utils/builtins.h"
|
|
|
|
#include "utils/syscache.h"
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* SendFunctionResult
|
1996-07-09 08:22:35 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
static void
|
2000-05-28 19:56:29 +02:00
|
|
|
SendFunctionResult(Datum retval, /* actual return value */
|
1997-09-07 07:04:48 +02:00
|
|
|
bool retbyval,
|
2000-05-28 19:56:29 +02:00
|
|
|
int retlen) /* the length according to the catalogs */
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1999-04-25 05:19:27 +02:00
|
|
|
StringInfoData buf;
|
|
|
|
|
|
|
|
pq_beginmessage(&buf);
|
|
|
|
pq_sendbyte(&buf, 'V');
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
if (retlen != 0)
|
|
|
|
{
|
1999-04-25 05:19:27 +02:00
|
|
|
pq_sendbyte(&buf, 'G');
|
1997-09-07 07:04:48 +02:00
|
|
|
if (retbyval)
|
|
|
|
{ /* by-value */
|
1999-04-25 05:19:27 +02:00
|
|
|
pq_sendint(&buf, retlen, 4);
|
2000-05-28 19:56:29 +02:00
|
|
|
pq_sendint(&buf, DatumGetInt32(retval), retlen);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* by-reference ... */
|
|
|
|
if (retlen < 0)
|
|
|
|
{ /* ... varlena */
|
2000-05-28 19:56:29 +02:00
|
|
|
struct varlena *v = (struct varlena *) DatumGetPointer(retval);
|
|
|
|
|
|
|
|
pq_sendint(&buf, VARSIZE(v) - VARHDRSZ, VARHDRSZ);
|
|
|
|
pq_sendbytes(&buf, VARDATA(v), VARSIZE(v) - VARHDRSZ);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* ... fixed */
|
1999-04-25 05:19:27 +02:00
|
|
|
pq_sendint(&buf, retlen, 4);
|
2000-05-28 19:56:29 +02:00
|
|
|
pq_sendbytes(&buf, DatumGetPointer(retval), retlen);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1999-04-25 05:19:27 +02:00
|
|
|
pq_sendbyte(&buf, '0');
|
|
|
|
pq_endmessage(&buf);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This structure saves enough state so that one can avoid having to
|
1997-09-07 07:04:48 +02:00
|
|
|
* do catalog lookups over and over again. (Each RPC can require up
|
2000-01-10 18:14:46 +01:00
|
|
|
* to FUNC_MAX_ARGS+2 lookups, which is quite tedious.)
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* The previous incarnation of this code just assumed that any argument
|
1997-09-07 07:04:48 +02:00
|
|
|
* of size <= 4 was by value; this is not correct. There is no cheap
|
1996-07-09 08:22:35 +02:00
|
|
|
* way to determine function argument length etc.; one must simply pay
|
|
|
|
* the price of catalog lookups.
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
struct fp_info
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Oid funcid;
|
2000-05-28 19:56:29 +02:00
|
|
|
FmgrInfo flinfo; /* function lookup info for funcid */
|
2000-01-10 18:14:46 +01:00
|
|
|
bool argbyval[FUNC_MAX_ARGS];
|
|
|
|
int32 arglen[FUNC_MAX_ARGS]; /* signed (for varlena) */
|
1997-09-08 04:41:22 +02:00
|
|
|
bool retbyval;
|
|
|
|
int32 retlen; /* signed (for varlena) */
|
2000-05-28 19:56:29 +02:00
|
|
|
TransactionId xid; /* when the lookup was done */
|
1997-09-08 04:41:22 +02:00
|
|
|
CommandId cid;
|
1996-07-09 08:22:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* We implement one-back caching here. If we need to do more, we can.
|
1996-07-09 08:22:35 +02:00
|
|
|
* Most routines in tight loops (like PQfswrite -> F_LOWRITE) will do
|
|
|
|
* the same thing repeatedly.
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
static struct fp_info last_fp = {InvalidOid};
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* valid_fp_info
|
|
|
|
*
|
|
|
|
* RETURNS:
|
2000-05-28 19:56:29 +02:00
|
|
|
* T if the state in 'fip' is valid for the given func OID
|
|
|
|
* F otherwise
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2000-05-28 19:56:29 +02:00
|
|
|
* "invalid" means:
|
1996-07-09 08:22:35 +02:00
|
|
|
* The saved state was either uninitialized, for another function,
|
1997-09-07 07:04:48 +02:00
|
|
|
* or from a previous command. (Commands can do updates, which
|
|
|
|
* may invalidate catalog entries for subsequent commands. This
|
1996-07-09 08:22:35 +02:00
|
|
|
* is overly pessimistic but since there is no smarter invalidation
|
|
|
|
* scheme...).
|
|
|
|
*/
|
2000-05-28 19:56:29 +02:00
|
|
|
static bool
|
1997-09-07 07:04:48 +02:00
|
|
|
valid_fp_info(Oid func_id, struct fp_info * fip)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
Assert(OidIsValid(func_id));
|
|
|
|
Assert(fip != (struct fp_info *) NULL);
|
|
|
|
|
|
|
|
return (OidIsValid(fip->funcid) &&
|
|
|
|
oideq(func_id, fip->funcid) &&
|
|
|
|
TransactionIdIsCurrentTransactionId(fip->xid) &&
|
|
|
|
CommandIdIsCurrentCommandId(fip->cid));
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* update_fp_info
|
|
|
|
*
|
|
|
|
* Performs catalog lookups to load a struct fp_info 'fip' for the
|
|
|
|
* function 'func_id'.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
1997-09-07 07:04:48 +02:00
|
|
|
* The correct information in 'fip'. Sets 'fip->funcid' to
|
|
|
|
* InvalidOid if an exception occurs.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
static void
|
1997-09-07 07:04:48 +02:00
|
|
|
update_fp_info(Oid func_id, struct fp_info * fip)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
2000-01-10 17:13:23 +01:00
|
|
|
Oid *argtypes; /* an oidvector */
|
1997-09-08 04:41:22 +02:00
|
|
|
Oid rettype;
|
|
|
|
HeapTuple func_htp,
|
|
|
|
type_htp;
|
1998-09-01 05:29:17 +02:00
|
|
|
Form_pg_type tp;
|
1997-09-08 04:41:22 +02:00
|
|
|
Form_pg_proc pp;
|
|
|
|
int i;
|
1997-09-07 07:04:48 +02: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 22:07:04 +01:00
|
|
|
* fp_info, since we can be interrupted (i.e., with an elog(ERROR,
|
1997-09-07 07:04:48 +02:00
|
|
|
* ...)) at any time.
|
|
|
|
*/
|
1997-09-18 22:22:58 +02:00
|
|
|
MemSet((char *) fip, 0, (int) sizeof(struct fp_info));
|
1997-09-07 07:04:48 +02:00
|
|
|
fip->funcid = InvalidOid;
|
|
|
|
|
1999-11-22 18:56:41 +01:00
|
|
|
func_htp = SearchSysCacheTuple(PROCOID,
|
1998-08-19 04:04:17 +02:00
|
|
|
ObjectIdGetDatum(func_id),
|
1997-09-07 07:04:48 +02:00
|
|
|
0, 0, 0);
|
|
|
|
if (!HeapTupleIsValid(func_htp))
|
|
|
|
{
|
1999-05-10 02:46:32 +02:00
|
|
|
elog(ERROR, "update_fp_info: cache lookup for function %u failed",
|
1997-09-07 07:04:48 +02:00
|
|
|
func_id);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
pp = (Form_pg_proc) GETSTRUCT(func_htp);
|
|
|
|
rettype = pp->prorettype;
|
|
|
|
argtypes = pp->proargtypes;
|
|
|
|
|
2000-05-30 09:09:23 +02:00
|
|
|
fmgr_info(func_id, &fip->flinfo);
|
|
|
|
|
2000-05-28 19:56:29 +02:00
|
|
|
for (i = 0; i < fip->flinfo.fn_nargs; ++i)
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
|
|
|
if (OidIsValid(argtypes[i]))
|
|
|
|
{
|
1999-11-22 18:56:41 +01:00
|
|
|
type_htp = SearchSysCacheTuple(TYPEOID,
|
1997-09-07 07:04:48 +02:00
|
|
|
ObjectIdGetDatum(argtypes[i]),
|
|
|
|
0, 0, 0);
|
|
|
|
if (!HeapTupleIsValid(type_htp))
|
|
|
|
{
|
1999-05-10 02:46:32 +02:00
|
|
|
elog(ERROR, "update_fp_info: bad argument type %u for %u",
|
1997-09-07 07:04:48 +02:00
|
|
|
argtypes[i], func_id);
|
|
|
|
}
|
1998-09-01 05:29:17 +02:00
|
|
|
tp = (Form_pg_type) GETSTRUCT(type_htp);
|
1997-09-07 07:04:48 +02:00
|
|
|
fip->argbyval[i] = tp->typbyval;
|
|
|
|
fip->arglen[i] = tp->typlen;
|
|
|
|
} /* else it had better be VAR_LENGTH_ARG */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OidIsValid(rettype))
|
|
|
|
{
|
1999-11-22 18:56:41 +01:00
|
|
|
type_htp = SearchSysCacheTuple(TYPEOID,
|
1998-08-19 04:04:17 +02:00
|
|
|
ObjectIdGetDatum(rettype),
|
1997-09-07 07:04:48 +02:00
|
|
|
0, 0, 0);
|
|
|
|
if (!HeapTupleIsValid(type_htp))
|
|
|
|
{
|
1999-05-10 02:46:32 +02:00
|
|
|
elog(ERROR, "update_fp_info: bad return type %u for %u",
|
1997-09-07 07:04:48 +02:00
|
|
|
rettype, func_id);
|
|
|
|
}
|
1998-09-01 05:29:17 +02:00
|
|
|
tp = (Form_pg_type) GETSTRUCT(type_htp);
|
1997-09-07 07:04:48 +02:00
|
|
|
fip->retbyval = tp->typbyval;
|
|
|
|
fip->retlen = tp->typlen;
|
|
|
|
} /* else it had better by VAR_LENGTH_RESULT */
|
|
|
|
|
|
|
|
fip->xid = GetCurrentTransactionId();
|
|
|
|
fip->cid = GetCurrentCommandId();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This must be last!
|
|
|
|
*/
|
|
|
|
fip->funcid = func_id;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* HandleFunctionRequest
|
|
|
|
*
|
|
|
|
* Server side of PQfn (fastpath function calls from the frontend).
|
|
|
|
* This corresponds to the libpq protocol symbol "F".
|
|
|
|
*
|
|
|
|
* RETURNS:
|
1999-07-22 04:40:07 +02: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...
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
HandleFunctionRequest()
|
|
|
|
{
|
1997-09-08 04:41:22 +02:00
|
|
|
Oid fid;
|
|
|
|
int argsize;
|
|
|
|
int nargs;
|
1999-04-25 05:19:27 +02:00
|
|
|
int tmp;
|
2000-05-28 19:56:29 +02:00
|
|
|
FunctionCallInfoData fcinfo;
|
|
|
|
Datum retval;
|
1997-09-08 04:41:22 +02:00
|
|
|
int i;
|
|
|
|
char *p;
|
1997-09-07 07:04:48 +02:00
|
|
|
struct fp_info *fip;
|
|
|
|
|
1999-07-22 04:40:07 +02:00
|
|
|
if (pq_getint(&tmp, 4)) /* function oid */
|
|
|
|
return EOF;
|
1999-04-25 05:19:27 +02:00
|
|
|
fid = (Oid) tmp;
|
1999-07-22 04:40:07 +02:00
|
|
|
if (pq_getint(&nargs, 4)) /* # of arguments */
|
|
|
|
return EOF;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is where the one-back caching is done. If you want to save
|
|
|
|
* more state, make this a loop around an array.
|
|
|
|
*/
|
|
|
|
fip = &last_fp;
|
|
|
|
if (!valid_fp_info(fid, fip))
|
|
|
|
update_fp_info(fid, fip);
|
|
|
|
|
1999-07-22 04:40:07 +02:00
|
|
|
/*
|
2000-04-12 19:17:23 +02:00
|
|
|
* XXX FIXME: elog() here means we lose sync with the frontend, since
|
|
|
|
* we have not swallowed all of its input message. What should happen
|
|
|
|
* is we absorb all of the input message per protocol syntax, and
|
2000-05-28 19:56:29 +02:00
|
|
|
* *then* do error checking (including lookup of the given function ID)
|
|
|
|
* and elog if appropriate. Unfortunately, because we cannot even read
|
|
|
|
* the message properly without knowing whether the data types are
|
|
|
|
* pass-by-ref or pass-by-value, it's not all that easy to fix :-(.
|
|
|
|
* This protocol is misdesigned.
|
1999-07-22 04:40:07 +02:00
|
|
|
*/
|
|
|
|
|
2000-05-28 19:56:29 +02:00
|
|
|
if (fip->flinfo.fn_nargs != nargs || nargs > FUNC_MAX_ARGS)
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
1998-01-07 22:07:04 +01:00
|
|
|
elog(ERROR, "HandleFunctionRequest: actual arguments (%d) != registered arguments (%d)",
|
2000-05-28 19:56:29 +02:00
|
|
|
nargs, fip->flinfo.fn_nargs);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
|
|
|
|
2000-05-28 19:56:29 +02:00
|
|
|
MemSet(&fcinfo, 0, sizeof(fcinfo));
|
|
|
|
fcinfo.flinfo = &fip->flinfo;
|
|
|
|
fcinfo.nargs = nargs;
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
2000-05-28 19:56:29 +02:00
|
|
|
* Copy supplied arguments into arg vector. Note there is no way for
|
|
|
|
* frontend to specify a NULL argument --- more misdesign.
|
1997-09-07 07:04:48 +02:00
|
|
|
*/
|
2000-05-28 19:56:29 +02:00
|
|
|
for (i = 0; i < nargs; ++i)
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
2000-05-28 19:56:29 +02:00
|
|
|
if (pq_getint(&argsize, 4))
|
|
|
|
return EOF;
|
|
|
|
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] ? */
|
|
|
|
if (pq_getint(&tmp, argsize))
|
1999-07-22 04:40:07 +02:00
|
|
|
return EOF;
|
2000-05-28 19:56:29 +02:00
|
|
|
fcinfo.arg[i] = (Datum) tmp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* by-reference ... */
|
|
|
|
if (fip->arglen[i] < 0)
|
|
|
|
{ /* ... varlena */
|
|
|
|
if (argsize < 0)
|
|
|
|
elog(ERROR, "HandleFunctionRequest: bogus argsize %d",
|
|
|
|
argsize);
|
|
|
|
/* I suspect this +1 isn't really needed - tgl 5/2000 */
|
|
|
|
p = palloc(argsize + VARHDRSZ + 1); /* Added +1 to solve
|
|
|
|
* memory leak - Peter
|
|
|
|
* 98 Jan 6 */
|
|
|
|
VARSIZE(p) = argsize + VARHDRSZ;
|
|
|
|
if (pq_getbytes(VARDATA(p), argsize))
|
1999-07-22 04:40:07 +02:00
|
|
|
return EOF;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
else
|
2000-05-28 19:56:29 +02:00
|
|
|
{ /* ... fixed */
|
|
|
|
if (argsize != fip->arglen[i])
|
|
|
|
elog(ERROR, "HandleFunctionRequest: bogus argsize %d, should be %d",
|
|
|
|
argsize, fip->arglen[i]);
|
|
|
|
p = palloc(argsize + 1); /* +1 in case argsize is 0 */
|
|
|
|
if (pq_getbytes(p, argsize))
|
|
|
|
return EOF;
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
2000-05-28 19:56:29 +02:00
|
|
|
fcinfo.arg[i] = PointerGetDatum(p);
|
1997-09-07 07:04:48 +02:00
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
2000-05-28 19:56:29 +02:00
|
|
|
#ifdef NO_FASTPATH
|
|
|
|
/* force a NULL return */
|
|
|
|
retval = (Datum) 0;
|
|
|
|
fcinfo.isnull = true;
|
1996-07-09 08:22:35 +02:00
|
|
|
#else
|
2000-05-28 19:56:29 +02:00
|
|
|
retval = FunctionCallInvoke(&fcinfo);
|
1998-09-01 06:40:42 +02:00
|
|
|
#endif /* NO_FASTPATH */
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2000-05-28 19:56:29 +02:00
|
|
|
if (fcinfo.isnull)
|
|
|
|
SendFunctionResult(retval, fip->retbyval, 0);
|
|
|
|
else
|
|
|
|
SendFunctionResult(retval, fip->retbyval, fip->retlen);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-01 05:29:17 +02:00
|
|
|
return 0;
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|