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

Commitad1425a

Browse files
committed
Add send and recv functions for xml type.
1 parentd9e1c97 commitad1425a

File tree

5 files changed

+58
-9
lines changed

5 files changed

+58
-9
lines changed

‎src/backend/utils/adt/xml.c

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.6 2006/12/2803:17:38 petere Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.7 2006/12/2814:28:36 petere Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -34,6 +34,7 @@
3434
#endif/* USE_LIBXML */
3535

3636
#include"fmgr.h"
37+
#include"libpq/pqformat.h"
3738
#include"mb/pg_wchar.h"
3839
#include"nodes/execnodes.h"
3940
#include"utils/builtins.h"
@@ -83,8 +84,7 @@ xml_in(PG_FUNCTION_ARGS)
8384

8485
/*
8586
* Parse the data to check if it is well-formed XML data. Assume
86-
* that ERROR occurred if parsing failed. Do we need DTD
87-
* validation (if DTD exists)?
87+
* that ERROR occurred if parsing failed.
8888
*/
8989
xml_parse(vardata, false, true);
9090

@@ -112,6 +112,48 @@ xml_out(PG_FUNCTION_ARGS)
112112
}
113113

114114

115+
Datum
116+
xml_recv(PG_FUNCTION_ARGS)
117+
{
118+
#ifdefUSE_LIBXML
119+
StringInfobuf= (StringInfo)PG_GETARG_POINTER(0);
120+
xmltype*result;
121+
char*str;
122+
intnbytes;
123+
124+
str=pq_getmsgtext(buf,buf->len-buf->cursor,&nbytes);
125+
126+
result= (xmltype*)palloc(nbytes+VARHDRSZ);
127+
VARATT_SIZEP(result)=nbytes+VARHDRSZ;
128+
memcpy(VARDATA(result),str,nbytes);
129+
pfree(str);
130+
131+
/*
132+
* Parse the data to check if it is well-formed XML data. Assume
133+
* that ERROR occurred if parsing failed.
134+
*/
135+
xml_parse(result, false, true);
136+
137+
PG_RETURN_XML_P(result);
138+
#else
139+
NO_XML_SUPPORT();
140+
return0;
141+
#endif
142+
}
143+
144+
145+
Datum
146+
xml_send(PG_FUNCTION_ARGS)
147+
{
148+
xmltype*x=PG_GETARG_XML_P(0);
149+
StringInfoDatabuf;
150+
151+
pq_begintypsend(&buf);
152+
pq_sendbytes(&buf,VARDATA(x),VARSIZE(x)-VARHDRSZ);
153+
PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
154+
}
155+
156+
115157
#ifdefUSE_LIBXML
116158
staticvoid
117159
appendStringInfoText(StringInfostr,consttext*t)

‎src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.366 2006/12/24 00:29:19 tgl Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.367 2006/12/28 14:28:36 petere Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200612231
56+
#defineCATALOG_VERSION_NO200612281
5757

5858
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.432 2006/12/24 00:29:19 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.433 2006/12/28 14:28:36 petere Exp $
1111
*
1212
* NOTES
1313
* The script catalog/genbki.sh reads this file and generates .bki
@@ -3987,6 +3987,11 @@ DATA(insert OID = 2896 ( xml PGNSP PGUID 12 f f t f i 1 142 "25" _null_ _n
39873987
DESCR("perform a non-validating parse of a character string to produce an XML value");
39883988
DATA(insertOID=2897 (xmlvalidatePGNSPPGUID12fftfi216"142 25"_null__null__null_xmlvalidate-_null_ ));
39893989
DESCR("validate an XML value");
3990+
DATA(insertOID=2898 (xml_recvPGNSPPGUID12fftfs1142"2281"_null__null__null_xml_recv-_null_ ));
3991+
DESCR("I/O");
3992+
DATA(insertOID=2899 (xml_sendPGNSPPGUID12fftfs117"142"_null__null__null_xml_send-_null_ ));
3993+
DESCR("I/O");
3994+
39903995

39913996
/*
39923997
* Symbolic values for provolatile column: these indicate whether the result

‎src/include/catalog/pg_type.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.174 2006/12/2801:09:01 tgl Exp $
11+
* $PostgreSQL: pgsql/src/include/catalog/pg_type.h,v 1.175 2006/12/2814:28:36 petere Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -316,7 +316,7 @@ DATA(insert OID = 83 (pg_classPGNSP PGUID -1 f c t \054 1259 0 record_in reco
316316
#definePG_CLASS_RELTYPE_OID 83
317317

318318
/* OIDS 100 - 199 */
319-
DATA(insertOID=142 (xmlPGNSPPGUID-1fbt \05400xml_inxml_out---ixf0-10_null__null_ ));
319+
DATA(insertOID=142 (xmlPGNSPPGUID-1fbt \05400xml_inxml_outxml_recvxml_send-ixf0-10_null__null_ ));
320320
DESCR("XML content");
321321
#defineXMLOID 142
322322
DATA(insertOID=143 (_xmlPGNSPPGUID-1fbt \0540142array_inarray_outarray_recvarray_send-ixf0-10_null__null_ ));

‎src/include/utils/xml.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.3 2006/12/24 00:29:20 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/xml.h,v 1.4 2006/12/28 14:28:36 petere Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -26,6 +26,8 @@ typedef struct varlena xmltype;
2626

2727
externDatumxml_in(PG_FUNCTION_ARGS);
2828
externDatumxml_out(PG_FUNCTION_ARGS);
29+
externDatumxml_recv(PG_FUNCTION_ARGS);
30+
externDatumxml_send(PG_FUNCTION_ARGS);
2931
externDatumxmlcomment(PG_FUNCTION_ARGS);
3032
externDatumtexttoxml(PG_FUNCTION_ARGS);
3133
externDatumxmlvalidate(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp