From a9b31b0814b02e65930209b1a90a8293b2ca6619 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Fri, 9 Dec 2022 11:50:05 +0700 Subject: MDEV-29988: (revert) Major performance regression with 10.6.11 Reverted changed in server code introduced by the commit bd9274faa469cc164099c7497c18a0e0a9b1184b. Tests from this commit are retained. --- sql/item_cmpfunc.cc | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index b7b0c981c2d..fe6b8feb4de 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -442,18 +442,9 @@ bool Item_func::setup_args_and_comparator(THD *thd, Arg_comparator *cmp) if (args[0]->cmp_type() == STRING_RESULT && args[1]->cmp_type() == STRING_RESULT) { - Query_arena *arena, backup; - arena= thd->activate_stmt_arena_if_needed(&backup); - DTCollation tmp; - bool ret= agg_arg_charsets_for_comparison(tmp, args, 2); - - if (arena) - thd->restore_active_arena(arena, &backup); - - if (ret) - return ret; - + if (agg_arg_charsets_for_comparison(tmp, args, 2)) + return true; cmp->m_compare_collation= tmp.collation; } // Convert constants when compared to int/year field -- cgit v1.2.1 From 37a316c01d778a62a056d5d20110ef18bb55975e Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Fri, 9 Dec 2022 21:10:25 +0700 Subject: MDEV-29988: Major performance regression with 10.6.11 The idea is to put Item_direct_ref_to_item as a transparent and permanent wrapper before a string which require conversion. So that Item_direct_ref_to_item would be the only place where the pointer to the string item is stored, this pointer can be changed and restored during PS execution as needed. And if any permanent (subquery) optimization would need a pointer to the item, it'll use a pointer to the Item_direct_ref_to_item - which is a permanent item and won't go away. --- mysql-test/main/ps.result | 15 ++++++++ mysql-test/main/ps.test | 35 ++++++++++++++++++ sql/item.cc | 80 +++++++++++++++++++++++++++++++++------- sql/item.h | 93 +++++++++++++++++++++++++++++++++++++++++++++++ sql/sql_tvc.cc | 5 +-- sql/table.cc | 5 ++- 6 files changed, 215 insertions(+), 18 deletions(-) diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index 26c41526389..16700fd83d3 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -5700,3 +5700,18 @@ EXECUTE stmt USING 'd'; EXECUTE stmt USING 'd'; 300 DROP TABLE t1, t2, t3; +set @@max_session_mem_used=default; +create table t (a varchar(10)) character set utf8; +insert into t values (''); +prepare stmt from "select 1 from t where a = ?"; +set @@max_session_mem_used=(select memory_used*2 from information_schema.processlist where id=connection_id()); +deallocate prepare stmt; +drop table t; +set @@max_session_mem_used=default; +create table t (a varchar(10)) character set utf8; +insert into t values (''); +prepare stmt from "select 1 from t where a = 'a'"; +set @@max_session_mem_used=(select memory_used*2 from information_schema.processlist where id=connection_id()); +deallocate prepare stmt; +drop table t; +set @@max_session_mem_used=default; diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test index 2ccfac3c119..87cae7211a4 100644 --- a/mysql-test/main/ps.test +++ b/mysql-test/main/ps.test @@ -5116,3 +5116,38 @@ EXECUTE stmt USING 'b'; EXECUTE stmt USING 'd'; EXECUTE stmt USING 'd'; DROP TABLE t1, t2, t3; + +set @@max_session_mem_used=default; +create table t (a varchar(10)) character set utf8; +insert into t values (''); +prepare stmt from "select 1 from t where a = ?"; +set @@max_session_mem_used=(select memory_used*2 from information_schema.processlist where id=connection_id()); +let $run= 1000; +disable_result_log; +disable_query_log; +while ($run) { + execute stmt using repeat('x',10000); + dec $run; +} +enable_result_log; +enable_query_log; +deallocate prepare stmt; +drop table t; +set @@max_session_mem_used=default; + +create table t (a varchar(10)) character set utf8; +insert into t values (''); +prepare stmt from "select 1 from t where a = 'a'"; +set @@max_session_mem_used=(select memory_used*2 from information_schema.processlist where id=connection_id()); +let $run= 1000; +disable_result_log; +disable_query_log; +while ($run) { + execute stmt; + dec $run; +} +enable_result_log; +enable_query_log; +deallocate prepare stmt; +drop table t; +set @@max_session_mem_used=default; diff --git a/sql/item.cc b/sql/item.cc index 757f09dec01..03e6ffb5715 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -41,6 +41,7 @@ // find_item_in_list, // RESOLVED_AGAINST_ALIAS, ... #include "sql_expression_cache.h" +#include "sql_lex.h" // empty_clex_str const String my_null_string("NULL", 4, default_charset_info); const String my_default_string("DEFAULT", 7, default_charset_info); @@ -1401,13 +1402,11 @@ Item *Item_cache::safe_charset_converter(THD *thd, CHARSET_INFO *tocs) Item *conv= example->safe_charset_converter(thd, tocs); if (conv == example) return this; - Item_cache *cache; - if (!conv || conv->fix_fields(thd, (Item **) NULL) || - unlikely(!(cache= new (thd->mem_root) Item_cache_str(thd, conv)))) + if (!conv || conv->fix_fields(thd, (Item **) NULL)) return NULL; // Safe conversion is not possible, or OEM - cache->setup(thd, conv); - cache->fixed= false; // Make Item::fix_fields() happy - return cache; + setup(thd, conv); + thd->change_item_tree(&example, conv); + return this; } @@ -2782,7 +2781,6 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll, safe_args[1]= args[item_sep]; } - bool res= FALSE; uint i; DBUG_ASSERT(!thd->stmt_arena->is_stmt_prepare()); @@ -2802,19 +2800,31 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll, args[item_sep]= safe_args[1]; } my_coll_agg_error(args, nargs, fname, item_sep); - res= TRUE; - break; // we cannot return here, we need to restore "arena". + return TRUE; } - thd->change_item_tree(arg, conv); - if (conv->fix_fields(thd, arg)) + return TRUE; + + Query_arena *arena, backup; + arena= thd->activate_stmt_arena_if_needed(&backup); + if (arena) { - res= TRUE; - break; // we cannot return here, we need to restore "arena". + Item_direct_ref_to_item *ref= + new (thd->mem_root) Item_direct_ref_to_item(thd, *arg); + if ((ref == NULL) || ref->fix_fields(thd, (Item **)&ref)) + { + thd->restore_active_arena(arena, &backup); + return TRUE; + } + *arg= ref; + thd->restore_active_arena(arena, &backup); + ref->change_item(thd, conv); } + else + thd->change_item_tree(arg, conv); } - return res; + return FALSE; } @@ -10952,3 +10962,45 @@ void Item::register_in(THD *thd) next= thd->free_list; thd->free_list= this; } + + +Item_direct_ref_to_item::Item_direct_ref_to_item(THD *thd, Item *item) +: Item_direct_ref(thd, NULL, NULL, "", &empty_clex_str, FALSE) +{ + m_item= item; + ref= (Item**)&m_item; +} + +bool Item_direct_ref_to_item::fix_fields(THD *thd, Item **) +{ + DBUG_ASSERT(m_item != NULL); + if (m_item->fix_fields_if_needed_for_scalar(thd, ref)) + return TRUE; + set_properties(); + return FALSE; +} + +void Item_direct_ref_to_item::print(String *str, enum_query_type query_type) +{ + m_item->print(str, query_type); +} + +Item *Item_direct_ref_to_item::safe_charset_converter(THD *thd, + CHARSET_INFO *tocs) +{ + Item *conv= m_item->safe_charset_converter(thd, tocs); + if (conv != m_item) + { + if (conv== NULL || conv->fix_fields(thd, &conv)) + return NULL; + change_item(thd, conv); + } + return this; +} + +void Item_direct_ref_to_item::change_item(THD *thd, Item *i) +{ + DBUG_ASSERT(i->fixed); + thd->change_item_tree(ref, i); + set_properties(); +} diff --git a/sql/item.h b/sql/item.h index ec87a3fb812..e0bcaf41eac 100644 --- a/sql/item.h +++ b/sql/item.h @@ -6890,4 +6890,97 @@ inline void Virtual_column_info::print(String* str) expr->print_for_table_def(str); } +class Item_direct_ref_to_item : public Item_direct_ref +{ + Item *m_item; +public: + Item_direct_ref_to_item(THD *thd, Item *item); + + void change_item(THD *thd, Item *); + + bool fix_fields(THD *thd, Item **it); + + void print(String *str, enum_query_type query_type); + + Item *safe_charset_converter(THD *thd, CHARSET_INFO *tocs); + Item *get_tmp_table_item(THD *thd) + { return m_item->get_tmp_table_item(thd); } + Item *get_copy(THD *thd) + { return m_item->get_copy(thd); } + COND *build_equal_items(THD *thd, COND_EQUAL *inherited, + bool link_item_fields, + COND_EQUAL **cond_equal_ref) + { + return m_item->build_equal_items(thd, inherited, link_item_fields, + cond_equal_ref); + } + const char *full_name() const { return m_item->full_name(); } + void make_send_field(THD *thd, Send_field *field) + { m_item->make_send_field(thd, field); } + bool eq(const Item *item, bool binary_cmp) const + { + Item *it= ((Item *) item)->real_item(); + return m_item->eq(it, binary_cmp); + } + void fix_after_pullout(st_select_lex *new_parent, Item **refptr, bool merge) + { m_item->fix_after_pullout(new_parent, &m_item, merge); } + void save_val(Field *to) + { return m_item->save_val(to); } + void save_result(Field *to) + { return m_item->save_result(to); } + int save_in_field(Field *to, bool no_conversions) + { return m_item->save_in_field(to, no_conversions); } + const Type_handler *type_handler() const { return m_item->type_handler(); } + table_map used_tables() const { return m_item->used_tables(); } + void update_used_tables() + { m_item->update_used_tables(); } + bool const_item() const { return m_item->const_item(); } + table_map not_null_tables() const { return m_item->not_null_tables(); } + bool walk(Item_processor processor, bool walk_subquery, void *arg) + { + return m_item->walk(processor, walk_subquery, arg) || + (this->*processor)(arg); + } + bool enumerate_field_refs_processor(void *arg) + { return m_item->enumerate_field_refs_processor(arg); } + Item_field *field_for_view_update() + { return m_item->field_for_view_update(); } + + /* Row emulation: forwarding of ROW-related calls to orig_item */ + uint cols() const + { return m_item->cols(); } + Item* element_index(uint i) + { return this; } + Item** addr(uint i) + { return &m_item; } + bool check_cols(uint c) + { return Item::check_cols(c); } + bool null_inside() + { return m_item->null_inside(); } + void bring_value() + {} + + Item_equal *get_item_equal() { return m_item->get_item_equal(); } + void set_item_equal(Item_equal *item_eq) { m_item->set_item_equal(item_eq); } + Item_equal *find_item_equal(COND_EQUAL *cond_equal) + { return m_item->find_item_equal(cond_equal); } + Item *propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond) + { return m_item->propagate_equal_fields(thd, ctx, cond); } + Item *replace_equal_field(THD *thd, uchar *arg) + { return m_item->replace_equal_field(thd, arg); } + + bool excl_dep_on_table(table_map tab_map) + { return m_item->excl_dep_on_table(tab_map); } + bool excl_dep_on_grouping_fields(st_select_lex *sel) + { return m_item->excl_dep_on_grouping_fields(sel); } + bool is_expensive() { return m_item->is_expensive(); } + Item* build_clone(THD *thd) { return get_copy(thd); } + + /* + This processor states that this is safe for virtual columns + (because this Item transparency) + */ + bool check_vcol_func_processor(void *arg) { return FALSE;} +}; + #endif /* SQL_ITEM_INCLUDED */ diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index 43c25db5097..b2e9df2d745 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -539,7 +539,7 @@ bool Item_func_in::create_value_list_for_tvc(THD *thd, if (is_list_of_rows) { - Item_row *row_list= (Item_row *)(args[i]->build_clone(thd)); + Item_row *row_list= (Item_row *)(args[i]); if (!row_list) return true; @@ -564,8 +564,7 @@ bool Item_func_in::create_value_list_for_tvc(THD *thd, sprintf(col_name, "_col_%i", 1); args[i]->set_name(thd, col_name, strlen(col_name), thd->charset()); } - Item *arg_clone= args[i]->build_clone(thd); - if (!arg_clone || tvc_value->push_back(arg_clone)) + if (tvc_value->push_back(args[i])) return true; } diff --git a/sql/table.cc b/sql/table.cc index ec49241dd7a..a1ee2f3b8b3 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3010,7 +3010,7 @@ class Vcol_expr_context bool inited; THD *thd; TABLE *table; - Query_arena backup_arena; + Query_arena backup_arena, *stmt_arena; table_map old_map; Security_context *save_security_ctx; sql_mode_t save_sql_mode; @@ -3020,6 +3020,7 @@ public: inited(false), thd(_thd), table(_table), + stmt_arena(thd->stmt_arena), old_map(table->map), save_security_ctx(thd->security_ctx), save_sql_mode(thd->variables.sql_mode) {} @@ -3040,6 +3041,7 @@ bool Vcol_expr_context::init() thd->security_ctx= tl->security_ctx; thd->set_n_backup_active_arena(table->expr_arena, &backup_arena); + thd->stmt_arena= thd; inited= true; return false; @@ -3053,6 +3055,7 @@ Vcol_expr_context::~Vcol_expr_context() thd->security_ctx= save_security_ctx; thd->restore_active_arena(table->expr_arena, &backup_arena); thd->variables.sql_mode= save_sql_mode; + thd->stmt_arena= stmt_arena; } -- cgit v1.2.1 From 60f646e2f3fefa7909538ca8982393b74a9bf5f2 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 14 Dec 2022 14:36:27 +0100 Subject: MDEV-29988: (spider fix) Major performance regression with 10.6.11 Make Item_direct_ref_to_item transparent for Spider --- storage/spider/spd_db_conn.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 5a8c7492654..6e377b482a4 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -8853,6 +8853,12 @@ int spider_db_print_item_type( DBUG_ENTER("spider_db_print_item_type"); DBUG_PRINT("info",("spider COND type=%d", item->type())); + if (item->type() == Item::REF_ITEM && + ((Item_ref*)item)->ref_type() == Item_ref::DIRECT_REF) + { + item= item->real_item(); + DBUG_PRINT("info",("spider new COND type=%d", item->type())); + } switch (item->type()) { case Item::FUNC_ITEM: -- cgit v1.2.1 From 908c48a34dd94350c87c89a32937bf32399c3ab4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 18 Dec 2022 14:30:36 +0100 Subject: fixes for json.json_table and main.func_json in --ps --- sql/item.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/item.cc b/sql/item.cc index 03e6ffb5715..02220fd56bd 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2468,7 +2468,8 @@ void Item::split_sum_func2(THD *thd, Ref_ptr_array ref_pointer_array, if (unlikely((!(used_tables() & ~PARAM_TABLE_BIT) || (type() == REF_ITEM && - ((Item_ref*)this)->ref_type() != Item_ref::VIEW_REF)))) + ((Item_ref*)this)->ref_type() != Item_ref::VIEW_REF && + ((Item_ref*)this)->ref_type() != Item_ref::DIRECT_REF)))) return; } -- cgit v1.2.1 From 21223c0461455b4175bae91aee7e3525a51c6d70 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 18 Dec 2022 16:30:26 +0100 Subject: MDEV-29988 group by fix --- mysql-test/main/func_group.result | 11 ++++++++++- mysql-test/main/func_group.test | 12 ++++++++---- sql/item.h | 5 +++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/func_group.result b/mysql-test/main/func_group.result index 0f80d14b603..6617d21a197 100644 --- a/mysql-test/main/func_group.result +++ b/mysql-test/main/func_group.result @@ -1,4 +1,3 @@ -drop table if exists t1,t2,t3,t4,t5,t6; set @sav_dpi= @@div_precision_increment; set div_precision_increment= 5; show variables like 'div_precision_increment'; @@ -2566,5 +2565,15 @@ stddev_samp(i) stddev_pop(i) stddev(i) std(i) drop view v1; drop table t1; # +# MDEV-29988: Major performance regression with 10.6.11 +# +create table t1 (a varchar(10) charset utf8mb4, b int, c int); +insert t1 values (1,2,3),(4,5,6),(1,7,8); +select concat(a,":",group_concat(b)) from t1 group by a; +concat(a,":",group_concat(b)) +1:2,7 +4:5 +drop table t1; +# # End of 10.3 tests # diff --git a/mysql-test/main/func_group.test b/mysql-test/main/func_group.test index 6b3a15fd45e..5693940dda6 100644 --- a/mysql-test/main/func_group.test +++ b/mysql-test/main/func_group.test @@ -2,10 +2,6 @@ # simple test of all group functions # ---disable_warnings -drop table if exists t1,t2,t3,t4,t5,t6; ---enable_warnings - set @sav_dpi= @@div_precision_increment; set div_precision_increment= 5; show variables like 'div_precision_increment'; @@ -1800,6 +1796,14 @@ select * from v1; drop view v1; drop table t1; +--echo # +--echo # MDEV-29988: Major performance regression with 10.6.11 +--echo # +create table t1 (a varchar(10) charset utf8mb4, b int, c int); +insert t1 values (1,2,3),(4,5,6),(1,7,8); +select concat(a,":",group_concat(b)) from t1 group by a; +drop table t1; + --echo # --echo # End of 10.3 tests --echo # diff --git a/sql/item.h b/sql/item.h index e0bcaf41eac..35428b30252 100644 --- a/sql/item.h +++ b/sql/item.h @@ -6976,6 +6976,11 @@ public: bool is_expensive() { return m_item->is_expensive(); } Item* build_clone(THD *thd) { return get_copy(thd); } + void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, + List &fields, uint flags) + { + m_item->split_sum_func(thd, ref_pointer_array, fields, flags); + } /* This processor states that this is safe for virtual columns (because this Item transparency) -- cgit v1.2.1 From e51a1d6fc0c105d56c6f05efb3d9fd05b7e4f22f Mon Sep 17 00:00:00 2001 From: Andrew Hutchings Date: Tue, 3 Jan 2023 10:48:57 +1100 Subject: MDEV-30329: mariadb-service-convert resets systemd service to default User=root If mariadb-service-convert is run and the user variable is unset then this sets `User=` in `[Service]`, which then tries to run mariadb as root, which in-turn fails. This only happens when mysqld_safe is missing which is all the time now. So don't set `User=` if there is no user variable. Reviewer: Sergei Golubchik (in PR #2382) --- scripts/mariadb-service-convert | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mariadb-service-convert b/scripts/mariadb-service-convert index 38043733554..ade07e9a336 100755 --- a/scripts/mariadb-service-convert +++ b/scripts/mariadb-service-convert @@ -36,7 +36,7 @@ echo '[Service]' echo -if [[ ( "$user" != "root" && "$user" != "mysql" ) || "${SET_USER}" == 1 ]]; then +if [[ ( ! -z "$user" && "$user" != "root" && "$user" != "mysql" ) || "${SET_USER}" == 1 ]]; then echo User=$user fi -- cgit v1.2.1 From 758c24dae2c1e03f6c0837028e7e7f931497a9b5 Mon Sep 17 00:00:00 2001 From: lilinjie Date: Wed, 4 Jan 2023 18:32:54 +0800 Subject: fix typos Signed-off-by: lilinjie --- sql/field.cc | 2 +- sql/field.h | 2 +- sql/sp_head.cc | 4 ++-- sql/sql_yacc.yy | 2 +- sql/sql_yacc_ora.yy | 2 +- storage/connect/tabfmt.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index de92d1dea94..5fc033c0280 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -11287,7 +11287,7 @@ Create_field *Create_field::clone(MEM_ROOT *mem_root) const } /** - Return true if default is an expression that must be saved explicitely + Return true if default is an expression that must be saved explicitly This is: - Not basic constants diff --git a/sql/field.h b/sql/field.h index ce15184ea1d..f1087332087 100644 --- a/sql/field.h +++ b/sql/field.h @@ -4600,7 +4600,7 @@ public: return make_field(share, mem_root, (uchar *) 0, (uchar *) "", 0, field_name_arg); } - /* Return true if default is an expression that must be saved explicitely */ + /* Return true if default is an expression that must be saved explicitly */ bool has_default_expression(); bool has_default_now_unireg_check() const diff --git a/sql/sp_head.cc b/sql/sp_head.cc index df4ef8522ba..160e66f7bcd 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -2366,7 +2366,7 @@ sp_head::execute_procedure(THD *thd, List *args) Disable slow log if: - Slow logging is enabled (no change needed) - This is a normal SP (not event log) - - If we have not explicitely disabled logging of SP + - If we have not explicitly disabled logging of SP */ if (save_enable_slow_log && ((!(m_flags & LOG_SLOW_STATEMENTS) && @@ -2380,7 +2380,7 @@ sp_head::execute_procedure(THD *thd, List *args) Disable general log if: - If general log is enabled (no change needed) - This is a normal SP (not event log) - - If we have not explicitely disabled logging of SP + - If we have not explicitly disabled logging of SP */ if (!(thd->variables.option_bits & OPTION_LOG_OFF) && (!(m_flags & LOG_GENERAL_LOG) && diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 73922ceb4f4..3025d93de0f 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1750,7 +1750,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); TRANSACTION can be a non-empty history unit, or can be an identifier in bit_expr. - In the grammar below we use %prec to explicitely tell Bison to go + In the grammar below we use %prec to explicitly tell Bison to go through the empty branch in the optional rule only when the lookahead token does not belong to a small set of selected tokens. diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index 3a1b0c0e077..df90ba6c634 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -1144,7 +1144,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); TRANSACTION can be a non-empty history unit, or can be an identifier in bit_expr. - In the grammar below we use %prec to explicitely tell Bison to go + In the grammar below we use %prec to explicitly tell Bison to go through the empty branch in the optional rule only when the lookahead token does not belong to a small set of selected tokens. diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index 56d3cc05547..a57f0ef07aa 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -1055,7 +1055,7 @@ bool TDBCSV::PrepareWriting(PGLOBAL g) if (!strlen(Field[i])) { // Generally null fields are not quoted if (Quoted > 2) - // Except if explicitely required + // Except if explicitly required strcat(strcat(To_Line, qot), qot); } else if (Qot && (strchr(Field[i], Sep) || *Field[i] == Qot -- cgit v1.2.1 From af0ff8b4553f96f18b87f7a499846c510f17c49b Mon Sep 17 00:00:00 2001 From: Haidong Ji Date: Thu, 8 Dec 2022 19:34:00 +0000 Subject: MDEV-17093: SOURCE_REVISION in log and handle_fatal_signal MariaDB MDEV-12583 added `SOURCE_REVISION` variable that exposes the SHA1 of source code commit that the current running engine was built from. This info is useful for troubleshooting and debugging. This commit does the following: - addes the `SOURCE_REVISION` value into engine error log. - when a crash triggers handle_fatal_signal, the `SOURCE_REVISION` will be included in crash report. - resolves MDEV-20344: startup messages belong in stderr/error-log not stdout All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- sql/mysqld.cc | 24 +++++++++--------------- sql/signal_handler.cc | 4 +++- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b1cf5ab2796..75eb2230b32 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -119,6 +119,8 @@ #include +#include + #define mysqld_charset &my_charset_latin1 /* We have HAVE_valgrind below as this speeds up the shutdown of MySQL */ @@ -4445,21 +4447,6 @@ static int init_common_variables() mysql_real_data_home_len= uint(strlen(mysql_real_data_home)); - if (!opt_abort) - { - if (IS_SYSVAR_AUTOSIZE(&server_version_ptr)) - sql_print_information("%s (mysqld %s) starting as process %lu ...", - my_progname, server_version, (ulong) getpid()); - else - { - char real_server_version[SERVER_VERSION_LENGTH]; - set_server_version(real_server_version, sizeof(real_server_version)); - sql_print_information("%s (mysqld %s as %s) starting as process %lu ...", - my_progname, real_server_version, server_version, - (ulong) getpid()); - } - } - sf_leaking_memory= 0; // no memory leaks from now on #ifndef EMBEDDED_LIBRARY @@ -5258,6 +5245,13 @@ static int init_server_components() error_handler_hook= my_message_sql; proc_info_hook= set_thd_stage_info; + /* + Print source revision hash, as one of the first lines, if not the + first in error log, for troubleshooting and debugging purposes + */ + sql_print_information("Starting MariaDB %s source revision %s as process %lu", + server_version, SOURCE_REVISION, (ulong) getpid()); + #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE /* Parsing the performance schema command line option may have reported diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc index 915291185d5..a01950c99af 100644 --- a/sql/signal_handler.cc +++ b/sql/signal_handler.cc @@ -22,6 +22,7 @@ #include "mysqld.h" #include "sql_class.h" #include "my_stacktrace.h" +#include #ifdef __WIN__ #include @@ -177,7 +178,8 @@ extern "C" sig_handler handle_fatal_signal(int sig) "something is definitely wrong and this may fail.\n\n"); set_server_version(server_version, sizeof(server_version)); - my_safe_printf_stderr("Server version: %s\n", server_version); + my_safe_printf_stderr("Server version: %s source revision: %s\n", + server_version, SOURCE_REVISION); if (dflt_key_cache) my_safe_printf_stderr("key_buffer_size=%lu\n", -- cgit v1.2.1 From b21832ef1525e37f0dda4e17853bcca9e4e20f2b Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Wed, 26 Oct 2022 22:08:32 -0700 Subject: MDEV-27624 Wrong result for nested left join using not_exists optimization This bug affected queries with nested left joins having the same last inner table such that not_exists optimization could be applied to the most inner outer join when optimizer chose to use join buffers. The bug could lead to producing wrong a result set. If the WHERE condition a query contains a conjunctive IS NULL predicate over a non-nullable column of an inner table of a not nested outer join then not_exists optimization can be applied to tho the outer join. With this optimization when looking for matches for a certain record from the outer table of the join the records of the inner table can be ignored right after the first match satisfying the ON condition is found. In the case of nested outer joins having the same last inner table this optimization still can be applied but only if all ON conditions of the embedding outer joins are satisfied. Such check was missing in the code that tried to apply not_exists optimization when join buffers were used for outer join operations. This problem has been already fixed in the patch for bug MDEV-7992. Yet there it was resolved only for the cases when join buffers were not used for outer joins. Approved by Oleksandr Byelkin --- mysql-test/main/join_nested.result | 52 +++++++++++++++++++++++++++++++++ mysql-test/main/join_nested.test | 38 ++++++++++++++++++++++++ mysql-test/main/join_nested_jcl6.result | 52 +++++++++++++++++++++++++++++++++ sql/sql_join_cache.cc | 35 ++++++++++++++++++---- 4 files changed, 171 insertions(+), 6 deletions(-) diff --git a/mysql-test/main/join_nested.result b/mysql-test/main/join_nested.result index 5ab94a6b568..1efb2e64116 100644 --- a/mysql-test/main/join_nested.result +++ b/mysql-test/main/join_nested.result @@ -1999,3 +1999,55 @@ Note 1003 select `test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.` DROP TABLE t1,t2,t3; set join_cache_level= @save_join_cache_level; set optimizer_switch=@save_optimizer_switch; +# +# MDEV-27624: Nested left joins with not_exists optimization +# for most inner left join +# +set @save_join_cache_level= @@join_cache_level; +CREATE TABLE t1 (a INT NOT NULL, b INT, c INT); +INSERT INTO t1 VALUES (1,1,1), (1,2,1), (1,3,1); +CREATE TABLE t2(a INT NOT NULL); +INSERT INTO t2 VALUES (1), (2); +CREATE TABLE t3(a INT not null, b INT); +INSERT INTO t3 VALUES (1, 1), (2, 1), (3, 1); +set join_cache_level = 0; +EXPLAIN SELECT * +FROM t1 +LEFT JOIN +( t2 LEFT JOIN t3 ON t2.a = t3.b ) +ON t2.a = 1 AND (t3.b = t1.a AND t3.a > t1.b OR t3.a is NULL) +WHERE t1.c = 1 AND t3.a is NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Not exists +SELECT * +FROM t1 +LEFT JOIN +( t2 LEFT JOIN t3 ON t2.a = t3.b ) +ON t2.a = 1 AND (t3.b = t1.a AND t3.a > t1.b OR t3.a is NULL) +WHERE t1.c = 1 AND t3.a is NULL; +a b c a a b +1 3 1 NULL NULL NULL +set join_cache_level = 2; +EXPLAIN SELECT * +FROM t1 +LEFT JOIN +( t2 LEFT JOIN t3 ON t2.a = t3.b ) +ON t2.a = 1 AND (t3.b = t1.a AND t3.a > t1.b OR t3.a is NULL) +WHERE t1.c = 1 AND t3.a is NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Not exists; Using join buffer (incremental, BNL join) +SELECT * +FROM t1 +LEFT JOIN +( t2 LEFT JOIN t3 ON t2.a = t3.b ) +ON t2.a = 1 AND (t3.b = t1.a AND t3.a > t1.b OR t3.a is NULL) +WHERE t1.c = 1 AND t3.a is NULL; +a b c a a b +1 3 1 NULL NULL NULL +DROP TABLE t1, t2, t3; +set join_cache_level= @save_join_cache_level; +# end of 10.3 tests diff --git a/mysql-test/main/join_nested.test b/mysql-test/main/join_nested.test index eaf754fb0ca..6b2ae9a457f 100644 --- a/mysql-test/main/join_nested.test +++ b/mysql-test/main/join_nested.test @@ -1419,3 +1419,41 @@ DROP TABLE t1,t2,t3; set join_cache_level= @save_join_cache_level; set optimizer_switch=@save_optimizer_switch; + +--echo # +--echo # MDEV-27624: Nested left joins with not_exists optimization +--echo # for most inner left join +--echo # + +set @save_join_cache_level= @@join_cache_level; + +CREATE TABLE t1 (a INT NOT NULL, b INT, c INT); +INSERT INTO t1 VALUES (1,1,1), (1,2,1), (1,3,1); + +CREATE TABLE t2(a INT NOT NULL); +INSERT INTO t2 VALUES (1), (2); + +CREATE TABLE t3(a INT not null, b INT); +INSERT INTO t3 VALUES (1, 1), (2, 1), (3, 1); + +let $q= +SELECT * +FROM t1 + LEFT JOIN + ( t2 LEFT JOIN t3 ON t2.a = t3.b ) + ON t2.a = 1 AND (t3.b = t1.a AND t3.a > t1.b OR t3.a is NULL) +WHERE t1.c = 1 AND t3.a is NULL; + +set join_cache_level = 0; +eval EXPLAIN $q; +eval $q; + +set join_cache_level = 2; +eval EXPLAIN $q; +eval $q; + +DROP TABLE t1, t2, t3; + +set join_cache_level= @save_join_cache_level; + +--echo # end of 10.3 tests diff --git a/mysql-test/main/join_nested_jcl6.result b/mysql-test/main/join_nested_jcl6.result index 541cd47bf04..338705c0a29 100644 --- a/mysql-test/main/join_nested_jcl6.result +++ b/mysql-test/main/join_nested_jcl6.result @@ -2008,6 +2008,58 @@ Note 1003 select `test`.`t3`.`pk` AS `pk`,`test`.`t3`.`c1` AS `c1`,`test`.`t3`.` DROP TABLE t1,t2,t3; set join_cache_level= @save_join_cache_level; set optimizer_switch=@save_optimizer_switch; +# +# MDEV-27624: Nested left joins with not_exists optimization +# for most inner left join +# +set @save_join_cache_level= @@join_cache_level; +CREATE TABLE t1 (a INT NOT NULL, b INT, c INT); +INSERT INTO t1 VALUES (1,1,1), (1,2,1), (1,3,1); +CREATE TABLE t2(a INT NOT NULL); +INSERT INTO t2 VALUES (1), (2); +CREATE TABLE t3(a INT not null, b INT); +INSERT INTO t3 VALUES (1, 1), (2, 1), (3, 1); +set join_cache_level = 0; +EXPLAIN SELECT * +FROM t1 +LEFT JOIN +( t2 LEFT JOIN t3 ON t2.a = t3.b ) +ON t2.a = 1 AND (t3.b = t1.a AND t3.a > t1.b OR t3.a is NULL) +WHERE t1.c = 1 AND t3.a is NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Not exists +SELECT * +FROM t1 +LEFT JOIN +( t2 LEFT JOIN t3 ON t2.a = t3.b ) +ON t2.a = 1 AND (t3.b = t1.a AND t3.a > t1.b OR t3.a is NULL) +WHERE t1.c = 1 AND t3.a is NULL; +a b c a a b +1 3 1 NULL NULL NULL +set join_cache_level = 2; +EXPLAIN SELECT * +FROM t1 +LEFT JOIN +( t2 LEFT JOIN t3 ON t2.a = t3.b ) +ON t2.a = 1 AND (t3.b = t1.a AND t3.a > t1.b OR t3.a is NULL) +WHERE t1.c = 1 AND t3.a is NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where; Not exists; Using join buffer (incremental, BNL join) +SELECT * +FROM t1 +LEFT JOIN +( t2 LEFT JOIN t3 ON t2.a = t3.b ) +ON t2.a = 1 AND (t3.b = t1.a AND t3.a > t1.b OR t3.a is NULL) +WHERE t1.c = 1 AND t3.a is NULL; +a b c a a b +1 3 1 NULL NULL NULL +DROP TABLE t1, t2, t3; +set join_cache_level= @save_join_cache_level; +# end of 10.3 tests CREATE TABLE t5 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); CREATE TABLE t6 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); CREATE TABLE t7 (a int, b int, c int, PRIMARY KEY(a), KEY b_i (b)); diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 86df1d32bd9..0804f4f9463 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -2287,11 +2287,7 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last) int error; enum_nested_loop_state rc= NESTED_LOOP_OK; join_tab->table->null_row= 0; - bool check_only_first_match= - join_tab->check_only_first_match() && - (!join_tab->first_inner || // semi-join case - join_tab->first_inner == join_tab->first_unmatched); // outer join case - bool outer_join_first_inner= join_tab->is_first_inner_for_outer_join(); + bool check_only_first_match= join_tab->check_only_first_match(); DBUG_ENTER("JOIN_CACHE::join_matching_records"); /* Return at once if there are no records in the join buffer */ @@ -2355,7 +2351,34 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last) Also those records that must be null complemented are not considered as candidates for matches. */ - if ((!check_only_first_match && !outer_join_first_inner) || + + bool not_exists_opt_is_applicable= true; + if (check_only_first_match && join_tab->first_inner) + { + /* + This is the case with not_exists optimization for nested outer join + when join_tab is the last inner table for one or more embedding outer + joins. To safely use 'not_exists' optimization in this case we have + to check that the match flags for all these embedding outer joins are + in the 'on' state. + (See also a similar check in evaluate_join_record() for the case when + join buffer are not used.) + */ + for (JOIN_TAB *tab= join_tab->first_inner; + tab && tab->first_inner && tab->last_inner == join_tab; + tab= tab->first_inner->first_upper) + { + if (get_match_flag_by_pos_from_join_buffer(rec_ptr, tab) != + MATCH_FOUND) + { + not_exists_opt_is_applicable= false; + break; + } + } + } + + if (!check_only_first_match || + (join_tab->first_inner && !not_exists_opt_is_applicable) || !skip_next_candidate_for_match(rec_ptr)) { read_next_candidate_for_match(rec_ptr); -- cgit v1.2.1 From e64e6768e00c6ef58824b79f2009aa5668ccd538 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 8 Jan 2023 09:26:50 +1100 Subject: MDEV-17093: SOURCE_REVISION in log (postfix - not in help) Don't display the source revision in the mysqld --help output. --- sql/mysqld.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 75eb2230b32..e4a814b82dd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5249,8 +5249,9 @@ static int init_server_components()  Print source revision hash, as one of the first lines, if not the  first in error log, for troubleshooting and debugging purposes  */ - sql_print_information("Starting MariaDB %s source revision %s as process %lu", - server_version, SOURCE_REVISION, (ulong) getpid()); + if (!opt_help) + sql_print_information("Starting MariaDB %s source revision %s as process %lu", + server_version, SOURCE_REVISION, (ulong) getpid()); #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE /* -- cgit v1.2.1 From d7f447915c96681c85abf00d22de589a5332a6da Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sun, 8 Jan 2023 09:53:09 +1100 Subject: MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error regression from MDEV-29540 / 8c389393695. INSERT SELECT errors needed to be unconditionally ignored. As this touches the CREATE .. SELECT functionality, show the equalivent test there. --- mysql-test/main/create.result | 11 +++++++++++ mysql-test/main/create.test | 13 +++++++++++++ mysql-test/main/insert_select.result | 13 +++++++++++++ mysql-test/main/insert_select.test | 17 +++++++++++++++++ sql/sql_class.h | 4 ++-- sql/sql_insert.cc | 12 ++++++------ 6 files changed, 62 insertions(+), 8 deletions(-) diff --git a/mysql-test/main/create.result b/mysql-test/main/create.result index b7ed4388db7..290f293325d 100644 --- a/mysql-test/main/create.result +++ b/mysql-test/main/create.result @@ -2121,5 +2121,16 @@ Warnings: Warning 1280 Name 'foo' ignored for PRIMARY key. DROP TABLE t1; # +# MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error +# +create table t1(c1 varchar(1)); +insert into t1(c1) values('#'); +select @@sql_mode like '%strict_all_tables%'; +@@sql_mode like '%strict_all_tables%' +0 +create table t2 as select if(c1 = '#', c1 = 0, c1) as c1 from t1; +ERROR 22007: Truncated incorrect DECIMAL value: '#' +drop table t1; +# # End of 10.3 tests # diff --git a/mysql-test/main/create.test b/mysql-test/main/create.test index f1dfba65b4b..83c894dd8dc 100644 --- a/mysql-test/main/create.test +++ b/mysql-test/main/create.test @@ -1978,6 +1978,19 @@ create table t1 (c int(10) unsigned) engine=memory transactional=0; CREATE TABLE t1 ( id1 INT, id2 INT, CONSTRAINT `foo` PRIMARY KEY (id1), CONSTRAINT `bar` UNIQUE KEY(id2)); DROP TABLE t1; +--echo # +--echo # MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error +--echo # + +create table t1(c1 varchar(1)); +insert into t1(c1) values('#'); + +select @@sql_mode like '%strict_all_tables%'; +--error ER_TRUNCATED_WRONG_VALUE +create table t2 as select if(c1 = '#', c1 = 0, c1) as c1 from t1; + +drop table t1; + --echo # --echo # End of 10.3 tests --echo # diff --git a/mysql-test/main/insert_select.result b/mysql-test/main/insert_select.result index 6d939d0ed8e..29618c6ddd4 100644 --- a/mysql-test/main/insert_select.result +++ b/mysql-test/main/insert_select.result @@ -1042,4 +1042,17 @@ select * from t1; a deallocate prepare stmt; drop table t1,t2,t3; +# +# MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error +# +create table t1(c1 varchar(1)); +create table t2(c1 varchar(1)); +insert into t1(c1) values('#'); +select @@sql_mode like '%strict_all_tables%'; +@@sql_mode like '%strict_all_tables%' +0 +insert into t2(c1) select if(c1 = '#', c1 = 0, c1) as c1 from t1; +drop table t1, t2; +# # End of 10.3 test +# diff --git a/mysql-test/main/insert_select.test b/mysql-test/main/insert_select.test index 6baa7e43c34..a3604e38f34 100644 --- a/mysql-test/main/insert_select.test +++ b/mysql-test/main/insert_select.test @@ -595,4 +595,21 @@ deallocate prepare stmt; drop table t1,t2,t3; + +--echo # +--echo # MDEV-30342 Wrong "Truncated incorrect DECIMAL value" warning/error +--echo # + +create table t1(c1 varchar(1)); +create table t2(c1 varchar(1)); + +insert into t1(c1) values('#'); + +select @@sql_mode like '%strict_all_tables%'; +insert into t2(c1) select if(c1 = '#', c1 = 0, c1) as c1 from t1; + +drop table t1, t2; + +--echo # --echo # End of 10.3 test +--echo # diff --git a/sql/sql_class.h b/sql/sql_class.h index 5e209f56458..49a8509b519 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5455,7 +5455,7 @@ class select_insert :public select_result_interceptor { int prepare(List &list, SELECT_LEX_UNIT *u); virtual int prepare2(JOIN *join); virtual int send_data(List &items); - virtual bool store_values(List &values, bool ignore_errors); + virtual bool store_values(List &values); virtual bool can_rollback_data() { return 0; } bool prepare_eof(); bool send_ok_packet(); @@ -5497,7 +5497,7 @@ public: int prepare(List &list, SELECT_LEX_UNIT *u); int binlog_show_create_table(TABLE **tables, uint count); - bool store_values(List &values, bool ignore_errors); + bool store_values(List &values); bool send_eof(); virtual void abort_result_set(); virtual bool can_rollback_data() { return 1; } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 43007b2243a..b743fc88061 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -3928,7 +3928,7 @@ int select_insert::send_data(List &values) DBUG_RETURN(0); thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields - if (store_values(values, info.ignore)) + if (store_values(values)) DBUG_RETURN(1); thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; if (unlikely(thd->is_error())) @@ -3986,17 +3986,17 @@ int select_insert::send_data(List &values) } -bool select_insert::store_values(List &values, bool ignore_errors) +bool select_insert::store_values(List &values) { DBUG_ENTER("select_insert::store_values"); bool error; if (fields->elements) error= fill_record_n_invoke_before_triggers(thd, table, *fields, values, - ignore_errors, TRG_EVENT_INSERT); + true, TRG_EVENT_INSERT); else error= fill_record_n_invoke_before_triggers(thd, table, table->field_to_fill(), - values, ignore_errors, TRG_EVENT_INSERT); + values, true, TRG_EVENT_INSERT); DBUG_RETURN(error); } @@ -4669,10 +4669,10 @@ select_create::binlog_show_create_table(TABLE **tables, uint count) return result; } -bool select_create::store_values(List &values, bool ignore_errors) +bool select_create::store_values(List &values) { return fill_record_n_invoke_before_triggers(thd, table, field, values, - ignore_errors, TRG_EVENT_INSERT); + true, TRG_EVENT_INSERT); } -- cgit v1.2.1 From 56948ee54c9d113f07f725ebdc560d1919fc6676 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 10 Jan 2023 10:45:03 +1100 Subject: clang15 warnings - unused vars and old prototypes clang15 finally errors on old prototype definations. Its also a lot fussier about variables that aren't used as is the case a number of time with loop counters that aren't examined. RocksDB was complaining that its get_range function was declared without the array length in ha_rocksdb.h. While a constant is used rather than trying to import the Rdb_key_def::INDEX_NUMBER_SIZE header (was causing a lot of errors on the defination of other orders). If the constant does change can be assured that the same compile warnings will tell us of the error. The ha_rocksdb::index_read_map_impl DBUG_EXECUTE_IF was similar to the existing endless functions used in replication tests. Its rather moot point as the rocksdb.force_shutdown test that uses myrocks_busy_loop_on_row_read is currently disabled. --- storage/archive/azio.c | 21 ++++++--------------- storage/connect/connect.cc | 6 +++--- storage/connect/ioapi.c | 3 +-- storage/connect/tabtbl.cpp | 4 +--- storage/connect/zip.c | 5 ----- storage/rocksdb/ha_rocksdb.cc | 5 +---- storage/rocksdb/ha_rocksdb.h | 2 +- storage/tokudb/PerconaFT/ft/loader/loader.cc | 7 +------ storage/tokudb/PerconaFT/ft/txn/txn_manager.cc | 2 -- 9 files changed, 14 insertions(+), 41 deletions(-) diff --git a/storage/archive/azio.c b/storage/archive/azio.c index 0f66b999c94..916abc90d7b 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -249,8 +249,7 @@ int azdopen(azio_stream *s, File fd, int Flags) for end of file. IN assertion: the stream s has been sucessfully opened for reading. */ -int get_byte(s) - azio_stream *s; +int get_byte(azio_stream *s) { if (s->z_eof) return EOF; if (s->stream.avail_in == 0) @@ -427,8 +426,7 @@ void read_header(azio_stream *s, unsigned char *buffer) * Cleanup then free the given azio_stream. Return a zlib error code. Try freeing in the reverse order of allocations. */ -int destroy (s) - azio_stream *s; +int destroy (azio_stream *s) { int err = Z_OK; @@ -679,9 +677,7 @@ int do_flush (azio_stream *s, int flush) return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; } -int ZEXPORT azflush (s, flush) - azio_stream *s; - int flush; +int ZEXPORT azflush (azio_stream *s, int flush) { int err; @@ -708,8 +704,7 @@ int ZEXPORT azflush (s, flush) /* =========================================================================== Rewinds input file. */ -int azrewind (s) - azio_stream *s; +int azrewind (azio_stream *s) { if (s == NULL || s->mode != 'r') return -1; @@ -733,10 +728,7 @@ int azrewind (s) SEEK_END is not implemented, returns error. In this version of the library, azseek can be extremely slow. */ -my_off_t azseek (s, offset, whence) - azio_stream *s; - my_off_t offset; - int whence; +my_off_t azseek (azio_stream *s, my_off_t offset, int whence) { if (s == NULL || whence == SEEK_END || @@ -812,8 +804,7 @@ my_off_t azseek (s, offset, whence) given compressed file. This position represents a number of bytes in the uncompressed data stream. */ -my_off_t ZEXPORT aztell (file) - azio_stream *file; +my_off_t ZEXPORT aztell (azio_stream *file) { return azseek(file, 0L, SEEK_CUR); } diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 9b9a9d5acb8..73e852bbcba 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -237,7 +237,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, bool del, PHC) { char *p; - int i, n; + int n; bool rcop= true; PCOL colp; //PCOLUMN cp; @@ -276,7 +276,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, n = strlen(p) + 1; } // endfor p - for (i = 0, colp = tdbp->GetColumns(); colp; i++, colp = colp->GetNext()) { + for (colp = tdbp->GetColumns(); colp; colp = colp->GetNext()) { if (colp->InitValue(g)) throw 2; @@ -310,7 +310,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, n = strlen(p) + 1; } // endfor p - for (i = 0, colp = utp->GetColumns(); colp; i++, colp = colp->GetNext()) { + for (colp = utp->GetColumns(); colp; colp = colp->GetNext()) { if (colp->InitValue(g)) throw 5; diff --git a/storage/connect/ioapi.c b/storage/connect/ioapi.c index 1f339982926..b6a0ec318e6 100644 --- a/storage/connect/ioapi.c +++ b/storage/connect/ioapi.c @@ -221,8 +221,7 @@ static int ZCALLBACK ferror_file_func (voidpf opaque __attribute__((unused)), vo return ret; } -void fill_fopen_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; +void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen_file = fopen_file_func; pzlib_filefunc_def->zread_file = fread_file_func; diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index b2240bffa2c..607e7d131f3 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -230,7 +230,6 @@ PCOL TDBTBL::InsertSpecialColumn(PCOL scp) /***********************************************************************/ bool TDBTBL::InitTableList(PGLOBAL g) { - int n; uint sln; const char *scs; PTABLE tp, tabp; @@ -243,7 +242,7 @@ bool TDBTBL::InitTableList(PGLOBAL g) sln = hc->get_table()->s->connect_string.length; // PlugSetPath(filename, Tdbp->GetFile(g), Tdbp->GetPath()); - for (n = 0, tp = tdp->Tablep; tp; tp = tp->GetNext()) { + for (tp = tdp->Tablep; tp; tp = tp->GetNext()) { if (TestFil(g, To_CondFil, tp)) { tabp = new(g) XTAB(tp); @@ -276,7 +275,6 @@ bool TDBTBL::InitTableList(PGLOBAL g) else Tablist = tabp; - n++; } // endif filp } // endfor tp diff --git a/storage/connect/zip.c b/storage/connect/zip.c index 4bbe31ab7dd..d796fe09b87 100644 --- a/storage/connect/zip.c +++ b/storage/connect/zip.c @@ -1471,11 +1471,6 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in { uLong uTotalOutBefore = zi->ci.stream.total_out; err=deflate(&zi->ci.stream, Z_NO_FLUSH); - if(uTotalOutBefore > zi->ci.stream.total_out) - { - int bBreak = 0; - bBreak++; - } zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; } diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index b1a64b4aec0..502dd647a27 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -8468,8 +8468,7 @@ int ha_rocksdb::index_read_map_impl(uchar *const buf, const uchar *const key, const key_range *end_key) { DBUG_ENTER_FUNC(); - DBUG_EXECUTE_IF("myrocks_busy_loop_on_row_read", int debug_i = 0; - while (1) { debug_i++; }); + DBUG_EXECUTE_IF("myrocks_busy_loop_on_row_read", my_sleep(50000);); int rc = 0; @@ -12124,7 +12123,6 @@ static int calculate_stats( } } - int num_sst = 0; for (const auto &it : props) { std::vector sst_stats; Rdb_tbl_prop_coll::read_stats_from_tbl_props(it.second, &sst_stats); @@ -12153,7 +12151,6 @@ static int calculate_stats( stats[it1.m_gl_index_id].merge( it1, true, it_index->second->max_storage_fmt_length()); } - num_sst++; } if (include_memtables) { diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h index 758ca71fc95..6211c7ebc04 100644 --- a/storage/rocksdb/ha_rocksdb.h +++ b/storage/rocksdb/ha_rocksdb.h @@ -401,7 +401,7 @@ class ha_rocksdb : public my_core::handler { void free_key_buffers(); // the buffer size should be at least 2*Rdb_key_def::INDEX_NUMBER_SIZE - rocksdb::Range get_range(const int i, uchar buf[]) const; + rocksdb::Range get_range(const int i, uchar buf[2 * 4]) const; /* Perf timers for data reads diff --git a/storage/tokudb/PerconaFT/ft/loader/loader.cc b/storage/tokudb/PerconaFT/ft/loader/loader.cc index 3ff237f05c7..ce41783aa02 100644 --- a/storage/tokudb/PerconaFT/ft/loader/loader.cc +++ b/storage/tokudb/PerconaFT/ft/loader/loader.cc @@ -2423,7 +2423,6 @@ static int toku_loader_write_ft_from_q (FTLOADER bl, // The pivots file will contain all the pivot strings (in the form ) // The pivots_fname is the name of the pivots file. // Note that the pivots file will have one extra pivot in it (the last key in the dictionary) which will not appear in the tree. - int64_t n_pivots=0; // number of pivots in pivots_file FIDX pivots_file; // the file r = ft_loader_open_temp_file (bl, &pivots_file); @@ -2539,8 +2538,6 @@ static int toku_loader_write_ft_from_q (FTLOADER bl, allocate_node(&sts, lblock); - n_pivots++; - invariant(maxkey.data != NULL); if ((r = bl_write_dbt(&maxkey, pivots_stream, NULL, nullptr, bl))) { ft_loader_set_panic(bl, r, true, which_db, nullptr, nullptr); @@ -2616,8 +2613,6 @@ static int toku_loader_write_ft_from_q (FTLOADER bl, // We haven't paniced, so the sum should add up. invariant(used_estimate == total_disksize_estimate); - n_pivots++; - { DBT key = make_dbt(0,0); // must write an extra DBT into the pivots file. r = bl_write_dbt(&key, pivots_stream, NULL, nullptr, bl); @@ -3302,7 +3297,7 @@ static int write_nonleaves (FTLOADER bl, FIDX pivots_fidx, struct dbout *out, st int height = 1; // Watch out for the case where we saved the last pivot but didn't write any more nodes out. - // The trick is not to look at n_pivots, but to look at blocks.n_blocks + // The trick is to look at blocks.n_blocks while (sts->n_subtrees > 1) { // If there is more than one block in blocks, then we must build another level of the tree. diff --git a/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc b/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc index 1b55844bc7d..8af2f6aab63 100644 --- a/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc +++ b/storage/tokudb/PerconaFT/ft/txn/txn_manager.cc @@ -208,12 +208,10 @@ verify_snapshot_system(TXN_MANAGER txn_manager UU()) { { //verify neither pair->begin_id nor end_id is in snapshot_xids TOKUTXN curr_txn = txn_manager->snapshot_head; - uint32_t curr_index = 0; while (curr_txn != NULL) { invariant(tuple->begin_id != curr_txn->txnid.parent_id64); invariant(tuple->end_id != curr_txn->txnid.parent_id64); curr_txn = curr_txn->snapshot_next; - curr_index++; } } { -- cgit v1.2.1