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

Commitba1e066

Browse files
committed
Implement array_send/array_recv (binary I/O for arrays). This exposed
the folly of not passing element type to typsend/typreceive, so fix that.
1 parentb1ee615 commitba1e066

File tree

7 files changed

+316
-35
lines changed

7 files changed

+316
-35
lines changed

‎doc/src/sgml/ref/create_type.sgml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v 1.42 2003/05/08 22:19:56 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v 1.43 2003/05/09 23:01:44 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -117,15 +117,20 @@ CREATE TYPE <replaceable class="parameter">typename</replaceable> (
117117
representation is in the machine's native byte order.) The receive
118118
function should perform adequate checking to ensure that the value is
119119
valid.
120-
The receive function should be declared as taking one argument of type
121-
<type>internal</type> and returning a value of the data type itself.
122-
(The argument actually supplied is a pointer to a StringInfo buffer
123-
holding the received byte string.) Similarly, the optional
120+
The receive function may be declared as taking one argument of type
121+
<type>internal</type>, or two arguments of types <type>internal</type>
122+
and <type>oid</type>. It must return a value of the data type itself.
123+
(The first argument is a pointer to a StringInfo buffer
124+
holding the received byte string; the optional second argument is the
125+
element type in case this is an array type.) Similarly, the optional
124126
<replaceable class="parameter">send_function</replaceable> converts
125127
from the internal representation to the external binary representation.
126128
If this function is not supplied, the type cannot participate in binary
127-
output. The send function should be declared as taking one argument of the
128-
new data type and returning type <type>bytea</type>.
129+
output. The send function may be
130+
declared as taking one argument of the new data type, or as taking
131+
two arguments of which the second is type <type>oid</type>.
132+
The second argument is again the array element type for array types.
133+
The send function must return type <type>bytea</type>.
129134
</para>
130135

131136
<para>

‎src/backend/commands/typecmds.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.35 2003/05/08 22:19:56 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.36 2003/05/09 23:01:45 tgl Exp $
1212
*
1313
* DESCRIPTION
1414
* The "DefineFoo" routines take the parse tree and pick out the
@@ -911,7 +911,8 @@ findTypeReceiveFunction(List *procname, Oid typeOid)
911911
OidprocOid;
912912

913913
/*
914-
* Receive functions take a single argument of type INTERNAL.
914+
* Receive functions can take a single argument of type INTERNAL, or
915+
* two arguments (internal, oid).
915916
*/
916917
MemSet(argList,0,FUNC_MAX_ARGS*sizeof(Oid));
917918

@@ -921,6 +922,12 @@ findTypeReceiveFunction(List *procname, Oid typeOid)
921922
if (OidIsValid(procOid))
922923
returnprocOid;
923924

925+
argList[1]=OIDOID;
926+
927+
procOid=LookupFuncName(procname,2,argList);
928+
if (OidIsValid(procOid))
929+
returnprocOid;
930+
924931
func_error("TypeCreate",procname,1,argList,NULL);
925932

926933
returnInvalidOid;/* keep compiler quiet */
@@ -933,7 +940,8 @@ findTypeSendFunction(List *procname, Oid typeOid)
933940
OidprocOid;
934941

935942
/*
936-
* Send functions take a single argument of the type.
943+
* Send functions can take a single argument of the type, or two
944+
* arguments (data value, element OID).
937945
*/
938946
MemSet(argList,0,FUNC_MAX_ARGS*sizeof(Oid));
939947

@@ -943,6 +951,12 @@ findTypeSendFunction(List *procname, Oid typeOid)
943951
if (OidIsValid(procOid))
944952
returnprocOid;
945953

954+
argList[1]=OIDOID;
955+
956+
procOid=LookupFuncName(procname,2,argList);
957+
if (OidIsValid(procOid))
958+
returnprocOid;
959+
946960
func_error("TypeCreate",procname,1,argList,NULL);
947961

948962
returnInvalidOid;/* keep compiler quiet */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp