~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

  • Committer: LinuxJedi
  • Date: 2010-08-28 19:47:15 UTC
  • mto: (1737.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1738.
  • Revision ID: linuxjedi@linuxjedi-laptop-20100828194715-0by4n2t30r5z9wci
Further cleanups based on Monty's comments (also revert a couple of things)

Show diffs side-by-side

added added

removed removed

Lines of Context:
125
125
FILE *md_result_file= 0;
126
126
FILE *stderror_file= 0;
127
127
 
 
128
const string progname= "drizzledump";
 
129
 
128
130
string password,
129
131
  enclosed,
130
132
  escaped,
277
279
                ! fields_terminated.empty()))
278
280
  {
279
281
    fprintf(stderr,
280
 
            _("%s: You must use option --tab with --fields-...\n"), internal::my_progname);
 
282
            _("%s: You must use option --tab with --fields-...\n"), progname.c_str());
281
283
    return(EX_USAGE);
282
284
  }
283
285
 
284
286
  if (opt_single_transaction && opt_lock_all_tables)
285
287
  {
286
288
    fprintf(stderr, _("%s: You can't use --single-transaction and "
287
 
                      "--lock-all-tables at the same time.\n"), internal::my_progname);
 
289
                      "--lock-all-tables at the same time.\n"), progname.c_str());
288
290
    return(EX_USAGE);
289
291
  }
290
292
  if (! enclosed.empty() && ! opt_enclosed.empty())
291
293
  {
292
 
    fprintf(stderr, _("%s: You can't use ..enclosed.. and ..optionally-enclosed.. at the same time.\n"), internal::my_progname);
 
294
    fprintf(stderr, _("%s: You can't use ..enclosed.. and ..optionally-enclosed.. at the same time.\n"), progname.c_str());
293
295
    return(EX_USAGE);
294
296
  }
295
297
  if ((opt_databases || opt_alldbs) && ! path.empty())
296
298
  {
297
299
    fprintf(stderr,
298
300
            _("%s: --databases or --all-databases can't be used with --tab.\n"),
299
 
            internal::my_progname);
 
301
            progname.c_str());
300
302
    return(EX_USAGE);
301
303
  }
302
304
 
349
351
  vsnprintf(buffer, sizeof(buffer), fmt_reason, args);
350
352
  va_end(args);
351
353
 
352
 
  fprintf(stderr, "%s: %s\n", internal::my_progname, buffer);
 
354
  fprintf(stderr, "%s: %s\n", progname.c_str(), buffer);
353
355
  fflush(stderr);
354
356
 
355
357
  ignore_errors= 0; /* force the exit */
383
385
  vsnprintf(buffer, sizeof(buffer), fmt_reason, args);
384
386
  va_end(args);
385
387
 
386
 
  fprintf(stderr, "%s: %s\n", internal::my_progname, buffer);
 
388
  fprintf(stderr, "%s: %s\n", progname.c_str(), buffer);
387
389
  fflush(stderr);
388
390
 
389
391
  maybe_exit(error_num);
1006
1008
  else
1007
1009
  {
1008
1010
    verbose_msg(_("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n"),
1009
 
                internal::my_progname, drizzle_con_error(&dcon));
 
1011
                progname.c_str(), drizzle_con_error(&dcon));
1010
1012
 
1011
1013
    snprintf(query_buff, sizeof(query_buff), "show fields from %s",
1012
1014
             result_table);
1113
1115
      if (drizzleclient_query_with_error_report(&dcon, &result, buff, false))
1114
1116
      {
1115
1117
        fprintf(stderr, _("%s: Can't get keys for table %s\n"),
1116
 
                internal::my_progname, result_table);
 
1118
                progname.c_str(), result_table);
1117
1119
        if (! path.empty())
1118
1120
          fclose(sql_file);
1119
1121
        return false;
1477
1479
    if (drizzle_result_column_count(&result) != num_fields)
1478
1480
    {
1479
1481
      fprintf(stderr,_("%s: Error in field count for table: %s !  Aborting.\n"),
1480
 
              internal::my_progname, result_table);
 
1482
              progname.c_str(), result_table);
1481
1483
      error= EX_CONSCHECK;
1482
1484
      drizzle_result_free(&result);
1483
1485
      goto err;
1521
1523
        {
1522
1524
          fprintf(stderr,
1523
1525
                  _("%s: Error reading rows for table: %s (%d:%s) ! Aborting.\n"),
1524
 
                  internal::my_progname, result_table, ret, drizzle_con_error(&dcon));
 
1526
                  progname.c_str(), result_table, ret, drizzle_con_error(&dcon));
1525
1527
          drizzle_result_free(&result);
1526
1528
          goto err;
1527
1529
        }
2389
2391
try
2390
2392
{
2391
2393
  int exit_code;
2392
 
  MY_INIT("drizzledump");
2393
2394
  drizzle_result_st result;
2394
2395
 
2395
2396
  po::options_description commandline_options(N_("Options used only in command line"));
2566
2567
  po::notify(vm);  
2567
2568
  
2568
2569
  if ((not vm.count("database-used") && not vm.count("Table-used") 
2569
 
    && not opt_alldbs && path.empty())  || (vm.count("help")))
 
2570
    && not opt_alldbs && path.empty())
 
2571
    || (vm.count("help")) || vm.count("version"))
2570
2572
  {
2571
 
    printf(_("%s  Drizzle %s libdrizzle %s, for %s-%s (%s)\n"), internal::my_progname,
2572
 
      VERSION, drizzle_version(), HOST_VENDOR, HOST_OS, HOST_CPU);
 
2573
    printf(_("Drizzledump %s build %s, for %s-%s (%s)\n"),
 
2574
      drizzle_version(), VERSION, HOST_VENDOR, HOST_OS, HOST_CPU);
 
2575
    if (vm.count("version"))
 
2576
      exit(0);
2573
2577
    puts("");
2574
2578
    puts(_("This software comes with ABSOLUTELY NO WARRANTY. This is free software,\nand you are welcome to modify and redistribute it under the GPL license\n"));
2575
2579
    puts(_("Dumps definitions and data from a Drizzle database server"));
2576
 
    printf(_("Usage: %s [OPTIONS] database [tables]\n"), internal::my_progname);
 
2580
    printf(_("Usage: %s [OPTIONS] database [tables]\n"), progname.c_str());
2577
2581
    printf(_("OR     %s [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]\n"),
2578
 
          internal::my_progname);
2579
 
    printf(_("OR     %s [OPTIONS] --all-databases [OPTIONS]\n"), internal::my_progname);
 
2582
          progname.c_str());
 
2583
    printf(_("OR     %s [OPTIONS] --all-databases [OPTIONS]\n"), progname.c_str());
2580
2584
    cout << long_options;
2581
2585
    if (vm.count("help"))
2582
2586
      exit(0);
2644
2648
    }
2645
2649
  }
2646
2650
 
2647
 
  if (vm.count("version"))
2648
 
  {
2649
 
     printf(_("%s  Drizzle %s libdrizzle %s, for %s-%s (%s)\n"), internal::my_progname,
2650
 
       VERSION, drizzle_version(), HOST_VENDOR, HOST_OS, HOST_CPU);
2651
 
  }
2652
 
 
2653
2651
  if (vm.count("xml"))
2654
2652
  { 
2655
2653
    opt_xml= 1;