diff options
author | Michael Widenius <monty@mariadb.org> | 2014-03-26 21:58:27 +0200 |
---|---|---|
committer | Michael Widenius <monty@mariadb.org> | 2014-03-26 21:58:27 +0200 |
commit | ded448d1d035d211c8146141546a08126bb728b6 (patch) | |
tree | 0ebba8935193517995519651885a34e46ff53515 /storage/heap/ha_heap.cc | |
parent | 99316b51b6e78191eca303dc35ae5a204f8b5c4f (diff) | |
download | mariadb-git-ded448d1d035d211c8146141546a08126bb728b6.tar.gz |
MDEV-5905: Creating tmp. memory table kills the server
The reason was that a couple of variables that hold number of rows that was used to calculate buffers was uint and caused an overflow.
Fixed by changing variables that could hold number of rows from uint to ulong and also added a cast for this test.
include/heap.h:
Reorder to get better alignment. Changed variables that could hold number of rows from uint to ulong
mysql-test/suite/heap/heap.result:
Added test case
mysql-test/suite/heap/heap.test:
Added test case
mysql-test/suite/plugins/t/server_audit.test:
Added sleep as we want to have disconnect logged before we try a new connect
storage/heap/ha_heap.cc:
Changed variables that could hold number of rows from uint to ulong
Limit number of rows to 4G (as most of the variables that holds rows are ulong anyway)
reset records_changed when key_stat_version is changed to not cause increments for every row changed
storage/heap/ha_heap.h:
changed records_changed to ulong as this can get big
storage/heap/hp_create.c:
Changed variables that could hold number of rows from uint to ulong
Added cast (fixed the original bug)
storage/heap/hp_delete.c:
Changed variables that could hold number of rows from uint to ulong
storage/heap/hp_open.c:
Removed not needed cast
storage/heap/hp_write.c:
Changed variables that could hold number of rows from uint to ulong
support-files/compiler_warnings.supp:
Removed extra : from supression
Diffstat (limited to 'storage/heap/ha_heap.cc')
-rw-r--r-- | storage/heap/ha_heap.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 305a8cae720..ec219c1590d 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -225,7 +225,7 @@ void ha_heap::update_key_stats() else { ha_rows hash_buckets= file->s->keydef[i].hash_buckets; - uint no_records= hash_buckets ? (uint) (file->s->records/hash_buckets) : 2; + ha_rows no_records= hash_buckets ? (file->s->records/hash_buckets) : 2; if (no_records < 2) no_records= 2; key->rec_per_key[key->key_parts-1]= no_records; @@ -256,6 +256,7 @@ int ha_heap::write_row(uchar * buf) We can perform this safely since only one writer at the time is allowed on the table. */ + records_changed= 0; file->s->key_stat_version++; } return res; @@ -274,6 +275,7 @@ int ha_heap::update_row(const uchar * old_data, uchar * new_data) We can perform this safely since only one writer at the time is allowed on the table. */ + records_changed= 0; file->s->key_stat_version++; } return res; @@ -290,6 +292,7 @@ int ha_heap::delete_row(const uchar * buf) We can perform this safely since only one writer at the time is allowed on the table. */ + records_changed= 0; file->s->key_stat_version++; } return res; @@ -740,8 +743,8 @@ heap_prepare_hp_create_info(TABLE *table_arg, bool internal_table, if (share->max_rows && share->max_rows < max_rows) max_rows= share->max_rows; - hp_create_info->max_records= (ulong) max_rows; - hp_create_info->min_records= (ulong) share->min_rows; + hp_create_info->max_records= (ulong) min(max_rows, ULONG_MAX); + hp_create_info->min_records= (ulong) min(share->min_rows, ULONG_MAX); hp_create_info->keys= share->keys; hp_create_info->reclength= share->reclength; hp_create_info->keydef= keydef; |