1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00

MDEV-39589 Wrong results with xmltype as a virtual column.

Store value in the XML column even if an error happened.
This commit is contained in:
Alexey Botchkov
2026-05-13 18:27:59 +04:00
parent 2c7c7e1216
commit 6dcd3c9dc0
3 changed files with 42 additions and 1 deletions

View File

@@ -298,4 +298,25 @@ SELECT CAST(1 AS XMLTYPE CHARSET utf32);
ERROR 42000: This version of MariaDB doesn't yet support 'CAST(AS XMLTYPE CHARACTER SET ucs2/utf16/utf32)'
SELECT CAST("<a></a>" AS XMLTYPE CHARSET utf32);
ERROR 42000: This version of MariaDB doesn't yet support 'CAST(AS XMLTYPE CHARACTER SET ucs2/utf16/utf32)'
#
# MDEV-39589 Wrong results with xmltype as a virtual column.
#
CREATE TABLE t1(a VARCHAR(50), b XMLTYPE AS (a) VIRTUAL);
INSERT INTO t1(a) VALUES('<yyyyyyyyy>xxxxxxxxxxxxxxxxxxx</yyyyyyyyy>');
INSERT INTO t1(a) VALUES('a');
INSERT INTO t1(a) VALUES('b');
INSERT INTO t1(a) VALUES('<dddddddddd>tttttttttttttttttttttt</dddddddddd>');
INSERT INTO t1(a) VALUES('e');
SELECT * FROM t1;
a b
<yyyyyyyyy>xxxxxxxxxxxxxxxxxxx</yyyyyyyyy> <yyyyyyyyy>xxxxxxxxxxxxxxxxxxx</yyyyyyyyy>
a NULL
b NULL
<dddddddddd>tttttttttttttttttttttt</dddddddddd> <dddddddddd>tttttttttttttttttttttt</dddddddddd>
e NULL
Warnings:
Warning 1525 Incorrect XMLTYPE value: 'a'
Warning 1525 Incorrect XMLTYPE value: 'b'
Warning 1525 Incorrect XMLTYPE value: 'e'
DROP TABLE t1;
# End of 12.3 tests

View File

@@ -200,7 +200,6 @@ INSERT INTO t1 VALUES(@x);
DROP TABLE t1;
--echo #
--echo # MDEV-39575 Protocol::end_statement(): Assertion `0' failed after insert into xmltype union of valid and invalid xml.
--echo #
@@ -235,4 +234,20 @@ SELECT CAST(1 AS XMLTYPE CHARSET utf32);
--error ER_NOT_SUPPORTED_YET
SELECT CAST("<a></a>" AS XMLTYPE CHARSET utf32);
--echo #
--echo # MDEV-39589 Wrong results with xmltype as a virtual column.
--echo #
CREATE TABLE t1(a VARCHAR(50), b XMLTYPE AS (a) VIRTUAL);
INSERT INTO t1(a) VALUES('<yyyyyyyyy>xxxxxxxxxxxxxxxxxxx</yyyyyyyyy>');
INSERT INTO t1(a) VALUES('a');
INSERT INTO t1(a) VALUES('b');
INSERT INTO t1(a) VALUES('<dddddddddd>tttttttttttttttttttttt</dddddddddd>');
INSERT INTO t1(a) VALUES('e');
--disable_view_protocol
SELECT * FROM t1;
--enable_view_protocol
DROP TABLE t1;
--echo # End of 12.3 tests

View File

@@ -216,6 +216,11 @@ int Field_xmltype::store(const char *from, size_t length, CHARSET_INFO *cs)
return Field_blob::store(from, length, cs);
err:
if (maybe_null())
set_null();
else
Field_blob::store(STRING_WITH_LEN("<invalid_xml_replaced />"), cs);
my_error(ER_WRONG_VALUE, MYF(0),
"XMLTYPE", ErrConvString(from, length, cs).ptr());
return -1;