summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAndrei Elkin <andrei.elkin@mariadb.com>2019-01-10 16:32:56 +0200
committerAndrei Elkin <andrei.elkin@mariadb.com>2019-01-23 15:48:06 +0200
commitcce2b45c8f5b3245d2e63d2763aeec59153d2c6f (patch)
tree453828894d440f46a204914d5fa3338431814be6 /sql
parent2a0f1d613219ad7962c3394b9c1996ece40926df (diff)
downloadmariadb-git-cce2b45c8f5b3245d2e63d2763aeec59153d2c6f.tar.gz
MDEV-17803 Row-based event is not applied when table map id is greater
32 bit int Row-based slave applier could not parse correctly the table id when the value exceeded the max of 32 bit unsigned int. The reason turns out in that the being parsed value placeholder was sized as 4 bytes. The type is fixed to ulonglong. Additionally the patch works around Rows_log_event::m_table_id 4 bytes size on 32 bits platforms. In case of last_table_id value overflows the 4 byte max, there won't be the zero value for m_table_id generated and the first wrapped-around value is one, this is thanks to excluding UINT_MAX32 + 1 from TABLE_SHARE::table_map_id.
Diffstat (limited to 'sql')
-rw-r--r--sql/table.h2
-rw-r--r--sql/table_cache.cc5
2 files changed, 5 insertions, 2 deletions
diff --git a/sql/table.h b/sql/table.h
index 4a1552f8c0d..10c1d1bc68e 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1816,7 +1816,7 @@ struct TABLE_LIST
/* Index names in a "... JOIN ... USE/IGNORE INDEX ..." clause. */
List<Index_hint> *index_hints;
TABLE *table; /* opened table */
- uint table_id; /* table id (from binlog) for opened table */
+ ulonglong table_id; /* table id (from binlog) for opened table */
/*
select_result for derived table to pass it from table creation to table
filling procedure
diff --git a/sql/table_cache.cc b/sql/table_cache.cc
index f13d7183a99..1154017d8d5 100644
--- a/sql/table_cache.cc
+++ b/sql/table_cache.cc
@@ -1206,6 +1206,9 @@ void tdc_assign_new_table_id(TABLE_SHARE *share)
DBUG_ASSERT(share);
DBUG_ASSERT(tdc_inited);
+ DBUG_EXECUTE_IF("simulate_big_table_id",
+ if (last_table_id < UINT_MAX32)
+ last_table_id= UINT_MAX32 - 1;);
/*
There is one reserved number that cannot be used. Remember to
change this when 6-byte global table id's are introduced.
@@ -1215,7 +1218,7 @@ void tdc_assign_new_table_id(TABLE_SHARE *share)
my_atomic_rwlock_wrlock(&LOCK_tdc_atomics);
tid= my_atomic_add64(&last_table_id, 1);
my_atomic_rwlock_wrunlock(&LOCK_tdc_atomics);
- } while (unlikely(tid == ~0UL));
+ } while (unlikely(tid == ~0UL || tid == 0));
share->table_map_id= tid;
DBUG_PRINT("info", ("table_id= %lu", share->table_map_id));