diff options
author | unknown <istruewing@chilla.local> | 2007-04-27 19:09:39 +0200 |
---|---|---|
committer | unknown <istruewing@chilla.local> | 2007-04-27 19:09:39 +0200 |
commit | 2f664e46c69d5edf2b76763c872b71b956d45adc (patch) | |
tree | bcce20c17922057e22634534a05e0f8d72242d4a /sql/table.cc | |
parent | 7148d00222bfd2dc6eb698622b85729ff5a86520 (diff) | |
parent | 6cc76eb61cb190d5ec410ffe3bd2e064e7951e44 (diff) | |
download | mariadb-git-2f664e46c69d5edf2b76763c872b71b956d45adc.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.1-engines
into chilla.local:/home/mydev/mysql-5.1-wl2936-two
client/mysql.cc:
Auto merged
client/mysqltest.c:
Auto merged
include/my_global.h:
Auto merged
include/my_sys.h:
Auto merged
mysql-test/lib/mtr_cases.pl:
Auto merged
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/r/ndb_dd_basic.result:
Auto merged
mysql-test/r/variables.result:
Auto merged
mysql-test/t/ndb_dd_basic.test:
Auto merged
mysql-test/t/variables.test:
Auto merged
mysys/hash.c:
Auto merged
sql/event_queue.cc:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/ha_partition.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_sum.cc:
Auto merged
sql/log.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/opt_range.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_cache.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_connect.cc:
Auto merged
sql/sql_delete.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_lex.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_plugin.cc:
Auto merged
sql/sql_repl.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/structs.h:
Auto merged
sql/table.cc:
Auto merged
storage/innobase/handler/ha_innodb.cc:
Auto merged
storage/innobase/handler/ha_innodb.h:
Auto merged
include/typelib.h:
WL#2936 - Falcon & MySQL plugin interface: server variables
Manual merge
mysys/typelib.c:
WL#2936 - Falcon & MySQL plugin interface: server variables
Manual merge
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 65 |
1 files changed, 50 insertions, 15 deletions
diff --git a/sql/table.cc b/sql/table.cc index 39bdbb4cbb9..f5fb3b0bddd 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -237,6 +237,9 @@ void free_table_share(TABLE_SHARE *share) pthread_cond_destroy(&share->cond); } hash_free(&share->name_hash); + + plugin_unlock(NULL, share->db_plugin); + share->db_plugin= NULL; /* We must copy mem_root from share because share is allocated through it */ memcpy((char*) &mem_root, (char*) &share->mem_root, sizeof(mem_root)); @@ -500,7 +503,15 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, DBUG_PRINT("info", ("default_part_db_type = %u", head[61])); #endif legacy_db_type= (enum legacy_db_type) (uint) *(head+3); - share->db_type= ha_checktype(thd, legacy_db_type, 0, 0); + DBUG_ASSERT(share->db_plugin == NULL); + /* + if the storage engine is dynamic, no point in resolving it by its + dynamically allocated legacy_db_type. We will resolve it later by name. + */ + if (legacy_db_type > DB_TYPE_UNKNOWN && + legacy_db_type < DB_TYPE_FIRST_DYNAMIC) + share->db_plugin= ha_lock_engine(NULL, + ha_checktype(thd, legacy_db_type, 0, 0)); share->db_create_options= db_create_options= uint2korr(head+30); share->db_options_in_use= share->db_create_options; share->mysql_version= uint4korr(head+51); @@ -659,24 +670,47 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, { uint str_db_type_length= uint2korr(next_chunk); LEX_STRING name= { next_chunk + 2, str_db_type_length }; - handlerton *tmp_db_type= ha_resolve_by_name(thd, &name); - if (tmp_db_type != NULL) + plugin_ref tmp_plugin= ha_resolve_by_name(thd, &name); + if (tmp_plugin != NULL && !plugin_equals(tmp_plugin, share->db_plugin)) { - share->db_type= tmp_db_type; + if (legacy_db_type > DB_TYPE_UNKNOWN && + legacy_db_type < DB_TYPE_FIRST_DYNAMIC && + legacy_db_type != ha_legacy_type( + plugin_data(tmp_plugin, handlerton *))) + { + /* bad file, legacy_db_type did not match the name */ + my_free(buff, MYF(0)); + goto err; + } + /* + tmp_plugin is locked with a local lock. + we unlock the old value of share->db_plugin before + replacing it with a globally locked version of tmp_plugin + */ + plugin_unlock(NULL, share->db_plugin); + share->db_plugin= my_plugin_lock(NULL, &tmp_plugin); DBUG_PRINT("info", ("setting dbtype to '%.*s' (%d)", str_db_type_length, next_chunk + 2, - ha_legacy_type(share->db_type))); + ha_legacy_type(share->db_type()))); } #ifdef WITH_PARTITION_STORAGE_ENGINE else { - if (!strncmp(next_chunk + 2, "partition", str_db_type_length)) + LEX_STRING pname= { C_STRING_WITH_LEN( "partition" ) }; + if (str_db_type_length == pname.length && + !strncmp(next_chunk + 2, pname.str, pname.length)) { - /* Use partition handler */ - share->db_type= partition_hton; + /* + Use partition handler + tmp_plugin is locked with a local lock. + we unlock the old value of share->db_plugin before + replacing it with a globally locked version of tmp_plugin + */ + plugin_unlock(NULL, share->db_plugin); + share->db_plugin= ha_lock_engine(NULL, partition_hton); DBUG_PRINT("info", ("setting dbtype to '%.*s' (%d)", str_db_type_length, next_chunk + 2, - ha_legacy_type(share->db_type))); + ha_legacy_type(share->db_type()))); } } #endif @@ -742,7 +776,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, } parser_name.str= next_chunk; parser_name.length= strlen(next_chunk); - keyinfo->parser= plugin_lock(&parser_name, MYSQL_FTPARSER_PLUGIN); + keyinfo->parser= my_plugin_lock_by_name(NULL, &parser_name, + MYSQL_FTPARSER_PLUGIN); if (! keyinfo->parser) { my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), parser_name.str); @@ -858,7 +893,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, /* Allocate handler */ if (!(handler_file= get_new_handler(share, thd->mem_root, - share->db_type))) + share->db_type()))) goto err; record= (char*) share->default_values-1; /* Fieldstart = 1 */ @@ -1392,7 +1427,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, /* Allocate handler */ if (!(outparam->file= get_new_handler(share, &outparam->mem_root, - share->db_type))) + share->db_type()))) goto err; error= 4; @@ -1676,7 +1711,7 @@ int closefrm(register TABLE *table, bool free_share) { if (key_info->flags & HA_USES_PARSER) { - plugin_unlock(key_info->parser); + plugin_unlock(NULL, key_info->parser); key_info->flags= 0; } } @@ -1887,10 +1922,10 @@ void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg) handler *file= 0; const char *datext= ""; - if (share->db_type != NULL) + if (share->db_type() != NULL) { if ((file= get_new_handler(share, current_thd->mem_root, - share->db_type))) + share->db_type()))) { if (!(datext= *file->bas_ext())) datext= ""; |