~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Lee Bieber
  • Date: 2011-02-24 03:20:47 UTC
  • mfrom: (2196.1.4 build)
  • Revision ID: kalebral@gmail.com-20110224032047-avmw06iwww3m73cw
Merge Andrew - 723653: Docs day first pass fixes 
Merge Brian - Puts back in support for COM_KILL, Also adds back in the INTERACTIVE flag, and creates a DD to track sessions/check on usage
Merge Olaf - Use List::size()

Show diffs side-by-side

added added

removed removed

Lines of Context:
291
291
  auto_vertical_output= false,
292
292
  show_warnings= false, executing_query= false, interrupted_query= false,
293
293
  use_drizzle_protocol= false, opt_local_infile;
 
294
static uint32_t opt_kill= 0;
294
295
static uint32_t show_progress_size= 0;
295
296
static bool column_types_flag;
296
297
static bool preserve_comments= false;
297
298
static uint32_t opt_max_input_line;
298
299
static uint32_t opt_drizzle_port= 0;
299
300
static int  opt_silent, verbose= 0;
300
 
static drizzle_capabilities_t connect_flag= DRIZZLE_CAPABILITIES_NONE;
301
301
static char *histfile;
302
302
static char *histfile_tmp;
303
303
static string *glob_buffer;
1223
1223
  return true;
1224
1224
}
1225
1225
 
 
1226
static bool kill_query(uint32_t query_id)
 
1227
{
 
1228
  drizzle_result_st result;
 
1229
  drizzle_return_t ret;
 
1230
 
 
1231
  if (verbose)
 
1232
  {
 
1233
    printf(_("killing query %u"), query_id);
 
1234
    printf("... ");
 
1235
  }
 
1236
 
 
1237
  if (drizzle_kill(&con, &result, query_id,
 
1238
                   &ret) == NULL || ret != DRIZZLE_RETURN_OK)
 
1239
  {
 
1240
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
 
1241
    {
 
1242
      fprintf(stderr, _("kill failed; error: '%s'"),
 
1243
              drizzle_result_error(&result));
 
1244
      drizzle_result_free(&result);
 
1245
    }
 
1246
    else
 
1247
    {
 
1248
      fprintf(stderr, _("kill failed; error: '%s'"),
 
1249
              drizzle_con_error(&con));
 
1250
    }
 
1251
    return false;
 
1252
  }
 
1253
 
 
1254
  drizzle_result_free(&result);
 
1255
 
 
1256
  if (verbose)
 
1257
    printf(_("done\n"));
 
1258
 
 
1259
  return true;
 
1260
}
 
1261
 
1226
1262
/**
1227
1263
  Ping the server that we are currently connected to.
1228
1264
 
1292
1328
      *error= 1;
1293
1329
    executed= true;
1294
1330
  }
 
1331
 
 
1332
  if (opt_kill)
 
1333
  {
 
1334
    if (kill_query(opt_kill) == false)
 
1335
    {
 
1336
      *error= 1;
 
1337
    }
 
1338
    executed= true;
 
1339
  }
 
1340
 
1295
1341
  return executed;
1296
1342
}
1297
1343
 
1409
1455
  ("shutdown", po::value<bool>()->zero_tokens(),
1410
1456
  _("Shutdown the server"))
1411
1457
  ("silent,s", _("Be more silent. Print results with a tab as separator, each row on new line."))
 
1458
  ("kill", po::value<uint32_t>(&opt_kill)->default_value(0),
 
1459
  _("Kill a running query."))
1412
1460
  ("tee", po::value<string>(),
1413
1461
  _("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
1462
  ("disable-tee", po::value<bool>()->default_value(false)->zero_tokens(), 
1973
2021
    default_pager_set= 0;
1974
2022
    opt_outfile= 0;
1975
2023
    opt_reconnect= 0;
1976
 
    connect_flag= DRIZZLE_CAPABILITIES_NONE; /* Not in interactive mode */
1977
2024
  }
1978
2025
 
1979
2026
  if (tty_password)
4175
4222
  drizzle_create(&drizzle);
4176
4223
 
4177
4224
#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));
 
4225
  drizzle_con_options_t options= (drizzle_con_options_t) (DRIZZLE_CON_ADMIN | (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL|DRIZZLE_CON_INTERACTIVE));
4179
4226
#else
4180
 
  drizzle_con_options_t options= (drizzle_con_options_t) (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
 
4227
  drizzle_con_options_t options= (drizzle_con_options_t) (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL|DRIZZLE_CON_INTERACTIVE);
4181
4228
#endif
4182
4229
 
4183
4230
  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(),
4186
 
    options) == NULL)
 
4231
                          opt_drizzle_port, (char *)user.c_str(),
 
4232
                          (char *)password.c_str(), (char *)database.c_str(),
 
4233
                          options) == NULL)
4187
4234
  {
4188
4235
    (void) put_error(&con, NULL);
4189
4236
    (void) fflush(stdout);
4190
4237
    return 1;
4191
4238
  }
4192
4239
 
4193
 
/* XXX add this back in
4194
 
  if (opt_connect_timeout)
4195
 
  {
4196
 
    uint32_t timeout=opt_connect_timeout;
4197
 
    drizzleclient_options(&drizzle,DRIZZLE_OPT_CONNECT_TIMEOUT,
4198
 
                  (char*) &timeout);
4199
 
  }
4200
 
*/
4201
 
 
4202
 
/* XXX Do we need this?
4203
 
  if (safe_updates)
4204
 
  {
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);
4211
 
  }
4212
 
*/
4213
4240
  if ((ret= drizzle_con_connect(&con)) != DRIZZLE_RETURN_OK)
4214
4241
  {
4215
4242
 
4221
4248
    }
4222
4249
    return -1;          // Retryable
4223
4250
  }
4224
 
  connected=1;
 
4251
  connected= 1;
4225
4252
 
4226
4253
  ServerDetect server_detect(&con);
4227
4254
  server_type= server_detect.getServerType();