summaryrefslogtreecommitdiff
path: root/src/backend/tcop/fastpath.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/tcop/fastpath.c')
-rw-r--r--src/backend/tcop/fastpath.c165
1 files changed, 2 insertions, 163 deletions
diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c
index 1b76653caa4..77d17ebca94 100644
--- a/src/backend/tcop/fastpath.c
+++ b/src/backend/tcop/fastpath.c
@@ -58,98 +58,24 @@ struct fp_info
static int16 parse_fcall_arguments(StringInfo msgBuf, struct fp_info *fip,
FunctionCallInfo fcinfo);
-static int16 parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info *fip,
- FunctionCallInfo fcinfo);
-
-
-/* ----------------
- * 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.
- * ----------------
- */
-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 = pg_ntoh32(ibuf);
- /* For each argument ... */
- while (nargs-- > 0)
- {
- int argsize;
-
- /* argsize */
- if (pq_getbytes((char *) &ibuf, 4))
- return EOF;
- appendBinaryStringInfo(buf, (char *) &ibuf, 4);
- argsize = pg_ntoh32(ibuf);
- if (argsize < -1)
- {
- /* FATAL here since no hope of regaining message sync */
- ereport(FATAL,
- (errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid argument size %d in function call message",
- 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;
-}
/* ----------------
* SendFunctionResult
- *
- * Note: although this routine doesn't check, the format had better be 1
- * (binary) when talking to a pre-3.0 client.
* ----------------
*/
static void
SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format)
{
- bool newstyle = (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3);
StringInfoData buf;
pq_beginmessage(&buf, 'V');
if (isnull)
{
- if (newstyle)
- pq_sendint32(&buf, -1);
+ pq_sendint32(&buf, -1);
}
else
{
- if (!newstyle)
- pq_sendbyte(&buf, 'G');
-
if (format == 0)
{
Oid typoutput;
@@ -180,9 +106,6 @@ SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format)
errmsg("unsupported format code: %d", format)));
}
- if (!newstyle)
- pq_sendbyte(&buf, '0');
-
pq_endmessage(&buf);
}
@@ -288,9 +211,6 @@ HandleFunctionRequest(StringInfo msgBuf)
/*
* Begin parsing the buffer contents.
*/
- if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
- (void) pq_getmsgstring(msgBuf); /* dummy string */
-
fid = (Oid) pq_getmsgint(msgBuf, 4); /* function oid */
/*
@@ -334,10 +254,7 @@ HandleFunctionRequest(StringInfo msgBuf)
*/
InitFunctionCallInfoData(*fcinfo, &fip->flinfo, 0, InvalidOid, NULL, NULL);
- if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3)
- rformat = parse_fcall_arguments(msgBuf, fip, fcinfo);
- else
- rformat = parse_fcall_arguments_20(msgBuf, fip, fcinfo);
+ rformat = parse_fcall_arguments(msgBuf, fip, fcinfo);
/* Verify we reached the end of the message where expected. */
pq_getmsgend(msgBuf);
@@ -533,81 +450,3 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info *fip,
/* Return result format code */
return (int16) pq_getmsgint(msgBuf, 2);
}
-
-/*
- * Parse function arguments in a 2.0 protocol message
- *
- * Argument values are loaded into *fcinfo, and the desired result format
- * is returned.
- */
-static int16
-parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info *fip,
- FunctionCallInfo fcinfo)
-{
- int nargs;
- int i;
- StringInfoData abuf;
-
- nargs = pq_getmsgint(msgBuf, 4); /* # of arguments */
-
- if (fip->flinfo.fn_nargs != nargs || nargs > FUNC_MAX_ARGS)
- ereport(ERROR,
- (errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("function call message contains %d arguments but function requires %d",
- nargs, fip->flinfo.fn_nargs)));
-
- fcinfo->nargs = nargs;
-
- initStringInfo(&abuf);
-
- /*
- * Copy supplied arguments into arg vector. In protocol 2.0 these are
- * always assumed to be supplied in binary format.
- *
- * Note: although the original protocol 2.0 code did not have any way for
- * the frontend to specify a NULL argument, we now choose to interpret
- * length == -1 as meaning a NULL.
- */
- for (i = 0; i < nargs; ++i)
- {
- int argsize;
- Oid typreceive;
- Oid typioparam;
-
- getTypeBinaryInputInfo(fip->argtypes[i], &typreceive, &typioparam);
-
- argsize = pq_getmsgint(msgBuf, 4);
- if (argsize == -1)
- {
- fcinfo->args[i].isnull = true;
- fcinfo->args[i].value = OidReceiveFunctionCall(typreceive, NULL,
- typioparam, -1);
- continue;
- }
- fcinfo->args[i].isnull = false;
- if (argsize < 0)
- ereport(ERROR,
- (errcode(ERRCODE_PROTOCOL_VIOLATION),
- errmsg("invalid argument size %d in function call message",
- argsize)));
-
- /* Reset abuf to empty, and insert raw data into it */
- resetStringInfo(&abuf);
- appendBinaryStringInfo(&abuf,
- pq_getmsgbytes(msgBuf, argsize),
- argsize);
-
- fcinfo->args[i].value = OidReceiveFunctionCall(typreceive, &abuf,
- typioparam, -1);
-
- /* Trouble if it didn't eat the whole buffer */
- if (abuf.cursor != abuf.len)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
- errmsg("incorrect binary data format in function argument %d",
- i + 1)));
- }
-
- /* Desired result format is always binary in protocol 2.0 */
- return 1;
-}