From d513a4ce74cb1932ca945a8708a6746175ddf745 Mon Sep 17 00:00:00 2001 From: Rex Date: Tue, 30 Apr 2024 10:39:20 +1100 Subject: [PATCH 1/6] MDEV-19520 Extend condition normalization to include 'NOT a' Having Item_func_not items in item trees breaks assumptions during the optimization phase about transformation possibilities in fix_fields(). Remove Item_func_not by extending normalization during parsing. Reviewed by Oleksandr Byelkin (sanja@mariadb.com) --- mysql-test/main/having_cond_pushdown.result | 12 ++++++++++++ mysql-test/main/having_cond_pushdown.test | 12 ++++++++++++ sql/sql_parse.cc | 16 ++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/mysql-test/main/having_cond_pushdown.result b/mysql-test/main/having_cond_pushdown.result index fea8f83f9a1..1afed563fcb 100644 --- a/mysql-test/main/having_cond_pushdown.result +++ b/mysql-test/main/having_cond_pushdown.result @@ -4969,4 +4969,16 @@ SELECT a,b FROM t1 GROUP BY a,b HAVING a = (b IS NULL); a b 0 11 DROP TABLE t1; +# +# MDEV-19520 Extend condition normalization to include 'NOT a' +# having Item_func_not in item tree breaks assumptions during the +# optimization phase about transformation possibilities in fix_fields(). +# Remove Item_func_not by extending normalization during parsing. +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1); +SELECT a FROM t1 GROUP BY a HAVING NOT a; +a +0 +DROP TABLE t1; End of 10.4 tests diff --git a/mysql-test/main/having_cond_pushdown.test b/mysql-test/main/having_cond_pushdown.test index 6d42b4ffefe..57f70152375 100644 --- a/mysql-test/main/having_cond_pushdown.test +++ b/mysql-test/main/having_cond_pushdown.test @@ -1485,4 +1485,16 @@ SELECT a,b FROM t1 GROUP BY a,b HAVING a = (b IS NULL); DROP TABLE t1; +--echo # +--echo # MDEV-19520 Extend condition normalization to include 'NOT a' +--echo # having Item_func_not in item tree breaks assumptions during the +--echo # optimization phase about transformation possibilities in fix_fields(). +--echo # Remove Item_func_not by extending normalization during parsing. +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0),(1); +SELECT a FROM t1 GROUP BY a HAVING NOT a; +DROP TABLE t1; + --echo End of 10.4 tests diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f3b7cb75c81..561aca11e20 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -9234,6 +9234,7 @@ push_new_name_resolution_context(THD *thd, /** Fix condition which contains only field (f turns to f <> 0 ) + or only contains the function NOT field (not f turns to f == 0) @param cond The condition to fix @@ -9249,6 +9250,21 @@ Item *normalize_cond(THD *thd, Item *cond) { cond= new (thd->mem_root) Item_func_ne(thd, cond, new (thd->mem_root) Item_int(thd, 0)); } + else + { + if (type == Item::FUNC_ITEM) + { + Item_func *func_item= (Item_func *)cond; + if (func_item->functype() == Item_func::NOT_FUNC) + { + Item *arg= func_item->arguments()[0]; + if (arg->type() == Item::FIELD_ITEM || + arg->type() == Item::REF_ITEM) + cond= new (thd->mem_root) Item_func_eq(thd, arg, + new (thd->mem_root) Item_int(thd, 0)); + } + } + } } return cond; } From 8b169949d64ecfb4a6b6ba9f693d564e807df990 Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Mon, 24 Jun 2024 21:51:19 +0700 Subject: [PATCH 2/6] MDEV-24411: Trigger doesn't work correctly with bulk insert Executing an INSERT statement in PS mode having positional parameter bound with an array could result in incorrect number of inserted rows in case there is a BEFORE INSERT trigger that executes yet another INSERT statement to put a copy of row being inserted into some table. The reason for incorrect number of inserted rows is that a data structure used for binding positional argument with its actual values is stored in THD (this is thd->bulk_param) and reused on processing every INSERT statement. It leads to consuming actual values bound with top-level INSERT statement by other INSERT statements used by triggers' body. To fix the issue, reset the thd->bulk_param temporary to the value nullptr before invoking triggers and restore its value on finishing its execution. --- sql/sql_insert.cc | 21 ++++++++ tests/mysql_client_test.c | 100 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 2792ca8e015..35eec93f540 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1021,10 +1021,19 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, */ restore_record(table,s->default_values); // Get empty record table->reset_default_fields(); + /* + Reset the sentinel thd->bulk_param in order not to consume the next + values of a bound array in case one of statement executed by + the trigger's body is INSERT statement. + */ + void *save_bulk_param= thd->bulk_param; + thd->bulk_param= nullptr; + if (unlikely(fill_record_n_invoke_before_triggers(thd, table, fields, *values, 0, TRG_EVENT_INSERT))) { + thd->bulk_param= save_bulk_param; if (values_list.elements != 1 && ! thd->is_error()) { info.records++; @@ -1038,6 +1047,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, error=1; break; } + thd->bulk_param= save_bulk_param; } else { @@ -1067,12 +1077,22 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, } } table->reset_default_fields(); + + /* + Reset the sentinel thd->bulk_param in order not to consume the next + values of a bound array in case one of statement executed by + the trigger's body is INSERT statement. + */ + void *save_bulk_param= thd->bulk_param; + thd->bulk_param= nullptr; + if (unlikely(fill_record_n_invoke_before_triggers(thd, table, table-> field_to_fill(), *values, 0, TRG_EVENT_INSERT))) { + thd->bulk_param= save_bulk_param; if (values_list.elements != 1 && ! thd->is_error()) { info.records++; @@ -1081,6 +1101,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, error=1; break; } + thd->bulk_param= save_bulk_param; } /* diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index ebc462bea50..66281641b08 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -21870,6 +21870,103 @@ static void test_mdev19838() rc = mysql_query(mysql, "drop table mdev19838"); myquery(rc); } + +static void test_mdev_24411() +{ + int rc; + MYSQL_STMT *stmt; + MYSQL_BIND bind; + MYSQL_RES *result; + MYSQL_ROW row; + my_ulonglong row_count; + unsigned int vals[] = { 1, 2, 3}; + unsigned int vals_array_len = 3; + const char *insert_stmt= "INSERT INTO t1 VALUES (?)"; + + myheader("test_mdev_24411"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + myquery(rc); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t2"); + myquery(rc); + + rc= mysql_query(mysql, "CREATE TABLE t1 (a INT)"); + myquery(rc); + + rc= mysql_query(mysql, "CREATE TABLE t2 (a INT)"); + myquery(rc); + + rc= mysql_query(mysql, + "CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW " + "BEGIN INSERT INTO t2 (a) VALUES (NEW.a); END;"); + myquery(rc); + + stmt= mysql_stmt_init(mysql); + check_stmt(stmt); + + rc= mysql_stmt_prepare(stmt, insert_stmt, strlen(insert_stmt)); + check_execute(stmt, rc); + + memset(&bind, 0, sizeof(bind)); + bind.buffer_type= MYSQL_TYPE_LONG; + bind.buffer= vals; + + rc= mysql_stmt_attr_set(stmt, STMT_ATTR_ARRAY_SIZE, &vals_array_len); + check_execute(stmt, rc); + + rc= mysql_stmt_bind_param(stmt, &bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + /* + It's expected that the INSERT statement adds three rows into + the table t1 + */ + row_count = mysql_stmt_affected_rows(stmt); + DIE_UNLESS(row_count == 3); + + /* + * Check that the BEFORE INSERT trigger of the table t1 does work correct + * and inserted the rows (1), (2), (3) into the table t2. + */ + rc= mysql_query(mysql, "SELECT 't1' tname, a FROM t1 " + "UNION SELECT 't2' tname, a FROM t2 ORDER BY tname,a"); + myquery(rc); + + result= mysql_store_result(mysql); + + row = mysql_fetch_row(result); + DIE_UNLESS(strcmp(row[0], "t1") == 0 && atoi(row[1]) == 1); + + row = mysql_fetch_row(result); + DIE_UNLESS(strcmp(row[0], "t1") == 0 && atoi(row[1]) == 2); + + row = mysql_fetch_row(result); + DIE_UNLESS(strcmp(row[0], "t1") == 0 && atoi(row[1]) == 3); + + row = mysql_fetch_row(result); + DIE_UNLESS(strcmp(row[0], "t2") == 0 && atoi(row[1]) == 1); + + row = mysql_fetch_row(result); + DIE_UNLESS(strcmp(row[0], "t2") == 0 && atoi(row[1]) == 2); + + row = mysql_fetch_row(result); + DIE_UNLESS(strcmp(row[0], "t2") == 0 && atoi(row[1]) == 3); + + row= mysql_fetch_row(result); + DIE_UNLESS(row == NULL); + + mysql_free_result(result); + + mysql_stmt_close(stmt); + + rc= mysql_query(mysql, "DROP TABLE t1, t2"); + myquery(rc); +} + #endif // EMBEDDED_LIBRARY @@ -22307,6 +22404,9 @@ static struct my_tests_st my_tests[]= { { "test_mdev20261", test_mdev20261 }, { "test_mdev_30159", test_mdev_30159 }, { "test_connect_autocommit", test_connect_autocommit}, +#ifndef EMBEDDED_LIBRARY + { "test_mdev_24411", test_mdev_24411}, +#endif { 0, 0 } }; From aebd2397cce9b9b14a171ad9e3718fb07a017622 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 17 Jun 2024 14:08:20 +0800 Subject: [PATCH 3/6] MDEV-34404 Use safe_str in spider udfs to avoid passing NULL str --- sql/sql_class.h | 2 +- storage/spider/spd_copy_tables.cc | 2 +- storage/spider/spd_direct_sql.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index 63e21a35d86..08a04665383 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4580,7 +4580,7 @@ public: to->length= db.length; return to->str == NULL; /* True on error */ } - /* Get db name or "". Use for printing current db */ + /* Get db name or "". */ const char *get_db() { return safe_str(db.str); } diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc index 524ad7dd9e9..2a3b848c3ce 100644 --- a/storage/spider/spd_copy_tables.cc +++ b/storage/spider/spd_copy_tables.cc @@ -52,7 +52,7 @@ int spider_udf_set_copy_tables_param_default( copy_tables->database_length = SPIDER_THD_db_length(copy_tables->trx->thd); if ( !(copy_tables->database = spider_create_string( - SPIDER_THD_db_str(copy_tables->trx->thd), + copy_tables->trx->thd->get_db(), copy_tables->database_length)) ) { my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 15b777ea739..462d83f3a84 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -1109,7 +1109,7 @@ int spider_udf_set_direct_sql_param_default( direct_sql->tgt_default_db_name_length = SPIDER_THD_db_length(trx->thd); if ( !(direct_sql->tgt_default_db_name = spider_create_string( - SPIDER_THD_db_str(trx->thd), + trx->thd->get_db(), direct_sql->tgt_default_db_name_length)) ) { my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); From 01289dac4148da50c9bd13b07447d158fe0050c1 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 11 Jun 2024 16:40:53 +1000 Subject: [PATCH 4/6] MDEV-34361 Split my.cnf in the spider suite. Just like the spider/bugfix suite. One caveat is that my_2_3.cnf needs something under mysqld.2.3 group, otherwise mtr will fail with something like: There is no group named 'mysqld.2.3' that can be used to resolve 'port' for ... This will allow new tests under the spider suite to use what is needed. It also somehow fixes issues of running a test followed by spider.slave_trx_isolation. --- storage/spider/mysql-test/spider/my.cnf | 183 +------------------- storage/spider/mysql-test/spider/my_1_1.cnf | 44 +++++ storage/spider/mysql-test/spider/my_2_1.cnf | 56 ++++++ storage/spider/mysql-test/spider/my_2_2.cnf | 38 ++++ storage/spider/mysql-test/spider/my_2_3.cnf | 9 + storage/spider/mysql-test/spider/my_3_1.cnf | 11 ++ storage/spider/mysql-test/spider/my_3_2.cnf | 9 + storage/spider/mysql-test/spider/my_3_3.cnf | 9 + storage/spider/mysql-test/spider/my_4_1.cnf | 9 + 9 files changed, 193 insertions(+), 175 deletions(-) create mode 100644 storage/spider/mysql-test/spider/my_1_1.cnf create mode 100644 storage/spider/mysql-test/spider/my_2_1.cnf create mode 100644 storage/spider/mysql-test/spider/my_2_2.cnf create mode 100644 storage/spider/mysql-test/spider/my_2_3.cnf create mode 100644 storage/spider/mysql-test/spider/my_3_1.cnf create mode 100644 storage/spider/mysql-test/spider/my_3_2.cnf create mode 100644 storage/spider/mysql-test/spider/my_3_3.cnf create mode 100644 storage/spider/mysql-test/spider/my_4_1.cnf diff --git a/storage/spider/mysql-test/spider/my.cnf b/storage/spider/mysql-test/spider/my.cnf index db4f7656fbc..bef57333086 100644 --- a/storage/spider/mysql-test/spider/my.cnf +++ b/storage/spider/mysql-test/spider/my.cnf @@ -1,177 +1,10 @@ # Use default setting for mysqld processes !include include/default_mysqld.cnf - -[mysqld.1.1] -log-bin= master-bin -loose_handlersocket_port= 20000 -loose_handlersocket_port_wr= 20001 -loose_handlersocket_threads= 2 -loose_handlersocket_threads_wr= 1 -loose_handlersocket_support_merge_table= 0 -loose_handlersocket_direct_update_mode= 2 -loose_handlersocket_unlimited_boundary= 65536 -loose_handlersocket_bulk_insert= 0 -loose_handlersocket_bulk_insert_timeout= 0 -loose_handlersocket_general_log= 1 -loose_handlersocket_timeout= 30 -loose_handlersocket_close_table_interval=2 -open_files_limit= 4096 -loose_partition= 1 - -[mysqld.2.1] -loose_handlersocket_port= 20002 -loose_handlersocket_port_wr= 20003 -loose_handlersocket_threads= 2 -loose_handlersocket_threads_wr= 1 -loose_handlersocket_support_merge_table= 0 -loose_handlersocket_direct_update_mode= 2 -loose_handlersocket_unlimited_boundary= 65536 -loose_handlersocket_bulk_insert= 0 -loose_handlersocket_bulk_insert_timeout= 0 -loose_handlersocket_general_log= 1 -loose_handlersocket_timeout= 30 -loose_handlersocket_close_table_interval=2 -open_files_limit= 4096 - -[mysqld.2.2] -loose_handlersocket_port= 20004 -loose_handlersocket_port_wr= 20005 -loose_handlersocket_threads= 2 -loose_handlersocket_threads_wr= 1 -loose_handlersocket_support_merge_table= 0 -loose_handlersocket_direct_update_mode= 2 -loose_handlersocket_unlimited_boundary= 65536 -loose_handlersocket_bulk_insert= 0 -loose_handlersocket_bulk_insert_timeout= 0 -loose_handlersocket_general_log= 1 -loose_handlersocket_timeout= 30 -loose_handlersocket_close_table_interval=2 -open_files_limit= 4096 - -[mysqld.2.3] - -[mysqld.3.1] -loose_partition= 1 - -[mysqld.3.2] -loose_partition= 1 - -[mysqld.3.3] -loose_partition= 1 - -[mysqld.4.1] -loose_partition= 1 - - -[ENV] -USE_GEOMETRY_TEST= 1 -USE_FULLTEXT_TEST= 1 -USE_HA_TEST= 1 -USE_GENERAL_LOG= 1 -USE_REPLICATION= 1 -MASTER_1_MYPORT= @mysqld.1.1.port -MASTER_1_HSRPORT= 20000 -MASTER_1_HSWPORT= 20001 -MASTER_1_MYSOCK= @mysqld.1.1.socket -MASTER_1_ENGINE_TYPE= Spider -#MASTER_1_ENGINE_TYPE= MyISAM -MASTER_1_ENGINE= ENGINE=Spider -MASTER_1_CHARSET= DEFAULT CHARSET=utf8 -MASTER_1_ENGINE2= ENGINE=MyISAM -MASTER_1_CHARSET2= DEFAULT CHARSET=utf8 -MASTER_1_CHARSET3= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci -SLAVE1_1_MYPORT= @mysqld.4.1.port -SLAVE1_1_MYSOCK= @mysqld.4.1.socket -SLAVE1_1_ENGINE_TYPE= MyISAM -SLAVE1_1_ENGINE= ENGINE=MyISAM -SLAVE1_1_CHARSET= DEFAULT CHARSET=utf8 -USE_CHILD_GROUP2= 1 -OUTPUT_CHILD_GROUP2= 0 -CHILD2_1_MYPORT= @mysqld.2.1.port -CHILD2_1_HSRPORT= 20002 -CHILD2_1_HSWPORT= 20003 -CHILD2_1_MYSOCK= @mysqld.2.1.socket -CHILD2_1_ENGINE_TYPE= InnoDB -CHILD2_1_ENGINE= ENGINE=InnoDB -CHILD2_1_CHARSET= DEFAULT CHARSET=utf8 -CHILD2_1_CHARSET2= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci -CHILD2_2_MYPORT= @mysqld.2.2.port -CHILD2_2_HSRPORT= 20004 -CHILD2_2_HSWPORT= 20005 -CHILD2_2_MYSOCK= @mysqld.2.2.socket -CHILD2_2_ENGINE_TYPE= InnoDB -CHILD2_2_ENGINE= ENGINE=InnoDB -CHILD2_2_CHARSET= DEFAULT CHARSET=utf8 -CHILD2_3_MYPORT= @mysqld.2.3.port -CHILD2_3_MYSOCK= @mysqld.2.3.socket -CHILD2_3_ENGINE_TYPE= InnoDB -CHILD2_3_ENGINE= ENGINE=InnoDB -CHILD2_3_CHARSET= DEFAULT CHARSET=utf8 -CHILD2_1_FT_MYPORT= @mysqld.2.1.port -CHILD2_1_FT_MYSOCK= @mysqld.2.1.socket -CHILD2_1_FT_ENGINE_TYPE= MyISAM -CHILD2_1_FT_ENGINE= ENGINE=MyISAM -CHILD2_1_FT_CHARSET= DEFAULT CHARSET=utf8 -CHILD2_2_FT_MYPORT= @mysqld.2.2.port -CHILD2_2_FT_MYSOCK= @mysqld.2.2.socket -CHILD2_2_FT_ENGINE_TYPE= MyISAM -CHILD2_2_FT_ENGINE= ENGINE=MyISAM -CHILD2_2_FT_CHARSET= DEFAULT CHARSET=utf8 -CHILD2_1_GM_MYPORT= @mysqld.2.1.port -CHILD2_1_GM_MYSOCK= @mysqld.2.1.socket -CHILD2_1_GM_ENGINE_TYPE= MyISAM -CHILD2_1_GM_ENGINE= ENGINE=MyISAM -CHILD2_1_GM_CHARSET= DEFAULT CHARSET=utf8 -CHILD2_2_GM_MYPORT= @mysqld.2.2.port -CHILD2_2_GM_MYSOCK= @mysqld.2.2.socket -CHILD2_2_GM_ENGINE_TYPE= MyISAM -CHILD2_2_GM_ENGINE= ENGINE=MyISAM -CHILD2_2_GM_CHARSET= DEFAULT CHARSET=utf8 -USE_CHILD_GROUP3= 1 -OUTPUT_CHILD_GROUP3= 0 -CHILD3_1_MYPORT= @mysqld.3.1.port -CHILD3_1_MYSOCK= @mysqld.3.1.socket -CHILD3_1_ENGINE_TYPE= InnoDB -CHILD3_1_ENGINE= ENGINE=InnoDB -CHILD3_1_CHARSET= DEFAULT CHARSET=utf8 -CHILD3_2_MYPORT= @mysqld.3.2.port -CHILD3_2_MYSOCK= @mysqld.3.2.socket -CHILD3_2_ENGINE_TYPE= InnoDB -CHILD3_2_ENGINE= ENGINE=InnoDB -CHILD3_2_CHARSET= DEFAULT CHARSET=utf8 -CHILD3_3_MYPORT= @mysqld.3.3.port -CHILD3_3_MYSOCK= @mysqld.3.3.socket -CHILD3_3_ENGINE_TYPE= InnoDB -CHILD3_3_ENGINE= ENGINE=InnoDB -CHILD3_3_CHARSET= DEFAULT CHARSET=utf8 - -STR_SEMICOLON= ; - -#The followings are set in include/init_xxx.inc files -# MASTER_1_COMMENT_2_1 -# MASTER_1_COMMENT2_2_1 -# MASTER_1_COMMENT3_2_1 -# MASTER_1_COMMENT4_2_1 -# MASTER_1_COMMENT5_2_1 -# MASTER_1_COMMENT_P_2_1 -# CHILD2_1_DROP_TABLES -# CHILD2_1_CREATE_TABLES -# CHILD2_1_SELECT_TABLES -# CHILD2_1_DROP_TABLES2 -# CHILD2_1_CREATE_TABLES2 -# CHILD2_1_SELECT_TABLES2 -# CHILD2_1_DROP_TABLES3 -# CHILD2_1_CREATE_TABLES3 -# CHILD2_1_SELECT_TABLES3 -# CHILD2_1_DROP_TABLES4 -# CHILD2_1_CREATE_TABLES4 -# CHILD2_1_SELECT_TABLES4 -# CHILD2_1_DROP_TABLES5 -# CHILD2_1_CREATE_TABLES5 -# CHILD2_1_SELECT_TABLES5 -# CHILD2_1_DROP_TABLES6 -# CHILD2_1_CREATE_TABLES6 -# CHILD2_1_SELECT_TABLES6 -# CHILD2_2_DROP_TABLES -# CHILD2_2_CREATE_TABLES -# CHILD2_2_SELECT_TABLES +!include my_1_1.cnf +!include my_2_1.cnf +!include my_2_2.cnf +!include my_2_3.cnf +!include my_3_1.cnf +!include my_3_2.cnf +!include my_3_3.cnf +!include my_4_1.cnf diff --git a/storage/spider/mysql-test/spider/my_1_1.cnf b/storage/spider/mysql-test/spider/my_1_1.cnf new file mode 100644 index 00000000000..5f17295d895 --- /dev/null +++ b/storage/spider/mysql-test/spider/my_1_1.cnf @@ -0,0 +1,44 @@ +[mysqld.1.1] +log-bin= master-bin +loose_handlersocket_port= 20000 +loose_handlersocket_port_wr= 20001 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 +loose_partition= 1 + +[ENV] +USE_GEOMETRY_TEST= 1 +USE_FULLTEXT_TEST= 1 +USE_HA_TEST= 1 +USE_GENERAL_LOG= 1 +USE_REPLICATION= 1 +MASTER_1_MYPORT= @mysqld.1.1.port +MASTER_1_HSRPORT= 20000 +MASTER_1_HSWPORT= 20001 +MASTER_1_MYSOCK= @mysqld.1.1.socket +MASTER_1_ENGINE_TYPE= Spider +#MASTER_1_ENGINE_TYPE= MyISAM +MASTER_1_ENGINE= ENGINE=Spider +MASTER_1_CHARSET= DEFAULT CHARSET=utf8 +MASTER_1_ENGINE2= ENGINE=MyISAM +MASTER_1_CHARSET2= DEFAULT CHARSET=utf8 +MASTER_1_CHARSET3= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci + +STR_SEMICOLON= ; + +#The followings are set in include/init_xxx.inc files +# MASTER_1_COMMENT_2_1 +# MASTER_1_COMMENT2_2_1 +# MASTER_1_COMMENT3_2_1 +# MASTER_1_COMMENT4_2_1 +# MASTER_1_COMMENT5_2_1 +# MASTER_1_COMMENT_P_2_1 diff --git a/storage/spider/mysql-test/spider/my_2_1.cnf b/storage/spider/mysql-test/spider/my_2_1.cnf new file mode 100644 index 00000000000..24161645607 --- /dev/null +++ b/storage/spider/mysql-test/spider/my_2_1.cnf @@ -0,0 +1,56 @@ +[mysqld.2.1] +loose_handlersocket_port= 20002 +loose_handlersocket_port_wr= 20003 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 + +[ENV] +USE_CHILD_GROUP2= 1 +OUTPUT_CHILD_GROUP2= 0 +CHILD2_1_MYPORT= @mysqld.2.1.port +CHILD2_1_HSRPORT= 20002 +CHILD2_1_HSWPORT= 20003 +CHILD2_1_MYSOCK= @mysqld.2.1.socket +CHILD2_1_ENGINE_TYPE= InnoDB +CHILD2_1_ENGINE= ENGINE=InnoDB +CHILD2_1_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_CHARSET2= DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci +CHILD2_1_FT_MYPORT= @mysqld.2.1.port +CHILD2_1_FT_MYSOCK= @mysqld.2.1.socket +CHILD2_1_FT_ENGINE_TYPE= MyISAM +CHILD2_1_FT_ENGINE= ENGINE=MyISAM +CHILD2_1_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_1_GM_MYPORT= @mysqld.2.1.port +CHILD2_1_GM_MYSOCK= @mysqld.2.1.socket +CHILD2_1_GM_ENGINE_TYPE= MyISAM +CHILD2_1_GM_ENGINE= ENGINE=MyISAM +CHILD2_1_GM_CHARSET= DEFAULT CHARSET=utf8 + +#The followings are set in include/init_xxx.inc files +# CHILD2_1_DROP_TABLES +# CHILD2_1_CREATE_TABLES +# CHILD2_1_SELECT_TABLES +# CHILD2_1_DROP_TABLES2 +# CHILD2_1_CREATE_TABLES2 +# CHILD2_1_SELECT_TABLES2 +# CHILD2_1_DROP_TABLES3 +# CHILD2_1_CREATE_TABLES3 +# CHILD2_1_SELECT_TABLES3 +# CHILD2_1_DROP_TABLES4 +# CHILD2_1_CREATE_TABLES4 +# CHILD2_1_SELECT_TABLES4 +# CHILD2_1_DROP_TABLES5 +# CHILD2_1_CREATE_TABLES5 +# CHILD2_1_SELECT_TABLES5 +# CHILD2_1_DROP_TABLES6 +# CHILD2_1_CREATE_TABLES6 +# CHILD2_1_SELECT_TABLES6 diff --git a/storage/spider/mysql-test/spider/my_2_2.cnf b/storage/spider/mysql-test/spider/my_2_2.cnf new file mode 100644 index 00000000000..2d3c2a89a7d --- /dev/null +++ b/storage/spider/mysql-test/spider/my_2_2.cnf @@ -0,0 +1,38 @@ +[mysqld.2.2] +loose_handlersocket_port= 20004 +loose_handlersocket_port_wr= 20005 +loose_handlersocket_threads= 2 +loose_handlersocket_threads_wr= 1 +loose_handlersocket_support_merge_table= 0 +loose_handlersocket_direct_update_mode= 2 +loose_handlersocket_unlimited_boundary= 65536 +loose_handlersocket_bulk_insert= 0 +loose_handlersocket_bulk_insert_timeout= 0 +loose_handlersocket_general_log= 1 +loose_handlersocket_timeout= 30 +loose_handlersocket_close_table_interval=2 +open_files_limit= 4096 + +[ENV] +CHILD2_2_MYPORT= @mysqld.2.2.port +CHILD2_2_HSRPORT= 20004 +CHILD2_2_HSWPORT= 20005 +CHILD2_2_MYSOCK= @mysqld.2.2.socket +CHILD2_2_ENGINE_TYPE= InnoDB +CHILD2_2_ENGINE= ENGINE=InnoDB +CHILD2_2_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_FT_MYPORT= @mysqld.2.2.port +CHILD2_2_FT_MYSOCK= @mysqld.2.2.socket +CHILD2_2_FT_ENGINE_TYPE= MyISAM +CHILD2_2_FT_ENGINE= ENGINE=MyISAM +CHILD2_2_FT_CHARSET= DEFAULT CHARSET=utf8 +CHILD2_2_GM_MYPORT= @mysqld.2.2.port +CHILD2_2_GM_MYSOCK= @mysqld.2.2.socket +CHILD2_2_GM_ENGINE_TYPE= MyISAM +CHILD2_2_GM_ENGINE= ENGINE=MyISAM +CHILD2_2_GM_CHARSET= DEFAULT CHARSET=utf8 + +#The followings are set in include/init_xxx.inc files +# CHILD2_2_DROP_TABLES +# CHILD2_2_CREATE_TABLES +# CHILD2_2_SELECT_TABLES diff --git a/storage/spider/mysql-test/spider/my_2_3.cnf b/storage/spider/mysql-test/spider/my_2_3.cnf new file mode 100644 index 00000000000..3e62d151b3d --- /dev/null +++ b/storage/spider/mysql-test/spider/my_2_3.cnf @@ -0,0 +1,9 @@ +[mysqld.2.3] +loose_partition= 1 + +[ENV] +CHILD2_3_MYPORT= @mysqld.2.3.port +CHILD2_3_MYSOCK= @mysqld.2.3.socket +CHILD2_3_ENGINE_TYPE= InnoDB +CHILD2_3_ENGINE= ENGINE=InnoDB +CHILD2_3_CHARSET= DEFAULT CHARSET=utf8 diff --git a/storage/spider/mysql-test/spider/my_3_1.cnf b/storage/spider/mysql-test/spider/my_3_1.cnf new file mode 100644 index 00000000000..fad21607789 --- /dev/null +++ b/storage/spider/mysql-test/spider/my_3_1.cnf @@ -0,0 +1,11 @@ +[mysqld.3.1] +loose_partition= 1 + +[ENV] +USE_CHILD_GROUP3= 1 +OUTPUT_CHILD_GROUP3= 0 +CHILD3_1_MYPORT= @mysqld.3.1.port +CHILD3_1_MYSOCK= @mysqld.3.1.socket +CHILD3_1_ENGINE_TYPE= InnoDB +CHILD3_1_ENGINE= ENGINE=InnoDB +CHILD3_1_CHARSET= DEFAULT CHARSET=utf8 diff --git a/storage/spider/mysql-test/spider/my_3_2.cnf b/storage/spider/mysql-test/spider/my_3_2.cnf new file mode 100644 index 00000000000..6f027b6f525 --- /dev/null +++ b/storage/spider/mysql-test/spider/my_3_2.cnf @@ -0,0 +1,9 @@ +[mysqld.3.2] +loose_partition= 1 + +[ENV] +CHILD3_2_MYPORT= @mysqld.3.2.port +CHILD3_2_MYSOCK= @mysqld.3.2.socket +CHILD3_2_ENGINE_TYPE= InnoDB +CHILD3_2_ENGINE= ENGINE=InnoDB +CHILD3_2_CHARSET= DEFAULT CHARSET=utf8 diff --git a/storage/spider/mysql-test/spider/my_3_3.cnf b/storage/spider/mysql-test/spider/my_3_3.cnf new file mode 100644 index 00000000000..fbb33694738 --- /dev/null +++ b/storage/spider/mysql-test/spider/my_3_3.cnf @@ -0,0 +1,9 @@ +[mysqld.3.3] +loose_partition= 1 + +[ENV] +CHILD3_3_MYPORT= @mysqld.3.3.port +CHILD3_3_MYSOCK= @mysqld.3.3.socket +CHILD3_3_ENGINE_TYPE= InnoDB +CHILD3_3_ENGINE= ENGINE=InnoDB +CHILD3_3_CHARSET= DEFAULT CHARSET=utf8 diff --git a/storage/spider/mysql-test/spider/my_4_1.cnf b/storage/spider/mysql-test/spider/my_4_1.cnf new file mode 100644 index 00000000000..d1812a48b68 --- /dev/null +++ b/storage/spider/mysql-test/spider/my_4_1.cnf @@ -0,0 +1,9 @@ +[mysqld.4.1] +loose_partition= 1 + +[ENV] +SLAVE1_1_MYPORT= @mysqld.4.1.port +SLAVE1_1_MYSOCK= @mysqld.4.1.socket +SLAVE1_1_ENGINE_TYPE= MyISAM +SLAVE1_1_ENGINE= ENGINE=MyISAM +SLAVE1_1_CHARSET= DEFAULT CHARSET=utf8 From ad0ee8cdb9b5692745c7e4cae334133e45bf63e8 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 25 Jun 2024 14:22:25 +0800 Subject: [PATCH 5/6] MDEV-33746 [fixup] Add suggested overrides in oqgraph --- storage/oqgraph/graphcore.cc | 18 +++++----- storage/oqgraph/ha_oqgraph.h | 66 ++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/storage/oqgraph/graphcore.cc b/storage/oqgraph/graphcore.cc index 92796538de3..ecf7a066b2b 100644 --- a/storage/oqgraph/graphcore.cc +++ b/storage/oqgraph/graphcore.cc @@ -266,10 +266,10 @@ namespace open_query { : oqgraph_cursor(arg), no_weight(), sequence(0), results(), last() { } - int fetch_row(const row &, row&); - int fetch_row(const row &, row&, const reference&); + int fetch_row(const row &, row&) override; + int fetch_row(const row &, row&, const reference&) override; - void current(reference& ref) const + void current(reference& ref) const override { ref= last; } @@ -286,10 +286,10 @@ namespace open_query { : oqgraph_cursor(arg), position(0) { } - int fetch_row(const row &, row&); - int fetch_row(const row &, row&, const reference&); + int fetch_row(const row &, row&) override; + int fetch_row(const row &, row&, const reference&) override; - void current(reference& ref) const + void current(reference& ref) const override { ref= last; } @@ -308,10 +308,10 @@ namespace open_query { : oqgraph_cursor(arg), position(0), last() { } - int fetch_row(const row &, row&); - int fetch_row(const row &, row&, const reference&); + int fetch_row(const row &, row&) override; + int fetch_row(const row &, row&, const reference&) override; - void current(reference& ref) const + void current(reference& ref) const override { ref= last; } diff --git a/storage/oqgraph/ha_oqgraph.h b/storage/oqgraph/ha_oqgraph.h index c8e175df616..8303823da28 100644 --- a/storage/oqgraph/ha_oqgraph.h +++ b/storage/oqgraph/ha_oqgraph.h @@ -58,59 +58,59 @@ class ha_oqgraph: public handler public: #if MYSQL_VERSION_ID >= 50100 ha_oqgraph(handlerton *hton, TABLE_SHARE *table); - ulonglong table_flags() const; + ulonglong table_flags() const override; #else ha_oqgraph(TABLE *table); Table_flags table_flags() const; #endif virtual ~ha_oqgraph(); - const char *index_type(uint inx) + const char *index_type(uint inx) override { return "HASH"; } /* Rows also use a fixed-size format */ - enum row_type get_row_type() const { return ROW_TYPE_FIXED; } - ulong index_flags(uint inx, uint part, bool all_parts) const; + enum row_type get_row_type() const override { return ROW_TYPE_FIXED; } + ulong index_flags(uint inx, uint part, bool all_parts) const override; const char **bas_ext() const; - uint max_supported_keys() const { return MAX_KEY; } - uint max_supported_key_part_length() const { return MAX_KEY_LENGTH; } - double scan_time() { return (double) 1000000000; } - double read_time(uint index, uint ranges, ha_rows rows) + uint max_supported_keys() const override { return MAX_KEY; } + uint max_supported_key_part_length() const override { return MAX_KEY_LENGTH; } + double scan_time() override { return (double) 1000000000; } + double read_time(uint, uint, ha_rows) override { return 1; } // Doesn't make sense to change the engine on a virtual table. - virtual bool can_switch_engines() { return false; } + virtual bool can_switch_engines() override { return false; } - int open(const char *name, int mode, uint test_if_locked); - int close(void); - int write_row(const byte * buf); - int update_row(const uchar * old_data, const uchar * new_data); - int delete_row(const byte * buf); + int open(const char *name, int mode, uint test_if_locked) override; + int close(void) override; + int write_row(const byte * buf) override; + int update_row(const uchar * old_data, const uchar * new_data) override; + int delete_row(const byte * buf) override; int index_read(byte * buf, const byte * key, - uint key_len, enum ha_rkey_function find_flag); + uint key_len, enum ha_rkey_function find_flag) override; int index_read_idx(byte * buf, uint idx, const byte * key, uint key_len, enum ha_rkey_function find_flag); - int index_next_same(byte * buf, const byte * key, uint key_len); - int rnd_init(bool scan); - int rnd_next(byte *buf); - int rnd_pos(byte * buf, byte *pos); - void position(const byte *record); - int info(uint); - int extra(enum ha_extra_function operation); - int external_lock(THD *thd, int lock_type); - int delete_all_rows(void); + int index_next_same(byte * buf, const byte * key, uint key_len) override; + int rnd_init(bool scan) override; + int rnd_next(byte *buf) override; + int rnd_pos(byte * buf, byte *pos) override; + void position(const byte *record) override; + int info(uint) override; + int extra(enum ha_extra_function operation) override; + int external_lock(THD *thd, int lock_type) override; + int delete_all_rows(void) override; ha_rows records_in_range(uint inx, const key_range *min_key, - const key_range *max_key, page_range *pages); - int delete_table(const char *from); - int rename_table(const char * from, const char * to); - int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); - void update_create_info(HA_CREATE_INFO *create_info); + const key_range *max_key, page_range *pages) override; + int delete_table(const char *from) override; + int rename_table(const char * from, const char * to) override; + int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info) override; + void update_create_info(HA_CREATE_INFO *create_info) override; THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, - enum thr_lock_type lock_type); - int cmp_ref(const byte *ref1, const byte *ref2); + enum thr_lock_type lock_type) override; + int cmp_ref(const byte *ref1, const byte *ref2) override; - bool get_error_message(int error, String* buf); + bool get_error_message(int error, String* buf) override; void fprint_error(const char* fmt, ...); @@ -123,7 +123,7 @@ public: uint key_length, qc_engine_callback *engine_callback, - ulonglong *engine_data) + ulonglong *engine_data) override { /* Do not put data from OQGRAPH tables into query cache (because there From 53a4867837fa7012199a9ab6eef5c4a57f3df564 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Thu, 6 Jun 2024 15:53:16 +1000 Subject: [PATCH 6/6] MDEV-34313: compiler mariadb-binlog WITHOUT_SERVER The log_event_old.cc is included by mysqlbinlog.cc. With -DWITHOUT_SERVER the include path for the wsrep include headers isn't there. As these aren't needed by the mariadb-binlog, move these to under a ifndef MYSQL_CLIENT preprocessor. Caused by MDEV-18590 --- sql/log_event_old.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 4246595f8e4..a493cedfd94 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -27,13 +27,13 @@ #include "lock.h" // mysql_unlock_tables #include "rpl_rli.h" #include "rpl_utility.h" -#endif -#include "log_event_old.h" -#include "rpl_record_old.h" -#include "transaction.h" #ifdef WITH_WSREP #include "wsrep_mysqld.h" #endif /* WITH_WSREP */ +#endif /* MYSQL_CLIENT */ +#include "log_event_old.h" +#include "rpl_record_old.h" +#include "transaction.h" PSI_memory_key key_memory_log_event_old;