Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7888b52

Browse files
committed
Make casts from xml to text independent of the XML option setting, thus
immutable and indexable. Also fix the volatility settings of some other XML-related functions.
1 parent 542d04e commit 7888b52

File tree

6 files changed

+24
-13
lines changed

6 files changed

+24
-13
lines changed

src/backend/utils/adt/xml.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, 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.60 2007/11/25 12:08:11 petere Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.61 2007/11/27 12:21:05 petere Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -535,7 +535,8 @@ xmltotext(PG_FUNCTION_ARGS)
535535
{
536536
xmltype *data = PG_GETARG_XML_P(0);
537537

538-
PG_RETURN_TEXT_P(xmltotext_with_xmloption(data, xmloption));
538+
/* It's actually binary compatible. */
539+
return (text *) data;
539540
}
540541

541542

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-2007, 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.437 2007/10/24 02:24:47 tgl Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.438 2007/11/27 12:21:05 petere Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 200710232
56+
#define CATALOG_VERSION_NO 200711271
5757

5858
#endif

src/include/catalog/pg_cast.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* Copyright (c) 2002-2007, PostgreSQL Global Development Group
1212
*
13-
* $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.36 2007/11/15 21:14:42 momjian Exp $
13+
* $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.37 2007/11/27 12:21:05 petere Exp $
1414
*
1515
* NOTES
1616
* the genbki.sh script reads this file and generates .bki
@@ -292,7 +292,7 @@ DATA(insert ( 1560 23 1684 e ));
292292
DATA(insert ( 650 25 730 a ));
293293
DATA(insert ( 869 25 730 a ));
294294
DATA(insert ( 16 25 2971 a ));
295-
DATA(insert ( 142 25 2922 a ));
295+
DATA(insert ( 142 25 0 a ));
296296
DATA(insert ( 25 142 2896 e ));
297297

298298
/*
@@ -303,7 +303,7 @@ DATA(insert ( 25 142 2896 e ));
303303
DATA(insert ( 650 1043 730 a ));
304304
DATA(insert ( 869 1043 730 a ));
305305
DATA(insert ( 16 1043 2971 a ));
306-
DATA(insert ( 142 1043 2922 a ));
306+
DATA(insert ( 142 1043 0 a ));
307307
DATA(insert ( 1043 142 2896 e ));
308308

309309
/*
@@ -314,7 +314,7 @@ DATA(insert ( 1043 142 2896 e ));
314314
DATA(insert ( 650 1042 730 a ));
315315
DATA(insert ( 869 1042 730 a ));
316316
DATA(insert ( 16 1042 2971 a ));
317-
DATA(insert ( 142 1042 2922 a ));
317+
DATA(insert ( 142 1042 0 a ));
318318
DATA(insert ( 1042 142 2896 e ));
319319

320320
/*

src/include/catalog/pg_proc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, 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.478 2007/11/15 21:14:43 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.479 2007/11/27 12:21:05 petere Exp $
1111
*
1212
* NOTES
1313
* The script catalog/genbki.sh reads this file and generates .bki
@@ -4028,13 +4028,13 @@ DATA(insert OID = 2892 ( pg_advisory_unlock_all PGNSP PGUID 12 1 0 f f t f v 0
40284028
DESCR("release all advisory locks");
40294029

40304030
/* XML support */
4031-
DATA(insert OID = 2893 ( xml_in PGNSP PGUID 12 1 0 f f t f i 1 142 "2275" _null_ _null_ _null_ xml_in - _null_ _null_ ));
4031+
DATA(insert OID = 2893 ( xml_in PGNSP PGUID 12 1 0 f f t f s 1 142 "2275" _null_ _null_ _null_ xml_in - _null_ _null_ ));
40324032
DESCR("I/O");
40334033
DATA(insert OID = 2894 ( xml_out PGNSP PGUID 12 1 0 f f t f i 1 2275 "142" _null_ _null_ _null_ xml_out - _null_ _null_ ));
40344034
DESCR("I/O");
40354035
DATA(insert OID = 2895 ( xmlcomment PGNSP PGUID 12 1 0 f f t f i 1 142 "25" _null_ _null_ _null_ xmlcomment - _null_ _null_ ));
40364036
DESCR("generate an XML comment");
4037-
DATA(insert OID = 2896 ( xml PGNSP PGUID 12 1 0 f f t f i 1 142 "25" _null_ _null_ _null_ texttoxml - _null_ _null_ ));
4037+
DATA(insert OID = 2896 ( xml PGNSP PGUID 12 1 0 f f t f s 1 142 "25" _null_ _null_ _null_ texttoxml - _null_ _null_ ));
40384038
DESCR("perform a non-validating parse of a character string to produce an XML value");
40394039
DATA(insert OID = 2897 ( xmlvalidate PGNSP PGUID 12 1 0 f f t f i 2 16 "142 25" _null_ _null_ _null_ xmlvalidate - _null_ _null_ ));
40404040
DESCR("validate an XML value");
@@ -4046,7 +4046,7 @@ DATA(insert OID = 2900 ( xmlconcat2 PGNSP PGUID 12 1 0 f f f f i 2 142 "142
40464046
DESCR("aggregate transition function");
40474047
DATA(insert OID = 2901 ( xmlagg PGNSP PGUID 12 1 0 t f f f i 1 142 "142" _null_ _null_ _null_ aggregate_dummy - _null_ _null_ ));
40484048
DESCR("concatenate XML values");
4049-
DATA(insert OID = 2922 ( text PGNSP PGUID 12 1 0 f f t f s 1 25 "142" _null_ _null_ _null_ xmltotext - _null_ _null_ ));
4049+
DATA(insert OID = 2922 ( text PGNSP PGUID 12 1 0 f f t f i 1 25 "142" _null_ _null_ _null_ xmltotext - _null_ _null_ ));
40504050
DESCR("serialize an XML value to a character string");
40514051

40524052
DATA(insert OID = 2923 ( table_to_xml PGNSP PGUID 12 100 0 f f t f s 4 142 "2205 16 16 25" _null_ _null_ "{tbl,nulls,tableforest,targetns}" table_to_xml - _null_ _null_ ));

src/test/regress/expected/opr_sanity.out

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ WHERE c.castfunc = p.oid AND
288288
-- those are binary-compatible while the reverse way goes through rtrim().
289289
-- As of 8.2, this finds the cast from cidr to inet, because that is a
290290
-- trivial binary coercion while the other way goes through inet_to_cidr().
291+
-- As of 8.3, this finds the casts from xml to text, varchar, and bpchar,
292+
-- because those are binary-compatible while the reverse goes through
293+
-- texttoxml(), which does an XML syntax check.
291294
SELECT *
292295
FROM pg_cast c
293296
WHERE c.castfunc = 0 AND
@@ -300,7 +303,10 @@ WHERE c.castfunc = 0 AND
300303
25 | 1042 | 0 | i
301304
1043 | 1042 | 0 | i
302305
650 | 869 | 0 | i
303-
(3 rows)
306+
142 | 25 | 0 | a
307+
142 | 1043 | 0 | a
308+
142 | 1042 | 0 | a
309+
(6 rows)
304310

305311
-- **************** pg_operator ****************
306312
-- Look for illegal values in pg_operator fields.

src/test/regress/sql/opr_sanity.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ WHERE c.castfunc = p.oid AND
238238
-- As of 8.2, this finds the cast from cidr to inet, because that is a
239239
-- trivial binary coercion while the other way goes through inet_to_cidr().
240240

241+
-- As of 8.3, this finds the casts from xml to text, varchar, and bpchar,
242+
-- because those are binary-compatible while the reverse goes through
243+
-- texttoxml(), which does an XML syntax check.
244+
241245
SELECT *
242246
FROM pg_cast c
243247
WHERE c.castfunc = 0 AND

0 commit comments

Comments
 (0)