diff options
author | monty@hundin.mysql.fi <> | 2002-08-08 15:24:47 +0300 |
---|---|---|
committer | monty@hundin.mysql.fi <> | 2002-08-08 15:24:47 +0300 |
commit | 087261482a9bbdaa3bc0e26052a719ebdb73644b (patch) | |
tree | e7f4a2013ed3d66e640f6574e62cb7e534a5d77f /sql/sql_base.cc | |
parent | 8be1cdeb89ca59be790d58dc0d43993cdc4f4191 (diff) | |
parent | 3f48e0369b2e49026e9ddd4fddcee68ebe17db1e (diff) | |
download | mariadb-git-087261482a9bbdaa3bc0e26052a719ebdb73644b.tar.gz |
merge with 3.23.52
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 58d251162ff..0f540a3a4fd 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -32,7 +32,7 @@ TABLE *unused_tables; /* Used by mysql_test */ HASH open_cache; /* Used by mysql_test */ static int open_unireg_entry(THD *thd,TABLE *entry,const char *db, - const char *name, const char *alias, bool locked); + const char *name, const char *alias); static void free_cache_entry(TABLE *entry); static void mysql_rm_tmp_tables(void); static key_map get_key_map_from_key_list(TABLE *table, @@ -275,6 +275,16 @@ void intern_close_table(TABLE *table) VOID(closefrm(table)); // close file } +/* + Remove table from the open table cache + + SYNOPSIS + free_cache_entry() + table Table to remove + + NOTE + We need to have a lock on LOCK_open when calling this +*/ static void free_cache_entry(TABLE *table) { @@ -709,7 +719,7 @@ TABLE *reopen_name_locked_table(THD* thd, TABLE_LIST* table_list) key_length=(uint) (strmov(strmov(key,db)+1,table_name)-key)+1; pthread_mutex_lock(&LOCK_open); - if (open_unireg_entry(thd, table, db, table_name, table_name, 1) || + if (open_unireg_entry(thd, table, db, table_name, table_name) || !(table->table_cache_key =memdup_root(&table->mem_root,(char*) key, key_length))) { @@ -842,8 +852,11 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, /* make a new table */ if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME)))) + { + VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(NULL); - if (open_unireg_entry(thd, table,db,table_name,alias,1) || + } + if (open_unireg_entry(thd, table,db,table_name,alias) || !(table->table_cache_key=memdup_root(&table->mem_root,(char*) key, key_length))) { @@ -934,8 +947,7 @@ bool reopen_table(TABLE *table,bool locked) VOID(pthread_mutex_lock(&LOCK_open)); safe_mutex_assert_owner(&LOCK_open); - if (open_unireg_entry(current_thd,&tmp,db,table_name,table->table_name, - locked)) + if (open_unireg_entry(current_thd,&tmp,db,table_name,table->table_name)) goto end; free_io_cache(table); @@ -1176,7 +1188,6 @@ bool wait_for_tables(THD *thd) /* Now we can open all tables without any interference */ thd->proc_info="Reopen tables"; result=reopen_tables(thd,0,0); - } pthread_mutex_unlock(&LOCK_open); thd->proc_info=0; @@ -1241,7 +1252,7 @@ void abort_locked_tables(THD *thd,const char *db, const char *table_name) */ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, - const char *name, const char *alias, bool locked) + const char *name, const char *alias) { char path[FN_REFLEN]; int error; @@ -1261,23 +1272,17 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, table_list.db=(char*) db; table_list.name=(char*) name; table_list.next=0; - if (!locked) - pthread_mutex_lock(&LOCK_open); safe_mutex_assert_owner(&LOCK_open); if ((error=lock_table_name(thd,&table_list))) { if (error < 0) { - if (!locked) - pthread_mutex_unlock(&LOCK_open); goto err; } if (wait_for_locked_table_names(thd,&table_list)) { unlock_table_name(thd,&table_list); - if (!locked) - pthread_mutex_unlock(&LOCK_open); goto err; } } @@ -1307,9 +1312,9 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, thd->net.last_error[0]=0; // Clear error message thd->net.last_errno=0; } - if (locked) - pthread_mutex_lock(&LOCK_open); // Get back original lock + pthread_mutex_lock(&LOCK_open); unlock_table_name(thd,&table_list); + if (error) goto err; } @@ -1368,9 +1373,9 @@ int open_tables(THD *thd,TABLE_LIST *start) } } *prev_table=0; + pthread_mutex_unlock(&LOCK_open); if (found) VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh - pthread_mutex_unlock(&LOCK_open); goto restart; } result= -1; // Fatal error @@ -2207,6 +2212,7 @@ int setup_ftfuncs(THD *thd) return 0; } + int init_ftfuncs(THD *thd, bool no_order) { if (thd->lex.select->ftfunc_list.elements) @@ -2217,9 +2223,7 @@ int init_ftfuncs(THD *thd, bool no_order) thd->proc_info="FULLTEXT initialization"; while ((ifm=li++)) - { ifm->init_search(no_order); - } } return 0; } |