From 1ab9b012bdf1f106792fc523e21b9ca8299bb8ed Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 22 Feb 2011 13:08:22 -0500 Subject: 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 --- src/backend/utils/adt/pseudotypes.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/backend') diff --git a/src/backend/utils/adt/pseudotypes.c b/src/backend/utils/adt/pseudotypes.c index d9329f83428..ddb1bd2b71c 100644 --- a/src/backend/utils/adt/pseudotypes.c +++ b/src/backend/utils/adt/pseudotypes.c @@ -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. -- cgit v1.2.3