~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump_data.cc

  • Committer: Brian Aker
  • Date: 2010-10-20 20:25:52 UTC
  • mto: (1864.2.1 merge)
  • mto: This revision was merged to the branch mainline in revision 1865.
  • Revision ID: brian@tangent.org-20101020202552-51y5sz5ledoxbp7t
Add support for --with-valgrind

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 "client_priv.h"
 
22
#include <drizzled/gettext.h>
 
23
#include <string>
 
24
#include <iostream>
 
25
#include <boost/regex.hpp>
 
26
#include <boost/unordered_set.hpp>
 
27
 
 
28
#define EX_DRIZZLEERR 2
 
29
 
 
30
extern bool opt_no_create_info;
 
31
extern bool opt_no_data;
 
32
extern bool opt_create_db;
 
33
extern bool opt_disable_keys;
 
34
extern bool extended_insert;
 
35
extern bool opt_replace_into;
 
36
extern bool opt_drop;
 
37
extern bool verbose;
 
38
extern bool opt_databases;
 
39
extern bool opt_alldbs;
 
40
extern uint32_t show_progress_size;
 
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;
 
46
 
 
47
extern boost::unordered_set<std::string> ignore_table;
 
48
extern void maybe_exit(int error);
 
49
 
 
50
enum destinations {
 
51
  DESTINATION_DB,
 
52
  DESTINATION_FILES,
 
53
  DESTINATION_STDOUT
 
54
};
 
55
 
 
56
extern int opt_destination;
 
57
 
 
58
/* returns true on keep, false on ignore */
 
59
bool DrizzleDumpDatabase::ignoreTable(std::string tableName)
 
60
{
 
61
  std::string dbTable(databaseName);
 
62
  dbTable.append(".");
 
63
  dbTable.append(tableName);
 
64
 
 
65
  boost::unordered_set<std::string>::iterator iter= ignore_table.find(dbTable);
 
66
  return (iter == ignore_table.end());
 
67
}
 
68
 
 
69
void DrizzleDumpDatabase::cleanTableName(std::string &tableName)
 
70
{
 
71
  std::string replace("``");
 
72
  std::string find("`");
 
73
  size_t j = 0;
 
74
  for (;(j = tableName.find(find, j)) != std::string::npos;)
 
75
  {
 
76
    tableName.replace(j, find.length(), replace);
 
77
    j+= replace.length();
 
78
  }
 
79
 
 
80
}
 
81
 
 
82
std::ostream& operator <<(std::ostream &os, const DrizzleDumpForeignKey &obj)
 
83
{
 
84
  os << "  CONSTRAINT `" << obj.constraintName << "` FOREIGN KEY ("
 
85
    << obj.parentColumns << ") REFERENCES `" << obj.childTable << "` ("
 
86
    << obj.childColumns << ")";
 
87
 
 
88
  if (not obj.deleteRule.empty())
 
89
    os << " ON DELETE " << obj.deleteRule;
 
90
 
 
91
  if (not obj.updateRule.empty())
 
92
    os << " ON UPDATE " << obj.updateRule;
 
93
 
 
94
  return os;
 
95
}
 
96
 
 
97
std::ostream& operator <<(std::ostream &os, const DrizzleDumpIndex &obj)
 
98
{
 
99
  if (obj.isPrimary)
 
100
  {
 
101
    os << "  PRIMARY KEY ";
 
102
  }
 
103
  else if (obj.isUnique)
 
104
  {
 
105
    os << "  UNIQUE KEY `" << obj.indexName << "` ";
 
106
  }
 
107
  else
 
108
  {
 
109
    os << "  KEY `" << obj.indexName << "` ";
 
110
  }
 
111
 
 
112
  os << "(";
 
113
  
 
114
  std::vector<std::string>::iterator i;
 
115
  std::vector<std::string> fields = obj.columns;
 
116
  for (i= fields.begin(); i != fields.end(); ++i)
 
117
  {
 
118
    if (i != fields.begin())
 
119
      os << ",";
 
120
    std::string field= *i;
 
121
    os << "`" << field << "`";
 
122
    if (obj.length > 0)
 
123
      os << "(" << obj.length << ")";
 
124
  }
 
125
 
 
126
  os << ")";
 
127
 
 
128
  return os;
 
129
}
 
130
 
 
131
std::ostream& operator <<(std::ostream &os, const DrizzleDumpField &obj)
 
132
{
 
133
  os << "  `" << obj.fieldName << "` ";
 
134
  os << obj.type;
 
135
  if (((obj.type.compare("VARCHAR") == 0) or
 
136
   (obj.type.compare("VARBINARY") == 0)) and
 
137
   (obj.length > 0))
 
138
  {
 
139
    os << "(" << obj.length << ")";
 
140
  }
 
141
  else if (((obj.type.compare("DECIMAL") == 0) or
 
142
    (obj.type.compare("DOUBLE") == 0)) and
 
143
    ((obj.decimalPrecision + obj.decimalScale) > 0))
 
144
  {
 
145
    os << "(" << obj.decimalPrecision << "," << obj.decimalScale << ")";
 
146
  }
 
147
  else if (obj.type.compare("ENUM") == 0)
 
148
  {
 
149
    os << "(" << obj.enumValues << ")";
 
150
  }
 
151
 
 
152
  if (not obj.isNull)
 
153
  {
 
154
    os << " NOT NULL";
 
155
  }
 
156
 
 
157
  if ((not obj.collation.empty()) and (obj.collation.compare("binary") != 0))
 
158
  {
 
159
    os << " COLLATE " << obj.collation;
 
160
  }
 
161
 
 
162
  if (obj.isAutoIncrement)
 
163
    os << " AUTO_INCREMENT";
 
164
 
 
165
  if (not obj.defaultValue.empty())
 
166
  {
 
167
    if (obj.defaultValue.compare("CURRENT_TIMESTAMP") != 0)
 
168
     os << " DEFAULT '" << obj.defaultValue << "'";
 
169
    else
 
170
     os << " DEFAULT CURRENT_TIMESTAMP";
 
171
  }
 
172
  else if ((obj.defaultIsNull))
 
173
  {
 
174
    os << " DEFAULT NULL";
 
175
  }
 
176
 
 
177
  return os;
 
178
}
 
179
 
 
180
std::ostream& operator <<(std::ostream &os, const DrizzleDumpDatabase &obj)
 
181
{
 
182
  if ((opt_destination == DESTINATION_DB) or opt_databases or opt_alldbs)
 
183
  {
 
184
    if (verbose)
 
185
    {
 
186
      std::cerr << "--" << std::endl
 
187
        << "-- Current Database: `" << obj.databaseName << "`" << std::endl
 
188
        << "--" << std::endl << std::endl;
 
189
    }
 
190
 
 
191
    /* Love that this variable is the opposite of its name */
 
192
    if (not opt_create_db)
 
193
    {
 
194
      if (opt_drop_database)
 
195
        os << "DROP DATABASE IF EXISTS `" << obj.databaseName << "`" << std::endl;
 
196
 
 
197
      os << "CREATE DATABASE IF NOT EXISTS `" << obj.databaseName << "`";
 
198
      if (not obj.collate.empty())
 
199
       os << " COLLATE = " << obj.collate;
 
200
 
 
201
      os << ";" << std::endl << std::endl;
 
202
    }
 
203
 
 
204
    os << "USE `" << obj.databaseName << "`;" << std::endl << std::endl;
 
205
  }
 
206
 
 
207
  std::vector<DrizzleDumpTable*>::iterator i;
 
208
  std::vector<DrizzleDumpTable*> output_tables = obj.tables;
 
209
  for (i= output_tables.begin(); i != output_tables.end(); ++i)
 
210
  {
 
211
    DrizzleDumpTable *table= *i;
 
212
    if (not opt_no_create_info)
 
213
      os << *table;
 
214
    if (not opt_no_data)
 
215
    {
 
216
      obj.dcon->setDB(obj.databaseName);
 
217
      DrizzleDumpData *data= table->getData();
 
218
      if (data == NULL)
 
219
      {
 
220
        std::cerr << "Error: Could not get data for table " << table->displayName << std::endl;
 
221
        if (not ignore_errors)
 
222
          maybe_exit(EX_DRIZZLEERR);
 
223
        else
 
224
          continue;
 
225
      }
 
226
      os << *data;
 
227
      delete data;
 
228
    }
 
229
  }
 
230
 
 
231
  return os;
 
232
}
 
233
 
 
234
 
 
235
std::ostream& operator <<(std::ostream &os, const DrizzleDumpData &obj)
 
236
{
 
237
  bool new_insert= true;
 
238
  bool first= true;
 
239
  uint64_t rownr= 0;
 
240
  size_t byte_counter= 0;
 
241
 
 
242
  drizzle_row_t row;
 
243
 
 
244
  if (verbose)
 
245
    std::cerr << _("-- Retrieving data for ") << obj.table->displayName << "..." << std::endl;
 
246
 
 
247
  if (drizzle_result_row_count(obj.result) < 1)
 
248
  {
 
249
    if (verbose)
 
250
    {
 
251
      std::cerr << "--" << std::endl
 
252
        << "-- No data to dump for table `" << obj.table->displayName << "`"
 
253
        << std::endl << "--" << std::endl << std::endl;
 
254
    }
 
255
    return os;
 
256
  }
 
257
  else if (verbose)
 
258
  {
 
259
    std::cerr << "--" << std::endl
 
260
      << "-- Dumping data for table `" << obj.table->displayName << "`"
 
261
      << std::endl << "--" << std::endl << std::endl;
 
262
  }
 
263
  if (opt_disable_keys)
 
264
    os << "ALTER TABLE `" << obj.table->displayName << "` DISABLE KEYS;" << std::endl;
 
265
 
 
266
  /* Another option that does the opposite of its name, makes me sad :( */
 
267
  if (opt_autocommit)
 
268
    os << "START TRANSACTION;" << std::endl;
 
269
 
 
270
  std::streampos out_position= os.tellp();
 
271
 
 
272
  while((row= drizzle_row_next(obj.result)))
 
273
  {
 
274
    rownr++;
 
275
    if (verbose and (rownr % show_progress_size) == 0)
 
276
    {
 
277
      std::cerr << "-- " << rownr << _(" rows dumped for table ") << obj.table->displayName << std::endl;
 
278
    }
 
279
 
 
280
    size_t* row_sizes= drizzle_row_field_sizes(obj.result);
 
281
    for (uint32_t i= 0; i < drizzle_result_column_count(obj.result); i++)
 
282
      byte_counter+= row_sizes[i];
 
283
 
 
284
    if (not first and not new_insert)
 
285
    {
 
286
      if (extended_insert)
 
287
        os << "),(";
 
288
      else
 
289
        os << ");" << std::endl;
 
290
      byte_counter+= 3;
 
291
    }
 
292
    else
 
293
      first= false;
 
294
 
 
295
    if (new_insert)
 
296
    {
 
297
      if (opt_replace_into)
 
298
        os << "REPLACE ";
 
299
      else
 
300
      {
 
301
        os << "INSERT ";
 
302
        if (opt_ignore)
 
303
          os << "IGNORE ";
 
304
      }
 
305
      os << "INTO `" << obj.table->displayName << "` VALUES (";
 
306
      byte_counter+= 28 + obj.table->displayName.length();
 
307
      if (extended_insert)
 
308
        new_insert= false;
 
309
    }
 
310
    for (uint32_t i= 0; i < drizzle_result_column_count(obj.result); i++)
 
311
    {
 
312
      if (not row[i])
 
313
      {
 
314
        os << "NULL";
 
315
      }
 
316
      /* time/date conversion for MySQL connections */
 
317
      else if (obj.table->fields[i]->convertDateTime)
 
318
      {
 
319
        os << obj.checkDateTime(row[i], i);
 
320
      }
 
321
      else
 
322
      {
 
323
        if (obj.table->fields[i]->type.compare("INT") != 0)
 
324
        {
 
325
          /* Hex blob processing or escape text */
 
326
          if (((obj.table->fields[i]->type.compare("BLOB") == 0) or
 
327
            (obj.table->fields[i]->type.compare("VARBINARY") == 0)))
 
328
          {
 
329
            os << obj.convertHex((unsigned char*)row[i], row_sizes[i]);
 
330
            byte_counter+= row_sizes[i];
 
331
          }
 
332
          else
 
333
            os << "'" << DrizzleDumpData::escape(row[i], row_sizes[i]) << "'";
 
334
          byte_counter+= 3;
 
335
        }
 
336
        else
 
337
          os << row[i];
 
338
      }
 
339
      if (i != obj.table->fields.size() - 1)
 
340
        os << ",";
 
341
    }
 
342
    /* Break insert up if it is too long */
 
343
    if (extended_insert and
 
344
      (byte_counter >= DRIZZLE_MAX_LINE_LENGTH))
 
345
    {
 
346
      os << ");" << std::endl;
 
347
      new_insert= true;
 
348
      byte_counter= 0;
 
349
    }
 
350
  }
 
351
  os << ");" << std::endl;
 
352
 
 
353
  if (opt_autocommit)
 
354
    os << "COMMIT;" << std::endl;
 
355
 
 
356
  if (opt_disable_keys)
 
357
    os << "ALTER TABLE `" << obj.table->tableName << "` ENABLE KEYS;" << std::endl;
 
358
 
 
359
  os << std::endl;
 
360
 
 
361
  return os;
 
362
}
 
363
 
 
364
std::string DrizzleDumpData::convertHex(const unsigned char* from, size_t from_size) const
 
365
{
 
366
  std::ostringstream output;
 
367
  if (from_size > 0)
 
368
    output << "0x";
 
369
  while (from_size > 0)
 
370
  {
 
371
    /* Would be nice if std::hex liked uint8_t, ah well */
 
372
    output << std::uppercase << std::hex << std::setw(2) << std::setfill('0') << (unsigned short)(*from);
 
373
    (void) *from++;
 
374
    from_size--;
 
375
  }
 
376
 
 
377
  return output.str();
 
378
}
 
379
 
 
380
/* Ripped out of libdrizzle, hopefully a little safer */
 
381
std::string DrizzleDumpData::escape(const char* from, size_t from_size)
 
382
{
 
383
  std::string output;
 
384
 
 
385
  while (from_size > 0)
 
386
  {
 
387
    if (!(*from & 0x80))
 
388
    {
 
389
      switch (*from)
 
390
      {
 
391
         case 0:
 
392
           output.append("\\0");
 
393
           break;
 
394
         case '\n':
 
395
           output.append("\\n");
 
396
           break;
 
397
         case '\r':
 
398
           output.append("\\r");
 
399
           break;
 
400
         case '\\':
 
401
           output.append("\\\\");
 
402
           break;
 
403
         case '\'':
 
404
           output.append("\\'");
 
405
           break;
 
406
         case '"':
 
407
           output.append("\\\"");
 
408
           break;
 
409
         case '\032':
 
410
           output.append("\\Z");
 
411
           break;
 
412
         default:
 
413
           output.push_back(*from);
 
414
           break;
 
415
       }
 
416
    }
 
417
    else
 
418
      output.push_back(*from);
 
419
    (void) *from++;
 
420
    from_size--;
 
421
  }
 
422
 
 
423
  return output;
 
424
}
 
425
 
 
426
std::ostream& operator <<(std::ostream &os, const DrizzleDumpTable &obj)
 
427
{
 
428
  if (verbose)
 
429
  {
 
430
    std::cerr << "--" << std::endl
 
431
      << "-- Table structure for table `" << obj.displayName << "`" << std::endl
 
432
      << "--" << std::endl << std::endl;
 
433
  }
 
434
 
 
435
  if (opt_drop)
 
436
    os << "DROP TABLE IF EXISTS `" << obj.displayName <<  "`;" << std::endl;
 
437
 
 
438
  os << "CREATE TABLE `" << obj.displayName << "` (" << std::endl;
 
439
  std::vector<DrizzleDumpField*>::iterator i;
 
440
  std::vector<DrizzleDumpField*> output_fields = obj.fields;
 
441
  for (i= output_fields.begin(); i != output_fields.end(); ++i)
 
442
  {
 
443
    if (i != output_fields.begin())
 
444
      os << "," << std::endl;
 
445
    DrizzleDumpField *field= *i;
 
446
    os << *field;
 
447
  }
 
448
 
 
449
  std::vector<DrizzleDumpIndex*>::iterator j;
 
450
  std::vector<DrizzleDumpIndex*> output_indexes = obj.indexes;
 
451
  for (j= output_indexes.begin(); j != output_indexes.end(); ++j)
 
452
  {
 
453
    os << "," << std::endl;
 
454
    DrizzleDumpIndex *index= *j;
 
455
    os << *index;
 
456
  }
 
457
 
 
458
  std::vector<DrizzleDumpForeignKey*>::iterator k;
 
459
  std::vector<DrizzleDumpForeignKey*> output_fkeys = obj.fkeys;
 
460
  for (k= output_fkeys.begin(); k != output_fkeys.end(); ++k)
 
461
  {
 
462
    os << "," << std::endl;
 
463
    DrizzleDumpForeignKey *fkey= *k;
 
464
    os << *fkey;
 
465
  }
 
466
 
 
467
  os << std::endl;
 
468
  os << ") ENGINE=" << obj.engineName << " ";
 
469
  if (obj.autoIncrement > 0)
 
470
  {
 
471
    os << "AUTO_INCREMENT=" << obj.autoIncrement << " ";
 
472
  }
 
473
 
 
474
  os << "COLLATE = " << obj.collate;
 
475
 
 
476
  if (not obj.comment.empty())
 
477
  {
 
478
    os << " COMMENT = '" << obj.comment << "'";
 
479
  }
 
480
 
 
481
  os << ";" << std::endl << std::endl;
 
482
 
 
483
  return os;
 
484
}
 
485
 
 
486
DrizzleDumpConnection::DrizzleDumpConnection(std::string &host, uint16_t port, 
 
487
  std::string &username, std::string &password, bool drizzle_protocol) :
 
488
  hostName(host),
 
489
  drizzleProtocol(drizzle_protocol)
 
490
{
 
491
  drizzle_return_t ret;
 
492
 
 
493
  if (host.empty())
 
494
    host= "localhost";
 
495
 
 
496
  std::string protocol= (drizzle_protocol) ? "Drizzle" : "MySQL";
 
497
  if (verbose)
 
498
  {
 
499
    std::cerr << _("-- Connecting to ") << host  << _(" using protocol ")
 
500
      << protocol << "..." << std::endl;
 
501
  }
 
502
  drizzle_create(&drizzle);
 
503
  drizzle_con_create(&drizzle, &connection);
 
504
  drizzle_con_set_tcp(&connection, (char *)host.c_str(), port);
 
505
  drizzle_con_set_auth(&connection, (char *)username.c_str(),
 
506
    (char *)password.c_str());
 
507
  drizzle_con_add_options(&connection, 
 
508
    drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
 
509
  ret= drizzle_con_connect(&connection);
 
510
  if (ret != DRIZZLE_RETURN_OK)
 
511
  {
 
512
    errorHandler(NULL, ret, "when trying to connect");
 
513
    throw 1;
 
514
  }
 
515
 
 
516
  boost::match_flag_type flags = boost::match_default; 
 
517
 
 
518
  boost::regex mysql_regex("(5\\.[0-9]+\\.[0-9]+)");
 
519
  boost::regex drizzle_regex("(20[0-9]{2}\\.(0[1-9]|1[012])\\.[0-9]+)");
 
520
 
 
521
  std::string version(getServerVersion());
 
522
 
 
523
  if (regex_search(version, mysql_regex, flags))
 
524
    serverType= SERVER_MYSQL_FOUND;
 
525
  else if (regex_search(version, drizzle_regex, flags))
 
526
    serverType= SERVER_DRIZZLE_FOUND;
 
527
  else
 
528
    serverType= SERVER_UNKNOWN_FOUND;
 
529
}
 
530
 
 
531
drizzle_result_st* DrizzleDumpConnection::query(std::string &str_query)
 
532
{
 
533
  drizzle_return_t ret;
 
534
  drizzle_result_st* result= new drizzle_result_st;
 
535
  if (drizzle_query_str(&connection, result, str_query.c_str(), &ret) == NULL ||
 
536
      ret != DRIZZLE_RETURN_OK)
 
537
  {
 
538
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
 
539
    {
 
540
      std::cerr << _("Error executing query: ") <<
 
541
        drizzle_result_error(result) << std::endl;
 
542
      drizzle_result_free(result);
 
543
    }
 
544
    else
 
545
    {
 
546
      std::cerr << _("Error executing query: ") <<
 
547
        drizzle_con_error(&connection) << std::endl;
 
548
    }
 
549
    return NULL;
 
550
  }
 
551
 
 
552
  if (drizzle_result_buffer(result) != DRIZZLE_RETURN_OK)
 
553
  {
 
554
    std::cerr << _("Could not buffer result: ") <<
 
555
        drizzle_con_error(&connection) << std::endl;
 
556
    return NULL;
 
557
  }
 
558
  return result;
 
559
}
 
560
 
 
561
void DrizzleDumpConnection::freeResult(drizzle_result_st* result)
 
562
{
 
563
  drizzle_result_free(result);
 
564
  delete result;
 
565
}
 
566
 
 
567
bool DrizzleDumpConnection::queryNoResult(std::string &str_query)
 
568
{
 
569
  drizzle_return_t ret;
 
570
  drizzle_result_st result;
 
571
 
 
572
  if (drizzle_query_str(&connection, &result, str_query.c_str(), &ret) == NULL ||
 
573
      ret != DRIZZLE_RETURN_OK)
 
574
  {
 
575
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
 
576
    {
 
577
      std::cerr << _("Error executing query: ") <<
 
578
        drizzle_result_error(&result) << std::endl;
 
579
      drizzle_result_free(&result);
 
580
    }
 
581
    else
 
582
    {
 
583
      std::cerr << _("Error executing query: ") <<
 
584
        drizzle_con_error(&connection) << std::endl;
 
585
    }
 
586
    return false;
 
587
  }
 
588
 
 
589
  drizzle_result_free(&result);
 
590
  return true;
 
591
}
 
592
 
 
593
bool DrizzleDumpConnection::setDB(std::string databaseName)
 
594
{
 
595
  drizzle_return_t ret;
 
596
  drizzle_result_st result;
 
597
  if (drizzle_select_db(&connection, &result, databaseName.c_str(), &ret) == 
 
598
    NULL || ret != DRIZZLE_RETURN_OK)
 
599
  {
 
600
    std::cerr << _("Error: Could not set db '") << databaseName << "'" << std::endl;
 
601
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
 
602
      drizzle_result_free(&result);
 
603
    return false;
 
604
  }
 
605
  drizzle_result_free(&result);
 
606
  return true;
 
607
}
 
608
 
 
609
void DrizzleDumpConnection::errorHandler(drizzle_result_st *res,
 
610
  drizzle_return_t ret, const char *when)
 
611
{
 
612
  if (res == NULL)
 
613
  {
 
614
    std::cerr << _("Got error: ") << drizzle_con_error(&connection) << " "
 
615
      << when << std::endl;
 
616
  }
 
617
  else if (ret == DRIZZLE_RETURN_ERROR_CODE)
 
618
  {
 
619
    std::cerr << _("Got error: ") << drizzle_result_error(res)
 
620
      << " (" << drizzle_result_error_code(res) << ") " << when << std::endl;
 
621
    drizzle_result_free(res);
 
622
  }
 
623
  else
 
624
  {
 
625
    std::cerr << _("Got error: ") << ret << " " << when << std::endl;
 
626
  }
 
627
 
 
628
  return;
 
629
}
 
630
 
 
631
DrizzleDumpConnection::~DrizzleDumpConnection()
 
632
{
 
633
  if (verbose)
 
634
    std::cerr << _("-- Disconnecting from ") << hostName << "..." << std::endl;
 
635
  drizzle_con_free(&connection);
 
636
  drizzle_free(&drizzle);
 
637
}