From ba9d231b5ab75bc3614e53bdd95026e5fe9dd565 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 22 Nov 2021 12:29:15 +0100 Subject: MDEV-26713 Set activeCodePage=UTF8 for windows programs - Use corresponding entry in the manifest, as described in https://docs.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page - If if ANSI codepage is UTF8 (i.e for Windows 1903 and later) Use UTF8 as default client charset Set console codepage(s) to UTF8, in case process is using console - Allow some previously disabled MTR tests, that used Unicode for in "exec", for the recent Windows versions --- mysql-test/include/check_utf8_cli.inc | 3 +++ mysql-test/include/no_utf8_cli.inc | 3 +++ mysql-test/main/charset_client_win.test | 1 + mysql-test/main/charset_client_win_utf8mb4.result | 2 ++ mysql-test/main/charset_client_win_utf8mb4.test | 3 +++ mysql-test/main/grant_not_windows.result | 8 -------- mysql-test/main/grant_not_windows.test | 14 -------------- mysql-test/main/grant_utf8_cli.result | 8 ++++++++ mysql-test/main/grant_utf8_cli.test | 13 +++++++++++++ mysql-test/suite.pm | 22 ++++++++++++++++++++++ 10 files changed, 55 insertions(+), 22 deletions(-) create mode 100644 mysql-test/include/check_utf8_cli.inc create mode 100644 mysql-test/include/no_utf8_cli.inc create mode 100644 mysql-test/main/charset_client_win_utf8mb4.result create mode 100644 mysql-test/main/charset_client_win_utf8mb4.test delete mode 100644 mysql-test/main/grant_not_windows.result delete mode 100644 mysql-test/main/grant_not_windows.test create mode 100644 mysql-test/main/grant_utf8_cli.result create mode 100644 mysql-test/main/grant_utf8_cli.test (limited to 'mysql-test') diff --git a/mysql-test/include/check_utf8_cli.inc b/mysql-test/include/check_utf8_cli.inc new file mode 100644 index 00000000000..a1fac216446 --- /dev/null +++ b/mysql-test/include/check_utf8_cli.inc @@ -0,0 +1,3 @@ +# Check if utf8 can be used on the command line for --exec +# The real check is done in the suite.pm +# diff --git a/mysql-test/include/no_utf8_cli.inc b/mysql-test/include/no_utf8_cli.inc new file mode 100644 index 00000000000..19f9aa6df42 --- /dev/null +++ b/mysql-test/include/no_utf8_cli.inc @@ -0,0 +1,3 @@ +# Check if utf8 can't be used on the command line for --exec +# The real check is done in the suite.pm +# diff --git a/mysql-test/main/charset_client_win.test b/mysql-test/main/charset_client_win.test index b4a21d4f0a4..c3f649cb7d4 100644 --- a/mysql-test/main/charset_client_win.test +++ b/mysql-test/main/charset_client_win.test @@ -1,2 +1,3 @@ --source include/windows.inc +--source include/no_utf8_cli.inc --exec chcp 1257 > NUL && $MYSQL --default-character-set=auto -e "select @@character_set_client" diff --git a/mysql-test/main/charset_client_win_utf8mb4.result b/mysql-test/main/charset_client_win_utf8mb4.result new file mode 100644 index 00000000000..f7b5d376f9a --- /dev/null +++ b/mysql-test/main/charset_client_win_utf8mb4.result @@ -0,0 +1,2 @@ +@@character_set_client +utf8mb4 diff --git a/mysql-test/main/charset_client_win_utf8mb4.test b/mysql-test/main/charset_client_win_utf8mb4.test new file mode 100644 index 00000000000..2baf0d7c050 --- /dev/null +++ b/mysql-test/main/charset_client_win_utf8mb4.test @@ -0,0 +1,3 @@ +--source include/windows.inc +--source include/check_utf8_cli.inc +--exec $MYSQL --default-character-set=auto -e "select @@character_set_client" diff --git a/mysql-test/main/grant_not_windows.result b/mysql-test/main/grant_not_windows.result deleted file mode 100644 index fedfaf984b2..00000000000 --- a/mysql-test/main/grant_not_windows.result +++ /dev/null @@ -1,8 +0,0 @@ -set names utf8; -create user юзер_юзер@localhost; -grant select on test.* to юзер_юзер@localhost; -user() -юзер_юзер@localhost -revoke all on test.* from юзер_юзер@localhost; -drop user юзер_юзер@localhost; -set names default; diff --git a/mysql-test/main/grant_not_windows.test b/mysql-test/main/grant_not_windows.test deleted file mode 100644 index 55b09232edc..00000000000 --- a/mysql-test/main/grant_not_windows.test +++ /dev/null @@ -1,14 +0,0 @@ - # UTF8 parameters to mysql client do not work on Windows ---source include/not_windows.inc ---source include/not_embedded.inc - -# -# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte -# -set names utf8; -create user юзер_юзер@localhost; -grant select on test.* to юзер_юзер@localhost; ---exec $MYSQL --default-character-set=utf8 --user=юзер_юзер -e "select user()" -revoke all on test.* from юзер_юзер@localhost; -drop user юзер_юзер@localhost; -set names default; diff --git a/mysql-test/main/grant_utf8_cli.result b/mysql-test/main/grant_utf8_cli.result new file mode 100644 index 00000000000..fedfaf984b2 --- /dev/null +++ b/mysql-test/main/grant_utf8_cli.result @@ -0,0 +1,8 @@ +set names utf8; +create user юзер_юзер@localhost; +grant select on test.* to юзер_юзер@localhost; +user() +юзер_юзер@localhost +revoke all on test.* from юзер_юзер@localhost; +drop user юзер_юзер@localhost; +set names default; diff --git a/mysql-test/main/grant_utf8_cli.test b/mysql-test/main/grant_utf8_cli.test new file mode 100644 index 00000000000..bc811d5298e --- /dev/null +++ b/mysql-test/main/grant_utf8_cli.test @@ -0,0 +1,13 @@ +--source include/not_embedded.inc +--source include/check_utf8_cli.inc + +# +# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte +# +set names utf8; +create user юзер_юзер@localhost; +grant select on test.* to юзер_юзер@localhost; +--exec $MYSQL --default-character-set=utf8 --user=юзер_юзер -e "select user()" +revoke all on test.* from юзер_юзер@localhost; +drop user юзер_юзер@localhost; +set names default; diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index 4cc6b410fa1..ad67117a229 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -87,6 +87,28 @@ sub skip_combinations { $skip{'main/ssl_verify_ip.test'} = 'x509v3 support required' unless $openssl_ver ge "1.0.2"; + sub utf8_command_line_ok() { + if (IS_WINDOWS) { + # Can use UTF8 on command line since Windows 10 1903 (10.0.18362) + # or if OS codepage is set to UTF8 + my($os_name, $os_major, $os_minor, $os_build, $os_id) = Win32::GetOSVersion(); + if($os_major lt 10){ + return 0; + } elsif($os_major gt 10 or $os_minor gt 0 or $os_build ge 18362){ + return 1; + } elsif(Win32::GetACP() eq 65001) { + return 1; + } + return 0; + } + return 1; + } + + $skip{'include/check_utf8_cli.inc'} = 'No utf8 command line support' + unless utf8_command_line_ok(); + + $skip{'include/no_utf8_cli.inc'} = 'Not tested with utf8 command line support' + unless !utf8_command_line_ok(); %skip; } -- cgit v1.2.1 From 57d52657a27d702e86e99097d59195a9ad4cd968 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 23 Nov 2021 13:05:25 +0100 Subject: MDEV-26713 UTF8 support on Windows , add mysql_install_db tests Add mysql_install_db test with some i18n, for data dir and root password --- mysql-test/main/mysql_install_db_win_utf8.result | 14 ++++++++++ mysql-test/main/mysql_install_db_win_utf8.test | 35 ++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 mysql-test/main/mysql_install_db_win_utf8.result create mode 100644 mysql-test/main/mysql_install_db_win_utf8.test (limited to 'mysql-test') diff --git a/mysql-test/main/mysql_install_db_win_utf8.result b/mysql-test/main/mysql_install_db_win_utf8.result new file mode 100644 index 00000000000..744c982b291 --- /dev/null +++ b/mysql-test/main/mysql_install_db_win_utf8.result @@ -0,0 +1,14 @@ +Running bootstrap +Creating my.ini file +Removing default user +Allowing remote access for user root +Setting root password +Creation of the database was successful +# Kill the server +connect con1,localhost,root,パスワード,mysql; +SELECT @@datadir; +@@datadir +DATADIR/ +# Kill the server +connection default; +# restart diff --git a/mysql-test/main/mysql_install_db_win_utf8.test b/mysql-test/main/mysql_install_db_win_utf8.test new file mode 100644 index 00000000000..fc67b66d3ca --- /dev/null +++ b/mysql-test/main/mysql_install_db_win_utf8.test @@ -0,0 +1,35 @@ +--source include/windows.inc +--source include/check_utf8_cli.inc + +# Create database in tmp directory using mysql_install_db.exe, +# and start server from this directory. +let $ddir= $MYSQLTEST_VARDIR/tmp/датадир; +--error 0,1 +rmdir $ddir; +exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=パスワード -R; +--source include/kill_mysqld.inc + +# Note "restart" via MTR does not work, if server's command line has +# non-ASCII characters used (or, characters outside of ANSI codepage). +# This is a perl limitation, which is worked around in this test - +# the server started in background, via exec $MYSQLD + +--replace_result $MYSQLD MYSQLD $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +exec $MYSQLD --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.1 --datadir=$ddir --loose-innodb > NUL 2>&1 &; +--enable_reconnect +--source include/wait_until_connected_again.inc +--disable_reconnect + +connect (con1,localhost,root,パスワード,mysql); + +# Smoke test - check that we're actually using datadir +# we've created (i.e restart_parameters worked) +--replace_result $ddir DATADIR +SELECT @@datadir; +# restart in the original datadir again +--source include/kill_mysqld.inc +rmdir $ddir; + +connection default; +--source include/start_mysqld.inc + -- cgit v1.2.1 From 74f2e6c85e892b6b9e8d65d14db3246d34cc6fc7 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Wed, 24 Nov 2021 10:15:11 +0100 Subject: MDEV-26713 Add test for mysql_install_db creating service, with i18 --- mysql-test/include/check_windows_admin.inc | 3 ++ mysql-test/main/winservice.inc | 75 ++++++++++++++++++++++++++++++ mysql-test/main/winservice_basic.result | 12 +++++ mysql-test/main/winservice_basic.test | 5 ++ mysql-test/main/winservice_i18n.result | 12 +++++ mysql-test/main/winservice_i18n.test | 7 +++ mysql-test/suite.pm | 3 ++ 7 files changed, 117 insertions(+) create mode 100644 mysql-test/include/check_windows_admin.inc create mode 100644 mysql-test/main/winservice.inc create mode 100644 mysql-test/main/winservice_basic.result create mode 100644 mysql-test/main/winservice_basic.test create mode 100644 mysql-test/main/winservice_i18n.result create mode 100644 mysql-test/main/winservice_i18n.test (limited to 'mysql-test') diff --git a/mysql-test/include/check_windows_admin.inc b/mysql-test/include/check_windows_admin.inc new file mode 100644 index 00000000000..44a8b71a19f --- /dev/null +++ b/mysql-test/include/check_windows_admin.inc @@ -0,0 +1,3 @@ +# Check if current user is Windows admin +# Used for testing services with mysql_install_db.exe +# Actual value is set by suite.pm diff --git a/mysql-test/main/winservice.inc b/mysql-test/main/winservice.inc new file mode 100644 index 00000000000..42aab645cc8 --- /dev/null +++ b/mysql-test/main/winservice.inc @@ -0,0 +1,75 @@ +source include/check_windows_admin.inc; + +# The test uses return code from sc.exe utility, which are as follows +let $ERROR_SERVICE_DOES_NOT_EXIST= 1060; +let $ERROR_SERVICE_CANNOT_ACCEPT_CTRL=1061;# intermediate, during start or stop +let $ERROR_SERVICE_NOT_ACTIVE=1062;# service stopped + +let $sc_exe= C:\Windows\System32\sc.exe; +let $ddir= $MYSQLTEST_VARDIR/tmp/$datadir_name; +let $service_name=$service_name_prefix$MASTER_MYPORT; + + +error 0,1; +rmdir $ddir; + +--disable_result_log +error 0,$ERROR_SERVICE_DOES_NOT_EXIST; +exec $sc_exe delete $service_name; +--enable_result_log + +source include/kill_mysqld.inc; +echo # run mysql_install_db with --service parameter; +--disable_result_log +exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --port=$MASTER_MYPORT --password=$password --service=$service_name -R; +--enable_result_log + +echo # Start service; +--disable_result_log +exec $sc_exe start $service_name; +--enable_result_log + +enable_reconnect; +source include/wait_until_connected_again.inc; +disable_reconnect; + +echo # Connect with root user password=$password; +connect (con1,localhost,root,$password,mysql); + +# Smoke test - check that we're actually using datadir +# we've created (i.e restart_parameters worked) +replace_result $ddir DATADIR; +select @@datadir; + +echo # Stop service and wait until it is down; + +# stop service +--disable_result_log +exec $sc_exe stop $service_name; +# Wait until stopped +let $sys_errno=0; +while($sys_errno != $ERROR_SERVICE_NOT_ACTIVE) +{ + --error 0,$ERROR_SERVICE_CANNOT_ACCEPT_CTRL,$ERROR_SERVICE_NOT_ACTIVE + exec $sc_exe stop $service_name; + if($sys_errno != $ERROR_SERVICE_NOT_ACTIVE) + { + --real_sleep 0.1 + } +} +--enable_result_log + +echo # Delete service; +let $sys_errno=0; +--disable_result_log +exec $sc_exe delete $service_name; +--enable_result_log + +# Cleanup +source include/wait_until_disconnected.inc; +rmdir $ddir; + +#restart original server +connection default; +source include/start_mysqld.inc; + diff --git a/mysql-test/main/winservice_basic.result b/mysql-test/main/winservice_basic.result new file mode 100644 index 00000000000..a4de0080207 --- /dev/null +++ b/mysql-test/main/winservice_basic.result @@ -0,0 +1,12 @@ +# Kill the server +# run mysql_install_db with --service parameter +# Start service +# Connect with root user password=password +connect con1,localhost,root,$password,mysql; +select @@datadir; +@@datadir +DATADIR/ +# Stop service and wait until it is down +# Delete service +connection default; +# restart diff --git a/mysql-test/main/winservice_basic.test b/mysql-test/main/winservice_basic.test new file mode 100644 index 00000000000..33d072b4f70 --- /dev/null +++ b/mysql-test/main/winservice_basic.test @@ -0,0 +1,5 @@ +source include/windows.inc; +let $datadir_name=data; +let $service_name_prefix=mariadb; +let $password=password; +source winservice.inc; diff --git a/mysql-test/main/winservice_i18n.result b/mysql-test/main/winservice_i18n.result new file mode 100644 index 00000000000..873f0828b1f --- /dev/null +++ b/mysql-test/main/winservice_i18n.result @@ -0,0 +1,12 @@ +# Kill the server +# run mysql_install_db with --service parameter +# Start service +# Connect with root user password=パスワード +connect con1,localhost,root,$password,mysql; +select @@datadir; +@@datadir +DATADIR/ +# Stop service and wait until it is down +# Delete service +connection default; +# restart diff --git a/mysql-test/main/winservice_i18n.test b/mysql-test/main/winservice_i18n.test new file mode 100644 index 00000000000..c63b38fd2b8 --- /dev/null +++ b/mysql-test/main/winservice_i18n.test @@ -0,0 +1,7 @@ +source include/windows.inc; +source include/check_utf8_cli.inc; + +let $datadir_name=датадир; +let $service_name_prefix=mariadb_sörvis; +let $password=パスワード; +source winservice.inc; diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index ad67117a229..f30cc5ec431 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -109,6 +109,9 @@ sub skip_combinations { $skip{'include/no_utf8_cli.inc'} = 'Not tested with utf8 command line support' unless !utf8_command_line_ok(); + + $skip{'include/check_windows_admin.inc'} = 'Requires admin privileges' + unless IS_WINDOWS and Win32::IsAdminUser(); %skip; } -- cgit v1.2.1 From 71966c7306d6ae24bc052d5433e6d97cc81a436a Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 26 Nov 2021 18:41:35 +0100 Subject: MDEV-26713 allow users with non-UTF8 passwords to login after upgrade. Translate username, password and database from UTF8 into desired charset, if non-auto default-character-set was used, on Windows10 1903 This change is implemented only in the command line client, and mainly to allow users with non-UTF8 passwords to login. The user is supposed to use the same charset that was used during setting password (usually, console CP if used in CLI) Add a test to document the behavior. --- mysql-test/main/charset_client_win_utf8mb4.result | 4 ++++ mysql-test/main/charset_client_win_utf8mb4.test | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/main/charset_client_win_utf8mb4.result b/mysql-test/main/charset_client_win_utf8mb4.result index f7b5d376f9a..9bbf751e45c 100644 --- a/mysql-test/main/charset_client_win_utf8mb4.result +++ b/mysql-test/main/charset_client_win_utf8mb4.result @@ -1,2 +1,6 @@ @@character_set_client utf8mb4 +ERROR 1045 (28000): Access denied for user 'u'@'localhost' (using password: YES) +2 +2 +DROP user u; diff --git a/mysql-test/main/charset_client_win_utf8mb4.test b/mysql-test/main/charset_client_win_utf8mb4.test index 2baf0d7c050..e08afa250bd 100644 --- a/mysql-test/main/charset_client_win_utf8mb4.test +++ b/mysql-test/main/charset_client_win_utf8mb4.test @@ -1,3 +1,22 @@ --source include/windows.inc --source include/check_utf8_cli.inc --exec $MYSQL --default-character-set=auto -e "select @@character_set_client" + +# Test that a user with old, non-UTF8 password can still connect +# by setting setting non-auto --default-character-set +# This is important for backward compatibility + +# Emulate creating password in an interactive client session, with older clients +# which communicates with the server using with something like cp850 + +exec chcp 850 > NUL && echo CREATE USER 'u' IDENTIFIED by 'ü' | $MYSQL --default-character-set=cp850; + + +# Can't connect with UTF8 +--error 1 +exec $MYSQL --default-character-set=auto --user=u --password=ü -e "select 1" 2>&1; + +# Can connect with tweaked --default-character-set +exec $MYSQL --default-character-set=cp850 --user=u --password=ü -e "select 2"; +DROP user u; + -- cgit v1.2.1