~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

  • Committer: Andrew Hutchings
  • Date: 2010-10-17 16:04:42 UTC
  • mto: This revision was merged to the branch mainline in revision 1861.
  • Revision ID: andrew@linuxjedi.co.uk-20101017160442-htkekkxyny0qrzfk
Add unit tests for libdrizzle utility functions
Fix drizzle_escape_string

Show diffs side-by-side

added added

removed removed

Lines of Context:
200
200
      opt_destination_port, opt_destination_user, opt_destination_password,
201
201
      false);
202
202
  }
203
 
  catch (std::exception&)
 
203
  catch (...)
204
204
  {
205
205
    cerr << "Could not connect to destination database server" << endl;
206
206
    maybe_exit(EX_DRIZZLEERR);
225
225
      DrizzleDumpDatabase *database= *i;
226
226
      sout << *database;
227
227
    }
228
 
    catch (std::exception&)
 
228
    catch (...)
229
229
    {
230
 
      std::cout << _("Error inserting into destination database") << std::endl;
 
230
      std::cout << _("Error inserting into destnation database") << std::endl;
231
231
      if (not ignore_errors)
232
232
        maybe_exit(EX_DRIZZLEERR);
233
233
    }
357
357
  if (ignore_errors)
358
358
    return;
359
359
  delete db_connection;
360
 
  delete destination_connection;
 
360
  if (destination_connection)
 
361
    delete destination_connection;
361
362
  free_resources();
362
363
  exit(error);
363
364
}
531
532
  N_("Where to send output to (stdout|database"))
532
533
  ("destination-host", po::value<string>(&opt_destination_host)->default_value("localhost"),
533
534
  N_("Hostname for destination db server (requires --destination-type=database)"))
534
 
  ("destination-port", po::value<uint16_t>(&opt_destination_port)->default_value(4427),
 
535
  ("destination-port", po::value<uint16_t>(&opt_destination_port)->default_value(3306),
535
536
  N_("Port number for destination db server (requires --destination-type=database)"))
536
537
  ("destination-user", po::value<string>(&opt_destination_user),
537
538
  N_("User name for destination db server (resquires --destination-type=database)"))
575
576
 
576
577
  std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config"));
577
578
 
578
 
  if (user_config_dir.compare(0, 2, "~/") == 0)
579
 
  {
580
 
    char *homedir;
581
 
    homedir= getenv("HOME");
582
 
    if (homedir != NULL)
583
 
      user_config_dir.replace(0, 1, homedir);
584
 
  }
585
 
 
586
579
  po::positional_options_description p;
587
580
  p.add("database-used", 1);
588
581
  p.add("Table-used",-1);
754
747
    db_connection = new DrizzleDumpConnection(current_host, opt_drizzle_port,
755
748
      current_user, opt_password, use_drizzle_protocol);
756
749
  }
757
 
  catch (std::exception&)
 
750
  catch (...)
758
751
  {
759
752
    maybe_exit(EX_DRIZZLEERR);
760
753
  }
801
794
    dump_selected_tables(database_used, vm["Table-used"].as< vector<string> >());
802
795
  }
803
796
 
804
 
  if (vm.count("Table-used") and opt_databases)
 
797
  if (vm.count("Table-used") && opt_databases)
805
798
  {
 
799
/*
 
800
 * This is not valid!
806
801
    vector<string> database_used= vm["database-used"].as< vector<string> >();
807
802
    vector<string> table_used= vm["Table-used"].as< vector<string> >();
808
803
 
812
807
    {
813
808
      database_used.insert(database_used.end(), *it);
814
809
    }
815
 
 
816
810
    dump_databases(database_used);
817
 
    dump_all_tables();
 
811
    dump_tables();
 
812
*/
818
813
  }
819
 
 
 
814
  
820
815
  if (vm.count("database-used") && ! vm.count("Table-used"))
821
816
  {
822
817
    dump_databases(vm["database-used"].as< vector<string> >());
823
818
    dump_all_tables();
824
819
  }
825
 
 
826
820
  if (opt_destination == DESTINATION_STDOUT)
827
821
    generate_dump();
828
822
  else
844
838
  */
845
839
err:
846
840
  delete db_connection;
847
 
  delete destination_connection;
 
841
  if (destination_connection)
 
842
    delete destination_connection;
848
843
  if (path.empty())
849
844
    write_footer(md_result_file);
850
845
  free_resources();