summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2007-11-27 12:21:05 +0000
committerPeter Eisentraut2007-11-27 12:21:05 +0000
commit7888b52076562ba770ccfd863dc3c3c984788703 (patch)
treec6522ca7da2ad7fdd64e8183bae2d94655f01ec2
parent542d04e17944f8ceb36fc33061fc83d06efbd999 (diff)
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.
-rw-r--r--src/backend/utils/adt/xml.c5
-rw-r--r--src/include/catalog/catversion.h4
-rw-r--r--src/include/catalog/pg_cast.h8
-rw-r--r--src/include/catalog/pg_proc.h8
-rw-r--r--src/test/regress/expected/opr_sanity.out8
-rw-r--r--src/test/regress/sql/opr_sanity.sql4
6 files changed, 24 insertions, 13 deletions
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 777910791a..07ca7a8e78 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* 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)
{
xmltype *data = PG_GETARG_XML_P(0);
- PG_RETURN_TEXT_P(xmltotext_with_xmloption(data, xmloption));
+ /* It's actually binary compatible. */
+ return (text *) data;
}
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 7b4ccf4462..036d004b55 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* 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 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200710232
+#define CATALOG_VERSION_NO 200711271
#endif
diff --git a/src/include/catalog/pg_cast.h b/src/include/catalog/pg_cast.h
index f6750c796c..fa580cf949 100644
--- a/src/include/catalog/pg_cast.h
+++ b/src/include/catalog/pg_cast.h
@@ -10,7 +10,7 @@
*
* 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
* the genbki.sh script reads this file and generates .bki
@@ -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 ));
/*
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index 68c49e8bb3..1472437f71 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* 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
* 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
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_ ));
diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out
index b4d7d70d59..ef78711574 100644
--- a/src/test/regress/expected/opr_sanity.out
+++ b/src/test/regress/expected/opr_sanity.out
@@ -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.
diff --git a/src/test/regress/sql/opr_sanity.sql b/src/test/regress/sql/opr_sanity.sql
index 037eb9e74d..deaa3714fe 100644
--- a/src/test/regress/sql/opr_sanity.sql
+++ b/src/test/regress/sql/opr_sanity.sql
@@ -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