291
294
auto_vertical_output= false,
292
295
show_warnings= false, executing_query= false, interrupted_query= false,
293
296
use_drizzle_protocol= false, opt_local_infile;
297
static uint32_t opt_kill= 0;
294
298
static uint32_t show_progress_size= 0;
295
299
static bool column_types_flag;
296
300
static bool preserve_comments= false;
297
301
static uint32_t opt_max_input_line;
298
302
static uint32_t opt_drizzle_port= 0;
299
303
static int opt_silent, verbose= 0;
300
static drizzle_capabilities_t connect_flag= DRIZZLE_CAPABILITIES_NONE;
301
304
static char *histfile;
302
305
static char *histfile_tmp;
303
306
static string *glob_buffer;
1229
static bool kill_query(uint32_t query_id)
1231
drizzle_result_st result;
1232
drizzle_return_t ret;
1236
printf(_("killing query %u"), query_id);
1240
if (drizzle_kill(&con, &result, query_id,
1241
&ret) == NULL || ret != DRIZZLE_RETURN_OK)
1243
if (ret == DRIZZLE_RETURN_ERROR_CODE)
1245
fprintf(stderr, _("kill failed; error: '%s'"),
1246
drizzle_result_error(&result));
1247
drizzle_result_free(&result);
1251
fprintf(stderr, _("kill failed; error: '%s'"),
1252
drizzle_con_error(&con));
1257
drizzle_result_free(&result);
1260
printf(_("done\n"));
1227
1266
Ping the server that we are currently connected to.
1409
1458
("shutdown", po::value<bool>()->zero_tokens(),
1410
1459
_("Shutdown the server"))
1411
1460
("silent,s", _("Be more silent. Print results with a tab as separator, each row on new line."))
1461
("kill", po::value<uint32_t>(&opt_kill)->default_value(0),
1462
_("Kill a running query."))
1412
1463
("tee", po::value<string>(),
1413
1464
_("Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default."))
1414
1465
("disable-tee", po::value<bool>()->default_value(false)->zero_tokens(),
1422
1473
("max-join-size", po::value<uint32_t>(&max_join_size)->default_value(1000000L),
1423
1474
_("Automatic limit for rows in a join when using --safe-updates"))
1476
#ifndef DRIZZLE_ADMIN_TOOL
1477
const char* unix_user= getlogin();
1426
1479
po::options_description client_options(_("Options specific to the client"));
1427
1480
client_options.add_options()
1428
1481
("host,h", po::value<string>(¤t_host)->default_value("localhost"),
1434
1487
#ifdef DRIZZLE_ADMIN_TOOL
1435
1488
("user,u", po::value<string>(¤t_user)->default_value("root"),
1437
("user,u", po::value<string>(¤t_user)->default_value(""),
1490
("user,u", po::value<string>(¤t_user)->default_value((unix_user ? unix_user : "")),
1439
1492
_("User for login if not current user."))
1440
1493
("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
1441
_("The protocol of connection (mysql or drizzle)."))
1494
_("The protocol of connection (mysql, mysql-plugin-auth, or drizzle)."))
1444
1497
po::options_description long_options(_("Allowed Options"));
1654
1707
opt_protocol.begin(), ::tolower);
1656
1709
if (not opt_protocol.compare("mysql"))
1657
use_drizzle_protocol=false;
1712
global_con_options= (drizzle_con_options_t)(DRIZZLE_CON_MYSQL|DRIZZLE_CON_INTERACTIVE);
1713
use_drizzle_protocol= false;
1715
else if (not opt_protocol.compare("mysql-plugin-auth"))
1717
global_con_options= (drizzle_con_options_t)(DRIZZLE_CON_MYSQL|DRIZZLE_CON_INTERACTIVE|DRIZZLE_CON_AUTH_PLUGIN);
1718
use_drizzle_protocol= false;
1658
1720
else if (not opt_protocol.compare("drizzle"))
1659
use_drizzle_protocol=true;
1722
global_con_options= (drizzle_con_options_t)(DRIZZLE_CON_EXPERIMENTAL);
1723
use_drizzle_protocol= true;
1662
1727
cout << _("Error: Unknown protocol") << " '" << opt_protocol << "'" << endl;
4175
4240
drizzle_create(&drizzle);
4177
4242
#ifdef DRIZZLE_ADMIN_TOOL
4178
drizzle_con_options_t options= (drizzle_con_options_t) (DRIZZLE_CON_ADMIN | (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL));
4180
drizzle_con_options_t options= (drizzle_con_options_t) (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
4243
global_con_options= (drizzle_con_options_t) (DRIZZLE_CON_ADMIN | global_con_options);
4183
4246
if (drizzle_con_add_tcp(&drizzle, &con, (char *)host.c_str(),
4184
opt_drizzle_port, (char *)user.c_str(),
4185
(char *)password.c_str(), (char *)database.c_str(),
4247
opt_drizzle_port, (char *)user.c_str(),
4248
(char *)password.c_str(), (char *)database.c_str(),
4249
global_con_options) == NULL)
4188
4251
(void) put_error(&con, NULL);
4189
4252
(void) fflush(stdout);
4193
/* XXX add this back in
4194
if (opt_connect_timeout)
4196
uint32_t timeout=opt_connect_timeout;
4197
drizzleclient_options(&drizzle,DRIZZLE_OPT_CONNECT_TIMEOUT,
4202
/* XXX Do we need this?
4205
char init_command[100];
4206
sprintf(init_command,
4207
"SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=%"PRIu32
4208
",MAX_JOIN_SIZE=%"PRIu32,
4209
select_limit, max_join_size);
4210
drizzleclient_options(&drizzle, DRIZZLE_INIT_COMMAND, init_command);
4213
4256
if ((ret= drizzle_con_connect(&con)) != DRIZZLE_RETURN_OK)