~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump_data.cc

Merge to trunk.

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);
100
104
      os << ",";
101
105
    std::string field= *i;
102
106
    os << "`" << field << "`";
 
107
    if (obj.length > 0)
 
108
      os << "(" << obj.length << ")";
103
109
  }
104
110
 
105
111
  os << ")";
170
176
    /* Love that this variable is the opposite of its name */
171
177
    if (not opt_create_db)
172
178
    {
 
179
      if (opt_drop_database)
 
180
        os << "DROP DATABASE IF EXISTS `" << obj.databaseName << "`" << std::endl;
 
181
 
173
182
      os << "CREATE DATABASE IF NOT EXISTS `" << obj.databaseName << "`";
174
183
      if (not obj.collate.empty())
175
184
       os << " COLLATE = " << obj.collate;
194
203
      if (data == NULL)
195
204
      {
196
205
        std::cerr << "Error: Could not get data for table " << table->displayName << std::endl;
197
 
        maybe_exit(EX_DRIZZLEERR);
 
206
        if (not ignore_errors)
 
207
          maybe_exit(EX_DRIZZLEERR);
 
208
        else
 
209
          continue;
198
210
      }
199
211
      os << *data;
200
212
      delete data;
235
247
  if (opt_disable_keys)
236
248
    os << "ALTER TABLE `" << obj.table->displayName << "` DISABLE KEYS;" << std::endl;
237
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
 
238
254
  std::streampos out_position= os.tellp();
239
255
 
240
256
  while((row= drizzle_row_next(obj.result)))
309
325
  }
310
326
  os << ");" << std::endl;
311
327
 
 
328
  if (opt_autocommit)
 
329
    os << "COMMIT;" << std::endl;
 
330
 
312
331
  if (opt_disable_keys)
313
332
    os << "ALTER TABLE `" << obj.table->tableName << "` ENABLE KEYS;" << std::endl;
314
333
 
397
416
  }
398
417
  os << std::endl;
399
418
  os << ") ENGINE=" << obj.engineName << " ";
400
 
  if ((obj.dcon->getServerType() == DrizzleDumpConnection::SERVER_MYSQL_FOUND)
401
 
    and (obj.autoIncrement > 0))
 
419
  if (obj.autoIncrement > 0)
402
420
  {
403
421
    os << "AUTO_INCREMENT=" << obj.autoIncrement << " ";
404
422
  }
435
453
  if (ret != DRIZZLE_RETURN_OK)
436
454
  {
437
455
    errorHandler(NULL, ret, "when trying to connect");
438
 
    throw;
 
456
    throw 1;
439
457
  }
440
458
 
441
459
  boost::match_flag_type flags = boost::match_default; 
531
549
  return true;
532
550
}
533
551
 
534
 
void DrizzleDumpConnection::errorHandler(drizzle_result_st *res, drizzle_return_t ret,
535
 
                     const char *when)
 
552
void DrizzleDumpConnection::errorHandler(drizzle_result_st *res,
 
553
  drizzle_return_t ret, const char *when)
536
554
{
537
 
  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)
538
561
  {
539
562
    std::cerr << _("Got error: ") << drizzle_result_error(res)
540
563
      << " (" << drizzle_result_error_code(res) << ") " << when << std::endl;