~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

  • Committer: Monty Taylor
  • Date: 2011-02-14 20:25:28 UTC
  • mto: (2168.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2169.
  • Revision ID: mordred@inaugust.com-20110214202528-wfb2a5h51ntbl5ct
Fix daemonize c++ patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
bool extended_insert= true;
104
104
bool opt_replace_into= false;
105
105
bool opt_drop= true; 
 
106
bool opt_data_is_mangled= false;
106
107
uint32_t show_progress_size= 0;
107
108
static string insert_pat;
108
109
static uint32_t opt_drizzle_port= 0;
139
140
  opt_protocol,
140
141
  where;
141
142
 
142
 
//static const CHARSET_INFO *charset_info= &my_charset_utf8_general_ci;
143
 
 
144
143
boost::unordered_set<string> ignore_table;
145
144
 
146
145
void maybe_exit(int error);
472
471
{
473
472
  int exit_code;
474
473
 
475
 
  po::options_description commandline_options(N_("Options used only in command line"));
 
474
#if defined(ENABLE_NLS)
 
475
# if defined(HAVE_LOCALE_H)
 
476
  setlocale(LC_ALL, "");
 
477
# endif
 
478
  bindtextdomain("drizzle7", LOCALEDIR);
 
479
  textdomain("drizzle7");
 
480
#endif
 
481
 
 
482
  po::options_description commandline_options(_("Options used only in command line"));
476
483
  commandline_options.add_options()
477
484
  ("all-databases,A", po::value<bool>(&opt_alldbs)->default_value(false)->zero_tokens(),
478
 
  N_("Dump all the databases. This will be same as --databases with all databases selected."))
 
485
  _("Dump all the databases. This will be same as --databases with all databases selected."))
479
486
  ("all-tablespaces,Y", po::value<bool>(&opt_alltspcs)->default_value(false)->zero_tokens(),
480
 
  N_("Dump all the tablespaces."))
 
487
  _("Dump all the tablespaces."))
481
488
  ("complete-insert,c", po::value<bool>(&opt_complete_insert)->default_value(false)->zero_tokens(),
482
 
  N_("Use complete insert statements."))
 
489
  _("Use complete insert statements."))
483
490
  ("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"))
 
491
  _("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"))
485
492
  ("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
486
 
  N_("Continue even if we get an sql-error."))
487
 
  ("help,?", N_("Display this help message and exit."))
 
493
  _("Continue even if we get an sql-error."))
 
494
  ("help,?", _("Display this help message and exit."))
488
495
  ("lock-all-tables,x", po::value<bool>(&opt_lock_all_tables)->default_value(false)->zero_tokens(),
489
 
  N_("Locks all tables across all databases. This is achieved by taking a global read lock for the duration of the whole dump. Automatically turns --single-transaction off."))
 
496
  _("Locks all tables across all databases. This is achieved by taking a global read lock for the duration of the whole dump. Automatically turns --single-transaction off."))
490
497
  ("single-transaction", po::value<bool>(&opt_single_transaction)->default_value(false)->zero_tokens(),
491
 
  N_("Creates a consistent snapshot by dumping all tables in a single transaction. Works ONLY for tables stored in storage engines which support multiversioning (currently only InnoDB does); the dump is NOT guaranteed to be consistent for other storage engines. While a --single-transaction dump is in process, to ensure a valid dump file (correct table contents), no other connection should use the following statements: ALTER TABLE, DROP TABLE, RENAME TABLE, TRUNCATE TABLE, as consistent snapshot is not isolated from them."))
 
498
  _("Creates a consistent snapshot by dumping all tables in a single transaction. Works ONLY for tables stored in storage engines which support multiversioning (currently only InnoDB does); the dump is NOT guaranteed to be consistent for other storage engines. While a --single-transaction dump is in process, to ensure a valid dump file (correct table contents), no other connection should use the following statements: ALTER TABLE, DROP TABLE, RENAME TABLE, TRUNCATE TABLE, as consistent snapshot is not isolated from them."))
492
499
  ("skip-opt", 
493
 
  N_("Disable --opt. Disables --add-drop-table, --add-locks, --create-options, ---extended-insert and --disable-keys."))    
494
 
  ("tables", N_("Overrides option --databases (-B)."))
 
500
  _("Disable --opt. Disables --add-drop-table, --add-locks, --create-options, ---extended-insert and --disable-keys."))    
 
501
  ("tables", _("Overrides option --databases (-B)."))
495
502
  ("show-progress-size", po::value<uint32_t>(&show_progress_size)->default_value(10000),
496
 
  N_("Number of rows before each output progress report (requires --verbose)."))
 
503
  _("Number of rows before each output progress report (requires --verbose)."))
497
504
  ("verbose,v", po::value<bool>(&verbose)->default_value(false)->zero_tokens(),
498
 
  N_("Print info about the various stages."))
499
 
  ("version,V", N_("Output version information and exit."))
500
 
  ("skip-comments", N_("Turn off Comments"))
501
 
  ("skip-create", N_("Turn off create-options"))
502
 
  ("skip-extended-insert", N_("Turn off extended-insert"))
503
 
  ("skip-dump-date",N_( "Turn off dump date at the end of the output"))
504
 
  ("no-defaults", N_("Do not read from the configuration files"))
 
505
  _("Print info about the various stages."))
 
506
  ("version,V", _("Output version information and exit."))
 
507
  ("skip-comments", _("Turn off Comments"))
 
508
  ("skip-create", _("Turn off create-options"))
 
509
  ("skip-extended-insert", _("Turn off extended-insert"))
 
510
  ("skip-dump-date", _( "Turn off dump date at the end of the output"))
 
511
  ("no-defaults", _("Do not read from the configuration files"))
505
512
  ;
506
513
 
507
 
  po::options_description dump_options(N_("Options specific to the drizzle client"));
 
514
  po::options_description dump_options(_("Options specific to the drizzle client"));
508
515
  dump_options.add_options()
509
516
  ("add-drop-database", po::value<bool>(&opt_drop_database)->default_value(false)->zero_tokens(),
510
 
  N_("Add a 'DROP DATABASE' before each create."))
511
 
  ("skip-drop-table", N_("Do not add a 'drop table' before each create."))
 
517
  _("Add a 'DROP DATABASE' before each create."))
 
518
  ("skip-drop-table", _("Do not add a 'drop table' before each create."))
512
519
  ("compact", po::value<bool>(&opt_compact)->default_value(false)->zero_tokens(),
513
 
  N_("Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs.  Enables options --skip-add-drop-table --no-set-names --skip-disable-keys"))
 
520
  _("Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs.  Enables options --skip-add-drop-table --no-set-names --skip-disable-keys"))
514
521
  ("databases,B", po::value<bool>(&opt_databases)->default_value(false)->zero_tokens(),
515
 
  N_("To dump several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames. 'USE db_name;' will be included in the output."))
 
522
  _("To dump several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames. 'USE db_name;' will be included in the output."))
516
523
  ("skip-disable-keys,K",
517
 
  N_("'ALTER TABLE tb_name DISABLE KEYS; and 'ALTER TABLE tb_name ENABLE KEYS; will not be put in the output."))
 
524
  _("'ALTER TABLE tb_name DISABLE KEYS;' and 'ALTER TABLE tb_name ENABLE KEYS;' will not be put in the output."))
518
525
  ("ignore-table", po::value<string>(),
519
 
  N_("Do not dump the specified table. To specify more than one table to ignore, use the directive multiple times, once for each table.  Each table must be specified with both database and table names, e.g. --ignore-table=database.table"))
 
526
  _("Do not dump the specified table. To specify more than one table to ignore, use the directive multiple times, once for each table.  Each table must be specified with both database and table names, e.g. --ignore-table=database.table"))
520
527
  ("insert-ignore", po::value<bool>(&opt_ignore)->default_value(false)->zero_tokens(),
521
 
  N_("Insert rows with INSERT IGNORE."))
 
528
  _("Insert rows with INSERT IGNORE."))
522
529
  ("no-autocommit", po::value<bool>(&opt_autocommit)->default_value(false)->zero_tokens(),
523
 
  N_("Wrap a table's data in START TRANSACTION/COMMIT statements."))
 
530
  _("Wrap a table's data in START TRANSACTION/COMMIT statements."))
524
531
  ("no-create-db,n", po::value<bool>(&opt_create_db)->default_value(false)->zero_tokens(),
525
 
  N_("'CREATE DATABASE IF NOT EXISTS db_name;' will not be put in the output. The above line will be added otherwise, if --databases or --all-databases option was given."))
 
532
  _("'CREATE DATABASE IF NOT EXISTS db_name;' will not be put in the output. The above line will be added otherwise, if --databases or --all-databases option was given."))
526
533
  ("no-data,d", po::value<bool>(&opt_no_data)->default_value(false)->zero_tokens(),
527
 
  N_("No row information."))
 
534
  _("No row information."))
528
535
  ("replace", po::value<bool>(&opt_replace_into)->default_value(false)->zero_tokens(),
529
 
  N_("Use REPLACE INTO instead of INSERT INTO."))
 
536
  _("Use REPLACE INTO instead of INSERT INTO."))
530
537
  ("destination-type", po::value<string>()->default_value("stdout"),
531
 
  N_("Where to send output to (stdout|database"))
 
538
  _("Where to send output to (stdout|database"))
532
539
  ("destination-host", po::value<string>(&opt_destination_host)->default_value("localhost"),
533
 
  N_("Hostname for destination db server (requires --destination-type=database)"))
 
540
  _("Hostname for destination db server (requires --destination-type=database)"))
534
541
  ("destination-port", po::value<uint16_t>(&opt_destination_port)->default_value(4427),
535
 
  N_("Port number for destination db server (requires --destination-type=database)"))
 
542
  _("Port number for destination db server (requires --destination-type=database)"))
536
543
  ("destination-user", po::value<string>(&opt_destination_user),
537
 
  N_("User name for destination db server (resquires --destination-type=database)"))
 
544
  _("User name for destination db server (resquires --destination-type=database)"))
538
545
  ("destination-password", po::value<string>(&opt_destination_password),
539
 
  N_("Password for destination db server (requires --destination-type=database)"))
 
546
  _("Password for destination db server (requires --destination-type=database)"))
540
547
  ("destination-database", po::value<string>(&opt_destination_database),
541
 
  N_("The database in the destination db server (requires --destination-type=database, not for use with --all-databases)"))
 
548
  _("The database in the destination db server (requires --destination-type=database, not for use with --all-databases)"))
 
549
  ("my-data-is-mangled", po::value<bool>(&opt_data_is_mangled)->default_value(false)->zero_tokens(),
 
550
  _("Do not make a UTF8 connection to MySQL, use if you have UTF8 data in a non-UTF8 table"))
542
551
  ;
543
552
 
544
 
  po::options_description client_options(N_("Options specific to the client"));
 
553
  po::options_description client_options(_("Options specific to the client"));
545
554
  client_options.add_options()
546
555
  ("host,h", po::value<string>(&current_host)->default_value("localhost"),
547
 
  N_("Connect to host."))
 
556
  _("Connect to host."))
548
557
  ("password,P", po::value<string>(&password)->default_value(PASSWORD_SENTINEL),
549
 
  N_("Password to use when connecting to server. If password is not given it's solicited on the tty."))
 
558
  _("Password to use when connecting to server. If password is not given it's solicited on the tty."))
550
559
  ("port,p", po::value<uint32_t>(&opt_drizzle_port)->default_value(0),
551
 
  N_("Port number to use for connection."))
 
560
  _("Port number to use for connection."))
552
561
  ("user,u", po::value<string>(&current_user)->default_value(""),
553
 
  N_("User for login if not current user."))
 
562
  _("User for login if not current user."))
554
563
  ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
555
 
  N_("The protocol of connection (mysql or drizzle)."))
 
564
  _("The protocol of connection (mysql or drizzle)."))
556
565
  ;
557
566
 
558
 
  po::options_description hidden_options(N_("Hidden Options"));
 
567
  po::options_description hidden_options(_("Hidden Options"));
559
568
  hidden_options.add_options()
560
 
  ("database-used", po::value<vector<string> >(), N_("Used to select the database"))
561
 
  ("Table-used", po::value<vector<string> >(), N_("Used to select the tables"))
 
569
  ("database-used", po::value<vector<string> >(), _("Used to select the database"))
 
570
  ("Table-used", po::value<vector<string> >(), _("Used to select the tables"))
562
571
  ;
563
572
 
564
 
  po::options_description all_options(N_("Allowed Options + Hidden Options"));
 
573
  po::options_description all_options(_("Allowed Options + Hidden Options"));
565
574
  all_options.add(commandline_options).add(dump_options).add(client_options).add(hidden_options);
566
575
 
567
 
  po::options_description long_options(N_("Allowed Options"));
 
576
  po::options_description long_options(_("Allowed Options"));
568
577
  long_options.add(commandline_options).add(dump_options).add(client_options);
569
578
 
570
579
  std::string system_config_dir_dump(SYSCONFDIR); 
759
768
    maybe_exit(EX_DRIZZLEERR);
760
769
  }
761
770
 
762
 
  if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
 
771
  if ((db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND) and (not opt_data_is_mangled))
763
772
    db_connection->queryNoResult("SET NAMES 'utf8'");
764
773
 
765
774
  if (vm.count("destination-type"))