Skip to content

Commit 4c371e3

Browse files
author
Alexey Botchkov
committed
MDEV-38809 RBR fails upon DML with XML type.
Add Field_xmltype::rpl_conv_type_from() function to control replication data types.
1 parent 9653169 commit 4c371e3

4 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include/master-slave.inc
2+
[connection master]
3+
CREATE TABLE t1 (a xmltype);
4+
INSERT INTO t1 VALUES ('<a></a>');
5+
connection slave;
6+
SELECT * from t1;
7+
a
8+
<a></a>
9+
connection master;
10+
DROP TABLE t1;
11+
include/rpl_end.inc
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--source include/have_binlog_format_row.inc
2+
--source include/master-slave.inc
3+
4+
CREATE TABLE t1 (a xmltype);
5+
INSERT INTO t1 VALUES ('<a></a>');
6+
7+
--sync_slave_with_master
8+
9+
SELECT * from t1;
10+
11+
--connection master
12+
DROP TABLE t1;
13+
14+
--source include/rpl_end.inc
15+

plugin/type_xmltype/sql_type_xmltype.cc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,37 @@ int Field_xmltype::store(const char *from, size_t length, CHARSET_INFO *cs)
217217
}
218218

219219

220+
/*
221+
We allow any string input into the XMLTYPE,
222+
as it can fit into LONG BLOB without any loss.
223+
But in any case values themselves can be invalid XML-s.
224+
225+
TODO: when the replication start sending UDT informatio,
226+
we should only return CONV_TYPE_PRECISE for the XMLTYPE.
227+
*/
228+
enum_conv_type
229+
Field_xmltype::rpl_conv_type_from(const Conv_source &source,
230+
const Relay_log_info *rli,
231+
const Conv_param &param) const
232+
{
233+
const Type_handler *th= source.type_handler();
234+
if (th == &type_handler_tiny_blob ||
235+
th == &type_handler_medium_blob ||
236+
th == &type_handler_long_blob ||
237+
th == &type_handler_blob ||
238+
th == &type_handler_blob_compressed ||
239+
th == &type_handler_string ||
240+
th == &type_handler_var_string ||
241+
th == &type_handler_varchar ||
242+
th == &type_handler_varchar_compressed)
243+
{
244+
return CONV_TYPE_PRECISE;
245+
}
246+
247+
return CONV_TYPE_IMPOSSIBLE;
248+
}
249+
250+
220251
class Item_xmltype_typecast_func_handler: public Item_handled_func::Handler_str
221252
{
222253
public:

plugin/type_xmltype/sql_type_xmltype.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ class Field_xmltype :public Field_blob
119119
uint size_of() const override { return sizeof(*this); }
120120
int store(const char *to, size_t length, CHARSET_INFO *charset) override;
121121
using Field_str::store;
122+
enum_conv_type rpl_conv_type_from(const Conv_source &source,
123+
const Relay_log_info *rli,
124+
const Conv_param &param) const override;
122125
};
123126

124127

0 commit comments

Comments
 (0)