Skip to content

Commit 24bc986

Browse files
author
Paweł Andruszkiewicz
committed
BUG#35304391 MySQL Shell detect/warm case sensitivity
Dump loader did not warn if any rows were replaced during the load, this is now fixed. Change-Id: Ie580e8097813b4f40a8aee1924463836cac3f8d9 (cherry picked from commit 857fcd2ce3dba380525c4952dfdb541e76bf8383)
1 parent b11248d commit 24bc986

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

modules/util/load/dump_loader.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ void Dump_loader::Worker::Load_chunk_task::load(
870870

871871
loader->m_num_chunks_loaded += 1;
872872
loader->m_num_rows_loaded += rows_loaded;
873+
loader->m_num_rows_deleted += stats.total_deleted;
873874
loader->m_num_warnings += stats.total_warnings;
874875
}
875876

@@ -1957,6 +1958,12 @@ void Dump_loader::show_summary() {
19571958
.c_str()));
19581959
}
19591960

1961+
if (m_num_rows_deleted > 0) {
1962+
// BUG#35304391 - notify about replaced rows
1963+
console->print_info(std::to_string(m_num_rows_deleted) +
1964+
" rows were replaced");
1965+
}
1966+
19601967
if (m_options.load_users()) {
19611968
std::string msg =
19621969
std::to_string(m_loaded_accounts) + " accounts were loaded";

modules/util/load/dump_loader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ class Dump_loader {
589589

590590
size_t m_num_bytes_previously_loaded = 0;
591591
std::atomic<size_t> m_num_rows_loaded;
592+
std::atomic<size_t> m_num_rows_deleted = 0;
592593
std::atomic<size_t> m_num_bytes_loaded;
593594
std::atomic<size_t> m_num_raw_bytes_loaded;
594595
std::atomic<size_t> m_num_chunks_loaded;

unittest/scripts/auto/py_shell/scripts/util_dump_and_load_norecord.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,42 @@ def TEST_STRING_OPTION(option):
27252725
shell.connect(__sandbox_uri2)
27262726
dba.drop_metadata_schema({ 'force': True })
27272727

2728+
#@<> BUG#35304391 - loader should notify if rows were replaced during load
2729+
# constants
2730+
dump_dir = os.path.join(outdir, "bug_35304391")
2731+
tested_schema = "tested_schema"
2732+
tested_table = "tested_table"
2733+
2734+
# setup
2735+
shell.connect(__sandbox_uri1)
2736+
session.run_sql("DROP SCHEMA IF EXISTS !", [ tested_schema ])
2737+
session.run_sql("CREATE SCHEMA ! DEFAULT CHARACTER SET latin1 COLLATE latin1_general_cs", [ tested_schema ])
2738+
session.run_sql("CREATE TABLE !.! (id tinyint AUTO_INCREMENT PRIMARY KEY, alias varchar(12) NOT NULL UNIQUE KEY, name varchar(32) NOT NULL)", [ tested_schema, tested_table ])
2739+
session.run_sql("INSERT INTO !.! (alias, name) VALUES ('bond-007', 'James Bond'), ('Bond-007', 'James Bond')", [ tested_schema, tested_table ])
2740+
2741+
# dump
2742+
shell.connect(__sandbox_uri1)
2743+
EXPECT_NO_THROWS(lambda: util.dump_instance(dump_dir, { "includeSchemas": [ tested_schema ], "showProgress": False }), "Dump should not fail")
2744+
2745+
# load
2746+
shell.connect(__sandbox_uri2)
2747+
wipeout_server(session)
2748+
# load just the DDL
2749+
EXPECT_NO_THROWS(lambda: util.load_dump(dump_dir, { "loadData": False, "resetProgress": True, "showProgress": False }), "Load should not fail")
2750+
# change collation to case-insensitive
2751+
session.run_sql("ALTER SCHEMA ! CHARACTER SET latin1 COLLATE latin1_general_ci", [ tested_schema ])
2752+
session.run_sql("ALTER TABLE !.! CONVERT TO CHARACTER SET latin1 COLLATE latin1_general_ci", [ tested_schema, tested_table ])
2753+
# load the data
2754+
WIPE_OUTPUT()
2755+
EXPECT_NO_THROWS(lambda: util.load_dump(dump_dir, { "loadDdl": False, "resetProgress": True, "showProgress": False }), "Load should not fail")
2756+
2757+
# verification
2758+
EXPECT_STDOUT_CONTAINS("1 rows were replaced")
2759+
2760+
#@<> BUG#35304391 - cleanup
2761+
shell.connect(__sandbox_uri1)
2762+
session.run_sql("DROP SCHEMA IF EXISTS !", [tested_schema])
2763+
27282764
#@<> Cleanup
27292765
testutil.destroy_sandbox(__mysql_sandbox_port1)
27302766
testutil.destroy_sandbox(__mysql_sandbox_port2)

0 commit comments

Comments
 (0)