Make casts from xml to text independent of the XML option setting, thus
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 27 Nov 2007 12:21:05 +0000 (12:21 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Tue, 27 Nov 2007 12:21:05 +0000 (12:21 +0000)
immutable and indexable.  Also fix the volatility settings of some other
XML-related functions.

src/backend/utils/adt/xml.c
src/include/catalog/catversion.h
src/include/catalog/pg_cast.h
src/include/catalog/pg_proc.h
src/test/regress/expected/opr_sanity.out
src/test/regress/sql/opr_sanity.sql

index 19806819a869df5d5bfd3552d887e52a4e9ce710..472d3baf426730e581fc9f0efc1b3690068f855b 100644 (file)
@@ -535,7 +535,8 @@ xmltotext(PG_FUNCTION_ARGS)
 {
        xmltype    *data = PG_GETARG_XML_P(0);
 
-       PG_RETURN_TEXT_P(xmltotext_with_xmloption(data, xmloption));
+       /* It's actually binary compatible. */
+       return (text *) data;
 }
 
 
index 2f724b3e7f96efafc5fb09721c024155af6f01cb..6970f6ddb283ae305ab364a54ec39f923b8b4aa2 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                                                     yyyymmddN */
-#define CATALOG_VERSION_NO     200710232
+#define CATALOG_VERSION_NO     200711271
 
 #endif
index 60148738c4b3983db796405bfb06851aaa03015a..c779dc0e769f6be04f60a4ab35388115e464a842 100644 (file)
@@ -292,7 +292,7 @@ DATA(insert ( 1560   23 1684 e ));
 DATA(insert (  650      25  730 a ));
 DATA(insert (  869      25  730 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 ));
 
 /*
@@ -303,7 +303,7 @@ DATA(insert (       25      142 2896 e ));
 DATA(insert (  650 1043  730 a ));
 DATA(insert (  869 1043  730 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 ));
 
 /*
@@ -314,7 +314,7 @@ DATA(insert ( 1043  142 2896 e ));
 DATA(insert (  650 1042  730 a ));
 DATA(insert (  869 1042  730 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 ));
 
 /*
index b5e6ab4fbc47f63bf8ae499254ba0ef267e711a5..294ec736fe7c8848bfe44cb58d6937f11e7c87c0 100644 (file)
@@ -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");
 
 /* 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");
 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");
 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");
-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");
 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");
@@ -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");
 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");
-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");
 
 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_ ));
index b4d7d70d59c7bcc60a87e9b660ae63ff35514e3d..ef787115742fdcb1cc298eb6678ed0a3d1580a24 100644 (file)
@@ -288,6 +288,9 @@ WHERE c.castfunc = p.oid AND
 -- 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
 -- 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 *
 FROM pg_cast c
 WHERE c.castfunc = 0 AND
@@ -300,7 +303,10 @@ WHERE c.castfunc = 0 AND
          25 |       1042 |        0 | i
        1043 |       1042 |        0 | i
         650 |        869 |        0 | i
-(3 rows)
+        142 |         25 |        0 | a
+        142 |       1043 |        0 | a
+        142 |       1042 |        0 | a
+(6 rows)
 
 -- **************** pg_operator ****************
 -- Look for illegal values in pg_operator fields.
index 037eb9e74db7844024a2aa06a552e02e776d35bd..deaa3714feff0977870550f1548109d43254fb51 100644 (file)
@@ -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
 -- 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 *
 FROM pg_cast c
 WHERE c.castfunc = 0 AND