~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

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;
241
263
    cout << "-- Host: " << current_host << "    Database: " << db_name << endl;
242
264
    cout << "-- ------------------------------------------------------" << endl;
243
265
    cout << "-- Server version\t" << db_connection->getServerVersion();
244
 
    if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
 
266
    if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
245
267
      cout << " (MySQL server)";
246
 
    else if (db_connection->getServerType() == ServerDetect::SERVER_DRIZZLE_FOUND)
 
268
    else if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_DRIZZLE_FOUND)
247
269
      cout << " (Drizzle server)";
248
270
    cout << endl << endl;
249
271
  }
351
373
    std::cerr << _("-- Retrieving database structures...") << std::endl;
352
374
 
353
375
  /* 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)
 
376
  if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
355
377
    query= "SELECT SCHEMA_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME NOT IN ('information_schema', 'performance_schema', 'mysql')";
356
378
  else
357
379
    query= "SELECT SCHEMA_NAME, DEFAULT_COLLATION_NAME FROM DATA_DICTIONARY.SCHEMAS WHERE SCHEMA_NAME NOT IN ('information_schema','data_dictionary')";
360
382
  while ((row= drizzle_row_next(tableres)))
361
383
  {
362
384
    std::string database_name(row[0]);
363
 
    if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
 
385
    if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
364
386
      database= new DrizzleDumpDatabaseMySQL(database_name, db_connection);
365
387
    else
366
388
      database= new DrizzleDumpDatabaseDrizzle(database_name, db_connection);
383
405
  for (vector<string>::const_iterator it= db_names.begin(); it != db_names.end(); ++it)
384
406
  {
385
407
    temp= *it;
386
 
    if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
 
408
    if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
387
409
      database= new DrizzleDumpDatabaseMySQL(temp, db_connection);
388
410
    else
389
411
      database= new DrizzleDumpDatabaseDrizzle(temp, db_connection);
396
418
{
397
419
  DrizzleDumpDatabase *database;
398
420
 
399
 
  if (db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND)
 
421
  if (db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
400
422
    database= new DrizzleDumpDatabaseMySQL(db, db_connection);
401
423
  else
402
424
    database= new DrizzleDumpDatabaseDrizzle(db, db_connection);
461
483
  commandline_options.add_options()
462
484
  ("all-databases,A", po::value<bool>(&opt_alldbs)->default_value(false)->zero_tokens(),
463
485
  _("Dump all the databases. This will be same as --databases with all databases selected."))
 
486
  ("all-tablespaces,Y", po::value<bool>(&opt_alltspcs)->default_value(false)->zero_tokens(),
 
487
  _("Dump all the tablespaces."))
 
488
  ("complete-insert,c", po::value<bool>(&opt_complete_insert)->default_value(false)->zero_tokens(),
 
489
  _("Use complete insert statements."))
464
490
  ("flush-logs,F", po::value<bool>(&flush_logs)->default_value(false)->zero_tokens(),
465
491
  _("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
492
  ("force,f", po::value<bool>(&ignore_errors)->default_value(false)->zero_tokens(),
742
768
    maybe_exit(EX_DRIZZLEERR);
743
769
  }
744
770
 
745
 
  if ((db_connection->getServerType() == ServerDetect::SERVER_MYSQL_FOUND) and (not opt_data_is_mangled))
 
771
  if ((db_connection->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND) and (not opt_data_is_mangled))
746
772
    db_connection->queryNoResult("SET NAMES 'utf8'");
747
773
 
748
774
  if (vm.count("destination-type"))