~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

  • Committer: Brian Aker
  • Date: 2010-10-15 05:30:39 UTC
  • mfrom: (1843.8.7 trunk-drizzle)
  • Revision ID: brian@tangent.org-20101015053039-ebmv3hnn1yaq4wqy
Merge in refactoring on table (broken it up by type, this will allow me to
insert the new locking).

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);
207
207
  }
208
208
  sbuf.setConnection(destination_connection);
209
209
  std::ostream sout(&sbuf);
210
 
  sout.exceptions(ios_base::badbit);
211
210
 
212
211
  if (path.empty())
213
212
  {
220
219
 
221
220
  for (i= database_store.begin(); i != database_store.end(); ++i)
222
221
  {
223
 
    try
224
 
    {
225
 
      DrizzleDumpDatabase *database= *i;
226
 
      sout << *database;
227
 
    }
228
 
    catch (std::exception&)
229
 
    {
230
 
      std::cout << _("Error inserting into destination database") << std::endl;
231
 
      if (not ignore_errors)
232
 
        maybe_exit(EX_DRIZZLEERR);
233
 
    }
 
222
    DrizzleDumpDatabase *database= *i;
 
223
    sout << *database;
234
224
  }
235
225
 
236
226
  if (path.empty())
357
347
  if (ignore_errors)
358
348
    return;
359
349
  delete db_connection;
360
 
  delete destination_connection;
 
350
  if (destination_connection)
 
351
    delete destination_connection;
361
352
  free_resources();
362
353
  exit(error);
363
354
}
531
522
  N_("Where to send output to (stdout|database"))
532
523
  ("destination-host", po::value<string>(&opt_destination_host)->default_value("localhost"),
533
524
  N_("Hostname for destination db server (requires --destination-type=database)"))
534
 
  ("destination-port", po::value<uint16_t>(&opt_destination_port)->default_value(4427),
 
525
  ("destination-port", po::value<uint16_t>(&opt_destination_port)->default_value(3306),
535
526
  N_("Port number for destination db server (requires --destination-type=database)"))
536
527
  ("destination-user", po::value<string>(&opt_destination_user),
537
528
  N_("User name for destination db server (resquires --destination-type=database)"))
575
566
 
576
567
  std::string user_config_dir((getenv("XDG_CONFIG_HOME")? getenv("XDG_CONFIG_HOME"):"~/.config"));
577
568
 
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
569
  po::positional_options_description p;
587
570
  p.add("database-used", 1);
588
571
  p.add("Table-used",-1);
754
737
    db_connection = new DrizzleDumpConnection(current_host, opt_drizzle_port,
755
738
      current_user, opt_password, use_drizzle_protocol);
756
739
  }
757
 
  catch (std::exception&)
 
740
  catch (...)
758
741
  {
759
742
    maybe_exit(EX_DRIZZLEERR);
760
743
  }
801
784
    dump_selected_tables(database_used, vm["Table-used"].as< vector<string> >());
802
785
  }
803
786
 
804
 
  if (vm.count("Table-used") and opt_databases)
 
787
  if (vm.count("Table-used") && opt_databases)
805
788
  {
 
789
/*
 
790
 * This is not valid!
806
791
    vector<string> database_used= vm["database-used"].as< vector<string> >();
807
792
    vector<string> table_used= vm["Table-used"].as< vector<string> >();
808
793
 
812
797
    {
813
798
      database_used.insert(database_used.end(), *it);
814
799
    }
815
 
 
816
800
    dump_databases(database_used);
817
 
    dump_all_tables();
 
801
    dump_tables();
 
802
*/
818
803
  }
819
 
 
 
804
  
820
805
  if (vm.count("database-used") && ! vm.count("Table-used"))
821
806
  {
822
807
    dump_databases(vm["database-used"].as< vector<string> >());
823
808
    dump_all_tables();
824
809
  }
825
 
 
826
810
  if (opt_destination == DESTINATION_STDOUT)
827
811
    generate_dump();
828
812
  else
844
828
  */
845
829
err:
846
830
  delete db_connection;
847
 
  delete destination_connection;
 
831
  if (destination_connection)
 
832
    delete destination_connection;
848
833
  if (path.empty())
849
834
    write_footer(md_result_file);
850
835
  free_resources();