1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Allow binary I/O of type "void".

void_send is useful for the same reason that void_out doesn't throw error,
namely that someone might do "select void_returning_func(...)"  from a
client that prefers to operate in binary mode.  The void_recv function may
or may not have any practical use, but we provide it for symmetry.

Radosław Smogura
This commit is contained in:
Tom Lane
2011-02-22 13:08:22 -05:00
parent edb382179d
commit 1ab9b012bd
5 changed files with 36 additions and 2 deletions

View File

@ -212,6 +212,34 @@ void_out(PG_FUNCTION_ARGS)
PG_RETURN_CSTRING(pstrdup(""));
}
/*
* void_recv - binary input routine for pseudo-type VOID.
*
* Note that since we consume no bytes, an attempt to send anything but
* an empty string will result in an "invalid message format" error.
*/
Datum
void_recv(PG_FUNCTION_ARGS)
{
PG_RETURN_VOID();
}
/*
* void_send - binary output routine for pseudo-type VOID.
*
* We allow this so that "SELECT function_returning_void(...)" works
* even when binary output is requested.
*/
Datum
void_send(PG_FUNCTION_ARGS)
{
StringInfoData buf;
/* send an empty string */
pq_begintypsend(&buf);
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
}
/*
* trigger_in - input routine for pseudo-type TRIGGER.