Skip to content

Commit a22bc99

Browse files
author
Mats Kindahl
committed
WL#5151: Conversion between different types when replicating
Bug#49836 reports that the geometry type does not work with WL#5151 applied. The GEOMETRY type inherits the blob comparison function, which read the pack length from the metadata. The GEOMETRY type does not fill in the metadata with anything sensible, so it is always zero, meaning that the pack length for the source type is considered zero, rendering it always "smaller" than the target type which has pack length 4 (without pointer). This patch fixes the problem by defining Field_geom::pack_length_from_metadata() to always use the same as Field_geom::row_pack_length().
1 parent b524f27 commit a22bc99

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

mysql-test/extra/rpl_tests/type_conversions.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ connection slave;
1212
let $if_is_lossy = `SELECT FIND_IN_SET('ALL_LOSSY', @@SLAVE_TYPE_CONVERSIONS)`;
1313
let $if_is_non_lossy = `SELECT FIND_IN_SET('ALL_NON_LOSSY', @@SLAVE_TYPE_CONVERSIONS)`;
1414

15+
let $source_type = GEOMETRY;
16+
let $target_type = GEOMETRY;
17+
let $source_value = PointFromText('POINT(10 10)');
18+
let $target_value = PointFromText('POINT(10 10)');
19+
let $can_convert = 1;
20+
source extra/rpl_tests/check_type.inc;
21+
1522
let $source_type = BIT(1);
1623
let $target_type = BIT(1);
1724
let $source_value = b'1';

mysql-test/suite/rpl/r/rpl_typeconv.result

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ RESET MASTER;
6969
include/start_slave.inc
7070
**** Result of conversions ****
7171
Source_Type Target_Type All_Type_Conversion_Flags Value_On_Slave
72+
GEOMETRY GEOMETRY <Correct value>
7273
BIT(1) BIT(1) <Correct value>
7374
DATE DATE <Correct value>
7475
ENUM('master',' ENUM('master',' <Correct value>
@@ -171,6 +172,7 @@ BIT(5) BIT(6) <Correct error>
171172
BIT(6) BIT(5) <Correct error>
172173
BIT(5) BIT(12) <Correct error>
173174
BIT(12) BIT(5) <Correct error>
175+
GEOMETRY GEOMETRY ALL_NON_LOSSY <Correct value>
174176
BIT(1) BIT(1) ALL_NON_LOSSY <Correct value>
175177
DATE DATE ALL_NON_LOSSY <Correct value>
176178
ENUM('master',' ENUM('master',' ALL_NON_LOSSY <Correct value>
@@ -273,6 +275,7 @@ BIT(5) BIT(6) ALL_NON_LOSSY <Correct value>
273275
BIT(6) BIT(5) ALL_NON_LOSSY <Correct error>
274276
BIT(5) BIT(12) ALL_NON_LOSSY <Correct value>
275277
BIT(12) BIT(5) ALL_NON_LOSSY <Correct error>
278+
GEOMETRY GEOMETRY ALL_LOSSY <Correct value>
276279
BIT(1) BIT(1) ALL_LOSSY <Correct value>
277280
DATE DATE ALL_LOSSY <Correct value>
278281
ENUM('master',' ENUM('master',' ALL_LOSSY <Correct value>
@@ -375,6 +378,7 @@ BIT(5) BIT(6) ALL_LOSSY <Correct error>
375378
BIT(6) BIT(5) ALL_LOSSY <Correct value>
376379
BIT(5) BIT(12) ALL_LOSSY <Correct error>
377380
BIT(12) BIT(5) ALL_LOSSY <Correct value>
381+
GEOMETRY GEOMETRY ALL_LOSSY,ALL_NON_LOSSY <Correct value>
378382
BIT(1) BIT(1) ALL_LOSSY,ALL_NON_LOSSY <Correct value>
379383
DATE DATE ALL_LOSSY,ALL_NON_LOSSY <Correct value>
380384
ENUM('master',' ENUM('master',' ALL_LOSSY,ALL_NON_LOSSY <Correct value>

sql/field.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,10 @@ class Field_geom :public Field_blob {
18171817
uint size_of() const { return sizeof(*this); }
18181818
int reset(void) { return !maybe_null() || Field_blob::reset(); }
18191819
geometry_type get_geometry_type() { return geom_type; };
1820+
uint pack_length_from_metadata(uint field_metadata)
1821+
{
1822+
return pack_length_no_ptr();
1823+
}
18201824
};
18211825
#endif /*HAVE_SPATIAL*/
18221826

0 commit comments

Comments
 (0)