~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleslap.cc

  • Committer: Andrew Hutchings
  • Date: 2010-09-08 19:03:09 UTC
  • mfrom: (1750 staging)
  • mto: (1750.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1751.
  • Revision ID: andrew@linuxjedi.co.uk-20100908190309-mya1nu7xvo1fpvk8
Merge trunk into branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
 
4
 *  Copyright (C) 2010 Vijay Samuel
4
5
 *  Copyright (C) 2008 MySQL
5
6
 *
6
7
 *  This program is free software; you can redistribute it and/or modify
134
135
 
135
136
static vector<string> user_supplied_queries;
136
137
static string opt_verbose;
 
138
std::string opt_protocol;
137
139
string delimiter;
138
140
 
139
141
string create_schema_string;
140
142
 
141
 
static bool opt_mysql;
 
143
static bool use_drizzle_protocol= false;
142
144
static bool opt_preserve= true;
143
145
static bool opt_only_print;
144
146
static bool opt_burnin;
924
926
 
925
927
    po::options_description client_options("Options specific to the client");
926
928
    client_options.add_options()
927
 
      ("mysql,m", po::value<bool>(&opt_mysql)->default_value(true)->zero_tokens(),
928
 
       N_("Use MySQL Protocol."))
929
929
      ("host,h",po::value<string>(&host)->default_value("localhost"),"Connect to the host")
930
930
      ("password,P",po::value<char *>(&password),
931
931
       "Password to use when connecting to server. If password is not given it's asked from the tty")
932
932
      ("port,p",po::value<uint32_t>(), "Port number to use for connection")
933
 
      ("protocol",po::value<string>(),
934
 
       "The protocol of connection (tcp,socket,pipe,memory).")
 
933
      ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
 
934
       "The protocol of connection (mysql or drizzle).")
935
935
      ("user,u",po::value<string>(&user)->default_value(""),
936
936
       "User for login if not current user")  
937
937
      ;
992
992
      exit(0);
993
993
    }   
994
994
 
 
995
    if (vm.count("protocol"))
 
996
    {
 
997
      std::transform(opt_protocol.begin(), opt_protocol.end(),
 
998
        opt_protocol.begin(), ::tolower);
 
999
 
 
1000
      if (not opt_protocol.compare("mysql"))
 
1001
        use_drizzle_protocol=false;
 
1002
      else if (not opt_protocol.compare("drizzle"))
 
1003
        use_drizzle_protocol=true;
 
1004
      else
 
1005
      {
 
1006
        cout << _("Error: Unknown protocol") << " '" << opt_protocol << "'" << endl;
 
1007
        exit(-1);
 
1008
      }
 
1009
    }
995
1010
    if (vm.count("port")) 
996
1011
    {
997
1012
      temp_drizzle_port= vm["port"].as<uint32_t>();
2968
2983
    usleep(random()%opt_delayed_start);
2969
2984
 
2970
2985
  if ((drizzle= drizzle_create(NULL)) == NULL ||
2971
 
      drizzle_con_add_tcp(drizzle, con, host.c_str(), opt_drizzle_port, user.c_str(),
2972
 
                          opt_password.c_str(),
2973
 
                          connect_to_schema ? create_schema_string.c_str() : NULL,
2974
 
                          opt_mysql ? DRIZZLE_CON_MYSQL : DRIZZLE_CON_NONE) == NULL)
 
2986
      drizzle_con_add_tcp(drizzle, con, host.c_str(), opt_drizzle_port,
 
2987
        user.c_str(),
 
2988
        opt_password.c_str(),
 
2989
        connect_to_schema ? create_schema_string.c_str() : NULL,
 
2990
        use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL) == NULL)
2975
2991
  {
2976
2992
    fprintf(stderr,"%s: Error creating drizzle object\n", internal::my_progname);
2977
2993
    exit(1);