Skip to content

Commit c701fe6

Browse files
author
Mats Kindahl
committed
WL#5151: Conversion between different types when replicating
Fixing minor error when printing SQL types from master and cleaning some code. Updating result files.
1 parent c63df11 commit c701fe6

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ Replicate_Ignore_Table #
256256
Replicate_Wild_Do_Table
257257
Replicate_Wild_Ignore_Table
258258
Last_Errno 1641
259-
Last_Error Column 0 of table 'test.t1' cannot be converted from type 'bit(8)' to type 'bit(5)'
259+
Last_Error Column 0 of table 'test.t1' cannot be converted from type 'bit(64)' to type 'bit(5)'
260260
Skip_Counter 0
261261
Exec_Master_Log_Pos #
262262
Relay_Log_Space #
@@ -274,7 +274,7 @@ Master_SSL_Verify_Server_Cert No
274274
Last_IO_Errno #
275275
Last_IO_Error #
276276
Last_SQL_Errno 1641
277-
Last_SQL_Error Column 0 of table 'test.t1' cannot be converted from type 'bit(8)' to type 'bit(5)'
277+
Last_SQL_Error Column 0 of table 'test.t1' cannot be converted from type 'bit(64)' to type 'bit(5)'
278278
SELECT COUNT(*) FROM t1;
279279
COUNT(*)
280280
0
@@ -310,7 +310,7 @@ Replicate_Ignore_Table #
310310
Replicate_Wild_Do_Table
311311
Replicate_Wild_Ignore_Table
312312
Last_Errno 1641
313-
Last_Error Column 0 of table 'test.t1' cannot be converted from type 'bit(5)' to type 'bit(11)'
313+
Last_Error Column 0 of table 'test.t1' cannot be converted from type 'bit(12)' to type 'bit(11)'
314314
Skip_Counter 0
315315
Exec_Master_Log_Pos #
316316
Relay_Log_Space #
@@ -328,7 +328,7 @@ Master_SSL_Verify_Server_Cert No
328328
Last_IO_Errno #
329329
Last_IO_Error #
330330
Last_SQL_Errno 1641
331-
Last_SQL_Error Column 0 of table 'test.t1' cannot be converted from type 'bit(5)' to type 'bit(11)'
331+
Last_SQL_Error Column 0 of table 'test.t1' cannot be converted from type 'bit(12)' to type 'bit(11)'
332332
SELECT COUNT(*) FROM t1;
333333
COUNT(*)
334334
0

sql/rpl_utility.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,11 @@ max_display_length_for_field(enum_field_types sql_type, unsigned int metadata)
116116
return 8;
117117

118118
case MYSQL_TYPE_BIT:
119-
{
120119
/*
121120
Decode the size of the bit field from the master.
122-
from_len is the length in bytes from the master
123-
from_bit_len is the number of extra bits stored in the master record
124121
*/
125-
uint from_len= (metadata >> 8U) & 0x00ff;
126-
uint from_bit_len= metadata & 0x00ff;
127-
DBUG_ASSERT(from_bit_len <= 7);
128-
return 8 * from_len + from_bit_len;
129-
}
122+
DBUG_ASSERT((metadata & 0xff) <= 7);
123+
return 8 * (metadata >> 8U) + (metadata & 0x00ff);
130124

131125
case MYSQL_TYPE_VAR_STRING:
132126
case MYSQL_TYPE_VARCHAR:
@@ -422,7 +416,7 @@ void show_sql_type(enum_field_types type, uint16 metadata, String *str)
422416
case MYSQL_TYPE_BIT:
423417
{
424418
CHARSET_INFO *cs= str->charset();
425-
int bit_length= (metadata >> 8) + (metadata & 0xFF);
419+
int bit_length= 8 * (metadata >> 8) + (metadata & 0xFF);
426420
uint32 length=
427421
cs->cset->snprintf(cs, (char*) str->ptr(), str->alloced_length(),
428422
"bit(%d)", bit_length);

0 commit comments

Comments
 (0)