Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1ab9b01

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 aclient that prefers to operate in binary mode. The void_recv function mayor may not have any practical use, but we provide it for symmetry.Radosław Smogura
1 parentedb3821 commit1ab9b01

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+
StringInfoDatabuf;
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-
#defineCATALOG_VERSION_NO201102191
56+
#defineCATALOG_VERSION_NO201102221
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(insertOID=2503 (anyarray_sendPGNSPPGUID12100ffftfs1017"2277"_null__null__null__null_anyarray_send_null__null__null_ ));
42284228
DESCR("I/O");
4229+
DATA(insertOID=3120 (void_recvPGNSPPGUID12100ffftfi102278"2281"_null__null__null__null_void_recv_null__null__null_ ));
4230+
DESCR("I/O");
4231+
DATA(insertOID=3121 (void_sendPGNSPPGUID12100ffftfi1017"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(insertOID=2504 (pg_get_ruledefPGNSPPGUID12100ffftfs2025"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 ( anyPGNSP PGUID 4 t p P f t \054 0 0 0 any_in any_ou
615615
#defineANYOID2276
616616
DATA(insertOID=2277 (anyarrayPGNSPPGUID-1fpPft \054000anyarray_inanyarray_outanyarray_recvanyarray_send---dxf0-100_null__null_ ));
617617
#defineANYARRAYOID2277
618-
DATA(insertOID=2278 (voidPGNSPPGUID4tpPft \054000void_invoid_out-----ipf0-100_null__null_ ));
618+
DATA(insertOID=2278 (voidPGNSPPGUID4tpPft \054000void_invoid_outvoid_recvvoid_send---ipf0-100_null__null_ ));
619619
#defineVOIDOID2278
620620
DATA(insertOID=2279 (triggerPGNSPPGUID4tpPft \054000trigger_intrigger_out-----ipf0-100_null__null_ ));
621621
#defineTRIGGEROID2279

‎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
externDatumanyenum_out(PG_FUNCTION_ARGS);
505505
externDatumvoid_in(PG_FUNCTION_ARGS);
506506
externDatumvoid_out(PG_FUNCTION_ARGS);
507+
externDatumvoid_recv(PG_FUNCTION_ARGS);
508+
externDatumvoid_send(PG_FUNCTION_ARGS);
507509
externDatumtrigger_in(PG_FUNCTION_ARGS);
508510
externDatumtrigger_out(PG_FUNCTION_ARGS);
509511
externDatumlanguage_handler_in(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp