From 80c0891588dd8aef2a0e08864b00067ffd9de5ce Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 Apr 2013 09:58:51 +0300 Subject: MDEV-4326 fix. Removed "optimization" which caused preoblems on second execution of PS with string parameter in LIMIT clause. Fixed test_bug43560 to be able to skipp it if connection is UNIX socket. --- sql/sql_prepare.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 0c1c33dcee0..733fc00bf20 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -787,7 +787,7 @@ static bool insert_params_with_log(Prepared_statement *stmt, uchar *null_array, if (param->state == Item_param::NO_VALUE) DBUG_RETURN(1); - if (param->limit_clause_param && param->item_type != Item::INT_ITEM) + if (param->limit_clause_param) { param->set_int(param->val_int(), MY_INT64_NUM_DECIMAL_DIGITS); param->item_type= Item::INT_ITEM; -- cgit v1.2.1 From 682c8a36ca503f53db50628463424f205b609ab0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 May 2013 16:07:13 +0300 Subject: MDEV-4290: Fix agregate function resolution in derived tables (no name resolution over a derived table border) --- sql/item.h | 6 ++++++ sql/item_sum.cc | 21 ++++++++++++++++----- sql/sql_lex.cc | 1 + sql/sql_lex.h | 3 +++ 4 files changed, 26 insertions(+), 5 deletions(-) (limited to 'sql') diff --git a/sql/item.h b/sql/item.h index 1e35c7839de..1938273c261 100644 --- a/sql/item.h +++ b/sql/item.h @@ -353,6 +353,12 @@ struct Name_resolution_context: Sql_alloc { (*error_processor)(thd, error_processor_data); } + st_select_lex *outer_select() + { + return (outer_context ? + outer_context->select_lex : + NULL); + } }; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 3f2020efeb5..489c0f1c23e 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -53,7 +53,15 @@ bool Item_sum::init_sum_func_check(THD *thd) { - if (!thd->lex->allow_sum_func) + SELECT_LEX *curr_sel= thd->lex->current_select; + if (!curr_sel->name_visibility_map) + { + for (SELECT_LEX *sl= curr_sel; sl; sl= sl->context.outer_select()) + { + curr_sel->name_visibility_map|= (1 << sl-> nest_level); + } + } + if (!(thd->lex->allow_sum_func & curr_sel->name_visibility_map)) { my_message(ER_INVALID_GROUP_FUNC_USE, ER(ER_INVALID_GROUP_FUNC_USE), MYF(0)); @@ -124,8 +132,11 @@ bool Item_sum::init_sum_func_check(THD *thd) bool Item_sum::check_sum_func(THD *thd, Item **ref) { + SELECT_LEX *curr_sel= thd->lex->current_select; + nesting_map allow_sum_func= (thd->lex->allow_sum_func & + curr_sel->name_visibility_map); bool invalid= FALSE; - nesting_map allow_sum_func= thd->lex->allow_sum_func; + DBUG_ASSERT(curr_sel->name_visibility_map); // should be set already /* The value of max_arg_level is updated if an argument of the set function contains a column reference resolved against a subquery whose level is @@ -158,7 +169,7 @@ bool Item_sum::check_sum_func(THD *thd, Item **ref) if (!invalid && aggr_level < 0) { aggr_level= nest_level; - aggr_sel= thd->lex->current_select; + aggr_sel= curr_sel; } /* By this moment we either found a subquery where the set function is @@ -295,9 +306,9 @@ bool Item_sum::register_sum_func(THD *thd, Item **ref) { SELECT_LEX *sl; nesting_map allow_sum_func= thd->lex->allow_sum_func; - for (sl= thd->lex->current_select->master_unit()->outer_select() ; + for (sl= thd->lex->current_select->context.outer_select() ; sl && sl->nest_level > max_arg_level; - sl= sl->master_unit()->outer_select() ) + sl= sl->context.outer_select()) { if (aggr_level < 0 && (allow_sum_func & (1 << sl->nest_level))) { diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 5bacb675644..ab50ad99c28 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1690,6 +1690,7 @@ void st_select_lex::init_select() merged_into= 0; m_non_agg_field_used= false; m_agg_func_used= false; + name_visibility_map= 0; } /* diff --git a/sql/sql_lex.h b/sql/sql_lex.h index a3240d3bcab..4b4496a7df8 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -783,6 +783,9 @@ public: */ List *prev_join_using; + /* namp of nesting SELECT visibility (for aggregate functions check) */ + nesting_map name_visibility_map; + void init_query(); void init_select(); st_select_lex_unit* master_unit(); -- cgit v1.2.1 From 4a0f2563d3d1747a4704e6241380071efbeb3882 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 8 May 2013 14:32:32 +0200 Subject: MDEV-4462 mysqld gets SIGFPE when mysql.user table is empty avoid divison by zero --- sql/sql_acl.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sql') diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 29922aa5321..9983c52abb5 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -7367,6 +7367,12 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio, Security_context *sctx) cs->coll->hash_sort(cs, (uchar*) sctx->user, strlen(sctx->user), &nr1, &nr2); pthread_mutex_lock(&acl_cache->lock); + if (!acl_users.elements) + { + pthread_mutex_unlock(&acl_cache->lock); + login_failed_error(mpvio->thd); + return 1; + } uint i= nr1 % acl_users.elements; ACL_USER *acl_user_tmp= dynamic_element(&acl_users, i, ACL_USER*); mpvio->acl_user= acl_user_tmp->copy(mpvio->thd->mem_root); -- cgit v1.2.1 From 4e9bf37f1f70ddc0c901760e4302dd4040a2730c Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Sat, 11 May 2013 15:55:11 +0300 Subject: MDEV-4280: Assertion `empty_size == empty_size_on_page' failure in ma_blockrec.c or ER_NOT_KEYFILE on query with DISTINCT and GROUP BY This could happen when using Aria for internal temporary files (default case) and using DISTINCT. _ma_scan_restore_block_record() didn't work correctly if there was rows inserted, updated or deleted on the handler between calls to _ma_scan_remember_block_record() and _ma_scan_restore_block_record(). The effect was that some DISTINCT queries that used remove_dup_with_compare() could fail. .bzrignore: Ignore sql_yacc.hh mysql-test/suite/maria/r/distinct.result: Test case for MDEV-4280 mysql-test/suite/maria/t/distinct.test: Test case for MDEV-4280 mysql-test/t/mysql.test: Fixed test suite (we could get error -1 in some cases) sql/sql_select.cc: Break loop if restart_rnd_next() gives an error storage/maria/ha_maria.cc: scan_restore_pos() can return disk fault error. storage/maria/ma_blockrec.c: _ma_scan_remember_block_record() did incorrectly update scan.dir instead of scan_save.dir . _ma_scan_restore_block_record() didn't work correctly if there was rows inserted,updated or deleted on the handler between calls to _ma_scan_remember_block_record() and _ma_scan_restore_block_record(). Fixed by adding counters for row changes and reading the current scan page if changes had been made. storage/maria/ma_blockrec.h: scan_restore_pos() can return disk fault error. storage/maria/ma_delete.c: Increment row_changes storage/maria/ma_scan.c: scan_restore_pos() can return disk fault error. storage/maria/ma_update.c: Increment row_changes storage/maria/ma_write.c: Increment row_changes storage/maria/maria_def.h: scan_restore_pos() can return disk fault error. --- sql/sql_select.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 24ca1ab0174..b76e8afac36 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -14656,7 +14656,8 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, if (!found) break; // End of file /* Restart search on saved row */ - error=file->restart_rnd_next(record); + if ((error= file->restart_rnd_next(record))) + goto err; } file->extra(HA_EXTRA_NO_CACHE); -- cgit v1.2.1