~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: Lee Bieber
  • Date: 2010-11-20 01:33:21 UTC
  • mfrom: (1878.10.4 drizzle_bug665252)
  • Revision ID: kalebral@gmail.com-20101120013321-7nk9lq4nnr20zk6b
Merge Billy - removed my_getsysdate, my_micro_time and my_micro_time_and_time and replaced with boost::date_time for compatibility.

Show diffs side-by-side

added added

removed removed

Lines of Context:
360
360
  com_help(string *str,const char*), com_clear(string *str,const char*),
361
361
  com_connect(string *str,const char*), com_status(string *str,const char*),
362
362
  com_use(string *str,const char*), com_source(string *str, const char*),
363
 
  com_shutdown(string *str,const char*),
364
363
  com_rehash(string *str, const char*), com_tee(string *str, const char*),
365
364
  com_notee(string *str, const char*),
366
365
  com_prompt(string *str, const char*), com_delimiter(string *str, const char*),
492
491
    N_("Set outfile [to_outfile]. Append everything into given outfile.") ),
493
492
  Commands( "use",    'u', com_use,    1,
494
493
    N_("Use another database. Takes database name as argument.") ),
495
 
  Commands( "shutdown",    'u', com_shutdown,    1,
496
 
    N_("Shutdown the instance you are connected too.") ),
497
494
  Commands( "warnings", 'W', com_warnings,  0,
498
495
    N_("Show warnings after every statement.") ),
499
496
  Commands( "nowarning", 'w', com_nowarnings, 0,
1386
1383
  N_("Password to use when connecting to server. If password is not given it's asked from the tty."))
1387
1384
  ("port,p", po::value<uint32_t>()->default_value(0),
1388
1385
  N_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, built-in default"))
1389
 
#ifdef DRIZZLE_ADMIN_TOOL
1390
 
  ("user,u", po::value<string>(&current_user)->default_value("root"),
1391
 
#else
1392
1386
  ("user,u", po::value<string>(&current_user)->default_value(""),
1393
 
#endif
1394
1387
  N_("User for login if not current user."))
1395
1388
  ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
1396
1389
  N_("The protocol of connection (mysql or drizzle)."))
1450
1443
 
1451
1444
  po::notify(vm);
1452
1445
 
1453
 
#ifdef DRIZZLE_ADMIN_TOOL
1454
 
  default_prompt= strdup(getenv("DRIZZLE_PS1") ?
1455
 
                         getenv("DRIZZLE_PS1") :
1456
 
                         "drizzleadmin> ");
1457
 
#else
1458
1446
  default_prompt= strdup(getenv("DRIZZLE_PS1") ?
1459
1447
                         getenv("DRIZZLE_PS1") :
1460
1448
                         "drizzle> ");
1461
 
#endif
1462
1449
  if (default_prompt == NULL)
1463
1450
  {
1464
1451
    fprintf(stderr, _("Memory allocation error while constructing initial "
3917
3904
  return 0;
3918
3905
}
3919
3906
 
3920
 
static int com_shutdown(string *, const char *)
3921
 
{
3922
 
  drizzle_result_st result;
3923
 
  drizzle_return_t ret;
3924
 
 
3925
 
  if (verbose)
3926
 
  {
3927
 
    printf(_("shutting down drizzled"));
3928
 
    if (opt_drizzle_port > 0)
3929
 
      printf(_(" on port %d"), opt_drizzle_port);
3930
 
    printf("... ");
3931
 
  }
3932
 
 
3933
 
  if (drizzle_shutdown(&con, &result, DRIZZLE_SHUTDOWN_DEFAULT,
3934
 
                       &ret) == NULL || ret != DRIZZLE_RETURN_OK)
3935
 
  {
3936
 
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
3937
 
    {
3938
 
      fprintf(stderr, _("shutdown failed; error: '%s'"),
3939
 
              drizzle_result_error(&result));
3940
 
      drizzle_result_free(&result);
3941
 
    }
3942
 
    else
3943
 
    {
3944
 
      fprintf(stderr, _("shutdown failed; error: '%s'"),
3945
 
              drizzle_con_error(&con));
3946
 
    }
3947
 
    return false;
3948
 
  }
3949
 
 
3950
 
  drizzle_result_free(&result);
3951
 
 
3952
 
  if (verbose)
3953
 
    printf(_("done\n"));
3954
 
 
3955
 
  return false;
3956
 
}
3957
 
 
3958
3907
static int
3959
3908
com_warnings(string *, const char *)
3960
3909
{
4045
3994
    drizzle_free(&drizzle);
4046
3995
  }
4047
3996
  drizzle_create(&drizzle);
4048
 
 
4049
 
#ifdef DRIZZLE_ADMIN_TOOL
4050
 
  drizzle_con_options_t options= (drizzle_con_options_t) (DRIZZLE_CON_ADMIN | (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL));
4051
 
#else
4052
 
  drizzle_con_options_t options= (drizzle_con_options_t) (use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
4053
 
#endif
4054
 
 
4055
3997
  if (drizzle_con_add_tcp(&drizzle, &con, (char *)host.c_str(),
4056
3998
    opt_drizzle_port, (char *)user.c_str(),
4057
3999
    (char *)password.c_str(), (char *)database.c_str(),
4058
 
    options) == NULL)
 
4000
    use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL) == NULL)
4059
4001
  {
4060
4002
    (void) put_error(&con, NULL);
4061
4003
    (void) fflush(stdout);