From 838ae9a1c130062ff1892f3be067d35cca66b466 Mon Sep 17 00:00:00 2001 From: Sebastian Detert Date: Wed, 29 Oct 2025 09:24:15 +0100 Subject: [PATCH 1/2] add mysql_optional as dsn parameter --- bin/pt-online-schema-change | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 4c3b2dfaf..d9018d372 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -2293,7 +2293,7 @@ sub get_cxn_params { $dsn = 'DBI:mysql:' . ( $info->{D} || '' ) . ';' . join(';', map { "$opts{$_}->{dsn}=$info->{$_}" } grep { defined $info->{$_} } - qw(F h P S A s)) + qw(F h P S A s o)) . ';mysql_read_default_group=client' . ($info->{L} ? ';mysql_local_infile=1' : ''); } @@ -13439,6 +13439,12 @@ short form: -s; type: int Create SSL MySQL connection. +=item --mysql_ssl_optional + +short form: -o; type: int + +Disables strict SSL enforcement and makes SSL connection optional. + =item --preserve-triggers Preserves old triggers when specified. @@ -14161,6 +14167,12 @@ dsn: mysql_ssl; copy: yes Create SSL connection +=item * o + +dsn: mysql_ssl_optional; copy: yes + +Disables strict SSL enforcement and makes SSL connection optional + =back =head1 ENVIRONMENT From ddac296c7f1499fbb0f7ffe7ce6b9758749addd1 Mon Sep 17 00:00:00 2001 From: Sebastian Detert Date: Fri, 12 Dec 2025 09:05:50 +0100 Subject: [PATCH 2/2] add parameter mysql_optional --- lib/DSNParser.pm | 2 +- t/pt-online-schema-change/option_sanity.t | 7 ++++ t/pt-online-schema-change/ssl.t | 51 +++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/lib/DSNParser.pm b/lib/DSNParser.pm index c5f81ff5a..9f9ac570a 100644 --- a/lib/DSNParser.pm +++ b/lib/DSNParser.pm @@ -243,7 +243,7 @@ sub get_cxn_params { $dsn = 'DBI:mysql:' . ( $info->{D} || '' ) . ';' . join(';', map { "$opts{$_}->{dsn}=$info->{$_}" } grep { defined $info->{$_} } - qw(F h P S A s)) + qw(F h P S A s o)) . ';mysql_read_default_group=client' . ($info->{L} ? ';mysql_local_infile=1' : ''); } diff --git a/t/pt-online-schema-change/option_sanity.t b/t/pt-online-schema-change/option_sanity.t index d53e5b7cd..ad0f351ab 100644 --- a/t/pt-online-schema-change/option_sanity.t +++ b/t/pt-online-schema-change/option_sanity.t @@ -78,6 +78,13 @@ like( "Validates --critical-load" ); +$output = `$cmd --help`; +like( + $output, + qr/--mysql_ssl_optional/, + "--mysql_ssl_optional option exists in help" +); + # ############################################################################# # Done. # ############################################################################# diff --git a/t/pt-online-schema-change/ssl.t b/t/pt-online-schema-change/ssl.t index 584d0a428..8d112a572 100644 --- a/t/pt-online-schema-change/ssl.t +++ b/t/pt-online-schema-change/ssl.t @@ -179,6 +179,57 @@ like( 'SSL connection error with incorrect SSL options in the configuration file' ) or diag($output); +# ############################################################################# +# Test mysql_ssl_optional option +# ############################################################################# + +# Restoring environment for the new test +$sb->load_file('source', "$sample/del-trg-bug-1103672.sql"); + +($output, $exit_code) = full_output( + sub { pt_online_schema_change::main(@args, + "$source_dsn,D=test,t=t1,u=sha256_user,p=sha256_user%password,o=1", + "--alter", "drop primary key, add column _id int unsigned not null primary key auto_increment FIRST", + qw(--execute --no-check-alter)), + }, +); + +is( + $exit_code, + 0, + "No error when using mysql_ssl_optional DSN parameter (o=1)" +) or diag($output); + +like( + $output, + qr/Successfully altered `test`.`t1`/, + "DROP PRIMARY KEY with mysql_ssl_optional DSN parameter" +); + +# Restoring environment for the new test +$sb->load_file('source', "$sample/del-trg-bug-1103672.sql"); + +($output, $exit_code) = full_output( + sub { pt_online_schema_change::main(@args, + "$source_dsn,D=test,t=t1", + qw(--user sha256_user --password sha256_user%password --mysql_ssl_optional 1), + "--alter", "drop primary key, add column _id int unsigned not null primary key auto_increment FIRST", + qw(--execute --no-check-alter)), + }, +); + +is( + $exit_code, + 0, + "No error when using --mysql_ssl_optional option" +) or diag($output); + +like( + $output, + qr/Successfully altered `test`.`t1`/, + "DROP PRIMARY KEY with --mysql_ssl_optional option" +); + # ############################################################################# # Done. # #############################################################################