~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

  • Committer: lbieber
  • Date: 2010-10-05 21:14:30 UTC
  • mfrom: (1775.5.2 bug621331)
  • mto: This revision was merged to the branch mainline in revision 1814.
  • Revision ID: lbieber@orisndriz08-20101005211430-xmy19fcls25swctl
Merge Billy - fix bug 621331 - Replace use of stringstream with boost::lexical_cast

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
#define IGNORE_DATA 0x01 /* don't dump data for this table */
79
79
#define IGNORE_INSERT_DELAYED 0x02 /* table doesn't support INSERT DELAYED */
80
80
 
81
 
bool opt_alltspcs= false;
82
 
bool opt_complete_insert= false;
83
81
bool  verbose= false;
84
82
static bool use_drizzle_protocol= false;
85
83
bool ignore_errors= false;
86
 
static bool flush_logs= false;
 
84
bool opt_compress= false;
87
85
static bool create_options= true; 
88
86
static bool opt_quoted= false;
89
87
bool opt_databases= false; 
200
198
      opt_destination_port, opt_destination_user, opt_destination_password,
201
199
      false);
202
200
  }
203
 
  catch (std::exception&)
 
201
  catch (...)
204
202
  {
205
203
    cerr << "Could not connect to destination database server" << endl;
206
204
    maybe_exit(EX_DRIZZLEERR);
207
205
  }
208
206
  sbuf.setConnection(destination_connection);
209
207
  std::ostream sout(&sbuf);
210
 
  sout.exceptions(ios_base::badbit);
211
208
 
212
209
  if (path.empty())
213
210
  {
220
217
 
221
218
  for (i= database_store.begin(); i != database_store.end(); ++i)
222
219
  {
223
 
    try
224
 
    {
225
 
      DrizzleDumpDatabase *database= *i;
226
 
      sout << *database;
227
 
    }
228
 
    catch (std::exception&)
229
 
    {
230
 
      std::cout << _("Error inserting into destination database") << std::endl;
231
 
      if (not ignore_errors)
232
 
        maybe_exit(EX_DRIZZLEERR);
233
 
    }
 
220
    DrizzleDumpDatabase *database= *i;
 
221
    sout << *database;
234
222
  }
235
223
 
236
224
  if (path.empty())
357
345
  if (ignore_errors)
358
346
    return;
359
347
  delete db_connection;
360
 
  delete destination_connection;
 
348
  if (destination_connection)
 
349
    delete destination_connection;
361
350
  free_resources();
362
351
  exit(error);
363
352
}
476
465
  commandline_options.add_options()
477
466
  ("all-databases,A", po::value<bool>(&opt_alldbs)->default_value(false)->zero_tokens(),
478
467
  N_("Dump all the databases. This will be same as --databases with all databases selected."))
479
 
  ("all-tablespaces,Y", po::value<bool>(&opt_alltspcs)->default_value(false)->zero_tokens(),
480
 
  N_("Dump all the tablespaces."))
481
 
  ("complete-insert,c", po::value<bool>(&opt_complete_insert)->default_value(false)->zero_tokens(),
482
 
  N_("Use complete insert statements."))
483
 
  ("flush-logs,F", po::value<bool>(&flush_logs)->default_value(false)->zero_tokens(),
484
 
  N_("Flush logs file in server before starting dump. Note that if you dump many databases at once (using the option --databases= or --all-databases), the logs will be flushed for each database dumped. The exception is when using --lock-all-tables in this case the logs will be flushed only once, corresponding to the moment all tables are locked. So if you want your dump and the log flush to happen at the same exact moment you should use --lock-all-tables or --flush-logs"))
 
468
  ("compress,C", po::value<bool>(&opt_compress)->default_value(false)->zero_tokens(),
 
469
  N_("Use compression in server/client protocol."))
485
470
  ("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
486
471
  N_("Continue even if we get an sql-error."))
487
472
  ("help,?", N_("Display this help message and exit."))
531
516
  N_("Where to send output to (stdout|database"))
532
517
  ("destination-host", po::value<string>(&opt_destination_host)->default_value("localhost"),
533
518
  N_("Hostname for destination db server (requires --destination-type=database)"))
534
 
  ("destination-port", po::value<uint16_t>(&opt_destination_port)->default_value(4427),
 
519
  ("destination-port", po::value<uint16_t>(&opt_destination_port)->default_value(3306),
535
520
  N_("Port number for destination db server (requires --destination-type=database)"))
536
521
  ("destination-user", po::value<string>(&opt_destination_user),
537
522
  N_("User name for destination db server (resquires --destination-type=database)"))
575
560
 
576
561
  std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config"));
577
562
 
578
 
  if (user_config_dir.compare(0, 2, "~/") == 0)
579
 
  {
580
 
    char *homedir;
581
 
    homedir= getenv("HOME");
582
 
    if (homedir != NULL)
583
 
      user_config_dir.replace(0, 1, homedir);
584
 
  }
585
 
 
586
563
  po::positional_options_description p;
587
564
  p.add("database-used", 1);
588
565
  p.add("Table-used",-1);
754
731
    db_connection = new DrizzleDumpConnection(current_host, opt_drizzle_port,
755
732
      current_user, opt_password, use_drizzle_protocol);
756
733
  }
757
 
  catch (std::exception&)
 
734
  catch (...)
758
735
  {
759
736
    maybe_exit(EX_DRIZZLEERR);
760
737
  }
801
778
    dump_selected_tables(database_used, vm["Table-used"].as< vector<string> >());
802
779
  }
803
780
 
804
 
  if (vm.count("Table-used") and opt_databases)
 
781
  if (vm.count("Table-used") && opt_databases)
805
782
  {
 
783
/*
 
784
 * This is not valid!
806
785
    vector<string> database_used= vm["database-used"].as< vector<string> >();
807
786
    vector<string> table_used= vm["Table-used"].as< vector<string> >();
808
787
 
812
791
    {
813
792
      database_used.insert(database_used.end(), *it);
814
793
    }
815
 
 
816
794
    dump_databases(database_used);
817
 
    dump_all_tables();
 
795
    dump_tables();
 
796
*/
818
797
  }
819
 
 
 
798
  
820
799
  if (vm.count("database-used") && ! vm.count("Table-used"))
821
800
  {
822
801
    dump_databases(vm["database-used"].as< vector<string> >());
823
802
    dump_all_tables();
824
803
  }
825
 
 
826
804
  if (opt_destination == DESTINATION_STDOUT)
827
805
    generate_dump();
828
806
  else
844
822
  */
845
823
err:
846
824
  delete db_connection;
847
 
  delete destination_connection;
 
825
  if (destination_connection)
 
826
    delete destination_connection;
848
827
  if (path.empty())
849
828
    write_footer(md_result_file);
850
829
  free_resources();