Tom Lane wrote:
> Given the actual behavior of xmltotext_with_xmloption, it certainly
> seems like a pretty useless error check. Also, xml_out doesn't behave
> that way, so why should xmltotext?
>
> The volatility markings of xml_in and texttoxml seem wrong too.
This is the patch that came out of it.
> Should we force initdb to correct these pg_proc entries, or just quietly
> change pg_proc.h?
Considering the extent of the changes, I'd be in favor of forcing an initdb.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
diff -ur ../cvs-pgsql/src/backend/utils/adt/xml.c ./src/backend/utils/adt/xml.c
--- ../cvs-pgsql/src/backend/utils/adt/xml.c 2007-11-22 21:52:30.000000000 +0100
+++ ./src/backend/utils/adt/xml.c 2007-11-22 23:21:25.000000000 +0100
@@ -535,7 +535,8 @@
{
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 -ur ../cvs-pgsql/src/include/catalog/pg_cast.h ./src/include/catalog/pg_cast.h
--- ../cvs-pgsql/src/include/catalog/pg_cast.h 2007-11-16 21:25:20.000000000 +0100
+++ ./src/include/catalog/pg_cast.h 2007-11-22 23:34:23.000000000 +0100
@@ -292,7 +292,7 @@
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 ( 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 ( 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 -ur ../cvs-pgsql/src/include/catalog/pg_proc.h ./src/include/catalog/pg_proc.h
--- ../cvs-pgsql/src/include/catalog/pg_proc.h 2007-11-16 21:25:20.000000000 +0100
+++ ./src/include/catalog/pg_proc.h 2007-11-22 23:21:07.000000000 +0100
@@ -4028,13 +4028,13 @@
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 @@
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 -ur ../cvs-pgsql/src/test/regress/expected/opr_sanity.out ./src/test/regress/expected/opr_sanity.out
--- ../cvs-pgsql/src/test/regress/expected/opr_sanity.out 2007-09-12 20:57:22.000000000 +0200
+++ ./src/test/regress/expected/opr_sanity.out 2007-11-22 23:40:13.000000000 +0100
@@ -288,6 +288,9 @@
-- 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 @@
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 -ur ../cvs-pgsql/src/test/regress/sql/opr_sanity.sql ./src/test/regress/sql/opr_sanity.sql
--- ../cvs-pgsql/src/test/regress/sql/opr_sanity.sql 2007-09-12 20:57:23.000000000 +0200
+++ ./src/test/regress/sql/opr_sanity.sql 2007-11-22 23:38:45.000000000 +0100
@@ -238,6 +238,10 @@
-- 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
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly