76
67
static void add_load_option(string &str, const char *option,
77
68
const char *option_value);
78
static uint32_t find_set(TYPELIB *lib, const char *x, uint32_t length,
79
char **err_pos, uint32_t *err_len);
69
static uint32_t find_set(TYPELIB *lib, const char *x, uint length,
70
char **err_pos, uint *err_len);
81
72
static void field_escape(string &in, const char *from);
82
static bool verbose= false;
83
static bool opt_no_create_info= false;
84
static bool opt_no_data= false;
85
static bool opt_mysql= false;
86
static bool quick= true;
87
static bool extended_insert= true;
88
static bool ignore_errors= false;
89
static bool flush_logs= false;
90
static bool opt_drop= true;
91
static bool opt_keywords= false;
92
static bool opt_compress= false;
93
static bool opt_delayed= false;
94
static bool create_options= true;
95
static bool opt_quoted= false;
96
static bool opt_databases= false;
97
static bool opt_alldbs= false;
98
static bool opt_create_db= false;
99
static bool opt_lock_all_tables= false;
100
static bool opt_set_charset= false;
101
static bool opt_dump_date= true;
102
static bool opt_autocommit= false;
103
static bool opt_disable_keys= true;
104
static bool opt_xml= false;
105
static bool tty_password= false;
106
static bool opt_single_transaction= false;
107
static bool opt_comments= false;
108
static bool opt_compact= false;
109
static bool opt_hex_blob= false;
110
static bool opt_order_by_primary=false;
111
static bool opt_ignore= false;
112
static bool opt_complete_insert= false;
113
static bool opt_drop_database= false;
114
static bool opt_replace_into= false;
115
static bool opt_routines= false;
116
static bool opt_alltspcs= false;
117
static uint32_t show_progress_size= 0;
118
static uint64_t total_rows= 0;
119
static drizzle_st drizzle;
120
static drizzle_con_st dcon;
73
static bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0,
74
quick= 1, extended_insert= 1,
75
lock_tables=1,ignore_errors=0,flush_logs=0,flush_privileges=0,
76
opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0,
77
opt_delayed=0,create_options=1,opt_quoted=0,opt_databases=0,
78
opt_alldbs=0,opt_create_db=0,opt_lock_all_tables=0,
79
opt_set_charset=0, opt_dump_date=1,
80
opt_autocommit=0,opt_disable_keys=1,opt_xml=0,
81
opt_delete_master_logs=0, tty_password=0,
82
opt_single_transaction=0, opt_comments= 0, opt_compact= 0,
83
opt_hex_blob=0, opt_order_by_primary=0, opt_ignore=0,
84
opt_complete_insert= 0, opt_drop_database= 0,
86
opt_routines=0, opt_tz_utc=1,
88
opt_include_master_host_port= 0,
90
opt_alltspcs=0, opt_notspcs= 0;
91
static bool debug_info_flag= 0, debug_check_flag= 0;
92
static uint32_t opt_max_allowed_packet, opt_net_buffer_length;
93
static DRIZZLE drizzle_connection,*drizzle=0;
121
94
static string insert_pat;
122
static char *opt_password= NULL;
123
static char *current_user= NULL;
124
static char *current_host= NULL;
125
static char *path= NULL;
126
static char *fields_terminated= NULL;
127
static char *lines_terminated= NULL;
128
static char *enclosed= NULL;
129
static char *opt_enclosed= NULL;
130
static char *escaped= NULL;
131
static char *where= NULL;
132
static char *order_by= NULL;
133
static char *opt_compatible_mode_str= NULL;
134
static char *err_ptr= NULL;
135
static char **defaults_argv= NULL;
95
static char *opt_password=0,*current_user=0,
96
*current_host=0,*path=0,*fields_terminated=0,
97
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0,
98
*where=0, *order_by=0,
99
*opt_compatible_mode_str= 0,
101
*log_error_file= NULL;
102
static char **defaults_argv= 0;
136
103
static char compatible_mode_normal_str[255];
104
/* Server supports character_set_results session variable? */
105
static bool server_supports_switching_charsets= true;
137
106
static uint32_t opt_compatible_mode= 0;
138
static uint32_t opt_drizzle_port= 0;
139
static int first_error= 0;
107
#define DRIZZLE_OPT_MASTER_DATA_EFFECTIVE_SQL 1
108
#define DRIZZLE_OPT_MASTER_DATA_COMMENTED_SQL 2
109
#define DRIZZLE_OPT_SLAVE_DATA_EFFECTIVE_SQL 1
110
#define DRIZZLE_OPT_SLAVE_DATA_COMMENTED_SQL 2
111
static uint opt_drizzle_port= 0, opt_master_data;
112
static uint opt_slave_data;
113
static uint my_end_arg;
114
static int first_error=0;
140
115
static string extended_row;
141
116
FILE *md_result_file= 0;
142
FILE *stderror_file= 0;
117
FILE *stderror_file=0;
120
Constant for detection of default value of default_charset.
121
If default_charset is equal to drizzle_universal_client_charset, then
122
it is the default value which assigned at the very beginning of main().
124
static const char *drizzle_universal_client_charset=
125
DRIZZLE_UNIVERSAL_CLIENT_CHARSET;
126
static char *default_charset;
144
127
static const CHARSET_INFO *charset_info= &my_charset_utf8_general_ci;
146
static const char *compatible_mode_names[]=
128
const char *default_dbug_option="d:t:o,/tmp/drizzledump.trace";
129
/* have we seen any VIEWs during table scanning? */
131
const char *compatible_mode_names[]=
148
133
"MYSQL323", "MYSQL40", "POSTGRESQL", "ORACLE", "MSSQL", "DB2",
149
134
"MAXDB", "NO_KEY_OPTIONS", "NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS",
153
static TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1,
154
"", compatible_mode_names, NULL};
156
drizzled::hash_set<string> ignore_table;
158
static struct option my_long_options[] =
138
#define MASK_ANSI_QUOTES \
140
(1<<2) | /* POSTGRESQL */\
141
(1<<3) | /* ORACLE */\
142
(1<<4) | /* MSSQL */\
144
(1<<6) | /* MAXDB */\
147
TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1,
148
"", compatible_mode_names, NULL};
152
static struct my_option my_long_options[] =
160
154
{"all", 'a', "Deprecated. Use --create-options instead.",
161
(char**) &create_options, (char**) &create_options, 0, GET_BOOL, NO_ARG, 1,
155
(char**) &create_options, (char**) &create_options, 0, GET_BOOL, NO_ARG, 1,
163
157
{"all-databases", 'A',
164
"Dump all the databases. This will be same as --databases with all databases selected.",
165
(char**) &opt_alldbs, (char**) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
158
"Dump all the databases. This will be same as --databases with all databases selected.",
159
(char**) &opt_alldbs, (char**) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
167
161
{"all-tablespaces", 'Y',
168
"Dump all the tablespaces.",
169
(char**) &opt_alltspcs, (char**) &opt_alltspcs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
162
"Dump all the tablespaces.",
163
(char**) &opt_alltspcs, (char**) &opt_alltspcs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
165
{"no-tablespaces", 'y',
166
"Do not dump any tablespace information.",
167
(char**) &opt_notspcs, (char**) &opt_notspcs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
171
169
{"add-drop-database", OPT_DROP_DATABASE, "Add a 'DROP DATABASE' before each create.",
172
(char**) &opt_drop_database, (char**) &opt_drop_database, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
170
(char**) &opt_drop_database, (char**) &opt_drop_database, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
174
172
{"add-drop-table", OPT_DROP, "Add a 'drop table' before each create.",
175
(char**) &opt_drop, (char**) &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0,
173
(char**) &opt_drop, (char**) &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0,
175
{"add-locks", OPT_LOCKS, "Add locks around insert statements.",
176
(char**) &opt_lock, (char**) &opt_lock, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0,
177
178
{"allow-keywords", OPT_KEYWORDS,
178
"Allow creation of column names that are keywords.", (char**) &opt_keywords,
179
(char**) &opt_keywords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
179
"Allow creation of column names that are keywords.", (char**) &opt_keywords,
180
(char**) &opt_keywords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
181
{"apply-slave-statements", OPT_DRIZZLEDUMP_SLAVE_APPLY,
182
"Adds 'STOP SLAVE' prior to 'CHANGE MASTER' and 'START SLAVE' to bottom of dump.",
183
(char**) &opt_slave_apply, (char**) &opt_slave_apply, 0, GET_BOOL, NO_ARG,
185
{"character-sets-dir", OPT_CHARSETS_DIR,
186
"Directory where character sets are.", (char**) &charsets_dir,
187
(char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
180
188
{"comments", 'i', "Write additional information.",
181
(char**) &opt_comments, (char**) &opt_comments, 0, GET_BOOL, NO_ARG,
189
(char**) &opt_comments, (char**) &opt_comments, 0, GET_BOOL, NO_ARG,
183
191
{"compatible", OPT_COMPATIBLE,
184
"Change the dump to be compatible with a given mode. By default tables are dumped in a format optimized for MySQL. Legal modes are: ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, no_field_options. One can use several modes separated by commas. Note: Requires DRIZZLE server version 4.1.0 or higher. This option is ignored with earlier server versions.",
185
(char**) &opt_compatible_mode_str, (char**) &opt_compatible_mode_str, 0,
186
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
192
"Change the dump to be compatible with a given mode. By default tables are dumped in a format optimized for MySQL. Legal modes are: ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, no_field_options. One can use several modes separated by commas. Note: Requires DRIZZLE server version 4.1.0 or higher. This option is ignored with earlier server versions.",
193
(char**) &opt_compatible_mode_str, (char**) &opt_compatible_mode_str, 0,
194
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
187
195
{"compact", OPT_COMPACT,
188
"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",
189
(char**) &opt_compact, (char**) &opt_compact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
196
"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",
197
(char**) &opt_compact, (char**) &opt_compact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
191
199
{"complete-insert", 'c', "Use complete insert statements.",
192
(char**) &opt_complete_insert, (char**) &opt_complete_insert, 0, GET_BOOL,
193
NO_ARG, 0, 0, 0, 0, 0, 0},
200
(char**) &opt_complete_insert, (char**) &opt_complete_insert, 0, GET_BOOL,
201
NO_ARG, 0, 0, 0, 0, 0, 0},
194
202
{"compress", 'C', "Use compression in server/client protocol.",
195
(char**) &opt_compress, (char**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
203
(char**) &opt_compress, (char**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0,
197
205
{"create-options", OPT_CREATE_OPTIONS,
198
"Include all DRIZZLE specific create options.",
199
(char**) &create_options, (char**) &create_options, 0, GET_BOOL, NO_ARG, 1,
206
"Include all DRIZZLE specific create options.",
207
(char**) &create_options, (char**) &create_options, 0, GET_BOOL, NO_ARG, 1,
201
209
{"databases", 'B',
202
"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.",
203
(char**) &opt_databases, (char**) &opt_databases, 0, GET_BOOL, NO_ARG, 0, 0,
210
"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.",
211
(char**) &opt_databases, (char**) &opt_databases, 0, GET_BOOL, NO_ARG, 0, 0,
213
{"debug-check", OPT_DEBUG_CHECK, "Check memory and open file usage at exit.",
214
(char**) &debug_check_flag, (char**) &debug_check_flag, 0,
215
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
216
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.",
217
(char**) &debug_info_flag, (char**) &debug_info_flag,
218
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
219
{"default-character-set", OPT_DEFAULT_CHARSET,
220
"Set the default character set.", (char**) &default_charset,
221
(char**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
205
222
{"delayed-insert", OPT_DELAYED, "Insert rows with INSERT DELAYED; ",
206
(char**) &opt_delayed, (char**) &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
223
(char**) &opt_delayed, (char**) &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
225
{"delete-master-logs", OPT_DELETE_MASTER_LOGS,
226
"Delete logs on master after backup. This automatically enables --master-data.",
227
(char**) &opt_delete_master_logs, (char**) &opt_delete_master_logs, 0,
228
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
208
229
{"disable-keys", 'K',
209
"'ALTER TABLE tb_name DISABLE KEYS; and 'ALTER TABLE tb_name ENABLE KEYS; will be put in the output.", (char**) &opt_disable_keys,
210
(char**) &opt_disable_keys, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
230
"'/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and '/*!40000 ALTER TABLE tb_name ENABLE KEYS */; will be put in the output.", (char**) &opt_disable_keys,
231
(char**) &opt_disable_keys, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
232
{"dump-slave", OPT_DRIZZLEDUMP_SLAVE_DATA,
233
"This causes the binary log position and filename of the master to be "
234
"appended to the dumped data output. Setting the value to 1, will print"
235
"it as a CHANGE MASTER command in the dumped data output; if equal"
236
" to 2, that command will be prefixed with a comment symbol. "
237
"This option will turn --lock-all-tables on, unless "
238
"--single-transaction is specified too (in which case a "
239
"global read lock is only taken a short time at the beginning of the dump "
240
"- don't forget to read about --single-transaction below). In all cases "
241
"any action on logs will happen at the exact moment of the dump."
242
"Option automatically turns --lock-tables off.",
243
(char**) &opt_slave_data, (char**) &opt_slave_data, 0,
244
GET_UINT, OPT_ARG, 0, 0, DRIZZLE_OPT_SLAVE_DATA_COMMENTED_SQL, 0, 0, 0},
245
{"events", 'E', "Dump events.",
246
(char**) &opt_events, (char**) &opt_events, 0, GET_BOOL,
247
NO_ARG, 0, 0, 0, 0, 0, 0},
211
248
{"extended-insert", 'e',
212
"Allows utilization of the new, much faster INSERT syntax.",
213
(char**) &extended_insert, (char**) &extended_insert, 0, GET_BOOL, NO_ARG,
249
"Allows utilization of the new, much faster INSERT syntax.",
250
(char**) &extended_insert, (char**) &extended_insert, 0, GET_BOOL, NO_ARG,
215
252
{"fields-terminated-by", OPT_FTB,
216
"Fields in the textfile are terminated by ...", (char**) &fields_terminated,
217
(char**) &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
253
"Fields in the textfile are terminated by ...", (char**) &fields_terminated,
254
(char**) &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
218
255
{"fields-enclosed-by", OPT_ENC,
219
"Fields in the importfile are enclosed by ...", (char**) &enclosed,
220
(char**) &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0},
256
"Fields in the importfile are enclosed by ...", (char**) &enclosed,
257
(char**) &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0},
221
258
{"fields-optionally-enclosed-by", OPT_O_ENC,
222
"Fields in the i.file are opt. enclosed by ...", (char**) &opt_enclosed,
223
(char**) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0},
259
"Fields in the i.file are opt. enclosed by ...", (char**) &opt_enclosed,
260
(char**) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0},
224
261
{"fields-escaped-by", OPT_ESC, "Fields in the i.file are escaped by ...",
225
(char**) &escaped, (char**) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
262
(char**) &escaped, (char**) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
263
{"first-slave", 'x', "Deprecated, renamed to --lock-all-tables.",
264
(char**) &opt_lock_all_tables, (char**) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG,
226
266
{"flush-logs", 'F', "Flush logs file in server before starting dump. "
227
"Note that if you dump many databases at once (using the option "
228
"--databases= or --all-databases), the logs will be flushed for "
229
"each database dumped. The exception is when using --lock-all-tables "
230
"in this case the logs will be flushed only once, corresponding "
231
"to the moment all tables are locked. So if you want your dump and "
232
"the log flush to happen at the same exact moment you should use "
233
"--lock-all-tables or --flush-logs",
234
(char**) &flush_logs, (char**) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
267
"Note that if you dump many databases at once (using the option "
268
"--databases= or --all-databases), the logs will be flushed for "
269
"each database dumped. The exception is when using --lock-all-tables "
271
"in this case the logs will be flushed only once, corresponding "
272
"to the moment all tables are locked. So if you want your dump and "
273
"the log flush to happen at the same exact moment you should use "
274
"--lock-all-tables or --master-data with --flush-logs",
275
(char**) &flush_logs, (char**) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
277
{"flush-privileges", OPT_ESC, "Emit a FLUSH PRIVILEGES statement "
278
"after dumping the DRIZZLE database. This option should be used any "
279
"time the dump contains the DRIZZLE database and any other database "
280
"that depends on the data in the DRIZZLE database for proper restore. ",
281
(char**) &flush_privileges, (char**) &flush_privileges, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
236
283
{"force", 'f', "Continue even if we get an sql-error.",
237
(char**) &ignore_errors, (char**) &ignore_errors, 0, GET_BOOL, NO_ARG,
284
(char**) &ignore_errors, (char**) &ignore_errors, 0, GET_BOOL, NO_ARG,
239
286
{"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG,
240
NO_ARG, 0, 0, 0, 0, 0, 0},
287
NO_ARG, 0, 0, 0, 0, 0, 0},
241
288
{"hex-blob", OPT_HEXBLOB, "Dump binary strings (BINARY, "
242
289
"VARBINARY, BLOB) in hexadecimal format.",
243
(char**) &opt_hex_blob, (char**) &opt_hex_blob, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
290
(char**) &opt_hex_blob, (char**) &opt_hex_blob, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
244
291
{"host", 'h', "Connect to host.", (char**) ¤t_host,
245
(char**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
292
(char**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
246
293
{"ignore-table", OPT_IGNORE_TABLE,
247
"Do not dump the specified table. To specify more than one table to ignore, "
248
"use the directive multiple times, once for each table. Each table must "
249
"be specified with both database and table names, e.g. --ignore-table=database.table",
250
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
294
"Do not dump the specified table. To specify more than one table to ignore, "
295
"use the directive multiple times, once for each table. Each table must "
296
"be specified with both database and table names, e.g. --ignore-table=database.table",
297
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
298
{"include-master-host-port", OPT_DRIZZLEDUMP_INCLUDE_MASTER_HOST_PORT,
299
"Adds 'MASTER_HOST=<host>, MASTER_PORT=<port>' to 'CHANGE MASTER TO..' in dump produced with --dump-slave.",
300
(char**) &opt_include_master_host_port,
301
(char**) &opt_include_master_host_port,
251
304
{"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.",
252
(char**) &opt_ignore, (char**) &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
305
(char**) &opt_ignore, (char**) &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
254
307
{"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...",
255
(char**) &lines_terminated, (char**) &lines_terminated, 0, GET_STR,
256
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
308
(char**) &lines_terminated, (char**) &lines_terminated, 0, GET_STR,
309
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
257
310
{"lock-all-tables", 'x', "Locks all tables across all databases. This "
258
"is achieved by taking a global read lock for the duration of the whole "
259
"dump. Automatically turns --single-transaction and --lock-tables off.",
260
(char**) &opt_lock_all_tables, (char**) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG,
262
{"mysql", 'm', N_("Use MySQL Protocol."),
263
(char**) &opt_mysql, (char**) &opt_mysql, 0, GET_BOOL, NO_ARG, 1, 0, 0,
311
"is achieved by taking a global read lock for the duration of the whole "
312
"dump. Automatically turns --single-transaction and --lock-tables off.",
313
(char**) &opt_lock_all_tables, (char**) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG,
315
{"lock-tables", 'l', "Lock all tables for read.", (char**) &lock_tables,
316
(char**) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
317
{"log-error", OPT_ERROR_LOG_FILE, "Append warnings and errors to given file.",
318
(char**) &log_error_file, (char**) &log_error_file, 0, GET_STR,
319
REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
320
{"master-data", OPT_MASTER_DATA,
321
"This causes the binary log position and filename to be appended to the "
322
"output. If equal to 1, will print it as a CHANGE MASTER command; if equal"
323
" to 2, that command will be prefixed with a comment symbol. "
324
"This option will turn --lock-all-tables on, unless "
325
"--single-transaction is specified too (in which case a "
326
"global read lock is only taken a short time at the beginning of the dump "
327
"- don't forget to read about --single-transaction below). In all cases "
328
"any action on logs will happen at the exact moment of the dump."
329
"Option automatically turns --lock-tables off.",
330
(char**) &opt_master_data, (char**) &opt_master_data, 0,
331
GET_UINT, OPT_ARG, 0, 0, DRIZZLE_OPT_MASTER_DATA_COMMENTED_SQL, 0, 0, 0},
332
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "",
333
(char**) &opt_max_allowed_packet, (char**) &opt_max_allowed_packet, 0,
334
GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096,
335
(int64_t) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0},
336
{"net_buffer_length", OPT_NET_BUFFER_LENGTH, "",
337
(char**) &opt_net_buffer_length, (char**) &opt_net_buffer_length, 0,
338
GET_ULONG, REQUIRED_ARG, 1024*1024L-1025, 4096, 16*1024L*1024L,
339
MALLOC_OVERHEAD-1024, 1024, 0},
265
340
{"no-autocommit", OPT_AUTOCOMMIT,
266
"Wrap tables with autocommit/commit statements.",
267
(char**) &opt_autocommit, (char**) &opt_autocommit, 0, GET_BOOL, NO_ARG,
341
"Wrap tables with autocommit/commit statements.",
342
(char**) &opt_autocommit, (char**) &opt_autocommit, 0, GET_BOOL, NO_ARG,
269
344
{"no-create-db", 'n',
270
"'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.}.",
271
(char**) &opt_create_db, (char**) &opt_create_db, 0, GET_BOOL, NO_ARG, 0, 0,
345
"'CREATE DATABASE /*!32312 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.}.",
346
(char**) &opt_create_db, (char**) &opt_create_db, 0, GET_BOOL, NO_ARG, 0, 0,
273
348
{"no-create-info", 't', "Don't write table creation info.",
274
(char**) &opt_no_create_info, (char**) &opt_no_create_info, 0, GET_BOOL,
275
NO_ARG, 0, 0, 0, 0, 0, 0},
349
(char**) &opt_no_create_info, (char**) &opt_no_create_info, 0, GET_BOOL,
350
NO_ARG, 0, 0, 0, 0, 0, 0},
276
351
{"no-data", 'd', "No row information.", (char**) &opt_no_data,
277
(char**) &opt_no_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
352
(char**) &opt_no_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
278
353
{"no-set-names", 'N',
279
"Deprecated. Use --skip-set-charset instead.",
280
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
354
"Deprecated. Use --skip-set-charset instead.",
355
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
281
356
{"opt", OPT_OPTIMIZE,
282
"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.",
283
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
357
"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.",
358
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
284
359
{"order-by-primary", OPT_ORDER_BY_PRIMARY,
285
"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.",
286
(char**) &opt_order_by_primary, (char**) &opt_order_by_primary, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
288
"Password to use when connecting to server. If password is not given it's solicited on the tty.",
289
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
290
{"port", 'p', "Port number to use for connection.",
291
0, 0, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
360
"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.",
361
(char**) &opt_order_by_primary, (char**) &opt_order_by_primary, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
363
"Password to use when connecting to server. If password is not given it's solicited on the tty.",
364
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
365
{"port", 'P', "Port number to use for connection.", (char**) &opt_drizzle_port,
366
(char**) &opt_drizzle_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
292
368
{"quick", 'q', "Don't buffer query, dump directly to stdout.",
293
(char**) &quick, (char**) &quick, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
369
(char**) &quick, (char**) &quick, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
294
370
{"quote-names",'Q', "Quote table and column names with backticks (`).",
295
(char**) &opt_quoted, (char**) &opt_quoted, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
371
(char**) &opt_quoted, (char**) &opt_quoted, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0,
297
373
{"replace", OPT_DRIZZLE_REPLACE_INTO, "Use REPLACE INTO instead of INSERT INTO.",
298
(char**) &opt_replace_into, (char**) &opt_replace_into, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
374
(char**) &opt_replace_into, (char**) &opt_replace_into, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
300
376
{"result-file", 'r',
301
"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).",
302
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
377
"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).",
378
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
303
379
{"routines", 'R', "Dump stored routines (functions and procedures).",
304
(char**) &opt_routines, (char**) &opt_routines, 0, GET_BOOL,
305
NO_ARG, 0, 0, 0, 0, 0, 0},
380
(char**) &opt_routines, (char**) &opt_routines, 0, GET_BOOL,
381
NO_ARG, 0, 0, 0, 0, 0, 0},
382
{"set-charset", OPT_SET_CHARSET,
383
"Add 'SET NAMES default_character_set' to the output.",
384
(char**) &opt_set_charset, (char**) &opt_set_charset, 0, GET_BOOL, NO_ARG, 1,
386
{"set-variable", 'O',
387
"Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.",
388
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
390
Note that the combination --single-transaction --master-data
391
will give bullet-proof binlog position only if server >=4.1.3. That's the
392
old "FLUSH TABLES WITH READ LOCK does not block commit" fixed bug.
306
394
{"single-transaction", OPT_TRANSACTION,
307
"Creates a consistent snapshot by dumping all tables in a single "
308
"transaction. Works ONLY for tables stored in storage engines which "
309
"support multiversioning (currently only InnoDB does); the dump is NOT "
310
"guaranteed to be consistent for other storage engines. "
311
"While a --single-transaction dump is in process, to ensure a valid "
312
"dump file (correct table contents), no other "
313
"connection should use the following statements: ALTER TABLE, DROP "
314
"TABLE, RENAME TABLE, TRUNCATE TABLE, as consistent snapshot is not "
315
"isolated from them. Option automatically turns off --lock-tables.",
316
(char**) &opt_single_transaction, (char**) &opt_single_transaction, 0,
317
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
395
"Creates a consistent snapshot by dumping all tables in a single "
396
"transaction. Works ONLY for tables stored in storage engines which "
397
"support multiversioning (currently only InnoDB does); the dump is NOT "
398
"guaranteed to be consistent for other storage engines. "
399
"While a --single-transaction dump is in process, to ensure a valid "
400
"dump file (correct table contents and binary log position), no other "
401
"connection should use the following statements: ALTER TABLE, DROP "
402
"TABLE, RENAME TABLE, TRUNCATE TABLE, as consistent snapshot is not "
403
"isolated from them. Option automatically turns off --lock-tables.",
404
(char**) &opt_single_transaction, (char**) &opt_single_transaction, 0,
405
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
318
406
{"dump-date", OPT_DUMP_DATE, "Put a dump date to the end of the output.",
319
(char**) &opt_dump_date, (char**) &opt_dump_date, 0,
320
GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
407
(char**) &opt_dump_date, (char**) &opt_dump_date, 0,
408
GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
321
409
{"skip-opt", OPT_SKIP_OPTIMIZATION,
322
"Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys.",
323
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
410
"Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys.",
411
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
325
"Creates tab separated textfile for each table to given path. (creates .sql and .txt files). NOTE: This only works if drizzledump is run on the same machine as the drizzled daemon.",
326
(char**) &path, (char**) &path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
413
"Creates tab separated textfile for each table to given path. (creates .sql and .txt files). NOTE: This only works if mysqldump is run on the same machine as the mysqld daemon.",
414
(char**) &path, (char**) &path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
327
415
{"tables", OPT_TABLES, "Overrides option --databases (-B).",
328
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
329
{"show-progress-size", OPT_SHOW_PROGRESS_SIZE, N_("Number of rows before each output progress report (requires --verbose)."),
330
(char**) &show_progress_size, (char**) &show_progress_size, 0, GET_UINT32, REQUIRED_ARG,
331
10000, 0, 0, 0, 0, 0},
416
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
417
{"tz-utc", OPT_TZ_UTC,
418
"SET TIME_ZONE='+00:00' at top of dump to allow dumping of TIMESTAMP data when a server has data in different time zones or data is being moved between servers with different time zones.",
419
(char**) &opt_tz_utc, (char**) &opt_tz_utc, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
420
#ifndef DONT_ALLOW_USER_CHANGE
332
421
{"user", 'u', "User for login if not current user.",
333
(char**) ¤t_user, (char**) ¤t_user, 0, GET_STR, REQUIRED_ARG,
422
(char**) ¤t_user, (char**) ¤t_user, 0, GET_STR, REQUIRED_ARG,
335
425
{"verbose", 'v', "Print info about the various stages.",
336
(char**) &verbose, (char**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
426
(char**) &verbose, (char**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
337
427
{"version",'V', "Output version information and exit.", 0, 0, 0,
338
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
428
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
339
429
{"where", 'w', "Dump only selected records; QUOTES mandatory!",
340
(char**) &where, (char**) &where, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
430
(char**) &where, (char**) &where, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
341
431
{"xml", 'X', "Dump a database as well formed XML.", 0, 0, 0, GET_NO_ARG,
342
NO_ARG, 0, 0, 0, 0, 0, 0},
432
NO_ARG, 0, 0, 0, 0, 0, 0},
343
433
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}