~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzle.cc

  • Committer: lbieber
  • Date: 2010-09-07 22:29:56 UTC
  • mfrom: (1747.1.3 build)
  • Revision ID: lbieber@orisndriz03-20100907222956-d60u695b7hx3zs0d
Merge Andrew - bug 597778 - Timestamp cannot reliably store leap seconds, so don't try. Leave that to datetime only
Merge Andrew - bug 621862 - Add / clean-up error messages for unireg_abort
Merge Andrew - bug 629563 - Drop the broken --mysql options and Change the --protocol option to accept 'mysql' or 'drizzle' ('mysql' currently default)

Show diffs side-by-side

added added

removed removed

Lines of Context:
295
295
  default_pager_set= false, opt_sigint_ignore= false,
296
296
  auto_vertical_output= false,
297
297
  show_warnings= false, executing_query= false, interrupted_query= false,
298
 
  opt_mysql= false, opt_local_infile;
 
298
  use_drizzle_protocol= false, opt_local_infile;
299
299
static uint32_t show_progress_size= 0;
300
300
static bool column_types_flag;
301
301
static bool preserve_comments= false;
320
320
  current_user,
321
321
  opt_verbose,
322
322
  current_password,
323
 
  opt_password;
 
323
  opt_password,
 
324
  opt_protocol;
324
325
// TODO: Need to i18n these
325
326
static const char *day_names[]= {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
326
327
static const char *month_names[]= {"Jan","Feb","Mar","Apr","May","Jun","Jul",
1466
1467
 
1467
1468
  po::options_description client_options(N_("Options specific to the client"));
1468
1469
  client_options.add_options()
1469
 
  ("mysql,m", po::value<bool>(&opt_mysql)->default_value(true)->zero_tokens(),
1470
 
  N_("Use MySQL Protocol."))
1471
1470
  ("host,h", po::value<string>(&current_host)->default_value("localhost"),
1472
1471
  N_("Connect to host"))
1473
1472
  ("password,P", po::value<string>(&current_password)->default_value(PASSWORD_SENTINEL),
1476
1475
  N_("Port number to use for connection or 0 for default to, in order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, built-in default"))
1477
1476
  ("user,u", po::value<string>(&current_user)->default_value(""),
1478
1477
  N_("User for login if not current user."))
1479
 
  ("protocol",po::value<string>(),
1480
 
  N_("The protocol of connection (tcp,socket,pipe,memory)."))
 
1478
  ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
 
1479
  N_("The protocol of connection (mysql or drizzle)."))
1481
1480
  ;
1482
1481
 
1483
1482
  po::options_description long_options(N_("Allowed Options"));
1652
1651
 
1653
1652
  if (one_database)
1654
1653
    skip_updates= true;
1655
 
  
 
1654
 
 
1655
  if (vm.count("protocol"))
 
1656
  {
 
1657
    std::transform(opt_protocol.begin(), opt_protocol.end(), 
 
1658
      opt_protocol.begin(), ::tolower);
 
1659
 
 
1660
    if (not opt_protocol.compare("mysql"))
 
1661
      use_drizzle_protocol=false;
 
1662
    else if (not opt_protocol.compare("drizzle"))
 
1663
      use_drizzle_protocol=true;
 
1664
    else
 
1665
    {
 
1666
      cout << _("Error: Unknown protocol") << " '" << opt_protocol << "'" << endl;
 
1667
      exit(-1);
 
1668
    }
 
1669
  }
 
1670
 
1656
1671
  if (vm.count("port"))
1657
1672
  {
1658
1673
    opt_drizzle_port= vm["port"].as<uint32_t>();
1782
1797
  glob_buffer->reserve(512);
1783
1798
 
1784
1799
  snprintf(&output_buff[0], output_buff.size(),
1785
 
          _("Your Drizzle connection id is %u\nServer version: %s\n"),
 
1800
          _("Your Drizzle connection id is %u\nConnection protocol: %s\nServer version: %s\n"),
1786
1801
          drizzle_con_thread_id(&con),
 
1802
          opt_protocol.c_str(),
1787
1803
          server_version_string(&con));
1788
1804
  put_info(&output_buff[0], INFO_INFO, 0, 0);
1789
1805
 
 
1806
 
1790
1807
  initialize_readline((char *)current_prompt.c_str());
1791
1808
  if (!status.getBatch() && !quick)
1792
1809
  {
1894
1911
  }
1895
1912
 
1896
1913
  if (drizzle_con_add_tcp(&drizzle, &kill_drizzle, current_host.c_str(),
1897
 
                          opt_drizzle_port, current_user.c_str(), opt_password.c_str(), NULL,
1898
 
                          opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL)
 
1914
    opt_drizzle_port, current_user.c_str(), opt_password.c_str(), NULL,
 
1915
    use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL) == NULL)
1899
1916
  {
1900
1917
    goto err;
1901
1918
  }
4033
4050
    drizzle_free(&drizzle);
4034
4051
  }
4035
4052
  drizzle_create(&drizzle);
4036
 
  if (drizzle_con_add_tcp(&drizzle, &con, (char *)host.c_str(), opt_drizzle_port, (char *)user.c_str(),
4037
 
                          (char *)password.c_str(), (char *)database.c_str(), opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL)
 
4053
  if (drizzle_con_add_tcp(&drizzle, &con, (char *)host.c_str(),
 
4054
    opt_drizzle_port, (char *)user.c_str(),
 
4055
    (char *)password.c_str(), (char *)database.c_str(),
 
4056
    use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL) == NULL)
4038
4057
  {
4039
4058
    (void) put_error(&con, NULL);
4040
4059
    (void) fflush(stdout);
4092
4111
  tee_puts("--------------", stdout);
4093
4112
  printf(_("Drizzle client %s build %s, for %s-%s (%s) using readline %s\n"),
4094
4113
         drizzle_version(), VERSION,
4095
 
         HOST_VENDOR, HOST_OS,
 
4114
         HOST_VENDOR, HOST_OS, HOST_CPU,
4096
4115
         rl_library_version);
4097
4116
 
4098
4117
  if (connected)
4135
4154
  tee_fprintf(stdout, _("Using outfile:\t\t'%s'\n"), opt_outfile ? outfile.c_str() : "");
4136
4155
  tee_fprintf(stdout, _("Using delimiter:\t%s\n"), delimiter);
4137
4156
  tee_fprintf(stdout, _("Server version:\t\t%s\n"), server_version_string(&con));
 
4157
  tee_fprintf(stdout, _("Protocol:\t\t%s\n"), opt_protocol.c_str());
4138
4158
  tee_fprintf(stdout, _("Protocol version:\t%d\n"), drizzle_con_protocol_version(&con));
4139
4159
  tee_fprintf(stdout, _("Connection:\t\t%s\n"), drizzle_con_host(&con));
4140
4160
/* XXX need to save this from result