diff options
author | Guilhem Bichot <guilhem@mysql.com> | 2009-04-01 11:34:52 +0200 |
---|---|---|
committer | Guilhem Bichot <guilhem@mysql.com> | 2009-04-01 11:34:52 +0200 |
commit | c71aae73f6f864c97cf17b3e872346666b871c3f (patch) | |
tree | 4895816aee1a0fcef08daa0f68bf1b1fe9aa2b5a /sql/handler.cc | |
parent | 3c59ba32ab9cca29e01bd8dd2130af83ead8bde0 (diff) | |
parent | 7ca1ebd83a1a7d291593be7a94f5a37298dfc863 (diff) | |
download | mariadb-git-c71aae73f6f864c97cf17b3e872346666b871c3f.tar.gz |
merge of 5.1-main into 5.1-maria. MyISAM changes are propagated to Maria except
those of davi.arnaut@sun.com-20090219210935-9vilvcisyyieffxl (TODO).
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index ca04398aa35..1804eb5fbd3 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -429,14 +429,11 @@ int ha_initialize_handlerton(st_plugin_int *plugin) MYF(MY_WME | MY_ZEROFILL)); /* Historical Requirement */ plugin->data= hton; // shortcut for the future - if (plugin->plugin->init) + if (plugin->plugin->init && plugin->plugin->init(hton)) { - if (plugin->plugin->init(hton)) - { - sql_print_error("Plugin '%s' init function returned error.", - plugin->name.str); - goto err; - } + sql_print_error("Plugin '%s' init function returned error.", + plugin->name.str); + goto err; } /* @@ -463,17 +460,13 @@ int ha_initialize_handlerton(st_plugin_int *plugin) if (idx == (int) DB_TYPE_DEFAULT) { sql_print_warning("Too many storage engines!"); - DBUG_RETURN(1); + goto err_deinit; } if (hton->db_type != DB_TYPE_UNKNOWN) sql_print_warning("Storage engine '%s' has conflicting typecode. " "Assigning value %d.", plugin->plugin->name, idx); hton->db_type= (enum legacy_db_type) idx; } - installed_htons[hton->db_type]= hton; - tmp= hton->savepoint_offset; - hton->savepoint_offset= savepoint_alloc_size; - savepoint_alloc_size+= tmp; /* In case a plugin is uninstalled and re-installed later, it should @@ -494,11 +487,14 @@ int ha_initialize_handlerton(st_plugin_int *plugin) { sql_print_error("Too many plugins loaded. Limit is %lu. " "Failed on '%s'", (ulong) MAX_HA, plugin->name.str); - goto err; + goto err_deinit; } hton->slot= total_ha++; } - + installed_htons[hton->db_type]= hton; + tmp= hton->savepoint_offset; + hton->savepoint_offset= savepoint_alloc_size; + savepoint_alloc_size+= tmp; hton2plugin[hton->slot]=plugin; if (hton->prepare) total_ha_2pc++; @@ -530,7 +526,18 @@ int ha_initialize_handlerton(st_plugin_int *plugin) }; DBUG_RETURN(0); + +err_deinit: + /* + Let plugin do its inner deinitialization as plugin->init() + was successfully called before. + */ + if (plugin->plugin->deinit) + (void) plugin->plugin->deinit(NULL); + err: + my_free((uchar*) hton, MYF(0)); + plugin->data= NULL; DBUG_RETURN(1); } @@ -2928,7 +2935,7 @@ uint handler::get_dup_key(int error) if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOREIGN_DUPLICATE_KEY || error == HA_ERR_FOUND_DUPP_UNIQUE || error == HA_ERR_NULL_IN_SPATIAL || error == HA_ERR_DROP_INDEX_FK) - info(HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK); + table->file->info(HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK); DBUG_RETURN(table->file->errkey); } |