Browse Source

MDEV-27126 my_getopt compares option names case sensitively

my_getopt compares option names case-sensitively, causing
"Unknown option" errors when users type mixed-case options like
wsrep_slave_UK_checks in lowercase wsrep_slave_fk_checks.

Made the comparison in the getopt_compare_strings() case-insensitive.
bb-10.5-mdev-35874
Aryan Arora 8 months ago
committed by Vicențiu-Marian Ciorbaru
parent
commit
f3687ccaaf
  1. 1
      mysql-test/main/my_getopt_case_insensitive.opt
  2. 8
      mysql-test/main/my_getopt_case_insensitive.result
  3. 8
      mysql-test/main/my_getopt_case_insensitive.test
  4. 8
      mysql-test/suite/wsrep/r/wsrep_mixed_case_cmd_arg.result
  5. 7
      mysql-test/suite/wsrep/t/wsrep_mixed_case_cmd_arg.cnf
  6. 1
      mysql-test/suite/wsrep/t/wsrep_mixed_case_cmd_arg.opt
  7. 11
      mysql-test/suite/wsrep/t/wsrep_mixed_case_cmd_arg.test
  8. 3
      mysys/my_getopt.c

1
mysql-test/main/my_getopt_case_insensitive.opt

@ -0,0 +1 @@
--slOw_QuEry_loG=OFF

8
mysql-test/main/my_getopt_case_insensitive.result

@ -0,0 +1,8 @@
#
# MDEV-27126: my_getopt compares option names case sensitively
#
# Check if the variable is set correctly from options
SELECT @@GLOBAL.slow_query_log;
@@GLOBAL.slow_query_log
0
# End of test.

8
mysql-test/main/my_getopt_case_insensitive.test

@ -0,0 +1,8 @@
--echo #
--echo # MDEV-27126: my_getopt compares option names case sensitively
--echo #
--echo # Check if the variable is set correctly from options
SELECT @@GLOBAL.slow_query_log;
--echo # End of test.

8
mysql-test/suite/wsrep/r/wsrep_mixed_case_cmd_arg.result

@ -0,0 +1,8 @@
#
# MDEV-27126: my_getopt compares option names case sensitively
#
# Check if the variable is set correctly from options
SELECT @@GLOBAL.wsrep_slave_uk_checks;
@@GLOBAL.wsrep_slave_uk_checks
1
# End of test.

7
mysql-test/suite/wsrep/t/wsrep_mixed_case_cmd_arg.cnf

@ -0,0 +1,7 @@
!include ../my.cnf
[mysqld.1]
wsrep-on=ON
wsrep-provider=@ENV.WSREP_PROVIDER
wsrep-cluster-address=gcomm://

1
mysql-test/suite/wsrep/t/wsrep_mixed_case_cmd_arg.opt

@ -0,0 +1 @@
--wsrep-slave-uk-checks=1

11
mysql-test/suite/wsrep/t/wsrep_mixed_case_cmd_arg.test

@ -0,0 +1,11 @@
--source include/have_innodb.inc
--source include/have_wsrep_provider.inc
--source include/have_binlog_format_row.inc
--echo #
--echo # MDEV-27126: my_getopt compares option names case sensitively
--echo #
--echo # Check if the variable is set correctly from options
SELECT @@GLOBAL.wsrep_slave_uk_checks;
--echo # End of test.

3
mysys/my_getopt.c

@ -18,6 +18,7 @@
#include <mysys_priv.h>
#include <my_default.h>
#include <m_string.h>
#include <ctype.h>
#include <stdlib.h>
#include <mysys_err.h>
#include <my_getopt.h>
@ -962,7 +963,7 @@ my_bool getopt_compare_strings(register const char *s, register const char *t,
for (;s != end ; s++, t++)
{
if ((*s != '-' ? *s : '_') != (*t != '-' ? *t : '_'))
if ((*s != '-' ? tolower(*s) : '_') != (*t != '-' ? tolower(*t) : '_'))
DBUG_RETURN(1);
}
DBUG_RETURN(0);

Loading…
Cancel
Save