diff options
author | Igor Babaev <igor@askmonty.org> | 2011-10-16 13:23:57 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2011-10-16 13:23:57 -0700 |
commit | f5955f87c6aed0af0ffbbab918e953b8c340d466 (patch) | |
tree | 55f95cf25739c0f744a854dc0c1a079a3956e8cc /sql/table.cc | |
parent | 5e4a381cc51ab01e793fb4ca8a29b3daa9bf3ce9 (diff) | |
download | mariadb-git-f5955f87c6aed0af0ffbbab918e953b8c340d466.tar.gz |
Fixed LP bug #874006.
This bug manifested itself with queries containing non-correlated
IN subqueries over materialized views/derived tables.
The bug happened because the code of the function generate_derived_keys did
not take into account that the function could be called twice when the
optimizer was deciding whether in-exist transformation should be applied.
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sql/table.cc b/sql/table.cc index d54135b5620..382de16b81c 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5220,10 +5220,11 @@ void st_table::mark_virtual_columns_for_write(bool insert_fl) @brief Allocate space for keys - @param key_count number of keys to allocate + @param key_count number of keys to allocate additionally @details - The function allocates memory to fit 'key_count' keys for this table. + The function allocates memory to fit additionally 'key_count' keys + for this table. @return FALSE space was successfully allocated @return TRUE an error occur @@ -5231,9 +5232,11 @@ void st_table::mark_virtual_columns_for_write(bool insert_fl) bool TABLE::alloc_keys(uint key_count) { - key_info= s->key_info= (KEY*) alloc_root(&mem_root, sizeof(KEY)*key_count); - s->keys= 0; - max_keys= key_count; + key_info= (KEY*) alloc_root(&mem_root, sizeof(KEY)*(s->keys+key_count)); + if (s->keys) + memmove(key_info, s->key_info, sizeof(KEY)*s->keys); + s->key_info= key_info; + max_keys= s->keys+key_count; return !(key_info); } |