~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/alter_table.cc

  • Committer: Brian Aker
  • Date: 2011-01-12 20:53:05 UTC
  • mto: This revision was merged to the branch mainline in revision 2081.
  • Revision ID: brian@tangent.org-20110112205305-nlxgrqyr7fh4egoc
style cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
259
259
  message::Table::TableOptions *table_options;
260
260
  table_options= table_message.mutable_options();
261
261
 
262
 
  if (! (used_fields & HA_CREATE_USED_DEFAULT_CHARSET))
 
262
  if (not (used_fields & HA_CREATE_USED_DEFAULT_CHARSET))
263
263
    create_info->default_table_charset= table->getShare()->table_charset;
264
 
  if (! (used_fields & HA_CREATE_USED_AUTO) &&
265
 
      table->found_next_number_field)
 
264
 
 
265
  if (not (used_fields & HA_CREATE_USED_AUTO) && table->found_next_number_field)
266
266
  {
267
267
    /* Table has an autoincrement, copy value to new table */
268
268
    table->cursor->info(HA_STATUS_AUTO);
270
270
    if (create_info->auto_increment_value != original_proto.options().auto_increment_value())
271
271
      table_options->set_has_user_set_auto_increment_value(false);
272
272
  }
 
273
 
273
274
  table->restoreRecordAsDefault(); /* Empty record for DEFAULT */
274
275
  CreateField *def;
275
276
 
390
391
    {
391
392
      CreateField *find;
392
393
      find_it.rewind();
 
394
 
393
395
      while ((find= find_it++)) /* Add new columns */
394
396
      {
395
 
        if (! my_strcasecmp(system_charset_info,def->after, find->field_name))
 
397
        if (not my_strcasecmp(system_charset_info,def->after, find->field_name))
396
398
          break;
397
399
      }
398
 
      if (! find)
 
400
 
 
401
      if (not find)
399
402
      {
400
403
        my_error(ER_BAD_FIELD_ERROR, MYF(0), def->after, table->getMutableShare()->getTableName());
401
404
        return true;
402
405
      }
 
406
 
403
407
      find_it.after(def); /* Put element after this */
 
408
 
404
409
      /*
405
410
        XXX: hack for Bug#28427.
406
411
        If column order has changed, force OFFLINE ALTER Table
416
421
        my_error(ER_NOT_SUPPORTED_YET, MYF(0), session->getQueryString()->c_str());
417
422
        return true;
418
423
      }
 
424
 
419
425
      alter_info->build_method= HA_BUILD_OFFLINE;
420
426
    }
421
427
  }
429
435
    return true;
430
436
  }
431
437
 
432
 
  if (! new_create_list.elements)
 
438
  if (not new_create_list.elements)
433
439
  {
434
440
    my_message(ER_CANT_REMOVE_ALL_FIELDS,
435
441
               ER(ER_CANT_REMOVE_ALL_FIELDS),
445
451
  {
446
452
    char *key_name= key_info->name;
447
453
    AlterDrop *drop;
 
454
 
448
455
    drop_it.rewind();
449
456
    while ((drop= drop_it++))
450
457
    {
452
459
          ! my_strcasecmp(system_charset_info, key_name, drop->name))
453
460
        break;
454
461
    }
 
462
 
455
463
    if (drop)
456
464
    {
457
465
      drop_it.remove();
472
480
      {
473
481
        if (cfield->change)
474
482
        {
475
 
          if (! my_strcasecmp(system_charset_info, key_part_name, cfield->change))
 
483
          if (not my_strcasecmp(system_charset_info, key_part_name, cfield->change))
476
484
            break;
477
485
        }
478
 
        else if (! my_strcasecmp(system_charset_info, key_part_name, cfield->field_name))
 
486
        else if (not my_strcasecmp(system_charset_info, key_part_name, cfield->field_name))
479
487
          break;
480
488
      }
481
 
      if (! cfield)
 
489
 
 
490
      if (not cfield)
482
491
              continue; /* Field is removed */
483
492
      
484
493
      uint32_t key_part_length= key_part->length;
510
519
    }
511
520
    if (key_parts.elements)
512
521
    {
513
 
      KEY_CREATE_INFO key_create_info;
 
522
      key_create_information_st key_create_info;
514
523
      Key *key;
515
524
      enum Key::Keytype key_type;
516
525
      memset(&key_create_info, 0, sizeof(key_create_info));
815
824
 
816
825
      if (not name_lock)
817
826
      {
818
 
        std::string path;
819
 
        new_table_identifier.getSQLPath(path);
820
 
        my_error(ER_TABLE_EXISTS_ERROR, MYF(0), path.c_str());
 
827
        my_error(ER_TABLE_EXISTS_ERROR, new_table_identifier);
821
828
        return false;
822
829
      }
823
830
 
824
831
      if (plugin::StorageEngine::doesTableExist(session, new_table_identifier))
825
832
      {
826
 
        std::string path;
827
 
        new_table_identifier.getSQLPath(path);
828
 
 
829
833
        /* Table will be closed by Session::executeCommand() */
830
 
        my_error(ER_TABLE_EXISTS_ERROR, MYF(0), path.c_str());
 
834
        my_error(ER_TABLE_EXISTS_ERROR, new_table_identifier);
831
835
 
832
 
        table::Cache::singleton().mutex().lock(); /* ALTER TABLe */
833
 
        session.unlink_open_table(name_lock);
834
 
        table::Cache::singleton().mutex().unlock();
 
836
        {
 
837
          boost::mutex::scoped_lock scopedLock(table::Cache::singleton().mutex());
 
838
          session.unlink_open_table(name_lock);
 
839
        }
835
840
 
836
841
        return false;
837
842
      }