~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump_mysql.cc

  • Committer: Andrew Hutchings
  • Date: 2010-09-24 13:38:21 UTC
  • mto: (1792.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1793.
  • Revision ID: andrew@linuxjedi.co.uk-20100924133821-jzesmb013qy3525m
Fix error handling
Make work with dtr drizzledump test case

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
  drizzle_row_t row;
35
35
  std::string query;
36
36
 
37
 
  dcon->setDB(databaseName);
 
37
  if (not dcon->setDB(databaseName))
 
38
    return false;
38
39
 
39
40
  if (verbose)
40
41
    std::cerr << _("-- Retrieving table structures for ") << databaseName << "..." << std::endl;
45
46
 
46
47
  result= dcon->query(query);
47
48
 
 
49
  if (result == NULL)
 
50
    return false;
 
51
 
48
52
  while ((row= drizzle_row_next(result)))
49
53
  {
50
54
    std::string tableName(row[0]);
51
 
    if (not ignoreTable(tableName))
 
55
    std::string displayName(tableName);
 
56
    cleanTableName(displayName);
 
57
    if (not ignoreTable(displayName))
52
58
      continue;
53
59
 
54
60
    DrizzleDumpTableMySQL *table = new DrizzleDumpTableMySQL(tableName, dcon);
 
61
    table->displayName= displayName;
55
62
    table->setCollate(row[1]);
56
63
    table->setEngine(row[2]);
57
64
    if (row[3])
60
67
      table->autoIncrement= 0;
61
68
 
62
69
    table->database= this;
63
 
    table->populateFields();
64
 
    table->populateIndexes();
 
70
    if ((not table->populateFields()) or (not table->populateIndexes()))
 
71
    {
 
72
      delete table;
 
73
      return false;
 
74
    }
65
75
    tables.push_back(table);
66
76
  }
67
77
 
76
86
  drizzle_row_t row;
77
87
  std::string query;
78
88
 
79
 
  dcon->setDB(databaseName);
 
89
  if (not dcon->setDB(databaseName))
 
90
    return false;
80
91
 
81
92
  if (verbose)
82
93
    std::cerr << _("-- Retrieving table structures for ") << databaseName << "..." << std::endl;
83
94
  for (std::vector<std::string>::const_iterator it= table_names.begin(); it != table_names.end(); ++it)
84
95
  {
85
96
    std::string tableName= *it;
86
 
    if (not ignoreTable(tableName))
 
97
    std::string displayName(tableName);
 
98
    cleanTableName(displayName);
 
99
    if (not ignoreTable(displayName))
87
100
      continue;
88
101
 
89
102
    query="SELECT TABLE_NAME, TABLE_COLLATION, ENGINE, AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='";
94
107
 
95
108
    result= dcon->query(query);
96
109
 
 
110
    if (result == NULL)
 
111
      return false;
 
112
 
97
113
    if ((row= drizzle_row_next(result)))
98
114
    {
99
115
      DrizzleDumpTableMySQL *table = new DrizzleDumpTableMySQL(tableName, dcon);
 
116
      table->displayName= displayName;
100
117
      table->setCollate(row[1]);
101
118
      table->setEngine(row[2]);
102
119
      if (row[3])
105
122
        table->autoIncrement= 0;
106
123
 
107
124
      table->database= this;
108
 
      table->populateFields();
109
 
      table->populateIndexes();
 
125
      if ((not table->populateFields()) or (not table->populateIndexes()))
 
126
      {
 
127
        delete table;
 
128
        return false;
 
129
      }
110
130
      tables.push_back(table);
111
131
      dcon->freeResult(result);
112
132
    }
138
158
 
139
159
  result= dcon->query(query);
140
160
 
 
161
  if (result == NULL)
 
162
    return false;
 
163
 
141
164
  while ((row= drizzle_row_next(result)))
142
165
  {
143
166
    std::string fieldName(row[0]);
224
247
 
225
248
  result= dcon->query(query);
226
249
 
 
250
  if (result == NULL)
 
251
    return false;
 
252
 
227
253
  while ((row= drizzle_row_next(result)))
228
254
  {
229
255
    std::string indexName(row[2]);
353
379
 
354
380
DrizzleDumpData* DrizzleDumpTableMySQL::getData(void)
355
381
{
356
 
  return new DrizzleDumpDataMySQL(this, dcon);
 
382
  try
 
383
  {
 
384
    return new DrizzleDumpDataMySQL(this, dcon);
 
385
  }
 
386
  catch(...)
 
387
  {
 
388
    return NULL;
 
389
  }
357
390
}
358
391
 
359
392
void DrizzleDumpDatabaseMySQL::setCollate(const char* newCollate)
405
438
{
406
439
  std::string query;
407
440
  query= "SELECT * FROM `";
408
 
  query.append(table->tableName);
 
441
  query.append(table->displayName);
409
442
  query.append("`");
410
443
 
411
444
  result= dcon->query(query);
 
445
  if (result == NULL)
 
446
    throw 1;
412
447
}
413
448
 
414
449
DrizzleDumpDataMySQL::~DrizzleDumpDataMySQL()