81
81
bool verbose= false;
82
82
static bool use_drizzle_protocol= false;
83
static bool quick= true;
84
83
static bool ignore_errors= false;
85
static bool flush_logs= false;
86
static bool opt_compress= false;
87
static bool opt_delayed= false;
84
bool opt_compress= false;
88
85
static bool create_options= true;
89
86
static bool opt_quoted= false;
90
87
bool opt_databases= false;
91
88
bool opt_alldbs= false;
92
89
static bool opt_lock_all_tables= false;
93
static bool opt_set_charset= false;
94
90
static bool opt_dump_date= true;
95
static bool opt_autocommit= false;
91
bool opt_autocommit= false;
96
92
static bool opt_single_transaction= false;
97
93
static bool opt_compact;
98
94
bool opt_ignore= false;
99
95
static bool opt_complete_insert= false;
100
static bool opt_drop_database;
96
bool opt_drop_database;
101
97
bool opt_no_create_info;
102
98
bool opt_no_data= false;
103
99
bool opt_create_db= false;
106
102
bool opt_replace_into= false;
107
103
bool opt_drop= true;
108
104
uint32_t show_progress_size= 0;
109
//static uint64_t total_rows= 0;
110
105
static string insert_pat;
111
//static char *order_by= NULL;
112
106
static uint32_t opt_drizzle_port= 0;
113
107
static int first_error= 0;
114
108
static string extended_row;
171
165
void generate_dump(void)
173
167
std::vector<DrizzleDumpDatabase*>::iterator i;
175
cout << endl << "SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION;" << endl;
177
169
if (path.empty())
179
171
cout << endl << "SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;"
180
172
<< endl << "SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;" << endl;
176
cout << "SET AUTOCOMMIT=0;" << endl;
182
178
for (i= database_store.begin(); i != database_store.end(); ++i)
184
180
DrizzleDumpDatabase *database= *i;
212
204
sout << "SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;" << endl;
208
cout << "SET AUTOCOMMIT=0;" << endl;
215
210
for (i= database_store.begin(); i != database_store.end(); ++i)
217
212
DrizzleDumpDatabase *database= *i;
465
458
N_("Use complete insert statements."))
466
459
("compress,C", po::value<bool>(&opt_compress)->default_value(false)->zero_tokens(),
467
460
N_("Use compression in server/client protocol."))
468
("flush-logs,F", po::value<bool>(&flush_logs)->default_value(false)->zero_tokens(),
469
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"))
470
461
("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
471
462
N_("Continue even if we get an sql-error."))
472
463
("help,?", N_("Display this help message and exit."))
475
466
("single-transaction", po::value<bool>(&opt_single_transaction)->default_value(false)->zero_tokens(),
476
467
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."))
478
N_("Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys."))
469
N_("Disable --opt. Disables --add-drop-table, --add-locks, --create-options, ---extended-insert, --lock-tables, and --disable-keys."))
479
470
("tables", N_("Overrides option --databases (-B)."))
480
471
("show-progress-size", po::value<uint32_t>(&show_progress_size)->default_value(10000),
481
472
N_("Number of rows before each output progress report (requires --verbose)."))
495
486
N_("Add a 'DROP DATABASE' before each create."))
496
487
("skip-drop-table", N_("Do not add a 'drop table' before each create."))
497
488
("compact", po::value<bool>(&opt_compact)->default_value(false)->zero_tokens(),
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 --skip-add-locks"))
489
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"))
499
490
("databases,B", po::value<bool>(&opt_databases)->default_value(false)->zero_tokens(),
500
491
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."))
501
("delayed-insert", po::value<bool>(&opt_delayed)->default_value(false)->zero_tokens(),
502
N_("Insert rows with INSERT DELAYED;"))
503
492
("skip-disable-keys,K",
504
493
N_("'ALTER TABLE tb_name DISABLE KEYS; and 'ALTER TABLE tb_name ENABLE KEYS; will not be put in the output."))
505
494
("ignore-table", po::value<string>(),
507
496
("insert-ignore", po::value<bool>(&opt_ignore)->default_value(false)->zero_tokens(),
508
497
N_("Insert rows with INSERT IGNORE."))
509
498
("no-autocommit", po::value<bool>(&opt_autocommit)->default_value(false)->zero_tokens(),
510
N_("Wrap tables with autocommit/commit statements."))
499
N_("Wrap a table's data in START TRANSACTION/COMMIT statements."))
511
500
("no-create-db,n", po::value<bool>(&opt_create_db)->default_value(false)->zero_tokens(),
512
501
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."))
513
("no-create-info,t", po::value<bool>(&opt_no_create_info)->default_value(false)->zero_tokens(),
502
("skip-create,t", po::value<bool>(&opt_no_create_info)->default_value(false)->zero_tokens(),
514
503
N_("Don't write table creation info."))
515
504
("no-data,d", po::value<bool>(&opt_no_data)->default_value(false)->zero_tokens(),
516
505
N_("No row information."))
517
("no-set-names,N", N_("Deprecated. Use --skip-set-charset instead."))
518
("set-charset", po::value<bool>(&opt_set_charset)->default_value(false)->zero_tokens(),
519
N_("Enable set-name"))
520
("slow", N_("Buffer query instead of dumping directly to stdout."))
521
506
("replace", po::value<bool>(&opt_replace_into)->default_value(false)->zero_tokens(),
522
507
N_("Use REPLACE INTO instead of INSERT INTO."))
523
("result-file,r", po::value<string>(),
524
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)."))
525
508
("destination-type", po::value<string>()->default_value("stdout"),
526
509
N_("Where to send output to (stdout|database"))
527
510
("destination-host", po::value<string>(&opt_destination_host)->default_value("localhost"),
636
619
extended_insert= (vm.count("skip-extended-insert")) ? false : true;
637
620
opt_dump_date= (vm.count("skip-dump-date")) ? false : true;
638
621
opt_disable_keys= (vm.count("skip-disable-keys")) ? false : true;
639
quick= (vm.count("slow")) ? false : true;
640
622
opt_quoted= (vm.count("skip-quote-names")) ? false : true;
642
624
if (vm.count("protocol"))
706
677
if (vm.count("skip-opt"))
708
extended_insert= opt_drop= quick= create_options= 0;
709
opt_disable_keys= opt_set_charset= 0;
679
extended_insert= opt_drop= create_options= 0;
714
685
opt_drop= opt_disable_keys= 0;
718
688
if (vm.count("opt"))
720
extended_insert= opt_drop= quick= create_options= 1;
721
opt_disable_keys= opt_set_charset= 1;
690
extended_insert= opt_drop= create_options= 1;
724
694
if (vm.count("tables"))