~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#include <boost/program_options.hpp>
45
45
#include <boost/regex.hpp>
46
46
#include <boost/date_time/posix_time/posix_time.hpp>
47
 
#include "drizzledump_data.h"
48
 
#include "drizzledump_mysql.h"
49
 
#include "drizzledump_drizzle.h"
 
47
 
 
48
#include "client/drizzledump_data.h"
 
49
#include "client/drizzledump_mysql.h"
 
50
#include "client/drizzledump_drizzle.h"
 
51
 
 
52
#include "user_detect.h"
50
53
 
51
54
using namespace std;
52
55
using namespace drizzled;
462
465
# if defined(HAVE_LOCALE_H)
463
466
  setlocale(LC_ALL, "");
464
467
# endif
465
 
  bindtextdomain("drizzle7", LOCALEDIR);
466
 
  textdomain("drizzle7");
 
468
  bindtextdomain("drizzle", LOCALEDIR);
 
469
  textdomain("drizzle");
467
470
#endif
468
471
 
469
472
  po::options_description commandline_options(_("Options used only in command line"));
500
503
  _("Add a 'DROP DATABASE' before each create."))
501
504
  ("skip-drop-table", _("Do not add a 'drop table' before each create."))
502
505
  ("compact", po::value<bool>(&opt_compact)->default_value(false)->zero_tokens(),
503
 
  _("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"))
 
506
  _("Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs.  Enables option --skip-disable-keys"))
504
507
  ("databases,B", po::value<bool>(&opt_databases)->default_value(false)->zero_tokens(),
505
508
  _("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."))
506
509
  ("skip-disable-keys,K",
533
536
  _("Do not make a UTF8 connection to MySQL, use if you have UTF8 data in a non-UTF8 table"))
534
537
  ;
535
538
 
536
 
  const char* unix_user= getlogin();
537
 
 
538
539
  po::options_description client_options(_("Options specific to the client"));
539
540
  client_options.add_options()
540
541
  ("host,h", po::value<string>(&current_host)->default_value("localhost"),
543
544
  _("Password to use when connecting to server. If password is not given it's solicited on the tty."))
544
545
  ("port,p", po::value<uint32_t>(&opt_drizzle_port)->default_value(0),
545
546
  _("Port number to use for connection."))
546
 
  ("user,u", po::value<string>(&current_user)->default_value((unix_user ? unix_user : "")),
 
547
  ("user,u", po::value<string>(&current_user)->default_value(UserDetect().getUser()),
547
548
  _("User for login if not current user."))
548
549
  ("protocol",po::value<string>(&opt_protocol)->default_value("mysql"),
549
550
  _("The protocol of connection (mysql or drizzle)."))
639
640
 
640
641
  /* Inverted Booleans */
641
642
 
642
 
  opt_drop= (vm.count("skip-drop-table")) ? false : true;
643
 
  opt_comments= (vm.count("skip-comments")) ? false : true;
644
 
  extended_insert= (vm.count("skip-extended-insert")) ? false : true;
645
 
  opt_dump_date= (vm.count("skip-dump-date")) ? false : true;
646
 
  opt_disable_keys= (vm.count("skip-disable-keys")) ? false : true;
647
 
  opt_quoted= (vm.count("skip-quote-names")) ? false : true;
 
643
  opt_drop= not vm.count("skip-drop-table");
 
644
  opt_comments= not vm.count("skip-comments");
 
645
  extended_insert= not vm.count("skip-extended-insert");
 
646
  opt_dump_date= not vm.count("skip-dump-date");
 
647
  opt_disable_keys= not vm.count("skip-disable-keys");
 
648
  opt_quoted= not vm.count("skip-quote-names");
648
649
 
649
650
  if (vm.count("protocol"))
650
651
  {
651
 
    std::transform(opt_protocol.begin(), opt_protocol.end(),
652
 
      opt_protocol.begin(), ::tolower);
653
 
 
 
652
    boost::to_lower(opt_protocol);
654
653
    if (not opt_protocol.compare("mysql"))
655
654
      use_drizzle_protocol=false;
656
655
    else if (not opt_protocol.compare("drizzle"))
675
674
    }
676
675
  }
677
676
 
678
 
  if(vm.count("password"))
 
677
  if (vm.count("password"))
679
678
  {
680
679
    if (!opt_password.empty())
681
680
      opt_password.erase();
786
785
    dump_all_databases();
787
786
    dump_all_tables();
788
787
  }
789
 
  if (vm.count("database-used") && vm.count("Table-used") && ! opt_databases)
 
788
  if (vm.count("database-used") && vm.count("Table-used") && not opt_databases)
790
789
  {
791
790
    string database_used= *vm["database-used"].as< vector<string> >().begin();
792
791
    /* Only one database and selected table(s) */
793
792
    dump_selected_tables(database_used, vm["Table-used"].as< vector<string> >());
794
793
  }
795
794
 
796
 
  if (vm.count("Table-used") and opt_databases)
 
795
  if (vm.count("Table-used") && opt_databases)
797
796
  {
798
797
    vector<string> database_used= vm["database-used"].as< vector<string> >();
799
798
    vector<string> table_used= vm["Table-used"].as< vector<string> >();
809
808
    dump_all_tables();
810
809
  }
811
810
 
812
 
  if (vm.count("database-used") && ! vm.count("Table-used"))
 
811
  if (vm.count("database-used") && not vm.count("Table-used"))
813
812
  {
814
813
    dump_databases(vm["database-used"].as< vector<string> >());
815
814
    dump_all_tables();