From afc64eacc992dd9736a0284926a34d9d5124aabf Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 18 Aug 2023 07:42:06 +0400 Subject: [PATCH 01/10] MDEV-31719 Wrong result of: WHERE inet6_column IN ('','::1') The problem was earlier fixed by a patch for MDEV-27207 68403eeda320ad0831563ce09a9c4af1549fe65e and an additional cleanup patch for MDEV-27207 88dd50b80ad9624d05b72751fd6e4a2cfdb6a3fe The above patches added MTR tests for INET6. Now adding UUID specific MTR tests only. --- .../mysql-test/type_uuid/type_uuid.result | 15 +++++++++++++++ .../type_uuid/mysql-test/type_uuid/type_uuid.test | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result index dcbf9c5e51d49..62612354f7f8b 100644 --- a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.result @@ -3187,3 +3187,18 @@ SELECT * FROM t1 WHERE d >= ALL (SELECT * FROM t1); d 00000000-0000-0000-0000-111111111111 DROP TABLE t1; +# +# MDEV-31719 Wrong result of: WHERE inet6_column IN ('','::1') +# +CREATE TABLE t1 (a UUID); +INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000000'); +SELECT * FROM t1 WHERE a IN ('','00000000-0000-0000-0000-000000000001'); +a +Warnings: +Warning 1292 Incorrect uuid value: '' +SELECT * FROM t1 WHERE a=''; +a +Warnings: +Warning 1292 Incorrect uuid value: '' +Warning 1292 Incorrect uuid value: '' +DROP TABLE t1; diff --git a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.test b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.test index d4e34c5a74bff..0979582a69a18 100644 --- a/plugin/type_uuid/mysql-test/type_uuid/type_uuid.test +++ b/plugin/type_uuid/mysql-test/type_uuid/type_uuid.test @@ -1682,3 +1682,14 @@ SELECT * FROM t1 ORDER BY d; SELECT * FROM t1 WHERE d <= ALL (SELECT * FROM t1); SELECT * FROM t1 WHERE d >= ALL (SELECT * FROM t1); DROP TABLE t1; + + +--echo # +--echo # MDEV-31719 Wrong result of: WHERE inet6_column IN ('','::1') +--echo # + +CREATE TABLE t1 (a UUID); +INSERT INTO t1 VALUES ('00000000-0000-0000-0000-000000000000'); +SELECT * FROM t1 WHERE a IN ('','00000000-0000-0000-0000-000000000001'); +SELECT * FROM t1 WHERE a=''; +DROP TABLE t1; From bf3b787e02c51928eef6653f8b3edabda08b378a Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 25 Aug 2023 17:25:47 +0530 Subject: [PATCH 02/10] MDEV-31835 Remove unnecessary extra HA_EXTRA_IGNORE_INSERT call - This commit is different from 10.6 commit c438284863db2ccba8a04437c941a5c8a2d9225b. Due to Commit 045757af4c301757ba449269351cc27b1691a7d6 (MDEV-24621), InnoDB does buffer and pre-sort the records for each index, and build the indexes one page at a time. Multiple large insert ignore statment aborts the server during bulk insert operation. Problem is that InnoDB merge record exceeds the page size. To avoid this scenario, InnoDB should catch too big record while buffering the insert operation itself. row_merge_buf_encode(): returns length of the encoded index record row_merge_buf_write(): Catches the DB_TOO_BIG_RECORD earlier and returns error --- include/my_base.h | 4 +--- .../suite/innodb/r/insert_into_empty,4k.rdiff | 2 ++ mysql-test/suite/innodb/t/insert_into_empty.test | 8 ++++++++ sql/ha_partition.cc | 1 - sql/sql_insert.cc | 3 --- sql/sql_table.cc | 3 --- sql/table.cc | 1 - storage/innobase/handler/ha_innodb.cc | 7 ------- storage/innobase/include/trx0trx.h | 7 +++++++ storage/innobase/row/row0merge.cc | 16 ++++++++++++---- storage/innobase/trx/trx0roll.cc | 3 +++ storage/mroonga/ha_mroonga.cpp | 3 --- 12 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 mysql-test/suite/innodb/r/insert_into_empty,4k.rdiff diff --git a/include/my_base.h b/include/my_base.h index f237eb8a4d17b..9a5a4e945d558 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -218,9 +218,7 @@ enum ha_extra_function { /** Start writing rows during ALTER TABLE...ALGORITHM=COPY. */ HA_EXTRA_BEGIN_ALTER_COPY, /** Finish writing rows during ALTER TABLE...ALGORITHM=COPY. */ - HA_EXTRA_END_ALTER_COPY, - /** IGNORE is being used for the insert statement */ - HA_EXTRA_IGNORE_INSERT + HA_EXTRA_END_ALTER_COPY }; /* Compatible option, to be deleted in 6.0 */ diff --git a/mysql-test/suite/innodb/r/insert_into_empty,4k.rdiff b/mysql-test/suite/innodb/r/insert_into_empty,4k.rdiff new file mode 100644 index 0000000000000..baa017ecf863f --- /dev/null +++ b/mysql-test/suite/innodb/r/insert_into_empty,4k.rdiff @@ -0,0 +1,2 @@ +423a424 +> ERROR 42000: Row size too large (> 1982). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline. diff --git a/mysql-test/suite/innodb/t/insert_into_empty.test b/mysql-test/suite/innodb/t/insert_into_empty.test index ac55b9054a84e..baba5a146cc61 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty.test +++ b/mysql-test/suite/innodb/t/insert_into_empty.test @@ -435,6 +435,14 @@ CREATE TABLE t1 (pk int primary key, c01 text, c02 text, c03 text, SET GLOBAL INNODB_DEFAULT_ROW_FORMAT= COMPACT; --replace_result 1982 8126 4030 8126 ALTER TABLE t1 FORCE; +let $page_size= `SELECT @@innodb_page_size`; +let $error_code = 0; + +if ($page_size == 4096) { + let $error_code = ER_TOO_BIG_ROWSIZE; +} + +--error $error_code INSERT IGNORE INTO t1 VALUES (1, REPEAT('x',4805), REPEAT('t',2211), REPEAT('u',974), REPEAT('e',871), REPEAT('z',224), REPEAT('j',978), REPEAT('n',190), REPEAT('t',888), REPEAT('x',32768), REPEAT('e',968), REPEAT('b',913), REPEAT('x',12107)), (2, REPEAT('x',4805), REPEAT('t',2211), REPEAT('u',974), REPEAT('e',871), REPEAT('z',224), REPEAT('j',978), REPEAT('n',190), REPEAT('t',888), REPEAT('x',32768), REPEAT('e',968), REPEAT('b',913), REPEAT('x',12107)); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 40cf7cd9b5e04..c171f50574368 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -9479,7 +9479,6 @@ int ha_partition::extra(enum ha_extra_function operation) case HA_EXTRA_STARTING_ORDERED_INDEX_SCAN: case HA_EXTRA_BEGIN_ALTER_COPY: case HA_EXTRA_END_ALTER_COPY: - case HA_EXTRA_IGNORE_INSERT: DBUG_RETURN(loop_partitions(extra_cb, &operation)); default: { diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 3c32540947353..886c1300d2598 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2210,9 +2210,6 @@ int write_record(THD *thd, TABLE *table, COPY_INFO *info, select_result *sink) goto after_trg_or_ignored_err; } - /* Notify the engine about insert ignore operation */ - if (info->handle_duplicates == DUP_ERROR && info->ignore) - table->file->extra(HA_EXTRA_IGNORE_INSERT); after_trg_n_copied_inc: info->copied++; thd->record_first_successful_insert_id_in_cur_stmt(table->file->insert_id_for_cur_row); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2ba233d5286f6..5e58c0d0f8700 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -11841,9 +11841,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, } else { - /* In case of alter ignore, notify the engine about it. */ - if (ignore) - to->file->extra(HA_EXTRA_IGNORE_INSERT); DEBUG_SYNC(thd, "copy_data_between_tables_before"); found_count++; mysql_stage_set_work_completed(thd->m_stage_progress_psi, found_count); diff --git a/sql/table.cc b/sql/table.cc index bdfd9ff2c84f7..a906719bbe846 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -10088,7 +10088,6 @@ bool TR_table::update(ulonglong start_id, ulonglong end_id) table->file->print_error(error, MYF(0)); /* extra() is used to apply the bulk insert operation on mysql/transaction_registry table */ - table->file->extra(HA_EXTRA_IGNORE_INSERT); return error; } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e83ed4b1250e7..f9b9acd6c57e3 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -15679,13 +15679,6 @@ ha_innobase::extra( case HA_EXTRA_RESET_STATE: reset_template(); trx->duplicates = 0; - /* fall through */ - case HA_EXTRA_IGNORE_INSERT: - /* HA_EXTRA_IGNORE_INSERT is very similar to - HA_EXTRA_IGNORE_DUP_KEY, but with one crucial difference: - we want !trx->duplicates for INSERT IGNORE so that - row_ins_duplicate_error_in_clust() will acquire a - shared lock instead of an exclusive lock. */ stmt_boundary: trx->bulk_insert_apply(); trx->end_bulk_insert(*m_prebuilt->table); diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 152e794ac6ae7..770d80c48e781 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -532,6 +532,13 @@ class trx_mod_table_time_t { return bulk_store && is_bulk_insert(); } + + /** Free bulk insert operation */ + void clear_bulk_buffer() + { + delete bulk_store; + bulk_store= nullptr; + } }; /** Collection of persistent tables and their first modification diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 32e61e65ba13a..abfa79a59d98d 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -281,10 +281,10 @@ row_merge_insert_index_tuples( ut_stage_alter_t* stage= nullptr, merge_file_t* blob_file= nullptr); -/******************************************************//** -Encode an index record. */ +/** Encode an index record. +@return size of the record */ static MY_ATTRIBUTE((nonnull)) -void +ulint row_merge_buf_encode( /*=================*/ byte** b, /*!< in/out: pointer to @@ -315,6 +315,7 @@ row_merge_buf_encode( entry->fields, n_fields); *b += size; + return size; } static MY_ATTRIBUTE((malloc, nonnull)) @@ -1175,7 +1176,13 @@ dberr_t row_merge_buf_write(const row_merge_buf_t *buf, } } - row_merge_buf_encode(&b, index, entry, n_fields); + ulint rec_size= row_merge_buf_encode( + &b, index, entry, n_fields); + if (blob_file && rec_size > srv_page_size) { + err = DB_TOO_BIG_RECORD; + goto func_exit; + } + ut_ad(b < &block[srv_sort_buf_size]); DBUG_LOG("ib_merge_sort", @@ -5390,6 +5397,7 @@ dberr_t trx_t::bulk_insert_apply_low() if (t.second.get_first() < low_limit) low_limit= t.second.get_first(); delete t.second.bulk_store; + t.second.bulk_store= nullptr; } } trx_savept_t bulk_save{low_limit}; diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index 99cf1364192a1..f21ba4229b6a1 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -146,7 +146,10 @@ inline void trx_t::rollback_low(trx_savept_t *savept) trx_mod_tables_t::iterator j= i++; ut_ad(j->second.valid()); if (j->second.rollback(limit)) + { + j->second.clear_bulk_buffer(); mod_tables.erase(j); + } else if (!apply_online_log) apply_online_log= j->first->is_active_ddl(); } diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index a0eda4f4fce7a..f5a48ff17cbaa 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -596,9 +596,6 @@ static const char *mrn_inspect_extra_function(enum ha_extra_function operation) inspected = "HA_EXTRA_NO_AUTOINC_LOCKING"; break; #endif - case HA_EXTRA_IGNORE_INSERT: - inspected = "HA_EXTRA_IGNORE_INSERT"; - break; } return inspected; } From f4cec369a392c8a6056207012992ad4a5639965a Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Sat, 19 Aug 2023 22:48:16 +0800 Subject: [PATCH 03/10] MDEV-31963 cmake: fix libfmt usage `fmt::detail::make_arg` does not accept temporaries, so the code snippet checking system libfmt needs to be adjusted. Signed-off-by: Ruoyu Zhong --- cmake/libfmt.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/libfmt.cmake b/cmake/libfmt.cmake index 7eaa0dfa0128e..70b6a07216f90 100644 --- a/cmake/libfmt.cmake +++ b/cmake/libfmt.cmake @@ -33,8 +33,9 @@ MACRO (CHECK_LIBFMT) #include #include int main() { + int answer= 42; fmt::format_args::format_arg arg= - fmt::detail::make_arg(42); + fmt::detail::make_arg(answer); std::cout << fmt::vformat(\"The answer is {}.\", fmt::format_args(&arg, 1)); }" HAVE_SYSTEM_LIBFMT) From cd5808eb8da13c5626d4bdeb452cef6ada29cb1d Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Sun, 20 Aug 2023 19:43:57 +0800 Subject: [PATCH 04/10] MDEV-31963 Fix libfmt usage in SFORMAT `fmt::detail::make_arg` does not accept temporaries. Make it happy by storing the format arg values in a temporary array first. Signed-off-by: Ruoyu Zhong --- sql/item_strfunc.cc | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 007e2bbc16f6f..4bbf36ec1cf30 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1407,11 +1407,24 @@ namespace fmt { */ String *Item_func_sformat::val_str(String *res) { + /* + A union that stores a numeric format arg value. + fmt::detail::make_arg does not accept temporaries, so all of its numeric + args are temporarily stored in the fmt_args array. + See: https://github.com/fmtlib/fmt/issues/3596 + */ + union Format_arg_store { + longlong val_int; + float val_float; + double val_double; + }; + DBUG_ASSERT(fixed()); - using ctx= fmt::format_context; - String *fmt_arg= NULL; - String *parg= NULL; - fmt::format_args::format_arg *vargs= NULL; + using ctx= fmt::format_context; + String *fmt_arg= NULL; + String *parg= NULL; + fmt::format_args::format_arg *vargs= NULL; + Format_arg_store *fmt_args= NULL; null_value= true; if (!(fmt_arg= args[0]->val_str(res))) @@ -1420,25 +1433,39 @@ String *Item_func_sformat::val_str(String *res) if (!(vargs= new fmt::format_args::format_arg[arg_count - 1])) return NULL; + if (!(fmt_args= new Format_arg_store[arg_count - 1])) + { + delete [] vargs; + return NULL; + } + /* Creates the array of arguments for vformat */ for (uint carg= 1; carg < arg_count; carg++) { switch (args[carg]->result_type()) { case INT_RESULT: - vargs[carg-1]= fmt::detail::make_arg(args[carg]->val_int()); + fmt_args[carg-1].val_int= args[carg]->val_int(); + vargs[carg-1]= fmt::detail::make_arg(fmt_args[carg-1].val_int); break; case DECIMAL_RESULT: // TODO case REAL_RESULT: if (args[carg]->field_type() == MYSQL_TYPE_FLOAT) - vargs[carg-1]= fmt::detail::make_arg((float)args[carg]->val_real()); + { + fmt_args[carg-1].val_float= (float)args[carg]->val_real(); + vargs[carg-1]= fmt::detail::make_arg(fmt_args[carg-1].val_float); + } else - vargs[carg-1]= fmt::detail::make_arg(args[carg]->val_real()); + { + fmt_args[carg-1].val_double= args[carg]->val_real(); + vargs[carg-1]= fmt::detail::make_arg(fmt_args[carg-1].val_double); + } break; case STRING_RESULT: if (!(parg= args[carg]->val_str(&val_arg[carg-1]))) { delete [] vargs; + delete [] fmt_args; return NULL; } vargs[carg-1]= fmt::detail::make_arg(*parg); @@ -1448,6 +1475,7 @@ String *Item_func_sformat::val_str(String *res) default: DBUG_ASSERT(0); delete [] vargs; + delete [] fmt_args; return NULL; } } @@ -1471,6 +1499,7 @@ String *Item_func_sformat::val_str(String *res) null_value= true; } delete [] vargs; + delete [] fmt_args; return null_value ? NULL : res; } From cb384d0d04bed63b714d6d7b02d26b19d22740cc Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 29 Aug 2023 10:37:08 +0530 Subject: [PATCH 05/10] MDEV-32008 auto_increment value on table increments by one after restart - This issue caused by commit 4700f2ac70f8c79f2ac1968b6b59d18716f492bf(MDEV-30796) During bulk insert operation, InnoDB wrongly stores the next autoincrement value as current autoincrement value. So update the current autoincrement value rather than next auto increment value. --- .../innodb/r/insert_into_empty_notembedded.result | 15 +++++++++++++++ .../innodb/t/insert_into_empty_notembedded.test | 3 +++ storage/innobase/row/row0merge.cc | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/insert_into_empty_notembedded.result b/mysql-test/suite/innodb/r/insert_into_empty_notembedded.result index 789c17dfb202b..585a2e6c72553 100644 --- a/mysql-test/suite/innodb/r/insert_into_empty_notembedded.result +++ b/mysql-test/suite/innodb/r/insert_into_empty_notembedded.result @@ -28,6 +28,7 @@ DROP DATABASE db1; # # End of 10.6 tests # +SET foreign_key_checks=0, unique_checks=0; # # MDEV-30796 Auto_increment values not updated after bulk # insert operation @@ -35,7 +36,21 @@ DROP DATABASE db1; CREATE TABLE t1(f1 INT NOT NULL AUTO_INCREMENT, f2 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB; INSERT INTO t1 VALUES(1, 2), (25, 3), (2, 4); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL AUTO_INCREMENT, + `f2` int(11) NOT NULL, + PRIMARY KEY (`f1`) +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci # restart +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL AUTO_INCREMENT, + `f2` int(11) NOT NULL, + PRIMARY KEY (`f1`) +) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT INTO t1(f2) VALUES(5); SELECT max(f1) FROM t1; max(f1) diff --git a/mysql-test/suite/innodb/t/insert_into_empty_notembedded.test b/mysql-test/suite/innodb/t/insert_into_empty_notembedded.test index 0caeea59aae9e..078ca0205bd6c 100644 --- a/mysql-test/suite/innodb/t/insert_into_empty_notembedded.test +++ b/mysql-test/suite/innodb/t/insert_into_empty_notembedded.test @@ -42,6 +42,7 @@ DROP DATABASE db1; --echo # End of 10.6 tests --echo # +SET foreign_key_checks=0, unique_checks=0; --echo # --echo # MDEV-30796 Auto_increment values not updated after bulk --echo # insert operation @@ -49,7 +50,9 @@ DROP DATABASE db1; CREATE TABLE t1(f1 INT NOT NULL AUTO_INCREMENT, f2 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB; INSERT INTO t1 VALUES(1, 2), (25, 3), (2, 4); +SHOW CREATE TABLE t1; --source include/restart_mysqld.inc +SHOW CREATE TABLE t1; INSERT INTO t1(f2) VALUES(5); SELECT max(f1) FROM t1; DROP TABLE t1; diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index abfa79a59d98d..b6c3feb786ff9 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -5344,7 +5344,7 @@ dberr_t row_merge_bulk_t::write_to_index(ulint index_no, trx_t *trx) if (err != DB_SUCCESS) trx->error_info= index; else if (index->is_primary() && table->persistent_autoinc) - btr_write_autoinc(index, table->autoinc); + btr_write_autoinc(index, table->autoinc - 1); err= btr_bulk.finish(err); return err; } From 0b6de3d1ceb9a8943d62f0f6d7bf26363189bcb1 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 29 Aug 2023 11:24:16 +0200 Subject: [PATCH 06/10] avoid "'sh' is not recognized..." error in mtr on windows --- plugin/hashicorp_key_management/mysql-test/vault/suite.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/hashicorp_key_management/mysql-test/vault/suite.pm b/plugin/hashicorp_key_management/mysql-test/vault/suite.pm index 1d78985f363e4..fce1737311dad 100644 --- a/plugin/hashicorp_key_management/mysql-test/vault/suite.pm +++ b/plugin/hashicorp_key_management/mysql-test/vault/suite.pm @@ -4,13 +4,13 @@ package My::Suite::Vault; use strict; -return "Hashicorp Vault key management utility not found" - unless `sh -c "command -v vault"`; - return "You need to set the value of the VAULT_ADDR variable" unless $ENV{VAULT_ADDR}; return "You need to set the value of the VAULT_TOKEN variable" unless $ENV{VAULT_TOKEN}; +return "Hashicorp Vault key management utility not found" + unless `sh -c "command -v vault"`; + bless {}; From 69c420be3d78979090cf186a512a55ebfdcd71ec Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 18 Aug 2023 13:14:14 +0300 Subject: [PATCH 07/10] Added support for --skip-secure-file-priv This works the same as secure-file-priv="", but is more obvious way to turn of secure-file-priv. --- sql/mysqld.cc | 7 +++++++ sql/mysqld.h | 1 + sql/sys_vars.cc | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 99717a2c0582e..1f2a73bb06fdf 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8261,6 +8261,13 @@ mysqld_get_one_option(const struct my_option *opt, const char *argument, case OPT_SERVER_ID: ::server_id= global_system_variables.server_id; break; + case OPT_SEQURE_FILE_PRIV: + if (argument == disabled_my_option) + { + my_free(opt_secure_file_priv); + opt_secure_file_priv= 0; + } + break; case OPT_LOWER_CASE_TABLE_NAMES: lower_case_table_names_used= 1; break; diff --git a/sql/mysqld.h b/sql/mysqld.h index e99d5cb300c35..37ef697e66504 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -842,6 +842,7 @@ enum options_mysqld OPT_MYSQL_COMPATIBILITY, OPT_TLS_VERSION, OPT_MYSQL_TO_BE_IMPLEMENTED, + OPT_SEQURE_FILE_PRIV, OPT_which_is_always_the_last }; #endif diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 6142c0bf077bd..b9f48bfa6497f 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3389,7 +3389,7 @@ static Sys_var_charptr_fscs Sys_secure_file_priv( "Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files " "within specified directory", PREALLOCATED READ_ONLY GLOBAL_VAR(opt_secure_file_priv), - CMD_LINE(REQUIRED_ARG), DEFAULT(0)); + CMD_LINE(REQUIRED_ARG, OPT_SEQURE_FILE_PRIV), DEFAULT(0)); static bool check_server_id(sys_var *self, THD *thd, set_var *var) { From e39ed5d76fea4b6247db0db8d878cb2209e44455 Mon Sep 17 00:00:00 2001 From: Monty Date: Sat, 9 Sep 2023 15:14:28 +0300 Subject: [PATCH 08/10] Updated sql-bench to run with PostgreSQL 14.9 - Updated capabilities for PostgreSQL in server.cfg - Updated test-ATIS & test-table-elimination to work with PostgreSQL - Updated test-transaction test to also work with non transactional tables Other things: - Added test of tables with many keys in test-insert - Added 2 new GROUP BY .. ORDER BY test --- .gitignore | 1 + sql-bench/run-all-tests.sh | 2 +- sql-bench/server-cfg.sh | 111 ++++++----------- sql-bench/test-ATIS.sh | 4 +- sql-bench/test-insert.sh | 186 +++++++++++++++++++++++++++- sql-bench/test-select.sh | 25 +++- sql-bench/test-table-elimination.sh | 20 +-- sql-bench/test-transactions.sh | 25 ++-- 8 files changed, 267 insertions(+), 107 deletions(-) diff --git a/.gitignore b/.gitignore index fdba73a3edbaf..22de4d2b2ee32 100644 --- a/.gitignore +++ b/.gitignore @@ -186,6 +186,7 @@ sql-bench/innotest1b.pl sql-bench/innotest2.pl sql-bench/innotest2a.pl sql-bench/innotest2b.pl +sql-bench/output sql-bench/run-all-tests.pl sql-bench/server-cfg.pl sql-bench/test-ATIS.pl diff --git a/sql-bench/run-all-tests.sh b/sql-bench/run-all-tests.sh index ecab48e88fe02..d600541cbc49f 100644 --- a/sql-bench/run-all-tests.sh +++ b/sql-bench/run-all-tests.sh @@ -25,7 +25,7 @@ # All options to this script is passed to all test program. # useful options: # --fast --force --lock-tables -# --server ==> mysql (default) / mSQL / Pg (postgres) / Solid +# --server ==> mariadb (default) / mysql / Pg (postgres) / Oracle # --user ==> the user with permission to create / drop / select # --pass ==> password for the user # --cmp ==> Compare --server with one of the others (mysql/mSQL/Pg/Solid) diff --git a/sql-bench/server-cfg.sh b/sql-bench/server-cfg.sh index f0fca1d2f01a9..c7a45f888d5bd 100644 --- a/sql-bench/server-cfg.sh +++ b/sql-bench/server-cfg.sh @@ -37,7 +37,7 @@ sub get_server { my ($name,$host,$database,$odbc,$machine,$socket,$connect_options)=@_; my ($server); - if ($name =~ /mysql/i) + if ($name =~ /mysql/i || $name =~ /mariadb/i) { $server=new db_MySQL($host, $database, $machine, $socket,$connect_options); } elsif ($name =~ /pg/i) { $server= new db_Pg($host,$database); } @@ -77,7 +77,7 @@ sub get_server { $server= new db_interbase($host,$database); } else { - die "Unknown sql server name used: $name\nUse one of: Access, Adabas, AdabasD, Empress, FrontBase, Oracle, Informix, InterBase, DB2, mSQL, Mimer, MS-SQL, MySQL, Pg, Solid, SAPDB or Sybase.\nIf the connection is done trough ODBC the name must end with _ODBC\n"; + die "Unknown sql server name used: $name\nUse one of: Access, Adabas, AdabasD, Empress, FrontBase, Oracle, Informix, InterBase, DB2, mSQL, MariaDB, Mimer, MS-SQL, MySQL, Pg, Solid, SAPDB or Sybase.\nIf the connection is done trough ODBC the name must end with _ODBC\n"; } if ($name =~ /_ODBC$/i || defined($odbc) && $odbc) { @@ -98,12 +98,12 @@ sub get_server sub all_servers { return ["Access", "Adabas", "DB2", "Empress", "FrontBase", "Oracle", - "Informix", "InterBase", "Mimer", "mSQL", "MS-SQL", "MySQL", "Pg","SAPDB", - "Solid", "Sybase"]; + "Informix", "InterBase", "MariaDB", "Mimer", "mSQL", "MS-SQL", "MySQL", + "Pg","SAPDB", "Solid", "Sybase"]; } ############################################################################# -# First the configuration for MySQL off course :-) +# First the configuration for MariaDB / MySQL off course :-) ############################################################################# package db_MySQL; @@ -165,6 +165,7 @@ sub new $limits{'max_text_size'} = 1000000; # Good enough for tests $limits{'multi_drop'} = 1; # Drop table can take many tables $limits{'order_by_position'} = 1; # Can use 'ORDER BY 1' + $limits{'order_by_null'} = 1; # Can use 'ORDER BY NULL' $limits{'order_by_unused'} = 1; $limits{'query_size'} = 1000000; # Max size with default buffers. $limits{'select_without_from'}= 1; # Can do 'select 1'; @@ -224,7 +225,7 @@ sub version if ($sth->execute && (@row = $sth->fetchrow_array)) { $row[0] =~ s/-/ /g; # To get better tables with long names - $version="MySQL $row[0]"; + $version="$row[0]"; } $sth->finish; @@ -283,7 +284,6 @@ sub create } foreach $field (@$fields) { -# $field =~ s/ decimal/ double(10,2)/i; $field =~ s/ big_decimal/ double(10,2)/i; $query.= $field . ','; } @@ -604,12 +604,14 @@ sub new $self->{'transactions'} = 1; # Transactions enabled $self->{"vacuum"} = 1; $limits{'join_optimizer'} = 1; # Can optimize FROM tables + # load_data_infile could use function 'insert_file', but I could not get it to + # work because of permissions problems. Disabling for now. $limits{'load_data_infile'} = 0; - $limits{'NEG'} = 1; - $limits{'alter_add_multi_col'}= 0; # alter_add_multi_col ? + $limits{'alter_add_multi_col'}= 1; $limits{'alter_table'} = 1; - $limits{'alter_table_dropcol'}= 0; + $limits{'alter_table_dropcol'}= 1; + $limits{'alter_table_after'} = 0; # Have ALTER TABLE .. AFTER other_column $limits{'column_alias'} = 1; $limits{'func_extra_%'} = 1; $limits{'func_extra_if'} = 0; @@ -649,7 +651,7 @@ sub new $limits{'working_all_fields'} = 1; $limits{'working_blobs'} = 1; # If big varchar/blobs works $limits{'multi_distinct'} = 1; # allows select count(distinct a),count(distinct b).. - + $limits{'insert_multi_value'} = 1; # Have INSERT ... values (1,2),(3,4) return $self; } @@ -657,21 +659,20 @@ sub new sub version { - my ($version,$dir); - $version = "PostgreSQL version ???"; - foreach $dir ($ENV{'PGDATA'},"/usr/local/pgsql/data", "/usr/local/pg/data") + my ($self)=@_; + my ($dbh,$sth,$version,@row); + + $dbh=$self->connect(); + $sth = $dbh->prepare("select VERSION()") or die $DBI::errstr; + $version="PostgreSQL ?"; + if ($sth->execute && (@row = $sth->fetchrow_array)) { - if ($dir && -e "$dir/PG_VERSION") - { - $version= `cat $dir/PG_VERSION`; - if ($? == 0) - { - chomp($version); - $version .= "/ODBC" if ($self->{'data_source'} =~ /:ODBC:/); - return "PostgreSQL $version"; - } - } + $row[0] =~ s/-/ /g; # To get better tables with long names + $version="PostgreSQL $row[0]"; } + $sth->finish; + + $dbh->disconnect; $version .= "/ODBC" if ($self->{'data_source'} =~ /:ODBC:/); return $version; } @@ -707,9 +708,6 @@ sub create $field =~ s/int\(\d*\)/int/; $field =~ s/float\(\d*,\d*\)/float/; $field =~ s/ double/ float/; -# $field =~ s/ decimal/ float/i; -# $field =~ s/ big_decimal/ float/i; -# $field =~ s/ date/ int/i; # Pg doesn't have blob, it has text instead $field =~ s/ blob/ text/; $query.= $field . ','; @@ -718,13 +716,14 @@ sub create push(@queries,$query); foreach $index (@$index) { - $index =~ s/primary key/unique index primary_key/i; - if ($index =~ /^unique.*\(([^\(]*)\)$/i) + if ($index =~ /primary key/ || $index =~ /PRIMARY KEY/) { - # original: $indfield="using btree (" .$1.")"; - # using btree doesnīt seem to work with Postgres anymore; it creates - # the table and adds the index, but it isnīt unique - $indfield=" (" .$1.")"; + $query= substr($query, 0, length($query)-1) . ", $index )"; + next; + } + elsif ($index =~ /^unique.*\(([^\(]*)\)$/i) + { + $indfield=" (" .$1.")"; $in="unique index"; $table="index_$nr"; $nr++; } @@ -752,52 +751,14 @@ sub insert_file { # Syntax: # copy [binary] [with oids] # {to|from} {|stdin|stdout} [using delimiters ] - print "The ascii files aren't correct for postgres ....!!!\n"; - $command = "copy $dbname from '$file' using delimiters ','"; + $command = "copy $dbname from '$file' using delimiters ',' QUOTE ''''"; print "$command\n"; $sth = $dbh->do($command) or die $DBI::errstr; return $sth; } -# -# As postgreSQL wants A % B instead of standard mod(A,B) we have to map -# This will not handle all cases, but as the benchmarks doesn't use functions -# inside MOD() the following should work -# -# PostgreSQL cant handle count(*) or even count(1), but it can handle -# count(1+1) sometimes. ==> this is solved in PostgreSQL 6.3 -# -# PostgreSQL 6.5 is supporting MOD. - sub query { my($self,$sql) = @_; - my(@select,$change); -# if you use PostgreSQL 6.x and x is lower as 5 then uncomment the line below. -# $sql =~ s/mod\(([^,]*),([^\)]*)\)/\($1 % $2\)/gi; -# -# if you use PostgreSQL 6.1.x uncomment the lines below -# if ($sql =~ /select\s+count\(\*\)\s+from/i) { -# } -# elsif ($sql =~ /count\(\*\)/i) -# { -# if ($sql =~ /select\s+(.*)\s+from/i) -# { -# @select = split(/,/,$1); -# if ($select[0] =~ /(.*)\s+as\s+\w+$/i) -# { -# $change = $1; -# } -# else -# { -# $change = $select[0]; -# } -# } -# if (($change =~ /count/i) || ($change eq "")) { -# $change = "1+1"; -# } -# $sql =~ s/count\(\*\)/count($change)/gi; -# } -# till here. return $sql; } @@ -849,10 +810,8 @@ sub vacuum } else { -# $dbh->do("vacuum pg_attributes") || die "Got error: $DBI::errstr when executing 'vacuum'\n"; -# $dbh->do("vacuum pg_index") || die "Got error: $DBI::errstr when executing 'vacuum'\n"; - $dbh->do("vacuum analyze") || die "Got error: $DBI::errstr when executing 'vacuum analyze'\n"; - $dbh->do("vacuum") || die "Got error: $DBI::errstr when executing 'vacuum'\n"; + $dbh->do("vacuum analyze") || die "Got error: $DBI::errstr when executing 'vacuum analyze'\n"; + $dbh->do("vacuum") || die "Got error: $DBI::errstr when executing 'vacuum'\n"; } $end_time=new Benchmark; print "Time for book-keeping (1): " . diff --git a/sql-bench/test-ATIS.sh b/sql-bench/test-ATIS.sh index c51688de0c289..2eca4bed7dcb3 100644 --- a/sql-bench/test-ATIS.sh +++ b/sql-bench/test-ATIS.sh @@ -220,7 +220,7 @@ print "Retrieving data\n"; "select category,count(*) from aircraft where engines=2 group by category having count(*)>4",3,$limits->{'group_functions'} && $limits->{'having_with_group'}, "select flight_number,range_miles,fare_class FROM aircraft,flight,flight_class WHERE flight.flight_code=flight_class.flight_code AND flight.aircraft_code=aircraft.aircraft_code AND range_miles<>0 AND (stops=1 OR stops=2) GROUP BY flight_number,range_miles,fare_class",150,$limits->{'group_functions'}, "select distinct from_airport.time_zone_code,to_airport.time_zone_code,(FLOOR(arrival_time/100)*60+MOD(arrival_time,100)-FLOOR(departure_time/100)*60-MOD(departure_time,100)-time_elapsed)/60 AS time_zone_diff FROM flight,airport AS from_airport,airport AS to_airport WHERE flight.from_airport=from_airport.airport_code AND flight.to_airport=to_airport.airport_code GROUP BY from_airport.time_zone_code,to_airport.time_zone_code,arrival_time,departure_time,time_elapsed",21,$limits->{'func_odbc_mod'} && $limits->{'func_odbc_floor'} && $limits->{'group_functions'}, - "select DISTINCT from_airport.time_zone_code,to_airport.time_zone_code,MOD((FLOOR(arrival_time/100)*60+MOD(arrival_time,100)-FLOOR(departure_time/100)*60-MOD(departure_time,100)-time_elapsed)/60+36,24)-12 AS time_zone_diff FROM flight,airport AS from_airport,airport AS to_airport WHERE flight.from_airport=from_airport.airport_code AND flight.to_airport=to_airport.airport_code and MOD((FLOOR(arrival_time/100)*60+MOD(arrival_time,100)-FLOOR(departure_time/100)*60-MOD(departure_time,100)-time_elapsed)/60+36,24)-12 < 10",14,$limits->{'func_odbc_mod'} && $limits->{'func_odbc_floor'} && $limits->{'group_functions'}, + "select DISTINCT from_airport.time_zone_code,to_airport.time_zone_code,MOD(CAST((FLOOR(arrival_time/100)*60+MOD(arrival_time,100)-FLOOR(departure_time/100)*60-MOD(departure_time,100)-time_elapsed)/60+36 AS INTEGER),24)-12 AS time_zone_diff FROM flight,airport AS from_airport,airport AS to_airport WHERE flight.from_airport=from_airport.airport_code AND flight.to_airport=to_airport.airport_code and MOD(CAST((FLOOR(arrival_time/100)*60+MOD(arrival_time,100)-FLOOR(departure_time/100)*60-MOD(departure_time,100)-time_elapsed)/60+36 AS INTEGER),24)-12 < 10",14,$limits->{'func_odbc_mod'} && $limits->{'func_odbc_floor'} && $limits->{'group_functions'}, "select from_airport,to_airport,range_miles,time_elapsed FROM aircraft,flight WHERE aircraft.aircraft_code=flight.aircraft_code AND to_airport NOT LIKE from_airport AND range_miles<>0 AND time_elapsed<>0 GROUP BY from_airport,to_airport,range_miles,time_elapsed",409,$limits->{'group_functions'} && $limits->{'like_with_column'}, "SELECT airport.country_name,state.state_name,city.city_name,airport_service.direction FROM airport_service,state,airport,city WHERE airport_service.city_code=city.city_code AND airport_service.airport_code=airport.airport_code AND state.state_code=airport.state_code AND state.state_code=city.state_code AND airport.state_code=city.state_code AND airport.country_name=city.country_name AND airport.country_name=state.country_name AND city.time_zone_code=airport.time_zone_code GROUP BY airport.country_name,state.state_name,city.city_name,airport_service.direction ORDER BY state_name",11,$limits->{'group_functions'}, "SELECT airport.country_name,state.state_name,city.city_name,airport_service.direction FROM airport_service,state,airport,city WHERE airport_service.city_code=city.city_code AND airport_service.airport_code=airport.airport_code AND state.state_code=airport.state_code AND state.state_code=city.state_code AND airport.state_code=city.state_code AND airport.country_name=city.country_name AND airport.country_name=state.country_name AND city.time_zone_code=airport.time_zone_code GROUP BY airport.country_name,state.state_name,city.city_name,airport_service.direction ORDER BY state_name DESC",11,$limits->{'group_functions'}, @@ -369,7 +369,7 @@ sub init_data @class_of_service= $server->create("class_of_service", ["class_code char(2) NOT NULL", - "`rank` tinyint(2) NOT NULL", + "rank tinyint(2) NOT NULL", "class_description char(80) NOT NULL"], ["PRIMARY KEY (class_code)"]); @code_description= diff --git a/sql-bench/test-insert.sh b/sql-bench/test-insert.sh index dbdc58fdcca5b..5aee14dc47e30 100644 --- a/sql-bench/test-insert.sh +++ b/sql-bench/test-insert.sh @@ -39,6 +39,7 @@ $small_loop_count=10; # Loop for full table retrieval $range_loop_count=$small_loop_count*50; $many_keys_loop_count=$opt_loop_count; $opt_read_key_loop_count=$opt_loop_count; +$many_key_update=10000; $pwd = cwd(); $pwd = "." if ($pwd eq ''); require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n"; @@ -49,16 +50,19 @@ if ($opt_small_test) $many_keys_loop_count=$opt_loop_count/10; $range_loop_count=10; $opt_read_key_loop_count=10; + $many_key_update=10; } elsif ($opt_small_tables) { $opt_loop_count=10000; # number of rows/3 $many_keys_loop_count=$opt_loop_count; $opt_read_key_loop_count=10; + $many_key_update=10; } elsif ($opt_small_key_tables) { $many_keys_loop_count/=10; + $many_key_update/=10; } if ($opt_loop_count < 100) @@ -101,13 +105,16 @@ $dbh = $server->connect(); #### Create needed tables #### -goto keys_test if ($opt_stage == 2); goto select_test if ($opt_skip_create); -print "Creating tables\n"; $dbh->do("drop table bench1" . $server->{'drop_attr'}); $dbh->do("drop table bench2" . $server->{'drop_attr'}); $dbh->do("drop table bench3" . $server->{'drop_attr'}); + +goto keys_test if ($opt_stage == 2); +goto keys_test2 if ($opt_stage == 3); + +print "Creating tables\n"; do_many($dbh,$server->create("bench1", ["id int NOT NULL", "id2 int NOT NULL", @@ -1590,6 +1597,181 @@ if ($limits->{'insert_multi_value'}) timestr(timediff($end_time, $loop_time),"all") . "\n\n"; } +# +# Test insert and update on a table with a lot of different keys +# + +keys_test2: + +$keys=min($limits->{'max_index'},8); # 8 is more than enough +print "Insert into table with $many_keys_loop_count rows, $keys keys and with simple primary key\n"; + +@fields=(); +@keys=(); + +# Make keys on the most important types +@types=(0,0,1,1,0,0,1,1,1,1,1,1,1,1,1,1); # A 1 for each char field +push(@fields,"field1 integer not null"); +push(@fields,"field2 integer not null"); +push(@fields,"field3 char(16) not null"); +push(@fields,"field4 varchar(64) not null"); +push(@fields,"field5 float not null"); +push(@fields,"field6 double not null"); +push(@fields,"field7 integer not null"); +for ($i=8 ; $i <= 16 ; $i++) +{ + push(@fields,"field$i varchar(16) not null"); +} + +$query="primary key (field1) "; +push (@keys,$query); +# Create other keys +for ($i=2 ; $i <= $keys ; $i++) +{ + push(@keys,"index index$i (field$i)"); +} + +do_many($dbh,$server->create("bench1",\@fields,\@keys)); +if ($opt_lock_tables) +{ + $dbh->do("LOCK TABLES bench1 WRITE") || die $DBI::errstr; +} + +$loop_time=new Benchmark; +if ($opt_fast && $server->{transactions}) +{ + $dbh->{AutoCommit} = 0; +} + +$fields=$#fields+1; +if (($opt_fast || $opt_fast_insert) && $server->{'limits'}->{'insert_multi_value'}) +{ + $query_size=$server->{'limits'}->{'query_size'}; + $query="insert into bench1 values "; + $res=$query; + for ($i=1; $i <= $many_keys_loop_count; $i++) + { + $id= $i; + $rand=$random[$i]; + $tmp="($id,$id,'test$rand','ABCDEF$rand',$rand.0,$rand.0,$rand,"; + + for ($j=8; $j <= $fields ; $j++) + { + $tmp.= ($types[$j] == 0) ? "$rand," : "'$rand',"; + } + substr($tmp,-1)=")"; + if (length($tmp)+length($res) < $query_size) + { + $res.= $tmp . ","; + } + else + { + $sth = $dbh->do(substr($res,0,length($res)-1)) or die "$DBI::errstr"; + $res=$query . $tmp . ","; + } + } + $sth = $dbh->do(substr($res,0,length($res)-1)) or die $DBI::errstr; +} +else +{ + for ($i=1; $i <= $many_keys_loop_count; $i++) + { + $id= $i; + $rand=$random[$i]; + + + $query="insert into bench1 values ($id,$id,'test$rand','ABCDEF$rand',$rand.0,$rand.0,$rand,"; + + for ($j=8; $j <= $fields ; $j++) + { + $query.= ($types[$j] == 0) ? "$rand," : "'$rand',"; + } + substr($query,-1)=")"; + print "query1: $query\n" if ($opt_debug); + $dbh->do($query) or die "Got error $DBI::errstr with query: $query\n"; + } +} + +if ($opt_fast && $server->{transactions}) +{ + $dbh->commit; + $dbh->{AutoCommit} = 1; +} + +$end_time=new Benchmark; +print "Time for insert_many_keys ($many_keys_loop_count): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; + +if ($opt_fast && defined($server->{vacuum})) +{ + if ($opt_lock_tables) + { + do_query($dbh,"UNLOCK TABLES"); + } + + $server->vacuum(1,\$dbh,"bench1"); + if ($opt_lock_tables) + { + $sth = $dbh->do("LOCK TABLES bench1 WRITE") || die $DBI::errstr; + } +} + +# +# Testing of update of table with many keys +# + +$loop_time=new Benchmark; +for ($i=0 ; $i< $many_key_update; $i++) +{ + $tmp= ($i*11 % $many_keys_loop_count)+1; + $query="update bench1 set field7=$i where field1=$tmp"; + $dbh->do($query) or die "Got error $DBI::errstr with query $query\n"; +} +$end_time=new Benchmark; +print "Time for many_key_update_of_key_with_primary ($many_key_update): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; + +$loop_time=new Benchmark; +for ($i=0 ; $i< $many_key_update; $i++) +{ + $tmp= ($i*11 % $many_keys_loop_count)+1; + $query="update bench1 set field7=$i+1 where field2=$tmp"; + $dbh->do($query) or die "Got error $DBI::errstr with query $query\n"; +} +$end_time=new Benchmark; +print "Time for many_key_update_of_key_with_secondary ($many_key_update): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; + +$loop_time=new Benchmark; +for ($i=0 ; $i< $many_key_update; $i++) +{ + $tmp= ($i*11 % $many_keys_loop_count)+2; + $query="update bench1 set field8='hello', field9='world' where field1=$tmp"; + $dbh->do($query) or die "Got error $DBI::errstr with query $query\n"; +} +$end_time=new Benchmark; +print "Time for many_key_update_of_field_with_primary ($many_key_update): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; + +$loop_time=new Benchmark; +for ($i=0 ; $i< $many_key_update; $i++) +{ + $tmp= ($i*11 % $many_keys_loop_count)+3; + $query="update bench1 set field8='world', field9='hello' where field2=$tmp"; + $dbh->do($query) or die "Got error $DBI::errstr with query $query\n"; +} +$end_time=new Benchmark; +print "Time for many_key_update_of_field_with_secondary ($many_key_update): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; + + +$loop_time=new Benchmark; +$sth = $dbh->do("drop table bench1" . $server->{'drop_attr'}) or die $DBI::errstr; +$end_time=new Benchmark; +print "Time for drop table(1): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; + + #### #### End of benchmark #### diff --git a/sql-bench/test-select.sh b/sql-bench/test-select.sh index e3020698cb8c5..fefc860e6efcf 100644 --- a/sql-bench/test-select.sh +++ b/sql-bench/test-select.sh @@ -336,6 +336,29 @@ if ($limits->{'group_functions'}) print "Time for count_group ($i:$rows): " . timestr(timediff($end_time, $loop_time),"all") . "\n"; + $loop_time=new Benchmark; + $rows=0; + for ($i=0 ; $i < $opt_medium_loop_count ; $i++) + { + $rows+=fetch_all_rows($dbh,"select grp_no_key,count(*) from bench1 group by grp_no_key order by grp_no_key"); + } + $end_time=new Benchmark; + + print "Time for count_group_order_group ($i:$rows): " . + timestr(timediff($end_time, $loop_time),"all") . "\n"; + + if ($limits->{'order_by_null'}) + { + $loop_time=new Benchmark; + $rows=0; + for ($i=0 ; $i < $opt_medium_loop_count ; $i++) + { + $rows+=fetch_all_rows($dbh,"select grp_no_key,count(*) from bench1 group by grp_no_key order by null"); + } + $end_time=new Benchmark; + print "Time for count_group_order_null ($i:$rows): " . + timestr(timediff($end_time, $loop_time),"all") . "\n"; + } $loop_time=new Benchmark; $rows=0; for ($i=0 ; $i < $opt_medium_loop_count ; $i++) @@ -344,7 +367,7 @@ if ($limits->{'group_functions'}) } $end_time=new Benchmark; print "Time for count_group_with_order ($i:$rows): " . - timestr(timediff($end_time, $loop_time),"all") . "\n"; + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; } if ($limits->{'group_distinct_functions'}) diff --git a/sql-bench/test-table-elimination.sh b/sql-bench/test-table-elimination.sh index c3a264492a4b3..0f5e53e00a487 100755 --- a/sql-bench/test-table-elimination.sh +++ b/sql-bench/test-table-elimination.sh @@ -34,18 +34,7 @@ $select_current_full_facts=" A2.fromdate=(select MAX(fromdate) from elim_attr2 where id=A2.id); "; -$select_current_full_facts=" - select - F.id, A1.attr1, A2.attr2 - from - elim_facts F - left join elim_attr1 A1 on A1.id=F.id - left join elim_attr2 A2 on A2.id=F.id and - A2.fromdate=(select MAX(fromdate) from - elim_attr2 where id=F.id); -"; -# TODO: same as above but for some given date also? -# TODO: +# TODO: same as above but for some given date also? #### @@ -62,6 +51,7 @@ $start_time=new Benchmark; goto select_test if ($opt_skip_create); print "Creating tables\n"; +$dbh->do("drop view elim_current_facts"); $dbh->do("drop table elim_facts" . $server->{'drop_attr'}); $dbh->do("drop table elim_attr1" . $server->{'drop_attr'}); $dbh->do("drop table elim_attr2" . $server->{'drop_attr'}); @@ -76,7 +66,7 @@ do_many($dbh,$server->create("elim_attr1", ["id integer", "attr1 integer"], ["primary key (id)", - "key (attr1)"])); + "index ix_attr1 (attr1)"])); # Attribute2, time-versioned do_many($dbh,$server->create("elim_attr2", @@ -84,7 +74,7 @@ do_many($dbh,$server->create("elim_attr2", "attr2 integer", "fromdate date"], ["primary key (id, fromdate)", - "key (attr2,fromdate)"])); + "index ix_attr2 (attr2,fromdate)"])); #NOTE: ignoring: if ($limits->{'views'}) $dbh->do("drop view elim_current_facts"); @@ -304,8 +294,8 @@ if ($opt_lock_tables) } if (!$opt_skip_delete) { - do_query($dbh,"drop table elim_facts, elim_attr1, elim_attr2" . $server->{'drop_attr'}); $dbh->do("drop view elim_current_facts"); + do_query($dbh,"drop table elim_facts, elim_attr1, elim_attr2" . $server->{'drop_attr'}); } if ($opt_fast && defined($server->{vacuum})) diff --git a/sql-bench/test-transactions.sh b/sql-bench/test-transactions.sh index 334a6f0a3850a..1b88b258d90bf 100644 --- a/sql-bench/test-transactions.sh +++ b/sql-bench/test-transactions.sh @@ -45,13 +45,6 @@ if ($opt_small_test || $opt_small_tables) $opt_medium_loop_count/=10; } - -if (!$server->{transactions} && !$opt_force) -{ - print "Test skipped because the database doesn't support transactions\n"; - exit(0); -} - #### #### Connect and start timeing #### @@ -90,7 +83,10 @@ $dbh->{AutoCommit} = 0; ### Test insert perfomance ### -test_insert("bench1","insert_commit",0); +if ($server->{transactions}) +{ + test_insert("bench1","insert_commit",0); +} test_insert("bench2","insert_autocommit",1); sub test_insert @@ -130,6 +126,7 @@ print "Test transactions rollback performance\n" if($opt_debug); # then doing a rollback on these # +if ($server->{transactions}) { my ($id,$rev_id,$grp,$region,$end,$loop_time,$end_time,$commit_loop,$count); @@ -171,6 +168,7 @@ print "Test transactions rollback performance\n" if($opt_debug); # then doing a rollback on these # +if ($server->{transactions}) { my ($id,$loop_time,$end_time,$commit_loop,$count); @@ -208,6 +206,7 @@ print "Test transactions rollback performance\n" if($opt_debug); # then doing a rollback on these # +if ($server->{transactions}) { my ($id,$loop_time,$end_time,$commit_loop,$count); @@ -241,7 +240,10 @@ print "Test transactions rollback performance\n" if($opt_debug); ### Test update perfomance ### -test_update("bench1","update_commit",0); +if ($server->{transactions}) +{ + test_update("bench1","update_commit",0); +} test_update("bench2","update_autocommit",1); sub test_update @@ -267,7 +269,10 @@ sub test_update ### Test delete perfomance ### -test_delete("bench1","delete_commit",0); +if ($server->{transactions}) +{ + test_delete("bench1","delete_commit",0); +} test_delete("bench2","delete_autocommit",1); sub test_delete From 11c69177e9eebaab65984ee06e7b2873b3067d5f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 24 Sep 2023 19:32:04 +0200 Subject: [PATCH 09/10] fix galera.galera_as_slave_gtid_myisam for 10.10+ --- mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf index d3f33bd142703..4944c9a90cec7 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf +++ b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf @@ -4,4 +4,4 @@ log-bin=mysqld-bin log-slave-updates binlog-format=ROW -wsrep-replicate-myisam=ON +wsrep_mode=REPLICATE_MYISAM From 8044606a67b509d5bde483c5541efe0c91a4bbef Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 27 Sep 2023 14:54:16 +0200 Subject: [PATCH 10/10] MDEV-32252 "Backup Utilities" not available to install on windows Commit 738d4604b723237681cacbffd0fb88da14ed314a changed component name from "backup" to "Backup". Use the new name now. --- win/packaging/CPackWixConfig.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/packaging/CPackWixConfig.cmake b/win/packaging/CPackWixConfig.cmake index 4ac4d38471e40..afd05745b3cc4 100644 --- a/win/packaging/CPackWixConfig.cmake +++ b/win/packaging/CPackWixConfig.cmake @@ -9,7 +9,7 @@ IF(ESSENTIALS) ENDIF() ELSE() SET(CPACK_COMPONENTS_USED - "Server;Client;Development;SharedLibraries;Documentation;Readme;Common;connect-engine;ClientPlugins;gssapi-server;gssapi-client;aws-key-management;rocksdb-engine;backup;VCCRT") + "Server;Client;Development;SharedLibraries;Documentation;Readme;Common;connect-engine;ClientPlugins;gssapi-server;gssapi-client;aws-key-management;rocksdb-engine;Backup;VCCRT") ENDIF() SET( WIX_FEATURE_MySQLServer_EXTRA_FEATURES "DBInstance;SharedClientServerComponents")