~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump_data.cc

  • Committer: lbieber
  • Date: 2010-10-02 15:03:20 UTC
  • mfrom: (1808.1.3 build)
  • Revision ID: lbieber@orisndriz08-20101002150320-b4h2za7uf98juxql
Merge Andrew - fix bug 652645 - Bad error handling with Drizzledump connect
Merge Andrew - fix bug 652228 - drizzledump not dumping auto-inc when connecting to drizzle servers
Merge Andrew - fix bug 649844 - Clean up and fix some drizzledump options along with some documentation fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
extern bool opt_alldbs;
40
40
extern uint32_t show_progress_size;
41
41
extern bool opt_ignore;
 
42
extern bool opt_compress;
 
43
extern bool opt_drop_database;
 
44
extern bool opt_autocommit;
 
45
extern bool ignore_errors;
42
46
 
43
47
extern boost::unordered_set<std::string> ignore_table;
44
48
extern void maybe_exit(int error);
172
176
    /* Love that this variable is the opposite of its name */
173
177
    if (not opt_create_db)
174
178
    {
 
179
      if (opt_drop_database)
 
180
        os << "DROP DATABASE IF EXISTS `" << obj.databaseName << "`" << std::endl;
 
181
 
175
182
      os << "CREATE DATABASE IF NOT EXISTS `" << obj.databaseName << "`";
176
183
      if (not obj.collate.empty())
177
184
       os << " COLLATE = " << obj.collate;
196
203
      if (data == NULL)
197
204
      {
198
205
        std::cerr << "Error: Could not get data for table " << table->displayName << std::endl;
199
 
        maybe_exit(EX_DRIZZLEERR);
 
206
        if (not ignore_errors)
 
207
          maybe_exit(EX_DRIZZLEERR);
 
208
        else
 
209
          continue;
200
210
      }
201
211
      os << *data;
202
212
      delete data;
237
247
  if (opt_disable_keys)
238
248
    os << "ALTER TABLE `" << obj.table->displayName << "` DISABLE KEYS;" << std::endl;
239
249
 
 
250
  /* Another option that does the opposite of its name, makes me sad :( */
 
251
  if (opt_autocommit)
 
252
    os << "START TRANSACTION;" << std::endl;
 
253
 
240
254
  std::streampos out_position= os.tellp();
241
255
 
242
256
  while((row= drizzle_row_next(obj.result)))
311
325
  }
312
326
  os << ");" << std::endl;
313
327
 
 
328
  if (opt_autocommit)
 
329
    os << "COMMIT;" << std::endl;
 
330
 
314
331
  if (opt_disable_keys)
315
332
    os << "ALTER TABLE `" << obj.table->tableName << "` ENABLE KEYS;" << std::endl;
316
333
 
399
416
  }
400
417
  os << std::endl;
401
418
  os << ") ENGINE=" << obj.engineName << " ";
402
 
  if ((obj.dcon->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
403
 
    and (obj.autoIncrement > 0))
 
419
  if (obj.autoIncrement > 0)
404
420
  {
405
421
    os << "AUTO_INCREMENT=" << obj.autoIncrement << " ";
406
422
  }
437
453
  if (ret != DRIZZLE_RETURN_OK)
438
454
  {
439
455
    errorHandler(NULL, ret, "when trying to connect");
440
 
    throw;
 
456
    throw 1;
441
457
  }
442
458
 
443
459
  boost::match_flag_type flags = boost::match_default; 
533
549
  return true;
534
550
}
535
551
 
536
 
void DrizzleDumpConnection::errorHandler(drizzle_result_st *res, drizzle_return_t ret,
537
 
                     const char *when)
 
552
void DrizzleDumpConnection::errorHandler(drizzle_result_st *res,
 
553
  drizzle_return_t ret, const char *when)
538
554
{
539
 
  if (ret == DRIZZLE_RETURN_ERROR_CODE)
 
555
  if (res == NULL)
 
556
  {
 
557
    std::cerr << _("Got error: ") << drizzle_con_error(&connection) << " "
 
558
      << when << std::endl;
 
559
  }
 
560
  else if (ret == DRIZZLE_RETURN_ERROR_CODE)
540
561
  {
541
562
    std::cerr << _("Got error: ") << drizzle_result_error(res)
542
563
      << " (" << drizzle_result_error_code(res) << ") " << when << std::endl;