81
81
bool verbose= false;
82
82
static bool use_drizzle_protocol= false;
83
static bool quick= true;
84
static bool ignore_errors= false;
85
static bool flush_logs= false;
86
static bool opt_keywords= false;
87
static bool opt_compress= false;
88
static bool opt_delayed= false;
83
bool ignore_errors= false;
84
bool opt_compress= false;
89
85
static bool create_options= true;
90
86
static bool opt_quoted= false;
91
87
bool opt_databases= false;
92
88
bool opt_alldbs= false;
93
89
static bool opt_lock_all_tables= false;
94
static bool opt_set_charset= false;
95
90
static bool opt_dump_date= true;
96
static bool opt_autocommit= false;
91
bool opt_autocommit= false;
97
92
static bool opt_single_transaction= false;
98
93
static bool opt_comments;
99
94
static bool opt_compact;
100
static bool opt_order_by_primary=false;
101
95
bool opt_ignore= false;
102
static bool opt_complete_insert= false;
103
static bool opt_drop_database;
104
static bool opt_alltspcs= false;
96
bool opt_drop_database;
105
97
bool opt_no_create_info;
106
98
bool opt_no_data= false;
107
99
bool opt_create_db= false;
197
186
cout << "SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;"
198
187
<< endl << "SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;" << endl;
201
cout << "SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION;" << endl;
204
191
void generate_dump_db(void)
206
193
std::vector<DrizzleDumpDatabase*>::iterator i;
207
194
DrizzleStringBuf sbuf(1024);
208
destination_connection= new DrizzleDumpConnection(opt_destination_host,
209
opt_destination_port, opt_destination_user, opt_destination_password,
197
destination_connection= new DrizzleDumpConnection(opt_destination_host,
198
opt_destination_port, opt_destination_user, opt_destination_password,
203
cerr << "Could not connect to destination database server" << endl;
204
maybe_exit(EX_DRIZZLEERR);
211
206
sbuf.setConnection(destination_connection);
212
207
std::ostream sout(&sbuf);
214
sout << "SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION;" << endl;
216
209
if (path.empty())
484
465
commandline_options.add_options()
485
466
("all-databases,A", po::value<bool>(&opt_alldbs)->default_value(false)->zero_tokens(),
486
467
N_("Dump all the databases. This will be same as --databases with all databases selected."))
487
("all-tablespaces,Y", po::value<bool>(&opt_alltspcs)->default_value(false)->zero_tokens(),
488
N_("Dump all the tablespaces."))
489
("complete-insert,c", po::value<bool>(&opt_complete_insert)->default_value(false)->zero_tokens(),
490
N_("Use complete insert statements."))
491
468
("compress,C", po::value<bool>(&opt_compress)->default_value(false)->zero_tokens(),
492
469
N_("Use compression in server/client protocol."))
493
("flush-logs,F", po::value<bool>(&flush_logs)->default_value(false)->zero_tokens(),
494
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"))
495
470
("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
496
471
N_("Continue even if we get an sql-error."))
497
472
("help,?", N_("Display this help message and exit."))
498
473
("lock-all-tables,x", po::value<bool>(&opt_lock_all_tables)->default_value(false)->zero_tokens(),
499
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 and --lock-tables off."))
500
("order-by-primary", po::value<bool>(&opt_order_by_primary)->default_value(false)->zero_tokens(),
501
N_("Sorts each table's rows by primary key, or first unique key, if such a key exists. Useful when dumping a MyISAM table to be loaded into an InnoDB table, but will make the dump itself take considerably longer."))
474
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."))
502
475
("single-transaction", po::value<bool>(&opt_single_transaction)->default_value(false)->zero_tokens(),
503
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. Option automatically turns off --lock-tables."))
504
("opt", N_("Same as --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys. Enabled by default, disable with --skip-opt."))
476
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."))
506
N_("Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys."))
478
N_("Disable --opt. Disables --add-drop-table, --add-locks, --create-options, ---extended-insert and --disable-keys."))
507
479
("tables", N_("Overrides option --databases (-B)."))
508
480
("show-progress-size", po::value<uint32_t>(&show_progress_size)->default_value(10000),
509
481
N_("Number of rows before each output progress report (requires --verbose)."))
522
494
("add-drop-database", po::value<bool>(&opt_drop_database)->default_value(false)->zero_tokens(),
523
495
N_("Add a 'DROP DATABASE' before each create."))
524
496
("skip-drop-table", N_("Do not add a 'drop table' before each create."))
525
("allow-keywords", po::value<bool>(&opt_keywords)->default_value(false)->zero_tokens(),
526
N_("Allow creation of column names that are keywords."))
527
497
("compact", po::value<bool>(&opt_compact)->default_value(false)->zero_tokens(),
528
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 --skip-add-locks"))
498
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"))
529
499
("databases,B", po::value<bool>(&opt_databases)->default_value(false)->zero_tokens(),
530
500
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."))
531
("delayed-insert", po::value<bool>(&opt_delayed)->default_value(false)->zero_tokens(),
532
N_("Insert rows with INSERT DELAYED;"))
533
501
("skip-disable-keys,K",
534
502
N_("'ALTER TABLE tb_name DISABLE KEYS; and 'ALTER TABLE tb_name ENABLE KEYS; will not be put in the output."))
535
503
("ignore-table", po::value<string>(),
536
504
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"))
537
505
("insert-ignore", po::value<bool>(&opt_ignore)->default_value(false)->zero_tokens(),
538
506
N_("Insert rows with INSERT IGNORE."))
539
("lines-terminated-by", po::value<string>(&lines_terminated)->default_value(""),
540
N_("Lines in the i.file are terminated by ..."))
541
507
("no-autocommit", po::value<bool>(&opt_autocommit)->default_value(false)->zero_tokens(),
542
N_("Wrap tables with autocommit/commit statements."))
508
N_("Wrap a table's data in START TRANSACTION/COMMIT statements."))
543
509
("no-create-db,n", po::value<bool>(&opt_create_db)->default_value(false)->zero_tokens(),
544
510
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."))
545
("no-create-info,t", po::value<bool>(&opt_no_create_info)->default_value(false)->zero_tokens(),
546
N_("Don't write table creation info."))
547
511
("no-data,d", po::value<bool>(&opt_no_data)->default_value(false)->zero_tokens(),
548
512
N_("No row information."))
549
("no-set-names,N", N_("Deprecated. Use --skip-set-charset instead."))
550
("set-charset", po::value<bool>(&opt_set_charset)->default_value(false)->zero_tokens(),
551
N_("Enable set-name"))
552
("slow", N_("Buffer query instead of dumping directly to stdout."))
553
513
("replace", po::value<bool>(&opt_replace_into)->default_value(false)->zero_tokens(),
554
514
N_("Use REPLACE INTO instead of INSERT INTO."))
555
("result-file,r", po::value<string>(),
556
N_("Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed)."))
557
515
("destination-type", po::value<string>()->default_value("stdout"),
558
516
N_("Where to send output to (stdout|database"))
559
517
("destination-host", po::value<string>(&opt_destination_host)->default_value("localhost"),
560
N_("Hostname for destination db server (requires --destination=database)"))
518
N_("Hostname for destination db server (requires --destination-type=database)"))
561
519
("destination-port", po::value<uint16_t>(&opt_destination_port)->default_value(3306),
562
N_("Port number for destination db server (requires --destination=database)"))
520
N_("Port number for destination db server (requires --destination-type=database)"))
563
521
("destination-user", po::value<string>(&opt_destination_user),
564
N_("User name for destination db server (resquires --destination=database)"))
522
N_("User name for destination db server (resquires --destination-type=database)"))
565
523
("destination-password", po::value<string>(&opt_destination_password),
566
N_("Password for destination db server (requires --destination=database)"))
524
N_("Password for destination db server (requires --destination-type=database)"))
567
525
("destination-database", po::value<string>(&opt_destination_database),
568
N_("The database in the destination db server (requires --destination=database, not for use with --all-databases)"))
526
N_("The database in the destination db server (requires --destination-type=database, not for use with --all-databases)"))
571
529
po::options_description client_options(N_("Options specific to the client"));