Commit 7888b520 authored by Peter Eisentraut's avatar Peter Eisentraut

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.
parent 542d04e1
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.60 2007/11/25 12:08:11 petere Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.61 2007/11/27 12:21:05 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -535,7 +535,8 @@ xmltotext(PG_FUNCTION_ARGS) ...@@ -535,7 +535,8 @@ xmltotext(PG_FUNCTION_ARGS)
{ {
xmltype *data = PG_GETARG_XML_P(0); xmltype *data = PG_GETARG_XML_P(0);
PG_RETURN_TEXT_P(xmltotext_with_xmloption(data, xmloption)); /* It's actually binary compatible. */
return (text *) data;
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.437 2007/10/24 02:24:47 tgl Exp $ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.438 2007/11/27 12:21:05 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 200710232 #define CATALOG_VERSION_NO 200711271
#endif #endif
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* Copyright (c) 2002-2007, PostgreSQL Global Development Group * Copyright (c) 2002-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.36 2007/11/15 21:14:42 momjian Exp $ * $PostgreSQL: pgsql/src/include/catalog/pg_cast.h,v 1.37 2007/11/27 12:21:05 petere Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -292,7 +292,7 @@ DATA(insert ( 1560 23 1684 e )); ...@@ -292,7 +292,7 @@ DATA(insert ( 1560 23 1684 e ));
DATA(insert ( 650 25 730 a )); DATA(insert ( 650 25 730 a ));
DATA(insert ( 869 25 730 a )); DATA(insert ( 869 25 730 a ));
DATA(insert ( 16 25 2971 a )); DATA(insert ( 16 25 2971 a ));
DATA(insert ( 142 25 2922 a )); DATA(insert ( 142 25 0 a ));
DATA(insert ( 25 142 2896 e )); DATA(insert ( 25 142 2896 e ));
/* /*
...@@ -303,7 +303,7 @@ DATA(insert ( 25 142 2896 e )); ...@@ -303,7 +303,7 @@ DATA(insert ( 25 142 2896 e ));
DATA(insert ( 650 1043 730 a )); DATA(insert ( 650 1043 730 a ));
DATA(insert ( 869 1043 730 a )); DATA(insert ( 869 1043 730 a ));
DATA(insert ( 16 1043 2971 a )); DATA(insert ( 16 1043 2971 a ));
DATA(insert ( 142 1043 2922 a )); DATA(insert ( 142 1043 0 a ));
DATA(insert ( 1043 142 2896 e )); DATA(insert ( 1043 142 2896 e ));
/* /*
...@@ -314,7 +314,7 @@ DATA(insert ( 1043 142 2896 e )); ...@@ -314,7 +314,7 @@ DATA(insert ( 1043 142 2896 e ));
DATA(insert ( 650 1042 730 a )); DATA(insert ( 650 1042 730 a ));
DATA(insert ( 869 1042 730 a )); DATA(insert ( 869 1042 730 a ));
DATA(insert ( 16 1042 2971 a )); DATA(insert ( 16 1042 2971 a ));
DATA(insert ( 142 1042 2922 a )); DATA(insert ( 142 1042 0 a ));
DATA(insert ( 1042 142 2896 e )); DATA(insert ( 1042 142 2896 e ));
/* /*
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.478 2007/11/15 21:14:43 momjian Exp $ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.479 2007/11/27 12:21:05 petere Exp $
* *
* NOTES * NOTES
* The script catalog/genbki.sh reads this file and generates .bki * 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 ...@@ -4028,13 +4028,13 @@ DATA(insert OID = 2892 ( pg_advisory_unlock_all PGNSP PGUID 12 1 0 f f t f v 0
DESCR("release all advisory locks"); DESCR("release all advisory locks");
/* XML support */ /* XML support */
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_ )); 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_ ));
DESCR("I/O"); DESCR("I/O");
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_ )); 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_ ));
DESCR("I/O"); DESCR("I/O");
DATA(insert OID = 2895 ( xmlcomment PGNSP PGUID 12 1 0 f f t f i 1 142 "25" _null_ _null_ _null_ xmlcomment - _null_ _null_ )); DATA(insert OID = 2895 ( xmlcomment PGNSP PGUID 12 1 0 f f t f i 1 142 "25" _null_ _null_ _null_ xmlcomment - _null_ _null_ ));
DESCR("generate an XML comment"); DESCR("generate an XML comment");
DATA(insert OID = 2896 ( xml PGNSP PGUID 12 1 0 f f t f i 1 142 "25" _null_ _null_ _null_ texttoxml - _null_ _null_ )); DATA(insert OID = 2896 ( xml PGNSP PGUID 12 1 0 f f t f s 1 142 "25" _null_ _null_ _null_ texttoxml - _null_ _null_ ));
DESCR("perform a non-validating parse of a character string to produce an XML value"); DESCR("perform a non-validating parse of a character string to produce an XML value");
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_ )); 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_ ));
DESCR("validate an XML value"); 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 ...@@ -4046,7 +4046,7 @@ DATA(insert OID = 2900 ( xmlconcat2 PGNSP PGUID 12 1 0 f f f f i 2 142 "142
DESCR("aggregate transition function"); DESCR("aggregate transition function");
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_ )); 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_ ));
DESCR("concatenate XML values"); DESCR("concatenate XML values");
DATA(insert OID = 2922 ( text PGNSP PGUID 12 1 0 f f t f s 1 25 "142" _null_ _null_ _null_ xmltotext - _null_ _null_ )); DATA(insert OID = 2922 ( text PGNSP PGUID 12 1 0 f f t f i 1 25 "142" _null_ _null_ _null_ xmltotext - _null_ _null_ ));
DESCR("serialize an XML value to a character string"); DESCR("serialize an XML value to a character string");
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_ )); 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_ ));
......
...@@ -288,6 +288,9 @@ WHERE c.castfunc = p.oid AND ...@@ -288,6 +288,9 @@ WHERE c.castfunc = p.oid AND
-- those are binary-compatible while the reverse way goes through rtrim(). -- those are binary-compatible while the reverse way goes through rtrim().
-- As of 8.2, this finds the cast from cidr to inet, because that is a -- As of 8.2, this finds the cast from cidr to inet, because that is a
-- trivial binary coercion while the other way goes through inet_to_cidr(). -- trivial binary coercion while the other way goes through inet_to_cidr().
-- As of 8.3, this finds the casts from xml to text, varchar, and bpchar,
-- because those are binary-compatible while the reverse goes through
-- texttoxml(), which does an XML syntax check.
SELECT * SELECT *
FROM pg_cast c FROM pg_cast c
WHERE c.castfunc = 0 AND WHERE c.castfunc = 0 AND
...@@ -300,7 +303,10 @@ WHERE c.castfunc = 0 AND ...@@ -300,7 +303,10 @@ WHERE c.castfunc = 0 AND
25 | 1042 | 0 | i 25 | 1042 | 0 | i
1043 | 1042 | 0 | i 1043 | 1042 | 0 | i
650 | 869 | 0 | i 650 | 869 | 0 | i
(3 rows) 142 | 25 | 0 | a
142 | 1043 | 0 | a
142 | 1042 | 0 | a
(6 rows)
-- **************** pg_operator **************** -- **************** pg_operator ****************
-- Look for illegal values in pg_operator fields. -- Look for illegal values in pg_operator fields.
......
...@@ -238,6 +238,10 @@ WHERE c.castfunc = p.oid AND ...@@ -238,6 +238,10 @@ WHERE c.castfunc = p.oid AND
-- As of 8.2, this finds the cast from cidr to inet, because that is a -- As of 8.2, this finds the cast from cidr to inet, because that is a
-- trivial binary coercion while the other way goes through inet_to_cidr(). -- trivial binary coercion while the other way goes through inet_to_cidr().
-- As of 8.3, this finds the casts from xml to text, varchar, and bpchar,
-- because those are binary-compatible while the reverse goes through
-- texttoxml(), which does an XML syntax check.
SELECT * SELECT *
FROM pg_cast c FROM pg_cast c
WHERE c.castfunc = 0 AND WHERE c.castfunc = 0 AND
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment