summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMySQL Build Team <build@mysql.com>2009-06-24 19:11:06 +0200
committerMySQL Build Team <build@mysql.com>2009-06-24 19:11:06 +0200
commit92c64f157b77db5d47579ead90612638ec002942 (patch)
tree3624271391a17911b0377c3a7a6786173b9b58e7
parentf7b9700ad2f887ca07dfcd864b5d2a0c5b2cf284 (diff)
downloadmariadb-git-92c64f157b77db5d47579ead90612638ec002942.tar.gz
Backport into mysql-5.1.34sp1-release
> ------------------------------------------------------------ > revno: 2841.1.1 > revision-id: sergey.glukhov@sun.com-20090401084033-161k4f8qucafy6mj > parent: ramil@mysql.com-20090401053459-07x8z2pw2ev94xck > committer: Sergey Glukhov <Sergey.Glukhov@sun.com> > branch nick: mysql-5.1-bugteam > timestamp: Wed 2009-04-01 13:40:33 +0500 > message: > Bug#43183 ExctractValue() brings result list in missorder > The problem is that XML functions(items) do not reset null_value > before their execution and further item excution may use > null_value value of the previous result. > The fix is to reset null_value.
-rw-r--r--mysql-test/r/xml.result29
-rw-r--r--mysql-test/t/xml.test27
-rw-r--r--sql/item_xmlfunc.cc2
3 files changed, 58 insertions, 0 deletions
diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result
index 404b0dc3789..fad2cab0e57 100644
--- a/mysql-test/r/xml.result
+++ b/mysql-test/r/xml.result
@@ -1064,4 +1064,33 @@ select extractvalue('<a></a>','"b"/a');
ERROR HY000: XPATH syntax error: '/a'
select extractvalue('<a></a>','(1)/a');
ERROR HY000: XPATH syntax error: '/a'
+CREATE TABLE IF NOT EXISTS t1 (
+id int(10) unsigned NOT NULL AUTO_INCREMENT,
+xml text,
+PRIMARY KEY (id)
+) ENGINE=MyISAM;
+INSERT INTO t1 (id, xml) VALUES
+(15, '<?xml version="1.0"?><bla name="blubb"></bla>'),
+(14, '<xml version="kaputt">');
+SELECT
+extractvalue( xml, '/bla/@name' ),
+extractvalue( xml, '/bla/@name' )
+FROM t1 ORDER BY t1.id;
+extractvalue( xml, '/bla/@name' ) extractvalue( xml, '/bla/@name' )
+NULL NULL
+blubb blubb
+Warnings:
+Warning 1525 Incorrect XML value: 'parse error at line 1 pos 23: unexpected END-OF-INPUT'
+Warning 1525 Incorrect XML value: 'parse error at line 1 pos 23: unexpected END-OF-INPUT'
+SELECT
+UpdateXML(xml, '/bla/@name', 'test'),
+UpdateXML(xml, '/bla/@name', 'test')
+FROM t1 ORDER BY t1.id;
+UpdateXML(xml, '/bla/@name', 'test') UpdateXML(xml, '/bla/@name', 'test')
+NULL NULL
+<?xml version="1.0"?><bla test></bla> <?xml version="1.0"?><bla test></bla>
+Warnings:
+Warning 1525 Incorrect XML value: 'parse error at line 1 pos 23: unexpected END-OF-INPUT'
+Warning 1525 Incorrect XML value: 'parse error at line 1 pos 23: unexpected END-OF-INPUT'
+DROP TABLE t1;
End of 5.1 tests
diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test
index 74bce8dc962..6e7d38cdfca 100644
--- a/mysql-test/t/xml.test
+++ b/mysql-test/t/xml.test
@@ -590,4 +590,31 @@ select extractvalue('<a></a>','"b"/a');
--error ER_UNKNOWN_ERROR
select extractvalue('<a></a>','(1)/a');
+#
+# Bug#43183 ExctractValue() brings result list in missorder
+#
+CREATE TABLE IF NOT EXISTS t1 (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ xml text,
+ PRIMARY KEY (id)
+) ENGINE=MyISAM;
+
+INSERT INTO t1 (id, xml) VALUES
+(15, '<?xml version="1.0"?><bla name="blubb"></bla>'),
+(14, '<xml version="kaputt">');
+
+
+SELECT
+extractvalue( xml, '/bla/@name' ),
+extractvalue( xml, '/bla/@name' )
+FROM t1 ORDER BY t1.id;
+
+
+SELECT
+UpdateXML(xml, '/bla/@name', 'test'),
+UpdateXML(xml, '/bla/@name', 'test')
+FROM t1 ORDER BY t1.id;
+
+DROP TABLE t1;
+
--echo End of 5.1 tests
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index 5601a2b18c6..6320873e4d3 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -2785,6 +2785,7 @@ String *Item_xml_str_func::parse_xml(String *raw_xml, String *parsed_xml_buf)
String *Item_func_xml_extractvalue::val_str(String *str)
{
String *res;
+ null_value= 0;
if (!nodeset_func ||
!(res= args[0]->val_str(str)) ||
!parse_xml(res, &pxml))
@@ -2801,6 +2802,7 @@ String *Item_func_xml_update::val_str(String *str)
{
String *res, *nodeset, *rep;
+ null_value= 0;
if (!nodeset_func ||
!(res= args[0]->val_str(str)) ||
!(rep= args[2]->val_str(&tmp_value3)) ||