From 374ea106f5098e4a6ee79f217bf799d181d20a25 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Mar 2003 20:42:49 +0200 Subject: Fixed a deadlock problem when using LOCK TABLE in one thread and DROP TABLE in another sql/lock.cc: Added functions to handle list of table name locks sql/mysql_priv.h: Added functions to handle list of named locks sql/sql_rename.cc: Use new general table name lock functions sql/sql_table.cc: Require table name locks when doing drop table. This fixed a deadlock problem when using LOCK TABLE in one thread and DROP TABLE in another --- sql/sql_table.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sql/sql_table.cc') diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4691c2fd494..2ff7c9c1a75 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -49,7 +49,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) char path[FN_REFLEN]; String wrong_tables; bool some_tables_deleted=0; - uint error; + uint error= 1; db_type table_type; TABLE_LIST *table; DBUG_ENTER("mysql_rm_table"); @@ -66,7 +66,6 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) { my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), tables->real_name); - error = 1; goto err; } while (global_read_lock && ! thd->killed) @@ -76,9 +75,12 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) } + if (lock_table_names(thd, tables)) + goto err; + for (table=tables ; table ; table=table->next) { - char *db=table->db ? table->db : thd->db; + char *db=table->db ? table->db : (thd->db ? thd->db : (char*) ""); if (!close_temporary_table(thd, db, table->real_name)) { some_tables_deleted=1; // Log query @@ -149,9 +151,10 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) } error = 0; + unlock_table_names(thd, tables); + err: pthread_mutex_unlock(&LOCK_open); - VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= 0; -- cgit v1.2.1 From 03b0df9481c6f83ab67c1c79d8c6cc2db0ca9223 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Mar 2003 17:08:42 +0200 Subject: Check for empty table/column names mysql-test/t/create.test: Test for empty table/column name tests/grant.pl: More tests tests/grant.res: More tests --- sql/sql_table.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'sql/sql_table.cc') diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2ff7c9c1a75..f273821c5e0 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -244,6 +244,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, } if (!(sql_field->flags & NOT_NULL_FLAG)) null_fields++; + if (check_column_name(sql_field->field_name)) + { + my_error(ER_WRONG_COLUMN_NAME, MYF(0), sql_field->field_name); + DBUG_RETURN(-1); + } while ((dup_field=it2++) != sql_field) { if (my_strcasecmp(sql_field->field_name, dup_field->field_name) == 0) @@ -688,13 +693,6 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, while ((item=it++)) { create_field *cr_field; - if (strlen(item->name) > NAME_LEN || - check_column_name(item->name)) - { - my_error(ER_WRONG_COLUMN_NAME,MYF(0),item->name); - DBUG_RETURN(0); - } - Field *field=create_tmp_field(&tmp_table,item,item->type(), (Item_result_field***) 0, &tmp_field,0,0); if (!field || -- cgit v1.2.1