Skip to content

Commit bde5124

Browse files
committed
Bug #19545350 MYSQL_INSTALL_DB --HELP MESSAGE PROBLEMS
Merge of cset 8803 from trunk
1 parent fc61e2c commit bde5124

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

client/mysql_install_db.cc

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ my_bool opt_insecure= FALSE;
8383
my_bool opt_verbose= FALSE;
8484
my_bool opt_ssl= FALSE;
8585

86+
/**
87+
Connection options.
88+
@note first element must be 'help' and last element must be
89+
the end token: {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
90+
*/
8691
static struct my_option my_connection_options[]=
8792
{
8893
{"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG,
@@ -95,8 +100,7 @@ static struct my_option my_connection_options[]=
95100
&opt_builddir, 0, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
96101
{"srcdir", 0, "For internal use. This option specifies the directory under"
97102
" which mysql_install_db looks for support files such as the error"
98-
" message file and the file for populating the help tables."
99-
"This option was added in MySQL 5.0.32.", &opt_srcdir,
103+
" message file and the file for populating the help tables.", &opt_srcdir,
100104
0, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
101105
{"basedir", 0, "The path to the MySQL installation directory.",
102106
&opt_basedir, 0, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
@@ -112,33 +116,33 @@ static struct my_option my_connection_options[]=
112116
"admin-host options. Use the login-path option to change the default "
113117
"credential category (default is 'client').",
114118
&opt_adminlogin, 0, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
115-
{"extra-sql-file", 'f', "Optional SQL file to execute during bootstrap",
119+
{"extra-sql-file", 'f', "Optional SQL file to execute during bootstrap.",
116120
&opt_sqlfile, 0, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
117-
{"admin-user", 0, "Username part of the default admin account",
121+
{"admin-user", 0, "Username part of the default admin account.",
118122
&opt_adminuser, 0, 0, GET_STR_ALLOC, REQUIRED_ARG,
119123
(longlong)&default_adminuser, 0, 0, 0, 0, 0},
120-
{"admin-host", 0, "Hostname part of the default admin account",
124+
{"admin-host", 0, "Hostname part of the default admin account.",
121125
&opt_adminhost, 0, 0, GET_STR_ALLOC,REQUIRED_ARG,
122126
(longlong)&default_adminhost, 0, 0, 0, 0, 0},
123-
{"admin-auth-plugin", 0, "Plugin to use for the default admin account",
127+
{"admin-auth-plugin", 0, "Plugin to use for the default admin account.",
124128
&opt_authplugin, 0, 0, GET_STR_ALLOC, REQUIRED_ARG,
125129
(longlong)&default_authplugin, 0, 0, 0, 0, 0},
126-
{"admin-require-ssl", 0, "Default SSL/TLS restrictions for the default admin "
127-
"account", &opt_ssl, 0, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
128-
{"mysqld-file", 0, "Qualified path to the mysqld binary", &opt_mysqldfile,
130+
{"admin-require-ssl", 0, "Require SSL/TLS for the default admin account.",
131+
&opt_ssl, 0, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
132+
{"mysqld-file", 0, "Qualified path to the mysqld binary.", &opt_mysqldfile,
129133
0, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
130134
{"random-password-file", 0, "Specifies the qualified path to the "
131-
".mysql_secret temporary password file", &opt_randpwdfile,
135+
".mysql_secret temporary password file.", &opt_randpwdfile,
132136
0, 0, GET_STR_ALLOC, REQUIRED_ARG, 0,
133137
0, 0, 0, 0, 0},
134-
{"insecure", 0, "Disables random passwords for the default admin account",
138+
{"insecure", 0, "Disables random passwords for the default admin account.",
135139
&opt_insecure, 0, 0, GET_BOOL, NO_ARG, 0, 0, 0,
136140
0, 0, 0},
137-
{"verbose", 'v', "Be more verbose when running program",
141+
{"verbose", 'v', "Be more verbose when running program.",
138142
&opt_verbose, 0, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
139-
{"version", 'V', "Print program version and exit",
143+
{"version", 'V', "Print program version and exit.",
140144
&opt_verbose, 0, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
141-
{"lc-messages-dir", 'l', "Specifies the path to the language files",
145+
{"lc-messages-dir", 'l', "Specifies the path to the language files.",
142146
&opt_langpath, 0, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
143147
{"lc-messages", 0, "Specifies the language to use.", &opt_lang,
144148
0, 0, GET_STR_ALLOC, REQUIRED_ARG, (longlong)&default_lang, 0, 0, 0, 0, 0},
@@ -148,7 +152,7 @@ static struct my_option my_connection_options[]=
148152
&opt_defaults, 0, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
149153
{"defaults-file", 0, "Use only the given option file.",
150154
&opt_defaults_file, 0, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
151-
{"defaults-extra-file", 0, "Read this file after the global files are read",
155+
{"defaults-extra-file", 0, "Read this file after the global files are read.",
152156
&opt_def_extra_file, 0, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
153157
/* End token */
154158
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
@@ -1158,7 +1162,11 @@ int generate_password_file(Path &pwdfile, const string &adminuser,
11581162
return ALL_OK;
11591163
}
11601164

1161-
1165+
int connection_options_sorter(const void *a, const void *b)
1166+
{
1167+
return strcmp(static_cast<const my_option*>(a)->name,
1168+
static_cast<const my_option *>(b)->name);
1169+
}
11621170

11631171
int main(int argc,char *argv[])
11641172
{
@@ -1177,6 +1185,13 @@ int main(int argc,char *argv[])
11771185
if (load_defaults("my", load_default_groups, &argc, &argv))
11781186
return 1;
11791187

1188+
// Assert that the help messages are in sorted order
1189+
// except that --help must be the first element and 0 must indicate the end.
1190+
my_qsort(my_connection_options + 1,
1191+
sizeof(my_connection_options)/sizeof(my_option) - 2,
1192+
sizeof(my_option),
1193+
connection_options_sorter);
1194+
11801195
int rc= 0;
11811196
if ((rc= handle_options(&argc, &argv, my_connection_options,
11821197
my_arguments_get_one_option)))

0 commit comments

Comments
 (0)