Skip to content

Commit a829315

Browse files
author
Paweł Andruszkiewicz
committed
BUG#35860654 cannot dump a table with single generated column
It was not possible to dump a table which consisted of only a single generated column, this is now fixed. Change-Id: I5b755ca4fe9aabb1412e2813096d216a5f43d139 (cherry picked from commit 876341e9ca517753ed52357eb13710ac5899ee8e)
1 parent 65c6deb commit a829315

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

modules/util/dump/dumper.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4218,9 +4218,10 @@ std::string Dumper::get_query_comment(const Table_data_task &task,
42184218
}
42194219

42204220
bool Dumper::should_dump_data(const Table_task &table) const {
4221-
if (table.schema == "mysql" &&
4222-
(table.name == "apply_status" || table.name == "general_log" ||
4223-
table.name == "schema" || table.name == "slow_log")) {
4221+
if (table.info->columns.empty() ||
4222+
(table.schema == "mysql" &&
4223+
(table.name == "apply_status" || table.name == "general_log" ||
4224+
table.name == "schema" || table.name == "slow_log"))) {
42244225
return false;
42254226
} else {
42264227
return true;

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,6 +3080,35 @@ def create_mhs_schemas(s):
30803080
for schema_name in schema_names:
30813081
session.run_sql("DROP SCHEMA !;", [schema_name])
30823082

3083+
#@<> BUG#35860654 - cannot dump a table with single generated column
3084+
# constants
3085+
dump_dir = os.path.join(outdir, "bug_35860654")
3086+
tested_schema = "tested_schema"
3087+
tested_table = "tested_table"
3088+
3089+
# setup
3090+
session1.run_sql("DROP SCHEMA IF EXISTS !", [ tested_schema ])
3091+
session1.run_sql("CREATE SCHEMA !", [ tested_schema ])
3092+
session1.run_sql("CREATE TABLE !.! (a date GENERATED ALWAYS AS (50399) STORED)", [ tested_schema, tested_table ])
3093+
3094+
#@<> BUG#35860654 - dumping with ocimds should fail, complaining that table doesn't have a PK
3095+
shell.connect(__sandbox_uri1)
3096+
EXPECT_THROWS(lambda: util.dump_schemas([ tested_schema ], dump_dir, { "ocimds": True, "showProgress": False }), "Compatibility issues were found")
3097+
EXPECT_STDOUT_CONTAINS(create_invisible_pks(tested_schema, tested_table).error())
3098+
wipe_dir(dump_dir)
3099+
3100+
#@<> BUG#35860654 - test
3101+
shell.connect(__sandbox_uri1)
3102+
EXPECT_NO_THROWS(lambda: util.dump_schemas([ tested_schema ], dump_dir, { "ocimds": True, "compatibility": [ "create_invisible_pks" ], "showProgress": False }), "dump should not throw")
3103+
EXPECT_STDOUT_CONTAINS(create_invisible_pks(tested_schema, tested_table).fixed())
3104+
3105+
shell.connect(__sandbox_uri2)
3106+
wipeout_server(session)
3107+
EXPECT_NO_THROWS(lambda: util.load_dump(dump_dir, { "createInvisiblePKs": True if __version_num > 80024 else False,"showProgress": False }), "load should not throw")
3108+
3109+
#@<> BUG#35860654 - cleanup
3110+
session1.run_sql("DROP SCHEMA IF EXISTS !", [ tested_schema ])
3111+
30833112
#@<> Cleanup
30843113
testutil.destroy_sandbox(__mysql_sandbox_port1)
30853114
testutil.destroy_sandbox(__mysql_sandbox_port2)

0 commit comments

Comments
 (0)