Skip to content

Commit 75ded7d

Browse files
spetruniaOlernov
authored andcommitted
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. (cherry picked from commit 8664461)
1 parent a18f8d3 commit 75ded7d

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
@@ -743,8 +743,7 @@ The following specify which files/extra groups are read (specified before remain
743743
Number of seconds to wait for a block to be written to a
744744
connection before aborting the write
745745
--new-mode=name Used to introduce new behavior to existing MariaDB
746-
versions. Any combination of: TEST_WARNING1
747-
Use 'ALL' to set all combinations.
746+
versions. No currently supported values.
748747
--note-verbosity=name
749748
Verbosity level for note-warnings given to the user. See
750749
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
@@ -1569,6 +1569,7 @@ void my_print_help(const struct my_option *options)
15691569
for (optp= options; optp->name; optp++)
15701570
{
15711571
const char *typelib_help= 0;
1572+
my_bool skip_or_all_message= 0;
15721573
if (!optp->comment)
15731574
continue;
15741575
if (optp->id && optp->id < 256)
@@ -1612,6 +1613,7 @@ void my_print_help(const struct my_option *options)
16121613
if (optp->comment && *optp->comment)
16131614
{
16141615
uint count;
1616+
uint hidden_value_count= 0;
16151617

16161618
if (col > name_space)
16171619
{
@@ -1632,8 +1634,22 @@ void my_print_help(const struct my_option *options)
16321634
count= optp->typelib->count;
16331635
break;
16341636
case GET_SET:
1635-
typelib_help= ". Any combination of: ";
1637+
if (optp->typelib->hidden_values)
1638+
{
1639+
/* Count how many values are hidden */
1640+
for (const int *val= optp->typelib->hidden_values; *val>= 0; val++)
1641+
hidden_value_count++;
1642+
}
16361643
count= optp->typelib->count;
1644+
if (count == hidden_value_count)
1645+
{
1646+
/* All values are hidden */
1647+
typelib_help= ". No currently supported values.";
1648+
count= 0;
1649+
skip_or_all_message= 1;
1650+
}
1651+
else
1652+
typelib_help= ". Any combination of: ";
16371653
break;
16381654
case GET_FLAGSET:
16391655
typelib_help= ". Takes a comma-separated list of option=value pairs, "
@@ -1645,9 +1661,9 @@ void my_print_help(const struct my_option *options)
16451661
strstr(optp->comment, optp->typelib->type_names[0]) == NULL)
16461662
{
16471663
uint i;
1664+
my_bool printing_first= 1;
16481665
col= print_comment(typelib_help, col, name_space, comment_space);
1649-
col= print_comment(optp->typelib->type_names[0], col, name_space, comment_space);
1650-
for (i= 1; i < count; i++)
1666+
for (i= 0; i < count; i++)
16511667
{
16521668
my_bool skip_value= 0;
16531669
/* Do not print the value if it is listed in hidden_values */
@@ -1665,7 +1681,10 @@ void my_print_help(const struct my_option *options)
16651681
}
16661682
if (skip_value)
16671683
continue;
1668-
col= print_comment(", ", col, name_space, comment_space);
1684+
if (printing_first)
1685+
printing_first= 0;
1686+
else
1687+
col= print_comment(", ", col, name_space, comment_space);
16691688
col= print_comment(optp->typelib->type_names[i], col, name_space, comment_space);
16701689
}
16711690
}
@@ -1681,7 +1700,7 @@ void my_print_help(const struct my_option *options)
16811700
printf(" to disable.)\n");
16821701
}
16831702
}
1684-
else if ((optp->var_type & GET_TYPE_MASK) == GET_SET)
1703+
else if ((optp->var_type & GET_TYPE_MASK) == GET_SET && !skip_or_all_message)
16851704
printf(" Use 'ALL' to set all combinations.\n");
16861705
}
16871706
DBUG_VOID_RETURN;

0 commit comments

Comments
 (0)