382
by Monty Taylor
Removed bogus copyright headers. |
1 |
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 MySQL
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; either version 2 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
|
1
by brian
clean slate |
20 |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
21 |
/* maintaince of drizzle databases */
|
1
by brian
clean slate |
22 |
|
23 |
#include "client_priv.h" |
|
24 |
#include <signal.h> |
|
212.5.13
by Monty Taylor
Moved my_sys/my_pthread/my_nosys and mysys_err to mysys. |
25 |
#include <mysys/my_pthread.h> /* because of signal() */ |
1
by brian
clean slate |
26 |
#include <sys/stat.h> |
27 |
||
264.1.21
by forstm1w
Added gettext translations to strings. |
28 |
/* Added this for string translation. */
|
29 |
#include <libdrizzle/gettext.h> |
|
30 |
||
1
by brian
clean slate |
31 |
#define ADMIN_VERSION "8.42"
|
32 |
#define SHUTDOWN_DEF_TIMEOUT 3600 /* Wait for shutdown */ |
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
33 |
|
165
by Brian Aker
mysqladmin patch (plus removal of password auth bits) |
34 |
char *host= NULL, *user= NULL, *opt_password= NULL; |
35 |
static bool interrupted= false, opt_verbose= false,tty_password= false; |
|
36 |
static uint32_t tcp_port= 0, option_wait= 0, option_silent= 0; |
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
37 |
static uint32_t my_end_arg; |
38 |
static uint32_t opt_connect_timeout, opt_shutdown_timeout; |
|
1
by brian
clean slate |
39 |
static myf error_flags; /* flags to pass to my_printf_error, like ME_BELL */ |
40 |
||
41 |
/*
|
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
42 |
Forward declarations
|
1
by brian
clean slate |
43 |
*/
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
44 |
static void usage(void); |
1
by brian
clean slate |
45 |
static void print_version(void); |
454
by Monty Taylor
Removed RETSIGHANDLER to sig_handler define. |
46 |
extern "C" RETSIGTYPE endprog(int signal_number); |
143
by Brian Aker
Bool cleanup. |
47 |
extern "C" bool get_one_option(int optid, const struct my_option *opt, |
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
48 |
char *argument); |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
49 |
static int execute_commands(DRIZZLE *drizzle,int argc, char **argv); |
50 |
static bool sql_connect(DRIZZLE *drizzle, uint wait); |
|
1
by brian
clean slate |
51 |
|
52 |
/*
|
|
53 |
The order of commands must be the same as command_names,
|
|
54 |
except ADMIN_ERROR
|
|
55 |
*/
|
|
56 |
enum commands { |
|
57 |
ADMIN_ERROR, |
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
58 |
ADMIN_SHUTDOWN, |
59 |
ADMIN_PING
|
|
1
by brian
clean slate |
60 |
};
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
61 |
|
1
by brian
clean slate |
62 |
static const char *command_names[]= { |
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
63 |
"shutdown", |
64 |
"ping", |
|
461
by Monty Taylor
Removed NullS. bu-bye. |
65 |
NULL
|
1
by brian
clean slate |
66 |
};
|
67 |
||
68 |
static TYPELIB command_typelib= |
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
69 |
{ array_elements(command_names)-1,"commands", command_names, NULL }; |
1
by brian
clean slate |
70 |
|
71 |
static struct my_option my_long_options[] = |
|
72 |
{
|
|
264.1.21
by forstm1w
Added gettext translations to strings. |
73 |
{"help", '?', N_("Display this help and exit."), 0, 0, 0, GET_NO_ARG, |
1
by brian
clean slate |
74 |
NO_ARG, 0, 0, 0, 0, 0, 0}, |
264.1.21
by forstm1w
Added gettext translations to strings. |
75 |
{"host", 'h', N_("Connect to host."), (char**) &host, (char**) &host, 0, GET_STR, |
1
by brian
clean slate |
76 |
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
77 |
{"password", 'p', |
264.1.21
by forstm1w
Added gettext translations to strings. |
78 |
N_("Password to use when connecting to server. If password is not given it's asked from the tty."), |
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
79 |
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, |
264.1.21
by forstm1w
Added gettext translations to strings. |
80 |
{"port", 'P', N_("Port number to use for connection or 0 for default to, in " |
301
by Brian Aker
Clean up port startup |
81 |
"order of preference, my.cnf, $DRIZZLE_TCP_PORT, "
|
82 |
"built-in default (" STRINGIFY_ARG(DRIZZLE_PORT) ")."), |
|
77.1.77
by Monty Taylor
A crapton more warning cleanups (I turned on more warnings) |
83 |
(char**) &tcp_port, |
84 |
(char**) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
|
264.1.21
by forstm1w
Added gettext translations to strings. |
85 |
{"silent", 's', N_("Silently exit if one can't connect to server."), |
1
by brian
clean slate |
86 |
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, |
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
87 |
#ifndef DONT_ALLOW_USER_CHANGE
|
264.1.21
by forstm1w
Added gettext translations to strings. |
88 |
{"user", 'u', N_("User for login if not current user."), (char**) &user, |
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
89 |
(char**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, |
90 |
#endif
|
|
264.1.21
by forstm1w
Added gettext translations to strings. |
91 |
{"verbose", 'v', N_("Write more information."), (char**) &opt_verbose, |
77.1.77
by Monty Taylor
A crapton more warning cleanups (I turned on more warnings) |
92 |
(char**) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, |
264.1.21
by forstm1w
Added gettext translations to strings. |
93 |
{"version", 'V', N_("Output version information and exit."), 0, 0, 0, GET_NO_ARG, |
1
by brian
clean slate |
94 |
NO_ARG, 0, 0, 0, 0, 0, 0}, |
264.1.21
by forstm1w
Added gettext translations to strings. |
95 |
{"wait", 'w', N_("Wait and retry if connection is down."), 0, 0, 0, GET_UINT, |
1
by brian
clean slate |
96 |
OPT_ARG, 0, 0, 0, 0, 0, 0}, |
77.1.77
by Monty Taylor
A crapton more warning cleanups (I turned on more warnings) |
97 |
{"connect_timeout", OPT_CONNECT_TIMEOUT, "", (char**) &opt_connect_timeout, |
98 |
(char**) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 3600*12, 0, |
|
1
by brian
clean slate |
99 |
3600*12, 0, 1, 0}, |
77.1.77
by Monty Taylor
A crapton more warning cleanups (I turned on more warnings) |
100 |
{"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", (char**) &opt_shutdown_timeout, |
101 |
(char**) &opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG, |
|
1
by brian
clean slate |
102 |
SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0}, |
103 |
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} |
|
104 |
};
|
|
105 |
||
106 |
||
206.3.1
by Patrick Galbraith
Most everything working with client rename |
107 |
static const char *load_default_groups[]= { "drizzleadmin","client",0 }; |
1
by brian
clean slate |
108 |
|
143
by Brian Aker
Bool cleanup. |
109 |
bool
|
1
by brian
clean slate |
110 |
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), |
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
111 |
char *argument) |
1
by brian
clean slate |
112 |
{
|
113 |
int error = 0; |
|
114 |
||
115 |
switch(optid) { |
|
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
116 |
case 'p': |
117 |
if (argument) |
|
118 |
{
|
|
119 |
char *start=argument; |
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
120 |
free(opt_password); |
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
121 |
opt_password= my_strdup(argument,MYF(MY_FAE)); |
122 |
while (*argument) *argument++= 'x'; /* Destroy argument */ |
|
123 |
if (*start) |
|
124 |
start[1]=0; /* Cut length of argument */ |
|
125 |
tty_password= 0; |
|
126 |
}
|
|
127 |
else
|
|
128 |
tty_password= 1; |
|
129 |
break; |
|
1
by brian
clean slate |
130 |
case 's': |
131 |
option_silent++; |
|
132 |
break; |
|
133 |
case 'V': |
|
134 |
print_version(); |
|
135 |
exit(0); |
|
136 |
break; |
|
137 |
case 'w': |
|
138 |
if (argument) |
|
139 |
{
|
|
140 |
if ((option_wait=atoi(argument)) <= 0) |
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
141 |
option_wait=1; |
1
by brian
clean slate |
142 |
}
|
143 |
else
|
|
144 |
option_wait= ~(uint)0; |
|
145 |
break; |
|
146 |
case '?': |
|
147 |
case 'I': /* Info */ |
|
148 |
error++; |
|
149 |
break; |
|
150 |
}
|
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
151 |
|
1
by brian
clean slate |
152 |
if (error) |
153 |
{
|
|
154 |
usage(); |
|
155 |
exit(1); |
|
156 |
}
|
|
157 |
return 0; |
|
158 |
}
|
|
159 |
||
160 |
int main(int argc,char *argv[]) |
|
161 |
{
|
|
162 |
int error= 0, ho_error; |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
163 |
DRIZZLE drizzle; |
1
by brian
clean slate |
164 |
char **commands, **save_argv; |
165 |
||
166 |
MY_INIT(argv[0]); |
|
202.2.4
by Monty Taylor
Merged from Patrick. |
167 |
drizzle_create(&drizzle); |
1
by brian
clean slate |
168 |
load_defaults("my",load_default_groups,&argc,&argv); |
169 |
save_argv = argv; /* Save for free_defaults */ |
|
170 |
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) |
|
171 |
{
|
|
172 |
free_defaults(save_argv); |
|
173 |
exit(ho_error); |
|
174 |
}
|
|
175 |
||
176 |
if (argc == 0) |
|
177 |
{
|
|
178 |
usage(); |
|
179 |
exit(1); |
|
180 |
}
|
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
181 |
|
1
by brian
clean slate |
182 |
commands = argv; |
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
183 |
if (tty_password) |
461
by Monty Taylor
Removed NullS. bu-bye. |
184 |
opt_password = get_tty_password(NULL); |
1
by brian
clean slate |
185 |
|
398.1.10
by Monty Taylor
Actually removed VOID() this time. |
186 |
signal(SIGINT,endprog); /* Here if abort */ |
187 |
signal(SIGTERM,endprog); /* Here if abort */ |
|
1
by brian
clean slate |
188 |
|
189 |
if (opt_connect_timeout) |
|
190 |
{
|
|
191 |
uint tmp=opt_connect_timeout; |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
192 |
drizzle_options(&drizzle,DRIZZLE_OPT_CONNECT_TIMEOUT, (char*) &tmp); |
1
by brian
clean slate |
193 |
}
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
194 |
|
195 |
error_flags= (myf)0; |
|
1
by brian
clean slate |
196 |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
197 |
if (sql_connect(&drizzle, option_wait)) |
1
by brian
clean slate |
198 |
{
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
199 |
unsigned int err= drizzle_errno(&drizzle); |
1
by brian
clean slate |
200 |
if (err >= CR_MIN_ERROR && err <= CR_MAX_ERROR) |
201 |
error= 1; |
|
202 |
else
|
|
203 |
{
|
|
204 |
/* Return 0 if all commands are PING */
|
|
205 |
for (; argc > 0; argv++, argc--) |
|
206 |
{
|
|
207 |
if (find_type(argv[0], &command_typelib, 2) != ADMIN_PING) |
|
208 |
{
|
|
209 |
error= 1; |
|
210 |
break; |
|
211 |
}
|
|
212 |
}
|
|
213 |
}
|
|
214 |
}
|
|
215 |
else
|
|
216 |
{
|
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
217 |
error=execute_commands(&drizzle,argc,commands); |
218 |
drizzle_close(&drizzle); |
|
1
by brian
clean slate |
219 |
}
|
477
by Monty Taylor
Removed my_free(). It turns out that it had been def'd to ignore the flags passed to it in the second arg anyway. Gotta love that. |
220 |
free(opt_password); |
221 |
free(user); |
|
1
by brian
clean slate |
222 |
free_defaults(save_argv); |
223 |
my_end(my_end_arg); |
|
224 |
exit(error ? 1 : 0); |
|
225 |
}
|
|
226 |
||
454
by Monty Taylor
Removed RETSIGHANDLER to sig_handler define. |
227 |
RETSIGTYPE endprog(int signal_number __attribute__((unused))) |
1
by brian
clean slate |
228 |
{
|
229 |
interrupted=1; |
|
230 |
}
|
|
231 |
||
206.3.1
by Patrick Galbraith
Most everything working with client rename |
232 |
static bool sql_connect(DRIZZLE *drizzle, uint wait) |
1
by brian
clean slate |
233 |
{
|
143
by Brian Aker
Bool cleanup. |
234 |
bool info=0; |
1
by brian
clean slate |
235 |
|
236 |
for (;;) |
|
237 |
{
|
|
461
by Monty Taylor
Removed NullS. bu-bye. |
238 |
if (drizzle_connect(drizzle,host,user,opt_password,NULL,tcp_port,NULL,0)) |
1
by brian
clean slate |
239 |
{
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
240 |
drizzle->reconnect= 1; |
1
by brian
clean slate |
241 |
if (info) |
242 |
{
|
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
243 |
fputs("\n",stderr); |
244 |
(void) fflush(stderr); |
|
1
by brian
clean slate |
245 |
}
|
246 |
return 0; |
|
247 |
}
|
|
248 |
||
249 |
if (!wait) |
|
250 |
{
|
|
251 |
if (!option_silent) |
|
252 |
{
|
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
253 |
if (!host) |
254 |
host= (char*) LOCAL_HOST; |
|
255 |
||
264.1.21
by forstm1w
Added gettext translations to strings. |
256 |
my_printf_error(0,_("connect to server at '%s' failed\nerror: '%s'"), |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
257 |
error_flags, host, drizzle_error(drizzle)); |
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
258 |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
259 |
if (drizzle_errno(drizzle) == CR_CONN_HOST_ERROR || |
260 |
drizzle_errno(drizzle) == CR_UNKNOWN_HOST) |
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
261 |
{
|
264.1.21
by forstm1w
Added gettext translations to strings. |
262 |
fprintf(stderr,_("Check that drizzled is running on %s"),host); |
263 |
fprintf(stderr,_(" and that the port is %d.\n"), |
|
390.1.5
by Monty Taylor
Moved more functions into drizzle.c as part of the split of code. |
264 |
tcp_port ? tcp_port: drizzle_get_default_port()); |
264.1.21
by forstm1w
Added gettext translations to strings. |
265 |
fprintf(stderr,_("You can check this by doing 'telnet %s %d'\n"), |
390.1.5
by Monty Taylor
Moved more functions into drizzle.c as part of the split of code. |
266 |
host, tcp_port ? tcp_port: drizzle_get_default_port()); |
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
267 |
}
|
1
by brian
clean slate |
268 |
}
|
269 |
return 1; |
|
270 |
}
|
|
365.2.8
by Monty Taylor
More MAX macros. |
271 |
if (wait != UINT32_MAX) |
1
by brian
clean slate |
272 |
wait--; /* One less retry */ |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
273 |
if ((drizzle_errno(drizzle) != CR_CONN_HOST_ERROR) && |
274 |
(drizzle_errno(drizzle) != CR_CONNECTION_ERROR)) |
|
1
by brian
clean slate |
275 |
{
|
264.1.21
by forstm1w
Added gettext translations to strings. |
276 |
fprintf(stderr,_("Got error: %s\n"), drizzle_error(drizzle)); |
1
by brian
clean slate |
277 |
}
|
278 |
else if (!option_silent) |
|
279 |
{
|
|
280 |
if (!info) |
|
281 |
{
|
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
282 |
info=1; |
264.1.21
by forstm1w
Added gettext translations to strings. |
283 |
fputs(_("Waiting for Drizzle server to answer"),stderr); |
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
284 |
(void) fflush(stderr); |
1
by brian
clean slate |
285 |
}
|
286 |
else
|
|
287 |
{
|
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
288 |
putc('.',stderr); |
289 |
(void) fflush(stderr); |
|
1
by brian
clean slate |
290 |
}
|
291 |
}
|
|
292 |
sleep(5); |
|
293 |
}
|
|
294 |
}
|
|
295 |
||
296 |
/*
|
|
297 |
Execute a command.
|
|
298 |
Return 0 on ok
|
|
299 |
-1 on retryable error
|
|
300 |
1 on fatal error
|
|
301 |
*/
|
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
302 |
static int execute_commands(DRIZZLE *drizzle,int argc, char **argv) |
1
by brian
clean slate |
303 |
{
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
304 |
|
1
by brian
clean slate |
305 |
/*
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
306 |
DRIZZLE documentation relies on the fact that drizzleadmin will
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
307 |
execute commands in the order specified.
|
1
by brian
clean slate |
308 |
If this behaviour is ever changed, Docs should be notified.
|
309 |
*/
|
|
310 |
for (; argc > 0 ; argv++,argc--) |
|
311 |
{
|
|
312 |
switch (find_type(argv[0],&command_typelib,2)) { |
|
313 |
case ADMIN_SHUTDOWN: |
|
314 |
{
|
|
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
315 |
if (opt_verbose) |
264.1.21
by forstm1w
Added gettext translations to strings. |
316 |
printf(_("shutting down drizzled...\n")); |
1
by brian
clean slate |
317 |
|
438.1.9
by Brian Aker
Removed dead shutdown code. |
318 |
if (drizzle_shutdown(drizzle)) |
1
by brian
clean slate |
319 |
{
|
264.1.21
by forstm1w
Added gettext translations to strings. |
320 |
my_printf_error(0, _("shutdown failed; error: '%s'"), error_flags, |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
321 |
drizzle_error(drizzle)); |
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
322 |
return -1; |
1
by brian
clean slate |
323 |
}
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
324 |
drizzle_close(drizzle); /* Close connection to avoid error messages */ |
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
325 |
|
326 |
if (opt_verbose) |
|
264.1.21
by forstm1w
Added gettext translations to strings. |
327 |
printf(_("done\n")); |
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
328 |
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
329 |
argc=1; /* Force SHUTDOWN to be the last command */ |
154.1.2
by Toru Maesaka
further slimdown of mysqladmin and code review fixes |
330 |
break; |
1
by brian
clean slate |
331 |
}
|
332 |
case ADMIN_PING: |
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
333 |
drizzle->reconnect=0; /* We want to know of reconnects */ |
334 |
if (!drizzle_ping(drizzle)) |
|
1
by brian
clean slate |
335 |
{
|
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
336 |
if (option_silent < 2) |
264.1.21
by forstm1w
Added gettext translations to strings. |
337 |
puts(_("drizzled is alive")); |
1
by brian
clean slate |
338 |
}
|
339 |
else
|
|
340 |
{
|
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
341 |
if (drizzle_errno(drizzle) == CR_SERVER_GONE_ERROR) |
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
342 |
{
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
343 |
drizzle->reconnect=1; |
344 |
if (!drizzle_ping(drizzle)) |
|
264.1.21
by forstm1w
Added gettext translations to strings. |
345 |
puts(_("connection was down, but drizzled is now alive")); |
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
346 |
}
|
347 |
else
|
|
348 |
{
|
|
264.1.21
by forstm1w
Added gettext translations to strings. |
349 |
my_printf_error(0,_("drizzled doesn't answer to ping, error: '%s'"), |
206.3.1
by Patrick Galbraith
Most everything working with client rename |
350 |
error_flags, drizzle_error(drizzle)); |
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
351 |
return -1; |
352 |
}
|
|
1
by brian
clean slate |
353 |
}
|
206.3.1
by Patrick Galbraith
Most everything working with client rename |
354 |
drizzle->reconnect=1; /* Automatic reconnect is default */ |
1
by brian
clean slate |
355 |
break; |
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
356 |
|
1
by brian
clean slate |
357 |
default: |
264.1.21
by forstm1w
Added gettext translations to strings. |
358 |
my_printf_error(0, _("Unknown command: '%-.60s'"), error_flags, argv[0]); |
1
by brian
clean slate |
359 |
return 1; |
360 |
}
|
|
361 |
}
|
|
362 |
return 0; |
|
363 |
}
|
|
364 |
||
365 |
static void print_version(void) |
|
366 |
{
|
|
264.1.21
by forstm1w
Added gettext translations to strings. |
367 |
printf(_("%s Ver %s Distrib %s, for %s on %s\n"),my_progname,ADMIN_VERSION, |
264.1.10
by Monty Taylor
Removed client insistence on version.h stuff. |
368 |
drizzle_get_client_info(),SYSTEM_TYPE,MACHINE_TYPE); |
1
by brian
clean slate |
369 |
}
|
370 |
||
371 |
static void usage(void) |
|
372 |
{
|
|
373 |
print_version(); |
|
264.1.21
by forstm1w
Added gettext translations to strings. |
374 |
puts(_("Copyright (C) 2000-2008 MySQL AB")); |
375 |
puts(_("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n")); |
|
376 |
puts(_("Administration program for the drizzled daemon.")); |
|
377 |
printf(_("Usage: %s [OPTIONS] command command....\n"), my_progname); |
|
1
by brian
clean slate |
378 |
my_print_help(my_long_options); |
264.1.21
by forstm1w
Added gettext translations to strings. |
379 |
puts(_("\ |
154.1.1
by Toru Maesaka
Slimmed down mysqladmin to ping and shutdown only. Some dead code were removed too |
380 |
ping Check if server is down\n\ |
264.1.21
by forstm1w
Added gettext translations to strings. |
381 |
shutdown Take server down\n")); |
1
by brian
clean slate |
382 |
}
|