~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Brian Aker
  • Date: 2011-02-22 22:57:45 UTC
  • mto: (2194.4.1 drizzle-build)
  • mto: This revision was merged to the branch mainline in revision 2197.
  • Revision ID: brian@tangent.org-20110222225745-973fbdcutp2m1w0h
Add in KILL protocol support.

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;
1223
1224
  return true;
1224
1225
}
1225
1226
 
 
1227
static bool kill_query(uint32_t query_id)
 
1228
{
 
1229
  drizzle_result_st result;
 
1230
  drizzle_return_t ret;
 
1231
 
 
1232
  if (verbose)
 
1233
  {
 
1234
    printf(_("killing query %u"), query_id);
 
1235
    printf("... ");
 
1236
  }
 
1237
 
 
1238
  if (drizzle_kill(&con, &result, query_id,
 
1239
                   &ret) == NULL || ret != DRIZZLE_RETURN_OK)
 
1240
  {
 
1241
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
 
1242
    {
 
1243
      fprintf(stderr, _("kill failed; error: '%s'"),
 
1244
              drizzle_result_error(&result));
 
1245
      drizzle_result_free(&result);
 
1246
    }
 
1247
    else
 
1248
    {
 
1249
      fprintf(stderr, _("kill failed; error: '%s'"),
 
1250
              drizzle_con_error(&con));
 
1251
    }
 
1252
    return false;
 
1253
  }
 
1254
 
 
1255
  drizzle_result_free(&result);
 
1256
 
 
1257
  if (verbose)
 
1258
    printf(_("done\n"));
 
1259
 
 
1260
  return true;
 
1261
}
 
1262
 
1226
1263
/**
1227
1264
  Ping the server that we are currently connected to.
1228
1265
 
1292
1329
      *error= 1;
1293
1330
    executed= true;
1294
1331
  }
 
1332
 
 
1333
  if (opt_kill)
 
1334
  {
 
1335
    if (kill_query(opt_kill) == false)
 
1336
    {
 
1337
      *error= 1;
 
1338
    }
 
1339
    executed= true;
 
1340
  }
 
1341
 
1295
1342
  return executed;
1296
1343
}
1297
1344
 
1409
1456
  ("shutdown", po::value<bool>()->zero_tokens(),
1410
1457
  _("Shutdown the server"))
1411
1458
  ("silent,s", _("Be more silent. Print results with a tab as separator, each row on new line."))
 
1459
  ("kill", po::value<uint32_t>(&opt_kill)->default_value(0),
 
1460
  _("Kill a running query."))
1412
1461
  ("tee", po::value<string>(),
1413
1462
  _("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
1463
  ("disable-tee", po::value<bool>()->default_value(false)->zero_tokens(),