Skip to content

Commit 8664461

Browse files
committed
MDEV-37784 Introduce @@new_mode: support all values being hidden
Fix my_print_help() to print "No currently supported values". It used to print the first value even if it was hidden.
1 parent 32940e3 commit 8664461

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

mysql-test/main/mysqld--help.result

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,7 @@ The following specify which files/extra groups are read (specified before remain
784784
Number of seconds to wait for a block to be written to a
785785
connection before aborting the write
786786
--new-mode=name Used to introduce new behavior to existing MariaDB
787-
versions. Any combination of: FIX_DISK_TMPTABLE_COSTS, or
788-
ALL to set all combinations
787+
versions. No currently supported values.
789788
--note-verbosity=name
790789
Verbosity level for note-warnings given to the user. See
791790
also @@sql_notes. Any combination of: basic,

mysys/my_getopt.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,8 @@ void my_print_help(const struct my_option *options)
16471647
if (optp->comment && *optp->comment)
16481648
{
16491649
uint count;
1650+
uint hidden_value_count= 0;
1651+
my_bool skip_or_all_message= 0;
16501652

16511653
if (col > name_space)
16521654
{
@@ -1667,8 +1669,22 @@ void my_print_help(const struct my_option *options)
16671669
count= optp->typelib->count;
16681670
break;
16691671
case GET_SET:
1670-
typelib_help= ". Any combination of: ";
1672+
if (optp->typelib->hidden_values)
1673+
{
1674+
/* Count how many values are hidden */
1675+
for (const int *val= optp->typelib->hidden_values; *val>= 0; val++)
1676+
hidden_value_count++;
1677+
}
16711678
count= optp->typelib->count;
1679+
if (count == hidden_value_count)
1680+
{
1681+
/* All values are hidden */
1682+
typelib_help= ". No currently supported values.";
1683+
count= 0;
1684+
skip_or_all_message= 1;
1685+
}
1686+
else
1687+
typelib_help= ". Any combination of: ";
16721688
break;
16731689
case GET_FLAGSET:
16741690
typelib_help= ". Takes a comma-separated list of option=value pairs, "
@@ -1680,9 +1696,9 @@ void my_print_help(const struct my_option *options)
16801696
strstr(optp->comment, optp->typelib->type_names[0]) == NULL)
16811697
{
16821698
uint i;
1699+
my_bool printing_first= 1;
16831700
col= print_comment(typelib_help, col, name_space, comment_space);
1684-
col= print_comment(optp->typelib->type_names[0], col, name_space, comment_space);
1685-
for (i= 1; i < count; i++)
1701+
for (i= 0; i < count; i++)
16861702
{
16871703
my_bool skip_value= 0;
16881704
/* Do not print the value if it is listed in hidden_values */
@@ -1700,11 +1716,14 @@ void my_print_help(const struct my_option *options)
17001716
}
17011717
if (skip_value)
17021718
continue;
1703-
col= print_comment(", ", col, name_space, comment_space);
1719+
if (printing_first)
1720+
printing_first= 0;
1721+
else
1722+
col= print_comment(", ", col, name_space, comment_space);
17041723
col= print_comment(optp->typelib->type_names[i], col, name_space, comment_space);
17051724
}
17061725
}
1707-
if ((optp->var_type & GET_TYPE_MASK) == GET_SET)
1726+
if ((optp->var_type & GET_TYPE_MASK) == GET_SET && !skip_or_all_message)
17081727
col= print_comment(", or ALL to set all combinations", col, name_space, comment_space);
17091728
if (optp->deprecation_substitute != NULL)
17101729
{

0 commit comments

Comments
 (0)