~clint-fewbar/drizzle/regex-policy-cache-limiter

« back to all changes in this revision

Viewing changes to client/drizzleimport.cc

  • Committer: Clint Byrum
  • Date: 2012-03-15 18:05:43 UTC
  • mfrom: (2224.1.302 workspace)
  • Revision ID: clint@ubuntu.com-20120315180543-9jxxm4q10k3np2ws
merging with latest trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <boost/program_options.hpp>
28
28
#include <pthread.h>
29
29
 
 
30
#include <drizzled/definitions.h>
 
31
#include <drizzled/internal/my_sys.h>
30
32
/* Added this for string translation. */
31
33
#include <drizzled/gettext.h>
32
34
#include <drizzled/configmake.h>
33
35
 
 
36
#include "user_detect.h"
 
37
 
34
38
namespace po= boost::program_options;
35
39
using namespace std;
36
40
using namespace drizzled;
197
201
  drizzle_return_t ret;
198
202
 
199
203
  if (verbose)
 
204
  {
200
205
    fprintf(stdout, "Connecting to %s, using protocol %s...\n", ! host.empty() ? host.c_str() : "localhost", opt_protocol.c_str());
201
 
  if (!(drizzle= drizzle_create(NULL)))
 
206
  }
 
207
 
 
208
  if ((drizzle= drizzle_create()) == NULL)
 
209
  {
202
210
    return 0;
203
 
  if (!(con= drizzle_con_add_tcp(drizzle,NULL,(char *)host.c_str(),opt_drizzle_port,(char *)user.c_str(),(char *)passwd.c_str(),
204
 
                                 (char *)database.c_str(), use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL)))
 
211
  }
 
212
 
 
213
  if (!(con= drizzle_con_add_tcp(drizzle,
 
214
                                 host.c_str(), opt_drizzle_port,
 
215
                                 user.c_str(), passwd.c_str(),
 
216
                                 database.c_str(),
 
217
                                 use_drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL)))
205
218
  {
206
219
    return 0;
207
220
  }
350
363
{
351
364
try
352
365
{
353
 
  int error=0;
354
 
 
355
366
  po::options_description commandline_options("Options used only in command line");
356
367
  commandline_options.add_options()
357
368
 
397
408
  "Load files in parallel. The argument is the number of threads to use for loading data (default is 4.")
398
409
  ;
399
410
 
400
 
  const char* unix_user= getlogin();
401
 
 
402
411
  po::options_description client_options("Options specific to the client");
403
412
  client_options.add_options()
404
413
  ("host,h", po::value<string>(&current_host)->default_value("localhost"),
409
418
  "Port number to use for connection") 
410
419
  ("protocol", po::value<string>(&opt_protocol)->default_value("mysql"),
411
420
  "The protocol of connection (mysql or drizzle).")
412
 
  ("user,u", po::value<string>(&current_user)->default_value((unix_user ? unix_user : "")),
 
421
  ("user,u", po::value<string>(&current_user)->default_value(UserDetect().getUser()),
413
422
  "User for login if not current user.")
414
423
  ;
415
424
 
461
470
  po::notify(vm);
462
471
  if (vm.count("protocol"))
463
472
  {
464
 
    std::transform(opt_protocol.begin(), opt_protocol.end(),
465
 
      opt_protocol.begin(), ::tolower);
466
 
 
 
473
    boost::to_lower(opt_protocol);
467
474
    if (not opt_protocol.compare("mysql"))
468
475
      use_drizzle_protocol=false;
469
476
    else if (not opt_protocol.compare("drizzle"))
601
608
    }
602
609
 
603
610
    for (; *argv != NULL; argv++)
604
 
      if ((error= write_to_table(*argv, con)))
 
611
      if (int error= write_to_table(*argv, con))
605
612
        if (exitcode == 0)
606
613
          exitcode= error;
607
614
    db_disconnect(current_host, con);