~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_table.cc

  • Committer: Monty Taylor
  • Date: 2009-05-08 19:27:21 UTC
  • mto: This revision was merged to the branch mainline in revision 1009.
  • Revision ID: mordred@inaugust.com-20090508192721-glbsg850k7wqp1rd
Further reversion of P.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3165
3165
  uint32_t flags= alter_info->flags;
3166
3166
 
3167
3167
  if (ALTER_ADD_COLUMN & flags)
3168
 
    alter_flags->set(HA_ADD_COLUMN);
 
3168
    *alter_flags|= HA_ADD_COLUMN;
3169
3169
  if (ALTER_DROP_COLUMN & flags)
3170
 
    alter_flags->set(HA_DROP_COLUMN);
 
3170
    *alter_flags|= HA_DROP_COLUMN;
3171
3171
  if (ALTER_RENAME & flags)
3172
 
    alter_flags->set(HA_RENAME_TABLE);
 
3172
    *alter_flags|= HA_RENAME_TABLE;
3173
3173
  if (ALTER_CHANGE_COLUMN & flags)
3174
 
    alter_flags->set(HA_CHANGE_COLUMN);
 
3174
    *alter_flags|= HA_CHANGE_COLUMN;
3175
3175
  if (ALTER_COLUMN_DEFAULT & flags)
3176
 
    alter_flags->set(HA_COLUMN_DEFAULT_VALUE);
 
3176
    *alter_flags|= HA_COLUMN_DEFAULT_VALUE;
3177
3177
  if (ALTER_COLUMN_STORAGE & flags)
3178
 
    alter_flags->set(HA_COLUMN_STORAGE);
 
3178
    *alter_flags|= HA_COLUMN_STORAGE;
3179
3179
  if (ALTER_COLUMN_FORMAT & flags)
3180
 
    alter_flags->set(HA_COLUMN_FORMAT);
 
3180
    *alter_flags|= HA_COLUMN_FORMAT;
3181
3181
  if (ALTER_COLUMN_ORDER & flags)
3182
 
    alter_flags->set(HA_ALTER_COLUMN_ORDER);
 
3182
    *alter_flags|= HA_ALTER_COLUMN_ORDER;
3183
3183
  if (ALTER_STORAGE & flags)
3184
 
    alter_flags->set(HA_ALTER_STORAGE);
 
3184
    *alter_flags|= HA_ALTER_STORAGE;
3185
3185
  if (ALTER_ROW_FORMAT & flags)
3186
 
    alter_flags->set(HA_ALTER_ROW_FORMAT);
 
3186
    *alter_flags|= HA_ALTER_ROW_FORMAT;
3187
3187
  if (ALTER_RECREATE & flags)
3188
 
    alter_flags->set(HA_RECREATE);
 
3188
    *alter_flags|= HA_RECREATE;
3189
3189
  if (ALTER_FOREIGN_KEY & flags)
3190
 
    alter_flags->set(HA_ALTER_FOREIGN_KEY);
 
3190
    *alter_flags|= HA_ALTER_FOREIGN_KEY;
3191
3191
}
3192
3192
 
3193
3193
 
3326
3326
      Check what has changed and set alter_flags
3327
3327
    */
3328
3328
    if (table->s->fields < alter_info->create_list.elements)
3329
 
      alter_flags->set(HA_ADD_COLUMN);
 
3329
      *alter_flags|= HA_ADD_COLUMN;
3330
3330
    else if (table->s->fields > alter_info->create_list.elements)
3331
 
      alter_flags->set(HA_DROP_COLUMN);
 
3331
      *alter_flags|= HA_DROP_COLUMN;
3332
3332
    if (create_info->db_type != table->s->db_type() ||
3333
3333
        create_info->used_fields & HA_CREATE_USED_ENGINE)
3334
 
      alter_flags->set(HA_ALTER_STORAGE_ENGINE);
 
3334
      *alter_flags|= HA_ALTER_STORAGE_ENGINE;
3335
3335
    if (create_info->used_fields & HA_CREATE_USED_CHARSET)
3336
 
      alter_flags->set(HA_CHANGE_CHARACTER_SET);
 
3336
      *alter_flags|= HA_CHANGE_CHARACTER_SET;
3337
3337
    if (create_info->used_fields & HA_CREATE_USED_DEFAULT_CHARSET)
3338
 
      alter_flags->set(HA_SET_DEFAULT_CHARACTER_SET);
 
3338
      *alter_flags|= HA_SET_DEFAULT_CHARACTER_SET;
3339
3339
    if (alter_info->flags & ALTER_RECREATE)
3340
 
      alter_flags->set(HA_RECREATE);
 
3340
      *alter_flags|= HA_RECREATE;
3341
3341
    /* TODO check for ADD/DROP FOREIGN KEY */
3342
3342
    if (alter_info->flags & ALTER_FOREIGN_KEY)
3343
 
      alter_flags->set(HA_ALTER_FOREIGN_KEY);
 
3343
      *alter_flags|=  HA_ALTER_FOREIGN_KEY;
3344
3344
  }
3345
3345
  /*
3346
3346
    Go through fields and check if the original ones are compatible
3365
3365
    {
3366
3366
      /* Evaluate changes bitmap and send to check_if_incompatible_data() */
3367
3367
      if (!(table_changes_local= field->is_equal(new_field)))
3368
 
        alter_flags->set(HA_ALTER_COLUMN_TYPE);
 
3368
        *alter_flags|= HA_ALTER_COLUMN_TYPE;
3369
3369
 
3370
3370
      /* Check if field was renamed */
3371
3371
      field->flags&= ~FIELD_IS_RENAMED;
3374
3374
                        new_field->field_name))
3375
3375
      {
3376
3376
        field->flags|= FIELD_IS_RENAMED;
3377
 
        alter_flags->set(HA_ALTER_COLUMN_NAME);
 
3377
        *alter_flags|= HA_ALTER_COLUMN_NAME;
3378
3378
      }
3379
3379
 
3380
3380
      *table_changes&= table_changes_local;
3381
3381
      if (table_changes_local == IS_EQUAL_PACK_LENGTH)
3382
 
        alter_flags->set(HA_ALTER_COLUMN_TYPE);
 
3382
        *alter_flags|= HA_ALTER_COLUMN_TYPE;
3383
3383
 
3384
3384
      /* Check that NULL behavior is same for old and new fields */
3385
3385
      if ((new_field->flags & NOT_NULL_FLAG) !=
3386
3386
          (uint32_t) (field->flags & NOT_NULL_FLAG))
3387
3387
      {
3388
3388
        *table_changes= IS_EQUAL_NO;
3389
 
        alter_flags->set(HA_ALTER_COLUMN_NULLABLE);
 
3389
        *alter_flags|= HA_ALTER_COLUMN_NULLABLE;
3390
3390
      }
3391
3391
    }
3392
3392
 
3433
3433
      {
3434
3434
        /* Unique key. Check for "PRIMARY". */
3435
3435
        if (is_primary_key(table_key))
3436
 
          alter_flags->set(HA_DROP_PK_INDEX);
 
3436
          *alter_flags|= HA_DROP_PK_INDEX;
3437
3437
        else
3438
 
          alter_flags->set(HA_DROP_UNIQUE_INDEX);
 
3438
          *alter_flags|= HA_DROP_UNIQUE_INDEX;
3439
3439
      }
3440
3440
      else
3441
 
        alter_flags->set(HA_DROP_INDEX);
 
3441
        *alter_flags|= HA_DROP_INDEX;
3442
3442
      *table_changes= IS_EQUAL_NO;
3443
3443
      continue;
3444
3444
    }
3453
3453
      {
3454
3454
        // Unique key. Check for "PRIMARY".
3455
3455
        if (is_primary_key(table_key))
3456
 
          alter_flags->set(HA_ALTER_PK_INDEX);
 
3456
          *alter_flags|= HA_ALTER_PK_INDEX;
3457
3457
        else
3458
 
          alter_flags->set(HA_ALTER_UNIQUE_INDEX);
 
3458
          *alter_flags|= HA_ALTER_UNIQUE_INDEX;
3459
3459
      }
3460
3460
      else
3461
 
        alter_flags->set(HA_ALTER_INDEX);
 
3461
        *alter_flags|= HA_ALTER_INDEX;
3462
3462
      goto index_changed;
3463
3463
    }
3464
3464
 
3482
3482
        {
3483
3483
          /* Unique key. Check for "PRIMARY" */
3484
3484
          if (is_primary_key(table_key))
3485
 
            alter_flags->set(HA_ALTER_PK_INDEX);
 
3485
            *alter_flags|= HA_ALTER_PK_INDEX;
3486
3486
          else
3487
 
            alter_flags->set(HA_ALTER_UNIQUE_INDEX);
 
3487
            *alter_flags|= HA_ALTER_UNIQUE_INDEX;
3488
3488
        }
3489
3489
        else
3490
 
          alter_flags->set(HA_ALTER_INDEX);
 
3490
          *alter_flags|= HA_ALTER_INDEX;
3491
3491
        goto index_changed;
3492
3492
      }
3493
3493
    }
3544
3544
      {
3545
3545
        /* Unique key. Check for "PRIMARY" */
3546
3546
        if (is_primary_key(new_key))
3547
 
          alter_flags->set(HA_ADD_PK_INDEX);
 
3547
          *alter_flags|= HA_ADD_PK_INDEX;
3548
3548
        else
3549
 
        alter_flags->set(HA_ADD_UNIQUE_INDEX);
 
3549
        *alter_flags|= HA_ADD_UNIQUE_INDEX;
3550
3550
      }
3551
3551
      else
3552
 
        alter_flags->set(HA_ADD_INDEX);
 
3552
        *alter_flags|= HA_ADD_INDEX;
3553
3553
      *table_changes= IS_EQUAL_NO;
3554
3554
    }
3555
3555
  }
4643
4643
      can do the change on-line
4644
4644
    */
4645
4645
    if (new_name == table_name && new_db == db &&
4646
 
        ha_alter_flags.any())
 
4646
        ha_alter_flags.is_set())
4647
4647
    {
4648
4648
      Alter_info tmp_alter_info(*alter_info, session->mem_root);
4649
4649