From 81d7adb1e2cdfb1064279b8643a8c3d22b3dd423 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 18 Nov 2021 00:51:17 +0100 Subject: MDEV-27075 mysql_upgrade_service.exe - using uninitialized memory 'defaults_file' Remove section that was trying to rename default-character-set to character-set-server This seems to be an old workaround for some upgrade warning, which did not work for some time already, because the ini filename was not initialized. --- sql/mysql_upgrade_service.cc | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'sql') diff --git a/sql/mysql_upgrade_service.cc b/sql/mysql_upgrade_service.cc index 37dae648563..5afe4ccbc52 100644 --- a/sql/mysql_upgrade_service.cc +++ b/sql/mysql_upgrade_service.cc @@ -317,9 +317,6 @@ void initiate_mysqld_shutdown() */ static void change_service_config() { - - char defaults_file[MAX_PATH]; - char default_character_set[64]; char buf[MAX_PATH]; char commandline[3*MAX_PATH + 19]; int i; @@ -382,22 +379,6 @@ static void change_service_config() */ WritePrivateProfileString("mysqld", "basedir",NULL, props.inifile); - /* - Replace default-character-set with character-set-server, to avoid - "default-character-set is deprecated and will be replaced ..." - message. - */ - default_character_set[0]= 0; - GetPrivateProfileString("mysqld", "default-character-set", NULL, - default_character_set, sizeof(default_character_set), defaults_file); - if (default_character_set[0]) - { - WritePrivateProfileString("mysqld", "default-character-set", NULL, - defaults_file); - WritePrivateProfileString("mysqld", "character-set-server", - default_character_set, defaults_file); - } - sprintf(defaults_file_param,"--defaults-file=%s", props.inifile); sprintf_s(commandline, "\"%s\" \"%s\" \"%s\"", mysqld_path, defaults_file_param, opt_service); -- cgit v1.2.1 From 7efcc2794d698f62074290232e0f71234c7a4b41 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sat, 20 Nov 2021 16:11:08 +0400 Subject: MDEV-27072 Subquery using the ALL keyword on date columns produces a wrong result --- sql/sql_class.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 2eec056ec9d..21c06029787 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3479,7 +3479,7 @@ bool select_max_min_finder_subselect::cmp_str() but added for safety */ val1= cache->val_str(&buf1); - val2= maxmin->val_str(&buf1); + val2= maxmin->val_str(&buf2); /* Ignore NULLs for ANY and keep them for ALL subqueries */ if (cache->null_value) -- cgit v1.2.1 From e9f171b4fe65399e9ebbb1660198b690582e2ef5 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Sat, 20 Nov 2021 21:49:25 +0400 Subject: MDEV-27098 Subquery using the ALL keyword on TIME columns produces a wrong result --- sql/sql_class.cc | 25 +++++++++++++++++++++++-- sql/sql_class.h | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 21c06029787..479578679f1 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -3394,7 +3394,7 @@ int select_max_min_finder_subselect::send_data(List &items) if (!cache) { cache= Item_cache::get_cache(thd, val_item); - switch (val_item->result_type()) { + switch (val_item->cmp_type()) { case REAL_RESULT: op= &select_max_min_finder_subselect::cmp_real; break; @@ -3407,8 +3407,13 @@ int select_max_min_finder_subselect::send_data(List &items) case DECIMAL_RESULT: op= &select_max_min_finder_subselect::cmp_decimal; break; - case ROW_RESULT: case TIME_RESULT: + if (val_item->field_type() == MYSQL_TYPE_TIME) + op= &select_max_min_finder_subselect::cmp_time; + else + op= &select_max_min_finder_subselect::cmp_str; + break; + case ROW_RESULT: // This case should never be choosen DBUG_ASSERT(0); op= 0; @@ -3453,6 +3458,22 @@ bool select_max_min_finder_subselect::cmp_int() return (val1 < val2); } +bool select_max_min_finder_subselect::cmp_time() +{ + Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); + longlong val1= cache->val_time_packed(), val2= maxmin->val_time_packed(); + + /* Ignore NULLs for ANY and keep them for ALL subqueries */ + if (cache->null_value) + return (is_all && !maxmin->null_value) || (!is_all && maxmin->null_value); + if (maxmin->null_value) + return !is_all; + + if (fmax) + return(val1 > val2); + return (val1 < val2); +} + bool select_max_min_finder_subselect::cmp_decimal() { Item *maxmin= ((Item_singlerow_subselect *)item)->element_index(0); diff --git a/sql/sql_class.h b/sql/sql_class.h index a767a34d869..9fff422684e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5396,6 +5396,7 @@ public: bool cmp_int(); bool cmp_decimal(); bool cmp_str(); + bool cmp_time(); }; /* EXISTS subselect interface class */ -- cgit v1.2.1 From 0dae41637abd24c8f08e925ef00490e949ce581d Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Fri, 19 Nov 2021 14:51:12 -0800 Subject: MDEV-27086 "No database selected" when using UNION of CTEs to define table This bug concerned only CREATE TABLE statements of the form CREATE TABLE AS . For such a statement not all references to CTE used in were resolved. As a result a bogus message was reported for the first unresolved reference. This happened because for such statements the function resolving references to CTEs LEX::check_cte_dependencies_and_resolve_references() was called prematurely in the parser. Approved by Oleksandr Byelkin --- sql/sql_yacc.yy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sql') diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 312ea682975..4dd292258d3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4869,6 +4869,10 @@ create_like: opt_create_select: /* empty */ {} | opt_duplicate opt_as create_select_query_expression + { + if (Lex->check_cte_dependencies_and_resolve_references()) + MYSQL_YYABORT; + } ; create_select_query_expression: @@ -4877,16 +4881,12 @@ create_select_query_expression: { Select->set_braces(0); Select->set_with_clause($1); - if (Lex->check_cte_dependencies_and_resolve_references()) - MYSQL_YYABORT; } union_clause | opt_with_clause SELECT_SYM create_select_part2 create_select_part3_union_not_ready create_select_part4 { Select->set_with_clause($1); - if (Lex->check_cte_dependencies_and_resolve_references()) - MYSQL_YYABORT; } | '(' create_select_query_specification ')' | '(' create_select_query_specification ')' -- cgit v1.2.1 From 114e18b8b68a00b3829ac231cc8f84187f529287 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 20 Nov 2021 21:35:54 -0800 Subject: MDEV-26470 "No database" selected when using CTE in a subquery of DELETE statement This bug led to reporting bogus messages "No database selected" for DELETE statements if they used subqueries in their WHERE conditions and these subqueries contained references to CTEs. The bug happened because the grammar rule for DELETE statement did not call the function LEX::check_cte_dependencies_and_resolve_references() and as a result of it references to CTEs were not identified as such. Approved by Oleksandr Byelkin --- sql/sql_yacc.yy | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql') diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 4dd292258d3..a4b105862f3 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -12668,6 +12668,10 @@ delete: lex->select_lex.init_order(); } opt_delete_options single_multi + { + if (Lex->check_cte_dependencies_and_resolve_references()) + MYSQL_YYABORT; + } ; single_multi: -- cgit v1.2.1 From 749d8dedc323154f4aa8a6e26dd464696e8c3fed Mon Sep 17 00:00:00 2001 From: Marc Olivier Bergeron Date: Wed, 17 Nov 2021 17:14:27 +1100 Subject: MDEV-27066: Fixed scientific notation parsing bug The bug occurs where the float token containing a dot with an 'e' notation was dropped from the request completely. This causes a manner of invalid SQL statements like: select id 1.e, char 10.e(id 2.e), concat 3.e('a'12356.e,'b'1.e,'c'1.1234e)1.e, 12 1.e*2 1.e, 12 1.e/2 1.e, 12 1.e|2 1.e, 12 1.e^2 1.e, 12 1.e%2 1.e, 12 1.e&2 from test; To be parsed correctly as if it was: select id, char(id), concat('a','b','c'), 12*2, 12/2, 12|2, 12^2, 12%2, 12&2 from test.test; This correct parsing occurs when e is followed by any of: ( ) . , | & % * ^ / --- sql/sql_lex.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index b7ed632ed12..ed0b4b36553 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1664,8 +1664,7 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd) c = lip->yyGet(); // Skip sign if (!my_isdigit(cs,c)) { // No digit after sign - state= MY_LEX_CHAR; - break; + return (ABORT_SYM); } while (my_isdigit(cs,lip->yyGet())) ; yylval->lex_str=get_token(lip, 0, lip->yyLength()); -- cgit v1.2.1 From a96b42826964b1dbb1eeee536c9f611e462719c0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 3 Nov 2021 15:34:28 +0100 Subject: MDEV-26755 innodb.undo_truncate: ilink::assert_linked(): Assertion `prev != 0 && next != 0' failed close_connections() in mysqld.cc sends a signal to all threads. But InnoDB is too busy purging, doesn't react immediately. close_connections() waits 20 seconds, which isn't enough in this particular case, and then unlinks all threads from the list and forcibly closes their vio connection. InnoDB background threads have no vio connection to close, but they're unlinked all the same. So when later they finally notice the shutdown request and try to unlink themselves, they fail to assert that they're still linked. Fix: don't assert_linked, as another thread can unlink this THD anytime --- sql/sql_class.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'sql') diff --git a/sql/sql_class.h b/sql/sql_class.h index 9fff422684e..3f0fba8fc10 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4557,12 +4557,10 @@ inline void add_to_active_threads(THD *thd) /* This should be called when you want to delete a thd that was not running any queries. - This function will assert that the THD is linked. */ inline void unlink_not_visible_thd(THD *thd) { - thd->assert_linked(); mysql_mutex_lock(&LOCK_thread_count); thd->unlink(); mysql_mutex_unlock(&LOCK_thread_count); -- cgit v1.2.1