Skip to content

Commit 1ab9b01

Browse files
committed
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
1 parent edb3821 commit 1ab9b01

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

src/backend/utils/adt/pseudotypes.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,34 @@ void_out(PG_FUNCTION_ARGS)
212212
PG_RETURN_CSTRING(pstrdup(""));
213213
}
214214

215+
/*
216+
* void_recv - binary input routine for pseudo-type VOID.
217+
*
218+
* Note that since we consume no bytes, an attempt to send anything but
219+
* an empty string will result in an "invalid message format" error.
220+
*/
221+
Datum
222+
void_recv(PG_FUNCTION_ARGS)
223+
{
224+
PG_RETURN_VOID();
225+
}
226+
227+
/*
228+
* void_send - binary output routine for pseudo-type VOID.
229+
*
230+
* We allow this so that "SELECT function_returning_void(...)" works
231+
* even when binary output is requested.
232+
*/
233+
Datum
234+
void_send(PG_FUNCTION_ARGS)
235+
{
236+
StringInfoData buf;
237+
238+
/* send an empty string */
239+
pq_begintypsend(&buf);
240+
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
241+
}
242+
215243

216244
/*
217245
* trigger_in - input routine for pseudo-type TRIGGER.

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201102191
56+
#define CATALOG_VERSION_NO 201102221
5757

5858
#endif

src/include/catalog/pg_proc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4226,6 +4226,10 @@ DATA(insert OID = 2502 ( anyarray_recv PGNSP PGUID 12 1 0 0 f f f t f s 1 0
42264226
DESCR("I/O");
42274227
DATA(insert OID = 2503 ( anyarray_send PGNSP PGUID 12 1 0 0 f f f t f s 1 0 17 "2277" _null_ _null_ _null_ _null_ anyarray_send _null_ _null_ _null_ ));
42284228
DESCR("I/O");
4229+
DATA(insert OID = 3120 ( void_recv PGNSP PGUID 12 1 0 0 f f f t f i 1 0 2278 "2281" _null_ _null_ _null_ _null_ void_recv _null_ _null_ _null_ ));
4230+
DESCR("I/O");
4231+
DATA(insert OID = 3121 ( void_send PGNSP PGUID 12 1 0 0 f f f t f i 1 0 17 "2278" _null_ _null_ _null_ _null_ void_send _null_ _null_ _null_ ));
4232+
DESCR("I/O");
42294233

42304234
/* System-view support functions with pretty-print option */
42314235
DATA(insert OID = 2504 ( pg_get_ruledef PGNSP PGUID 12 1 0 0 f f f t f s 2 0 25 "26 16" _null_ _null_ _null_ _null_ pg_get_ruledef_ext _null_ _null_ _null_ ));

src/include/catalog/pg_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ DATA(insert OID = 2276 ( any PGNSP PGUID 4 t p P f t \054 0 0 0 any_in any_ou
615615
#define ANYOID 2276
616616
DATA(insert OID = 2277 ( anyarray PGNSP PGUID -1 f p P f t \054 0 0 0 anyarray_in anyarray_out anyarray_recv anyarray_send - - - d x f 0 -1 0 0 _null_ _null_ ));
617617
#define ANYARRAYOID 2277
618-
DATA(insert OID = 2278 ( void PGNSP PGUID 4 t p P f t \054 0 0 0 void_in void_out - - - - - i p f 0 -1 0 0 _null_ _null_ ));
618+
DATA(insert OID = 2278 ( void PGNSP PGUID 4 t p P f t \054 0 0 0 void_in void_out void_recv void_send - - - i p f 0 -1 0 0 _null_ _null_ ));
619619
#define VOIDOID 2278
620620
DATA(insert OID = 2279 ( trigger PGNSP PGUID 4 t p P f t \054 0 0 0 trigger_in trigger_out - - - - - i p f 0 -1 0 0 _null_ _null_ ));
621621
#define TRIGGEROID 2279

src/include/utils/builtins.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,8 @@ extern Datum anyenum_in(PG_FUNCTION_ARGS);
504504
extern Datum anyenum_out(PG_FUNCTION_ARGS);
505505
extern Datum void_in(PG_FUNCTION_ARGS);
506506
extern Datum void_out(PG_FUNCTION_ARGS);
507+
extern Datum void_recv(PG_FUNCTION_ARGS);
508+
extern Datum void_send(PG_FUNCTION_ARGS);
507509
extern Datum trigger_in(PG_FUNCTION_ARGS);
508510
extern Datum trigger_out(PG_FUNCTION_ARGS);
509511
extern Datum language_handler_in(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy