From efc7b884ebaa81416743b98fdbf909189443e70a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 May 2005 11:44:34 +0100 Subject: Bug#7241 - Invalid response when DELETE .. USING and LOCK TABLES used. Only acquire necessary write lock for multi-delete mysql-test/r/lock.result: Test for Bug#7241 mysql-test/t/lock.test: Test for Bug#7241 sql/sql_parse.cc: Bug#7241 Don't acquire write lock on all tables. Make sure to set lock_type on real table_list --- sql/sql_parse.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c5b429ec8fc..2c1723be5d9 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4141,6 +4141,7 @@ void mysql_init_multi_delete(LEX *lex) lex->select_lex.select_limit= lex->unit.select_limit_cnt= HA_POS_ERROR; lex->select_lex.table_list.save_and_clear(&lex->auxilliary_table_list); + lex->lock_option= using_update_log ? TL_READ_NO_INSERT : TL_READ; } @@ -5437,6 +5438,11 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) } walk->lock_type= target_tbl->lock_type; target_tbl->table_list= walk; // Remember corresponding table + if (walk->table_list) + { + target_tbl->table_list= walk->table_list; + walk->table_list->lock_type= walk->lock_type; + } } DBUG_RETURN(0); } -- cgit v1.2.1 From 1a8f64d71557fee049497827a6fbc6da46fed3d8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 24 May 2005 13:38:46 +0100 Subject: Add comments --- sql/sql_parse.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2c1723be5d9..80c68dad247 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1992,6 +1992,10 @@ mysql_execute_command(THD *thd) #endif } #endif /* !HAVE_REPLICATION */ + + /* When subselects or time_zone info is used in a query + * we create a new TABLE_LIST containing all referenced tables + * and set local variable 'tables' to point to this list. */ if ((&lex->select_lex != lex->all_selects_list || lex->time_zone_tables_used) && lex->unit.create_total_list(thd, lex, &tables)) @@ -5438,6 +5442,9 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) } walk->lock_type= target_tbl->lock_type; target_tbl->table_list= walk; // Remember corresponding table + + /* in case of subselects, we need to set lock_type in + * corresponding table in list of all tables */ if (walk->table_list) { target_tbl->table_list= walk->table_list; -- cgit v1.2.1 From 549f56dc3d7fdae2cf7d8ebfbc8a118bf21f12a0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 May 2005 12:56:47 +0300 Subject: Cleanup during code review Faster detection of wrong table names (like PRN) on windows include/my_sys.h: Added check_if_legal_filename() mysys/my_access.c: Added check_if_legal_filename() Set errno if my_access() fails mysys/my_fopen.c: USe check_if_legal_filename() instead of my_access() to detect wrong file names on windows mysys/my_open.c: USe check_if_legal_filename() instead of my_access() to detect wrong file names on windows sql/sql_lex.cc: Portability fix sql/sql_parse.cc: Simple cleanup sql/sql_repl.cc: Cleanup during code review --- sql/sql_parse.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index c5b429ec8fc..05838b340b8 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2819,8 +2819,8 @@ unsent_create_error: TABLE *table= tables->table; /* Skip first table, which is the table we are inserting in */ - lex->select_lex.table_list.first= (byte*) first_local_table->next; - tables= (TABLE_LIST *) lex->select_lex.table_list.first; + select_lex->table_list.first= (byte*) first_local_table->next; + tables= (TABLE_LIST *) select_lex->table_list.first; first_local_table->next= 0; if (!(res= mysql_prepare_insert(thd, tables, first_local_table, @@ -5389,6 +5389,7 @@ int multi_update_precheck(THD *thd, TABLE_LIST *tables) 1 error (message is sent to user) -1 error (message is not sent to user) */ + int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count) { DBUG_ENTER("multi_delete_precheck"); -- cgit v1.2.1 From b36a6032fbf81603f0011b273aa28b523d93573f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 May 2005 16:44:46 +0200 Subject: BUG#9993 2 unexpected warnings when dropping a routine and --skip-grant-tables - Dont perform automatic privilege handling for stored procedures when server is started --skip-grant-tables - Renamed view_skip_grants to skip_grants and added test cases for this mysql-test/t/skip_grants-master.opt: Rename: mysql-test/t/view_skip_grants-master.opt -> mysql-test/t/skip_grants-master.opt mysql-test/r/skip_grants.result: Added test for create and drop procedure with --skip-grant-tables mysql-test/t/skip_grants.test: Added test for create and drop procedure with --skip-grant-tables sql/mysql_priv.h: Make opt_noacl global sql/mysqld.cc: Make opt_noacl global sql/sql_parse.cc: On ly perform automatic privilege add/revoke if server is not started with --skip-grant-tables --- sql/sql_parse.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 47ac8d3afc1..4751e8b6aa7 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3982,7 +3982,7 @@ unsent_create_error: lex->sphead= 0; #ifndef NO_EMBEDDED_ACCESS_CHECKS /* only add privileges if really neccessary */ - if (sp_automatic_privileges && + if (sp_automatic_privileges && !opt_noacl && check_procedure_access(thd, DEFAULT_CREATE_PROC_ACLS, db, name, 1)) { @@ -4247,7 +4247,7 @@ unsent_create_error: if (check_procedure_access(thd, ALTER_PROC_ACL, db, name, 0)) goto error; #ifndef NO_EMBEDDED_ACCESS_CHECKS - if (sp_automatic_privileges && + if (sp_automatic_privileges && !opt_noacl && sp_revoke_privileges(thd, db, name)) { push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, -- cgit v1.2.1 From 8264f9bd5e3b681bb216f655a598fae99a570fc5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 27 May 2005 18:01:09 +0500 Subject: Fix for bug #9992: mysql_next_result hangs on error set net->no_send_error to 0 before execution of each element of multiquery statement to provide the sending of error to client tests/mysql_client_test.c: Fix for bug #9992: mysql_next_result hangs on error test case --- sql/sql_parse.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5a06364cd22..7a3d3073520 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1655,6 +1655,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, while (!thd->killed && thd->lex->found_semicolon && !thd->net.report_error) { char *packet= thd->lex->found_semicolon; + net->no_send_error= 0; /* Multiple queries exits, execute them individually in embedded server - just store them to be executed later -- cgit v1.2.1 From 78422442df581b736862bd090ab3c18d92e7d324 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 30 May 2005 20:54:37 +0400 Subject: Preparatory (and the most problematic) patch for Bug#7306 "the server side preparedStatement error for LIMIT placeholder", which moves all uses of LIMIT clause from PREPARE to OPTIMIZE and later steps. After-review fixes. mysql-test/r/group_min_max.result: Test results fixed for EXPLAINs when using GROUP_MIN_MAX access plan. sql/item_subselect.cc: Move setting of the internal LIMIT used for IN/ALL/ANY/EXISTS subqueries to one place: Item_exists_subselect::fix_length_and_dec(). This implies that unit->select_limit_cnt is not set until the item is fixed. This is OK, as now LIMIT values are not used until JOIN::optimize. sql/mysql_priv.h: setup_tables no longer needs a special flag for the case when it's called from JOIN::reinit() (we don't need to call setup_tables between two executions of a correlated subquery). sql/opt_range.cc: Fix a glitch in GROUP_MIN_MAX access plan: we should use table metadata, not field data, to evaluate max_used_key_length, which is then used for explain. sql/sp.cc: - setup_tables signature changed. sql/sql_base.cc: - setup_tables no longer needs a special mode for subqueries. Unused checks were removed. sql/sql_delete.cc: - setup_tables signature changed sql/sql_help.cc: - setup_tables signature changed sql/sql_insert.cc: - setup_tables signature changed sql/sql_lex.cc: Consolidate setting of internal LIMIT for IN/ALL/ANY/EXISTS subqeries in one place, and hence remove it from st_select_lex::test_limit(). sql/sql_lex.h: Cleanup signature of st_select_lex_unit::init_prepare_fake_select_lex(). sql/sql_load.cc: - setup_tables signature changed sql/sql_olap.cc: - setup_tables signature changed sql/sql_parse.cc: - st_select_lex_unit::set_limit() signature changed sql/sql_select.cc: Move setting of JOIN::select_limit from JOIN::prepare to JOIN::optimize. At prepare, limit is unknown yet. Remove excessive cleanups from JOIN::reinit which were overwriting join->join_tab[i]->table->used_keys. This fixes the bug which was triggered by the change in item_subselect.cc. sql/sql_union.cc: Class st_select_lex_unit was changed to avoid calls to st_select_lex_unit::set_limit from places where it may be unknown. Now unit->select_limit_cnt is set at ::exec(). st_select_lex_unit::init_prepare_fake_select_lex(): - move out set_limit functionality - remove a few lines of dead code. st_select_lex_unit::prepare(): - now we don't call set_limit at the time of prepare, so the value of unit->select_limit_cnt may be unknown here. Use sl->select_limit instead. st_select_lex_unit::exec(): - cleanup - call set_limit explicitly as it has been moved out of init_prepare_fake_select_lex. sql/sql_update.cc: - setup_tables signature changed --- sql/sql_parse.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7078c8e7181..84bf8f76d18 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2777,7 +2777,7 @@ mysql_execute_command(THD *thd) select_result *result; select_lex->options|= SELECT_NO_UNLOCK; - unit->set_limit(select_lex, select_lex); + unit->set_limit(select_lex); if (!(res= open_and_lock_tables(thd, select_tables))) { @@ -3175,7 +3175,7 @@ unsent_create_error: select_lex->options|= SELECT_NO_UNLOCK; select_result *result; - unit->set_limit(select_lex, select_lex); + unit->set_limit(select_lex); if (!(res= open_and_lock_tables(thd, all_tables))) { -- cgit v1.2.1