~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzletest.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
113
114
static bool abort_on_error= true;
114
115
static bool server_initialized= false;
115
116
static bool is_windows= false;
116
 
static bool opt_mysql= false;
 
117
static bool use_drizzle_protocol= false;
117
118
static char line_buffer[MAX_DELIMITER_LENGTH], *line_buffer_pos= line_buffer;
118
119
 
119
120
std::string opt_basedir,
126
127
  password,
127
128
  opt_password,
128
129
  result_file_name,
129
 
  opt_user;
 
130
  opt_user,
 
131
  opt_protocol;
130
132
 
131
133
static uint32_t start_lineno= 0; /* Start line of current command */
132
134
 
3937
3939
    die("Failed on drizzle_create()");
3938
3940
  if (!drizzle_con_create(con_slot->drizzle, &con_slot->con))
3939
3941
    die("Failed on drizzle_con_create()");
3940
 
  if (opt_mysql)
3941
 
    drizzle_con_add_options(&con_slot->con, DRIZZLE_CON_MYSQL);
 
3942
  drizzle_con_add_options(&con_slot->con, use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
3942
3943
 
3943
3944
  /* Use default db name */
3944
3945
  if (ds_database.length() == 0)
5452
5453
 
5453
5454
  ("host,h", po::value<string>(&opt_host)->default_value("localhost"),
5454
5455
  "Connect to host.")
5455
 
  ("mysql,m", po::value<bool>(&opt_mysql)->default_value(true)->zero_tokens(),
5456
 
  N_("Use MySQL Protocol."))
5457
5456
  ("password,P", po::value<string>(&password)->default_value("PASSWORD_SENTINEL"),
5458
5457
  "Password to use when connecting to server.")
5459
5458
  ("port,p", po::value<uint32_t>(&opt_port)->default_value(0),
5460
5459
  "Port number to use for connection or 0 for default")
5461
 
  ("protocol", po::value<string>(),
5462
 
  "The protocol of connection (tcp,socket,pipe,memory).")
 
5460
  ("protocol", po::value<string>(&opt_protocol),
 
5461
  "The protocol of connection (mysql or drizzle).")
5463
5462
  ("user,u", po::value<string>(&opt_user)->default_value(""),
5464
5463
  "User for login.")
5465
5464
  ;
5586
5585
    unlink(timer_file);       /* Ignore error, may not exist */
5587
5586
  }
5588
5587
 
 
5588
  if (vm.count("protocol"))
 
5589
  {
 
5590
    std::transform(opt_protocol.begin(), opt_protocol.end(),
 
5591
      opt_protocol.begin(), ::tolower);
 
5592
 
 
5593
    if (not opt_protocol.compare("mysql"))
 
5594
      use_drizzle_protocol=false;
 
5595
    else if (not opt_protocol.compare("drizzle"))
 
5596
      use_drizzle_protocol=true;
 
5597
    else
 
5598
    {
 
5599
      cout << _("Error: Unknown protocol") << " '" << opt_protocol << "'" << endl;
 
5600
      exit(-1);
 
5601
    }
 
5602
  }
 
5603
 
5589
5604
  if (vm.count("port"))
5590
5605
  {
5591
5606
    /* If the port number is > 65535 it is not a valid port
5660
5675
    die("Failed in drizzle_create()");
5661
5676
  if (!( drizzle_con_create(cur_con->drizzle, &cur_con->con)))
5662
5677
    die("Failed in drizzle_con_create()");
5663
 
  if (opt_mysql)
5664
 
    drizzle_con_add_options(&cur_con->con, DRIZZLE_CON_MYSQL);
 
5678
  drizzle_con_add_options(&cur_con->con, use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
5665
5679
 
5666
5680
  if (!(cur_con->name = strdup("default")))
5667
5681
    die("Out of memory");