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 */
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
bool ignore_errors= false;
83
static bool quick= true;
84
static bool ignore_errors= false;
86
85
static bool flush_logs= false;
86
static bool opt_keywords= false;
87
static bool opt_compress= false;
88
static bool opt_delayed= false;
87
89
static bool create_options= true;
88
90
static bool opt_quoted= false;
89
91
bool opt_databases= false;
90
92
bool opt_alldbs= false;
91
93
static bool opt_lock_all_tables= false;
94
static bool opt_set_charset= false;
92
95
static bool opt_dump_date= true;
93
bool opt_autocommit= false;
96
static bool opt_autocommit= false;
94
97
static bool opt_single_transaction= false;
95
98
static bool opt_comments;
96
99
static bool opt_compact;
100
static bool opt_order_by_primary=false;
97
101
bool opt_ignore= false;
98
bool opt_drop_database;
102
static bool opt_complete_insert= false;
103
static bool opt_drop_database;
104
static bool opt_alltspcs= false;
99
105
bool opt_no_create_info;
100
106
bool opt_no_data= false;
101
107
bool opt_create_db= false;
188
197
cout << "SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;"
189
198
<< endl << "SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;" << endl;
201
cout << "SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION;" << endl;
193
204
void generate_dump_db(void)
195
206
std::vector<DrizzleDumpDatabase*>::iterator i;
196
207
DrizzleStringBuf sbuf(1024);
199
destination_connection= new DrizzleDumpConnection(opt_destination_host,
200
opt_destination_port, opt_destination_user, opt_destination_password,
203
catch (std::exception&)
205
cerr << "Could not connect to destination database server" << endl;
206
maybe_exit(EX_DRIZZLEERR);
208
destination_connection= new DrizzleDumpConnection(opt_destination_host,
209
opt_destination_port, opt_destination_user, opt_destination_password,
208
211
sbuf.setConnection(destination_connection);
209
212
std::ostream sout(&sbuf);
210
sout.exceptions(ios_base::badbit);
214
sout << "SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION;" << endl;
212
216
if (path.empty())
480
488
N_("Dump all the tablespaces."))
481
489
("complete-insert,c", po::value<bool>(&opt_complete_insert)->default_value(false)->zero_tokens(),
482
490
N_("Use complete insert statements."))
491
("compress,C", po::value<bool>(&opt_compress)->default_value(false)->zero_tokens(),
492
N_("Use compression in server/client protocol."))
483
493
("flush-logs,F", po::value<bool>(&flush_logs)->default_value(false)->zero_tokens(),
484
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"))
485
495
("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
486
496
N_("Continue even if we get an sql-error."))
487
497
("help,?", N_("Display this help message and exit."))
488
498
("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."))
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."))
490
502
("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."))
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."))
493
N_("Disable --opt. Disables --add-drop-table, --add-locks, --create-options, ---extended-insert and --disable-keys."))
506
N_("Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys."))
494
507
("tables", N_("Overrides option --databases (-B)."))
495
508
("show-progress-size", po::value<uint32_t>(&show_progress_size)->default_value(10000),
496
509
N_("Number of rows before each output progress report (requires --verbose)."))
509
522
("add-drop-database", po::value<bool>(&opt_drop_database)->default_value(false)->zero_tokens(),
510
523
N_("Add a 'DROP DATABASE' before each create."))
511
524
("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."))
512
527
("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"))
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"))
514
529
("databases,B", po::value<bool>(&opt_databases)->default_value(false)->zero_tokens(),
515
530
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;"))
516
533
("skip-disable-keys,K",
517
534
N_("'ALTER TABLE tb_name DISABLE KEYS; and 'ALTER TABLE tb_name ENABLE KEYS; will not be put in the output."))
518
535
("ignore-table", po::value<string>(),
519
536
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"))
520
537
("insert-ignore", po::value<bool>(&opt_ignore)->default_value(false)->zero_tokens(),
521
538
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 ..."))
522
541
("no-autocommit", po::value<bool>(&opt_autocommit)->default_value(false)->zero_tokens(),
523
N_("Wrap a table's data in START TRANSACTION/COMMIT statements."))
542
N_("Wrap tables with autocommit/commit statements."))
524
543
("no-create-db,n", po::value<bool>(&opt_create_db)->default_value(false)->zero_tokens(),
525
544
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."))
526
547
("no-data,d", po::value<bool>(&opt_no_data)->default_value(false)->zero_tokens(),
527
548
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."))
528
553
("replace", po::value<bool>(&opt_replace_into)->default_value(false)->zero_tokens(),
529
554
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)."))
530
557
("destination-type", po::value<string>()->default_value("stdout"),
531
558
N_("Where to send output to (stdout|database"))
532
559
("destination-host", po::value<string>(&opt_destination_host)->default_value("localhost"),
533
N_("Hostname for destination db server (requires --destination-type=database)"))
534
("destination-port", po::value<uint16_t>(&opt_destination_port)->default_value(4427),
535
N_("Port number for destination db server (requires --destination-type=database)"))
560
N_("Hostname for destination db server (requires --destination=database)"))
561
("destination-port", po::value<uint16_t>(&opt_destination_port)->default_value(3306),
562
N_("Port number for destination db server (requires --destination=database)"))
536
563
("destination-user", po::value<string>(&opt_destination_user),
537
N_("User name for destination db server (resquires --destination-type=database)"))
564
N_("User name for destination db server (resquires --destination=database)"))
538
565
("destination-password", po::value<string>(&opt_destination_password),
539
N_("Password for destination db server (requires --destination-type=database)"))
566
N_("Password for destination db server (requires --destination=database)"))
540
567
("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)"))
568
N_("The database in the destination db server (requires --destination=database, not for use with --all-databases)"))
544
571
po::options_description client_options(N_("Options specific to the client"));