~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump_data.cc

  • Committer: Brian Aker
  • Date: 2010-11-04 20:51:35 UTC
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: brian@tangent.org-20101104205135-vci0i54v1d0loai8
Merge of partial set of patches for locks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
166
166
  if (not obj.defaultValue.empty())
167
167
  {
168
168
    if (obj.defaultValue.compare("CURRENT_TIMESTAMP") != 0)
169
 
    {
170
 
      if (obj.defaultValue.compare(0, 2, "b'") == 0)
171
 
      {
172
 
        os << " DEFAULT " << obj.defaultValue;
173
 
      }
174
 
      else
175
 
      {
176
 
        os << " DEFAULT '" << obj.defaultValue << "'";
177
 
      }
178
 
    }
 
169
     os << " DEFAULT '" << obj.defaultValue << "'";
179
170
    else
180
 
    {
181
171
     os << " DEFAULT CURRENT_TIMESTAMP";
182
 
    }
183
172
  }
184
173
  else if ((obj.defaultIsNull))
185
174
  {
186
175
    os << " DEFAULT NULL";
187
176
  }
188
177
 
189
 
  if (not obj.comment.empty())
190
 
  {
191
 
    os << " COMMENT '" << DrizzleDumpData::escape(obj.comment.c_str(), obj.comment.length()) << "'";
192
 
  }
193
 
 
194
178
  return os;
195
179
}
196
180
 
335
319
      if (not row[i])
336
320
      {
337
321
        os << "NULL";
338
 
        if (i != obj.table->fields.size() - 1)
339
 
          os << ",";
340
 
        continue;
341
 
      }
342
 
 
343
 
      if ((obj.table->fields[i]->rangeCheck) and
344
 
        (obj.table->fields[i]->type.compare("BIGINT") == 0) and
345
 
        (boost::lexical_cast<uint64_t>(row[i]) > INT64_MAX))
346
 
      {
347
 
        std::cerr << "Error: Data for column " << obj.table->fields[i]->fieldName << " is greater than max BIGINT, cannot migrate automatically" << std::endl;
348
 
        if (not ignore_errors)
349
 
          maybe_exit(EX_DRIZZLEERR);
350
 
        else
351
 
          continue;
352
 
      }
353
 
 
 
322
      }
354
323
      /* time/date conversion for MySQL connections */
355
324
      else if (obj.table->fields[i]->convertDateTime)
356
325
      {
358
327
      }
359
328
      else
360
329
      {
361
 
        if ((obj.table->fields[i]->type.compare("INT") != 0) and
362
 
          (obj.table->fields[i]->type.compare("BIGINT") != 0))
 
330
        if (obj.table->fields[i]->type.compare("INT") != 0)
363
331
        {
364
332
          /* Hex blob processing or escape text */
365
333
          if (((obj.table->fields[i]->type.compare("BLOB") == 0) or
373
341
          {
374
342
            os << "NULL";
375
343
          }
376
 
          else if (obj.table->fields[i]->type.compare("BOOLEAN") == 0)
377
 
          {
378
 
            if (strncmp(row[i], "1", 1) == 0)
379
 
              os << "TRUE";
380
 
            else
381
 
              os << "FALSE";
382
 
          }
383
344
          else
384
345
            os << "'" << DrizzleDumpData::escape(row[i], row_sizes[i]) << "'";
385
346
          byte_counter+= 3;
565
526
  if (ret != DRIZZLE_RETURN_OK)
566
527
  {
567
528
    errorHandler(NULL, ret, "when trying to connect");
568
 
    throw std::exception();
 
529
    throw 1;
569
530
  }
570
531
 
571
 
  ServerDetect server_detect= ServerDetect(&connection);
572
 
 
573
 
  serverType= server_detect.getServerType();
574
 
  serverVersion= server_detect.getServerVersion();
 
532
  boost::match_flag_type flags = boost::match_default; 
 
533
 
 
534
  boost::regex mysql_regex("(5\\.[0-9]+\\.[0-9]+)");
 
535
  boost::regex drizzle_regex("(20[0-9]{2}\\.(0[1-9]|1[012])\\.[0-9]+)");
 
536
 
 
537
  std::string version(getServerVersion());
 
538
 
 
539
  if (regex_search(version, mysql_regex, flags))
 
540
    serverType= SERVER_MYSQL_FOUND;
 
541
  else if (regex_search(version, drizzle_regex, flags))
 
542
    serverType= SERVER_DRIZZLE_FOUND;
 
543
  else
 
544
    serverType= SERVER_UNKNOWN_FOUND;
575
545
}
576
546
 
577
547
drizzle_result_st* DrizzleDumpConnection::query(std::string &str_query)