diff options
author | kaa@kaamos.(none) <> | 2008-03-12 11:19:46 +0300 |
---|---|---|
committer | kaa@kaamos.(none) <> | 2008-03-12 11:19:46 +0300 |
commit | 0a7052e4d3633b818ab4050adcad646b888c5430 (patch) | |
tree | f84e4ada799bf37a3d9ef074064f8a17f408aa89 /sql/handler.cc | |
parent | d4025ce1a60322635bf5f7adb765f4612563ee3a (diff) | |
parent | 7e365efa30f5d42aaf87ce9044176e266ee337eb (diff) | |
download | mariadb-git-0a7052e4d3633b818ab4050adcad646b888c5430.tar.gz |
Merge kaamos.(none):/data/src/mysql-5.1
into kaamos.(none):/data/src/opt/mysql-5.1-opt
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index 0fb61895a61..b8fc17be14d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1924,6 +1924,13 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, handler *handler::clone(MEM_ROOT *mem_root) { handler *new_handler= get_new_handler(table->s, mem_root, table->s->db_type()); + /* + Allocate handler->ref here because otherwise ha_open will allocate it + on this->table->mem_root and we will not be able to reclaim that memory + when the clone handler object is destroyed. + */ + if (!(new_handler->ref= (uchar*) alloc_root(mem_root, ALIGN_SIZE(ref_length)*2))) + return NULL; if (new_handler && !new_handler->ha_open(table, table->s->normalized_path.str, table->db_stat, @@ -1992,7 +1999,9 @@ int handler::ha_open(TABLE *table_arg, const char *name, int mode, table->db_stat|=HA_READ_ONLY; (void) extra(HA_EXTRA_NO_READCHECK); // Not needed in SQL - if (!(ref= (uchar*) alloc_root(&table->mem_root, ALIGN_SIZE(ref_length)*2))) + /* ref is already allocated for us if we're called from handler::clone() */ + if (!ref && !(ref= (uchar*) alloc_root(&table->mem_root, + ALIGN_SIZE(ref_length)*2))) { close(); error=HA_ERR_OUT_OF_MEM; |