~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump_mysql.cc

  • Committer: Brian Aker
  • Date: 2010-10-29 01:13:40 UTC
  • mto: (1890.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 1891.
  • Revision ID: brian@tangent.org-20101029011340-y9ixm180v9daypqr
Remove warnings for c++

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2010 Andrew Hutchings
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
#include "drizzledump_data.h"
 
21
#include "drizzledump_mysql.h"
 
22
#include "client_priv.h"
 
23
#include <string>
 
24
#include <iostream>
 
25
#include <boost/regex.hpp>
 
26
#include <boost/date_time/posix_time/posix_time.hpp>
 
27
#include <drizzled/gettext.h>
 
28
 
 
29
extern bool verbose;
 
30
extern bool ignore_errors;
 
31
 
 
32
bool DrizzleDumpDatabaseMySQL::populateTables()
 
33
{
 
34
  drizzle_result_st *result;
 
35
  drizzle_row_t row;
 
36
  std::string query;
 
37
 
 
38
  if (not dcon->setDB(databaseName))
 
39
    return false;
 
40
 
 
41
  if (verbose)
 
42
    std::cerr << _("-- Retrieving table structures for ") << databaseName << "..." << std::endl;
 
43
 
 
44
  query="SELECT TABLE_NAME, TABLE_COLLATION, ENGINE, AUTO_INCREMENT, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE != 'VIEW' AND TABLE_SCHEMA='";
 
45
  query.append(databaseName);
 
46
  query.append("' ORDER BY TABLE_NAME");
 
47
 
 
48
  result= dcon->query(query);
 
49
 
 
50
  if (result == NULL)
 
51
    return false;
 
52
 
 
53
  while ((row= drizzle_row_next(result)))
 
54
  {
 
55
    size_t* row_sizes= drizzle_row_field_sizes(result);
 
56
    std::string tableName(row[0]);
 
57
    std::string displayName(tableName);
 
58
    cleanTableName(displayName);
 
59
    if (not ignoreTable(displayName))
 
60
      continue;
 
61
 
 
62
    DrizzleDumpTableMySQL *table = new DrizzleDumpTableMySQL(tableName, dcon);
 
63
    table->displayName= displayName;
 
64
    table->setCollate(row[1]);
 
65
    table->setEngine(row[2]);
 
66
    if (row[3])
 
67
      table->autoIncrement= boost::lexical_cast<uint64_t>(row[3]);
 
68
    else
 
69
      table->autoIncrement= 0;
 
70
 
 
71
    if ((row[4]) and (strstr(row[4], "InnoDB free") == NULL))
 
72
      table->comment= DrizzleDumpData::escape(row[4], row_sizes[4]);
 
73
    else
 
74
      table->comment= "";
 
75
 
 
76
    table->database= this;
 
77
    if ((not table->populateFields()) or (not table->populateIndexes()) or
 
78
     (not table->populateFkeys()))
 
79
    {
 
80
      delete table;
 
81
      if (not ignore_errors)
 
82
        return false;
 
83
      else
 
84
        continue;
 
85
    }
 
86
    tables.push_back(table);
 
87
  }
 
88
 
 
89
  dcon->freeResult(result);
 
90
 
 
91
  return true;
 
92
}
 
93
 
 
94
bool DrizzleDumpDatabaseMySQL::populateTables(const std::vector<std::string> &table_names)
 
95
{
 
96
  drizzle_result_st *result;
 
97
  drizzle_row_t row;
 
98
  std::string query;
 
99
 
 
100
  if (not dcon->setDB(databaseName))
 
101
    return false;
 
102
 
 
103
  if (verbose)
 
104
    std::cerr << _("-- Retrieving table structures for ") << databaseName << "..." << std::endl;
 
105
  for (std::vector<std::string>::const_iterator it= table_names.begin(); it != table_names.end(); ++it)
 
106
  {
 
107
    std::string tableName= *it;
 
108
    std::string displayName(tableName);
 
109
    cleanTableName(displayName);
 
110
    if (not ignoreTable(displayName))
 
111
      continue;
 
112
 
 
113
    query="SELECT TABLE_NAME, TABLE_COLLATION, ENGINE, AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='";
 
114
    query.append(databaseName);
 
115
    query.append("' AND TABLE_NAME = '");
 
116
    query.append(tableName);
 
117
    query.append("'");
 
118
 
 
119
    result= dcon->query(query);
 
120
 
 
121
    if (result == NULL)
 
122
      return false;
 
123
 
 
124
    if ((row= drizzle_row_next(result)))
 
125
    {
 
126
      DrizzleDumpTableMySQL *table = new DrizzleDumpTableMySQL(tableName, dcon);
 
127
      table->displayName= displayName;
 
128
      table->setCollate(row[1]);
 
129
      table->setEngine(row[2]);
 
130
      if (row[3])
 
131
        table->autoIncrement= boost::lexical_cast<uint64_t>(row[3]);
 
132
      else
 
133
        table->autoIncrement= 0;
 
134
 
 
135
      table->database= this;
 
136
      if ((not table->populateFields()) or (not table->populateIndexes()))
 
137
      {
 
138
        delete table;
 
139
        if (not ignore_errors)
 
140
          return false;
 
141
        else
 
142
          continue;
 
143
      }
 
144
      tables.push_back(table);
 
145
      dcon->freeResult(result);
 
146
    }
 
147
    else
 
148
    {
 
149
      dcon->freeResult(result);
 
150
      if (not ignore_errors)
 
151
        return false;
 
152
      else
 
153
        continue;
 
154
    }
 
155
  }
 
156
 
 
157
  return true;
 
158
 
 
159
}
 
160
 
 
161
bool DrizzleDumpTableMySQL::populateFields()
 
162
{
 
163
  drizzle_result_st *result;
 
164
  drizzle_row_t row;
 
165
  std::string query;
 
166
 
 
167
  if (verbose)
 
168
    std::cerr << _("-- Retrieving fields for ") << tableName << "..." << std::endl;
 
169
 
 
170
  query="SELECT COLUMN_NAME, COLUMN_TYPE, COLUMN_DEFAULT, IS_NULLABLE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, COLLATION_NAME, EXTRA FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA='";
 
171
  query.append(database->databaseName);
 
172
  query.append("' AND TABLE_NAME='");
 
173
  query.append(tableName);
 
174
  query.append("' ORDER BY ORDINAL_POSITION");
 
175
 
 
176
  result= dcon->query(query);
 
177
 
 
178
  if (result == NULL)
 
179
    return false;
 
180
 
 
181
  while ((row= drizzle_row_next(result)))
 
182
  {
 
183
    std::string fieldName(row[0]);
 
184
    DrizzleDumpFieldMySQL *field = new DrizzleDumpFieldMySQL(fieldName, dcon);
 
185
    /* Stop valgrind warning */
 
186
    field->convertDateTime= false;
 
187
    /* Also sets collation */
 
188
    field->setType(row[1], row[8]);
 
189
    if (field->type.compare("ENUM") == 0)
 
190
      field->isNull= true;
 
191
    else
 
192
      field->isNull= (strcmp(row[3], "YES") == 0) ? true : false;
 
193
    if (row[2])
 
194
    {
 
195
      field->defaultValue= row[2];
 
196
    }
 
197
    else
 
198
     field->defaultValue= "";
 
199
 
 
200
    if (field->convertDateTime)
 
201
    {
 
202
      field->dateTimeConvert();
 
203
    }
 
204
 
 
205
 
 
206
    field->isAutoIncrement= (strcmp(row[8], "auto_increment") == 0) ? true : false;
 
207
    field->defaultIsNull= field->isNull;
 
208
    field->length= (row[4]) ? boost::lexical_cast<uint32_t>(row[4]) : 0;
 
209
    if ((row[5] != NULL) and (row[6] != NULL))
 
210
    {
 
211
      field->decimalPrecision= boost::lexical_cast<uint32_t>(row[5]);
 
212
      field->decimalScale= boost::lexical_cast<uint32_t>(row[6]);
 
213
    }
 
214
    else
 
215
    {
 
216
      field->decimalPrecision= 0;
 
217
      field->decimalScale= 0;
 
218
    }
 
219
 
 
220
    fields.push_back(field);
 
221
  }
 
222
 
 
223
  dcon->freeResult(result);
 
224
  return true;
 
225
}
 
226
 
 
227
 
 
228
void DrizzleDumpFieldMySQL::dateTimeConvert(void)
 
229
{
 
230
  boost::match_flag_type flags = boost::match_default;
 
231
 
 
232
  if (strcmp(defaultValue.c_str(), "CURRENT_TIMESTAMP") == 0)
 
233
    return;
 
234
 
 
235
  if (type.compare("INT") == 0)
 
236
  {
 
237
    /* We were a TIME, now we are an INT */
 
238
    std::string ts(defaultValue);
 
239
    boost::posix_time::time_duration td(boost::posix_time::duration_from_string(ts));
 
240
    defaultValue= boost::lexical_cast<std::string>(td.total_seconds());
 
241
    return;
 
242
  }
 
243
 
 
244
  boost::regex date_regex("(0000|-00)");
 
245
 
 
246
  if (regex_search(defaultValue, date_regex, flags))
 
247
  {
 
248
    defaultIsNull= true;
 
249
    defaultValue="";
 
250
  }
 
251
  isNull= true;
 
252
}
 
253
 
 
254
 
 
255
bool DrizzleDumpTableMySQL::populateIndexes()
 
256
{
 
257
  drizzle_result_st *result;
 
258
  drizzle_row_t row;
 
259
  std::string query;
 
260
  std::string lastKey;
 
261
  bool firstIndex= true;
 
262
  DrizzleDumpIndex *index;
 
263
 
 
264
  if (verbose)
 
265
    std::cerr << _("-- Retrieving indexes for ") << tableName << "..." << std::endl;
 
266
 
 
267
  query="SHOW INDEXES FROM ";
 
268
  query.append(tableName);
 
269
 
 
270
  result= dcon->query(query);
 
271
 
 
272
  if (result == NULL)
 
273
    return false;
 
274
 
 
275
  while ((row= drizzle_row_next(result)))
 
276
  {
 
277
    std::string indexName(row[2]);
 
278
    if (indexName.compare(lastKey) != 0)
 
279
    {
 
280
      if (strcmp(row[10], "FULLTEXT") == 0)
 
281
        continue;
 
282
 
 
283
      if (!firstIndex)
 
284
        indexes.push_back(index);
 
285
      index = new DrizzleDumpIndexMySQL(indexName, dcon);
 
286
      index->isPrimary= (strcmp(row[2], "PRIMARY") == 0);
 
287
      index->isUnique= (strcmp(row[1], "0") == 0);
 
288
      index->isHash= (strcmp(row[10], "HASH") == 0);
 
289
      index->length= (row[7]) ? boost::lexical_cast<uint32_t>(row[7]) : 0;
 
290
      lastKey= row[2];
 
291
      firstIndex= false;
 
292
    }
 
293
    index->columns.push_back(row[4]);
 
294
  }
 
295
  if (!firstIndex)
 
296
    indexes.push_back(index);
 
297
 
 
298
  dcon->freeResult(result);
 
299
  return true;
 
300
}
 
301
 
 
302
bool DrizzleDumpTableMySQL::populateFkeys()
 
303
{
 
304
  drizzle_result_st *result;
 
305
  drizzle_row_t row;
 
306
  std::string query;
 
307
  DrizzleDumpForeignKey *fkey;
 
308
 
 
309
  if (verbose)
 
310
    std::cerr << _("-- Retrieving foreign keys for ") << tableName << "..." << std::endl;
 
311
 
 
312
  query= "SHOW TABLES FROM INFORMATION_SCHEMA LIKE 'REFERENTIAL_CONSTRAINTS'";
 
313
 
 
314
  result= dcon->query(query);
 
315
 
 
316
  if (result == NULL)
 
317
    return false;
 
318
 
 
319
  uint64_t search_count = drizzle_result_row_count(result);
 
320
 
 
321
  dcon->freeResult(result);
 
322
 
 
323
  /* MySQL 5.0 will be 0 and MySQL 5.1 will be 1 */
 
324
  if (search_count > 0)
 
325
  {
 
326
    query= "select rc.constraint_name, rc.referenced_table_name, group_concat(distinct concat('`',kc.column_name,'`')), rc.update_rule, rc.delete_rule, rc.match_option, group_concat(distinct concat('`',kt.column_name,'`')) from information_schema.referential_constraints rc join information_schema.key_column_usage kt on (rc.constraint_schema = kt.constraint_schema and rc.constraint_name = kt.constraint_name) join information_schema.key_column_usage kc on (rc.constraint_schema = kc.constraint_schema and rc.referenced_table_name = kc.table_name and rc.unique_constraint_name = kc.constraint_name) where rc.constraint_schema='";
 
327
    query.append(database->databaseName);
 
328
    query.append("' and rc.table_name='");
 
329
    query.append(tableName);
 
330
    query.append("' group by rc.constraint_name");
 
331
 
 
332
    result= dcon->query(query);
 
333
 
 
334
    if (result == NULL)
 
335
      return false;
 
336
 
 
337
    while ((row= drizzle_row_next(result)))
 
338
    {
 
339
      fkey= new DrizzleDumpForeignKey(row[0], dcon);
 
340
      fkey->parentColumns= row[6];
 
341
      fkey->childTable= row[1];
 
342
      fkey->childColumns= row[2];
 
343
      fkey->updateRule= (strcmp(row[3], "RESTRICT") != 0) ? row[3] : "";
 
344
      fkey->deleteRule= (strcmp(row[4], "RESTRICT") != 0) ? row[4] : "";
 
345
      fkey->matchOption= (strcmp(row[5], "NONE") != 0) ? row[5] : "";
 
346
 
 
347
      fkeys.push_back(fkey);
 
348
    }
 
349
  }
 
350
  else
 
351
  {
 
352
    query= "SHOW CREATE TABLE `";
 
353
    query.append(database->databaseName);
 
354
    query.append("`.`");
 
355
    query.append(tableName);
 
356
    query.append("`");
 
357
    result= dcon->query(query);
 
358
 
 
359
    if (result == NULL)
 
360
      return false;
 
361
 
 
362
    if ((row= drizzle_row_next(result)))
 
363
    {
 
364
      boost::match_flag_type flags = boost::match_default;
 
365
      boost::regex constraint_regex("CONSTRAINT `(.*)` FOREIGN KEY \\((.*)\\) REFERENCES `(.*)` \\((.*)\\)( ON (UPDATE|DELETE) (CASCADE|RESTRICT|SET NULL))?( ON (UPDATE|DELETE) (CASCADE|RESTRICT|SET NULL))?");
 
366
 
 
367
      boost::match_results<std::string::const_iterator> constraint_results;
 
368
 
 
369
      std::string search_body(row[1]);
 
370
      std::string::const_iterator start, end;
 
371
      start= search_body.begin();
 
372
      end= search_body.end();
 
373
      while (regex_search(start, end, constraint_results, constraint_regex, flags))
 
374
      {
 
375
        fkey= new DrizzleDumpForeignKey(constraint_results[1], dcon);
 
376
        fkey->parentColumns= constraint_results[2];
 
377
        fkey->childTable= constraint_results[3];
 
378
        fkey->childColumns= constraint_results[4];
 
379
        
 
380
        if (constraint_results[5].compare("") != 0)
 
381
        {
 
382
          if (constraint_results[6].compare("UPDATE") == 0)
 
383
            fkey->updateRule= constraint_results[7];
 
384
          else if (constraint_results[6].compare("DELETE") == 0)
 
385
            fkey->deleteRule= constraint_results[7];
 
386
        }
 
387
        if (constraint_results[8].compare("") != 0)
 
388
        {
 
389
          if (constraint_results[9].compare("UPDATE") == 0)
 
390
            fkey->updateRule= constraint_results[10];
 
391
          else if (constraint_results[9].compare("DELETE") == 0)
 
392
            fkey->deleteRule= constraint_results[10];
 
393
        }
 
394
        fkey->matchOption= "";
 
395
 
 
396
        fkeys.push_back(fkey);
 
397
 
 
398
        start= constraint_results[0].second;
 
399
        flags |= boost::match_prev_avail; 
 
400
        flags |= boost::match_not_bob;
 
401
      }
 
402
    }
 
403
  }
 
404
  dcon->freeResult(result);
 
405
  return true;
 
406
}
 
407
 
 
408
void DrizzleDumpFieldMySQL::setType(const char* raw_type, const char* raw_collation)
 
409
{
 
410
  std::string old_type(raw_type);
 
411
  std::string extra;
 
412
  size_t pos;
 
413
  
 
414
  if ((pos= old_type.find("(")) != std::string::npos)
 
415
  {
 
416
    extra= old_type.substr(pos);
 
417
    old_type.erase(pos, std::string::npos);
 
418
  }
 
419
 
 
420
  std::transform(old_type.begin(), old_type.end(), old_type.begin(), ::toupper);
 
421
  if ((old_type.find("CHAR") != std::string::npos) or 
 
422
    (old_type.find("TEXT") != std::string::npos))
 
423
    setCollate(raw_collation);
 
424
 
 
425
  if ((old_type.compare("INT") == 0) and 
 
426
    ((extra.find("unsigned") != std::string::npos)))
 
427
  {
 
428
    type= "BIGINT";
 
429
    return;
 
430
  }
 
431
    
 
432
  if ((old_type.compare("TINYINT") == 0) or
 
433
    (old_type.compare("SMALLINT") == 0) or
 
434
    (old_type.compare("MEDIUMINT") == 0))
 
435
  {
 
436
    type= "INT";
 
437
    return;
 
438
  }
 
439
 
 
440
  if ((old_type.compare("TINYBLOB") == 0) or
 
441
    (old_type.compare("MEDIUMBLOB") == 0) or
 
442
    (old_type.compare("LONGBLOB") == 0))
 
443
  {
 
444
    type= "BLOB";
 
445
    return;
 
446
  }
 
447
 
 
448
  if ((old_type.compare("TINYTEXT") == 0) or
 
449
    (old_type.compare("MEDIUMTEXT") == 0) or
 
450
    (old_type.compare("LONGTEXT") == 0) or
 
451
    (old_type.compare("SET") == 0))
 
452
  {
 
453
    type= "TEXT";
 
454
    return;
 
455
  }
 
456
 
 
457
  if (old_type.compare("CHAR") == 0)
 
458
  {
 
459
    type= "VARCHAR";
 
460
    return;
 
461
  }
 
462
 
 
463
  if (old_type.compare("BINARY") == 0)
 
464
  {
 
465
    type= "VARBINARY";
 
466
    return;
 
467
  }
 
468
 
 
469
  if (old_type.compare("ENUM") == 0)
 
470
  {
 
471
    type= old_type;
 
472
    /* Strip out the braces, we add them again during output */
 
473
    enumValues= extra.substr(1, extra.length()-2);
 
474
    return;
 
475
  }
 
476
 
 
477
  if ((old_type.find("TIME") != std::string::npos) or
 
478
    (old_type.find("DATE") != std::string::npos))
 
479
  {
 
480
    /* Intended to catch TIME/DATE/TIMESTAMP/DATETIME 
 
481
       We may have a default TIME/DATE which needs converting */
 
482
    convertDateTime= true;
 
483
  }
 
484
 
 
485
  if ((old_type.compare("TIME") == 0) or (old_type.compare("YEAR") == 0))
 
486
  {
 
487
    type= "INT";
 
488
    return;
 
489
  }
 
490
 
 
491
  if (old_type.compare("FLOAT") == 0)
 
492
  {
 
493
    type= "DOUBLE";
 
494
    return;
 
495
  }
 
496
 
 
497
  type= old_type;
 
498
  return;
 
499
}
 
500
 
 
501
void DrizzleDumpTableMySQL::setEngine(const char* newEngine)
 
502
{
 
503
  if (strcmp(newEngine, "MyISAM") == 0)
 
504
    engineName= "InnoDB";
 
505
  else
 
506
    engineName= newEngine; 
 
507
}
 
508
 
 
509
DrizzleDumpData* DrizzleDumpTableMySQL::getData(void)
 
510
{
 
511
  try
 
512
  {
 
513
    return new DrizzleDumpDataMySQL(this, dcon);
 
514
  }
 
515
  catch(...)
 
516
  {
 
517
    return NULL;
 
518
  }
 
519
}
 
520
 
 
521
void DrizzleDumpDatabaseMySQL::setCollate(const char* newCollate)
 
522
{
 
523
  if (newCollate)
 
524
  {
 
525
    std::string tmpCollate(newCollate);
 
526
    if (tmpCollate.find("utf8") != std::string::npos)
 
527
    {
 
528
      collate= tmpCollate;
 
529
      return;
 
530
    }
 
531
  }
 
532
  collate= "utf8_general_ci";
 
533
}
 
534
 
 
535
void DrizzleDumpTableMySQL::setCollate(const char* newCollate)
 
536
{
 
537
  if (newCollate)
 
538
  {
 
539
    std::string tmpCollate(newCollate);
 
540
    if (tmpCollate.find("utf8") != std::string::npos)
 
541
    {
 
542
      collate= tmpCollate;
 
543
      return;
 
544
    }
 
545
  }
 
546
 
 
547
  collate= "utf8_general_ci";
 
548
}
 
549
 
 
550
void DrizzleDumpFieldMySQL::setCollate(const char* newCollate)
 
551
{
 
552
  if (newCollate)
 
553
  {
 
554
    std::string tmpCollate(newCollate);
 
555
    if (tmpCollate.find("utf8") != std::string::npos)
 
556
    {
 
557
      collation= tmpCollate;
 
558
      return;
 
559
    }
 
560
  }
 
561
  collation= "utf8_general_ci";
 
562
}
 
563
 
 
564
DrizzleDumpDataMySQL::DrizzleDumpDataMySQL(DrizzleDumpTable *dataTable,
 
565
  DrizzleDumpConnection *connection)
 
566
  : DrizzleDumpData(dataTable, connection)
 
567
{
 
568
  std::string query;
 
569
  query= "SELECT * FROM `";
 
570
  query.append(table->displayName);
 
571
  query.append("`");
 
572
 
 
573
  result= dcon->query(query);
 
574
  if (result == NULL)
 
575
    throw 1;
 
576
}
 
577
 
 
578
DrizzleDumpDataMySQL::~DrizzleDumpDataMySQL()
 
579
{
 
580
  drizzle_result_free(result);
 
581
  delete result;
 
582
}
 
583
 
 
584
long DrizzleDumpDataMySQL::convertTime(const char* oldTime) const
 
585
{
 
586
  std::string ts(oldTime);
 
587
  boost::posix_time::time_duration td(boost::posix_time::duration_from_string(ts));
 
588
  long seconds= td.total_seconds();
 
589
  return seconds;
 
590
}
 
591
 
 
592
std::string DrizzleDumpDataMySQL::convertDate(const char* oldDate) const
 
593
{
 
594
  boost::match_flag_type flags = boost::match_default;
 
595
  std::string output;
 
596
  boost::regex date_regex("(0000|-00)");
 
597
 
 
598
  if (not regex_search(oldDate, date_regex, flags))
 
599
  {
 
600
    output.push_back('\'');
 
601
    output.append(oldDate);
 
602
    output.push_back('\'');
 
603
  }
 
604
  else
 
605
    output= "NULL";
 
606
 
 
607
  return output;
 
608
}
 
609
 
 
610
std::string DrizzleDumpDataMySQL::checkDateTime(const char* item, uint32_t field) const
 
611
{
 
612
  std::string ret;
 
613
 
 
614
  if (table->fields[field]->convertDateTime)
 
615
  {
 
616
    if (table->fields[field]->type.compare("INT") == 0)
 
617
      ret= boost::lexical_cast<std::string>(convertTime(item));
 
618
    else
 
619
      ret= convertDate(item);
 
620
  }
 
621
  return ret;
 
622
}
 
623