mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-28 00:21:56 +00:00
PT-142 pt-online-schema-change find_child_tables slow
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
Changelog for Percona Toolkit
|
Changelog for Percona Toolkit
|
||||||
|
|
||||||
|
v3.0.4
|
||||||
|
* Fixed bug PT-142 : pt-online-schema-change find_child_tables slow
|
||||||
|
|
||||||
v3.0.3
|
v3.0.3
|
||||||
|
|
||||||
* Fixed bug PT-133 : Sandbox won't start correctly if autocommit=0 in my.cnf
|
* Fixed bug PT-133 : Sandbox won't start correctly if autocommit=0 in my.cnf
|
||||||
|
@@ -8770,6 +8770,7 @@ sub main {
|
|||||||
tbl => $orig_tbl,
|
tbl => $orig_tbl,
|
||||||
Cxn => $cxn,
|
Cxn => $cxn,
|
||||||
Quoter => $q,
|
Quoter => $q,
|
||||||
|
only_same_schema_fks => $o->get('only-same-schema-fks'),
|
||||||
);
|
);
|
||||||
if ( !$child_tables ) {
|
if ( !$child_tables ) {
|
||||||
if ( $alter_fk_method ) {
|
if ( $alter_fk_method ) {
|
||||||
@@ -10448,6 +10449,11 @@ sub find_child_tables {
|
|||||||
. "FROM information_schema.key_column_usage "
|
. "FROM information_schema.key_column_usage "
|
||||||
. "WHERE referenced_table_schema='$tbl->{db}' "
|
. "WHERE referenced_table_schema='$tbl->{db}' "
|
||||||
. "AND referenced_table_name='$tbl->{tbl}'";
|
. "AND referenced_table_name='$tbl->{tbl}'";
|
||||||
|
|
||||||
|
if ($args{only_same_schema_fks}) {
|
||||||
|
$sql .= " AND table_schema='$tbl->{db}'";
|
||||||
|
}
|
||||||
|
|
||||||
PTDEBUG && _d($sql);
|
PTDEBUG && _d($sql);
|
||||||
my $rows = $cxn->dbh()->selectall_arrayref($sql);
|
my $rows = $cxn->dbh()->selectall_arrayref($sql);
|
||||||
if ( !$rows || !@$rows ) {
|
if ( !$rows || !@$rows ) {
|
||||||
@@ -11869,6 +11875,13 @@ them. The rows which contain NULL values will be converted to the defined
|
|||||||
default value. If no explicit DEFAULT value is given MySQL will assign a default
|
default value. If no explicit DEFAULT value is given MySQL will assign a default
|
||||||
value based on datatype, e.g. 0 for number datatypes, '' for string datatypes.
|
value based on datatype, e.g. 0 for number datatypes, '' for string datatypes.
|
||||||
|
|
||||||
|
=item --only-same-schema-fks
|
||||||
|
|
||||||
|
Check foreigns keys only on tables on the same schema than the original table.
|
||||||
|
This option is dangerous since if you have FKs refenrencing tables in other
|
||||||
|
schemas, they won't be detected.
|
||||||
|
|
||||||
|
|
||||||
=item --password
|
=item --password
|
||||||
|
|
||||||
short form: -p; type: string
|
short form: -p; type: string
|
||||||
|
@@ -445,6 +445,31 @@ $output = output(
|
|||||||
# clear databases with their foreign keys
|
# clear databases with their foreign keys
|
||||||
$sb->load_file('master', "$sample/bug-1315130_cleanup.sql");
|
$sb->load_file('master', "$sample/bug-1315130_cleanup.sql");
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# Issue 1315130
|
||||||
|
# Failed to detect child tables in other schema, and falsely identified
|
||||||
|
# child tables in own schema
|
||||||
|
# #############################################################################
|
||||||
|
|
||||||
|
$sb->load_file('master', "$sample/bug-1315130_cleanup.sql");
|
||||||
|
$sb->load_file('master', "$sample/bug-1315130.sql");
|
||||||
|
|
||||||
|
$output = output(
|
||||||
|
sub { pt_online_schema_change::main(@args, "$master_dsn,D=bug_1315130_a,t=parent_table",
|
||||||
|
'--dry-run',
|
||||||
|
'--alter', "add column c varchar(16)",
|
||||||
|
'--alter-foreign-keys-method', 'auto', '--only-same-schema-fks'),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
like(
|
||||||
|
$output,
|
||||||
|
qr/Child tables:\s*`bug_1315130_a`\.`child_table_in_same_schema` \(approx\. 1 rows\)[^`]*?Will/s,
|
||||||
|
"Ignore child tables in other schemas.",
|
||||||
|
);
|
||||||
|
# clear databases with their foreign keys
|
||||||
|
$sb->load_file('master', "$sample/bug-1315130_cleanup.sql");
|
||||||
|
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Issue 1340728
|
# Issue 1340728
|
||||||
|
Reference in New Issue
Block a user