~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

  • Committer: Stewart Smith
  • Date: 2011-01-14 05:13:52 UTC
  • mto: (2086.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2087.
  • Revision ID: stewart@flamingspork.com-20110114051352-ytdw2wn6thbf4dr8
fix tpyo

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
 
57
57
#define EX_USAGE 1
58
58
#define EX_DRIZZLEERR 2
 
59
#define EX_CONSCHECK 3
 
60
#define EX_EOM 4
59
61
#define EX_EOF 5 /* ferror for output file was got */
60
 
 
 
62
#define EX_ILLEGAL_TABLE 6
 
63
#define EX_TABLE_STATUS 7
 
64
 
 
65
/* index into 'show fields from table' */
 
66
 
 
67
#define SHOW_FIELDNAME  0
 
68
#define SHOW_TYPE  1
 
69
#define SHOW_NULL  2
 
70
#define SHOW_DEFAULT  4
 
71
#define SHOW_EXTRA  5
 
72
 
 
73
/* Size of buffer for dump's select query */
 
74
#define QUERY_LENGTH 1536
 
75
 
 
76
/* ignore table flags */
 
77
#define IGNORE_NONE 0x00 /* no ignore */
 
78
#define IGNORE_DATA 0x01 /* don't dump data for this table */
 
79
#define IGNORE_INSERT_DELAYED 0x02 /* table doesn't support INSERT DELAYED */
 
80
 
 
81
bool opt_alltspcs= false;
 
82
bool opt_complete_insert= false;
61
83
bool  verbose= false;
62
84
static bool use_drizzle_protocol= false;
63
85
bool ignore_errors= false;
81
103
bool extended_insert= true;
82
104
bool opt_replace_into= false;
83
105
bool opt_drop= true; 
84
 
bool opt_data_is_mangled= false;
85
106
uint32_t show_progress_size= 0;
86
107
static string insert_pat;
87
108
static uint32_t opt_drizzle_port= 0;
118
139
  opt_protocol,
119
140
  where;
120
141
 
 
142
//static const CHARSET_INFO *charset_info= &my_charset_utf8_general_ci;
 
143
 
121
144
boost::unordered_set<string> ignore_table;
122
145
 
123
146
void maybe_exit(int error);
241
264
    cout << "-- Host: " << current_host << "    Database: " << db_name << endl;
242
265
    cout << "-- ------------------------------------------------------" << endl;
243
266
    cout << "-- Server version\t" << db_connection->getServerVersion();
244
 
    if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
 
267
    if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
245
268
      cout << " (MySQL server)";
246
 
    else if (db_connection->getServerType() == ServerDetect::SERVER_DRIZZLE_FOUND)
 
269
    else if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_DRIZZLE_FOUND)
247
270
      cout << " (Drizzle server)";
248
271
    cout << endl << endl;
249
272
  }
351
374
    std::cerr << _("-- Retrieving database structures...") << std::endl;
352
375
 
353
376
  /* Blocking the MySQL privilege tables too because we can't import them due to bug#646187 */
354
 
  if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
 
377
  if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
355
378
    query= "SELECT SCHEMA_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('information_schema', 'performance_schema', 'mysql')";
356
379
  else
357
380
    query= "SELECT SCHEMA_NAME, DEFAULT_COLLATION_NAME FROM DATA_DICTIONARY.SCHEMAS WHERE SCHEMA_NAME NOT IN ('information_schema','data_dictionary')";
360
383
  while ((row= drizzle_row_next(tableres)))
361
384
  {
362
385
    std::string database_name(row[0]);
363
 
    if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
 
386
    if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
364
387
      database= new DrizzleDumpDatabaseMySQL(database_name, db_connection);
365
388
    else
366
389
      database= new DrizzleDumpDatabaseDrizzle(database_name, db_connection);
383
406
  for (vector<string>::const_iterator it= db_names.begin(); it != db_names.end(); ++it)
384
407
  {
385
408
    temp= *it;
386
 
    if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
 
409
    if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
387
410
      database= new DrizzleDumpDatabaseMySQL(temp, db_connection);
388
411
    else
389
412
      database= new DrizzleDumpDatabaseDrizzle(temp, db_connection);
396
419
{
397
420
  DrizzleDumpDatabase *database;
398
421
 
399
 
  if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
 
422
  if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
400
423
    database= new DrizzleDumpDatabaseMySQL(db, db_connection);
401
424
  else
402
425
    database= new DrizzleDumpDatabaseDrizzle(db, db_connection);
461
484
  commandline_options.add_options()
462
485
  ("all-databases,A", po::value<bool>(&opt_alldbs)->default_value(false)->zero_tokens(),
463
486
  _("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
  _("Dump all the tablespaces."))
 
489
  ("complete-insert,c", po::value<bool>(&opt_complete_insert)->default_value(false)->zero_tokens(),
 
490
  _("Use complete insert statements."))
464
491
  ("flush-logs,F", po::value<bool>(&flush_logs)->default_value(false)->zero_tokens(),
465
492
  _("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"))
466
493
  ("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
520
547
  _("Password for destination db server (requires --destination-type=database)"))
521
548
  ("destination-database", po::value<string>(&opt_destination_database),
522
549
  _("The database in the destination db server (requires --destination-type=database, not for use with --all-databases)"))
523
 
  ("my-data-is-mangled", po::value<bool>(&opt_data_is_mangled)->default_value(false)->zero_tokens(),
524
 
  _("Do not make a UTF8 connection to MySQL, use if you have UTF8 data in a non-UTF8 table"))
525
550
  ;
526
551
 
527
552
  po::options_description client_options(_("Options specific to the client"));
742
767
    maybe_exit(EX_DRIZZLEERR);
743
768
  }
744
769
 
745
 
  if ((db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND) and (not opt_data_is_mangled))
 
770
  if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
746
771
    db_connection->queryNoResult("SET NAMES 'utf8'");
747
772
 
748
773
  if (vm.count("destination-type"))