3165
3165
uint32_t flags= alter_info->flags;
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;
3326
3326
Check what has changed and set alter_flags
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;
3346
3346
Go through fields and check if the original ones are compatible
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;
3370
3370
/* Check if field was renamed */
3371
3371
field->flags&= ~FIELD_IS_RENAMED;
3374
3374
new_field->field_name))
3376
3376
field->flags|= FIELD_IS_RENAMED;
3377
alter_flags->set(HA_ALTER_COLUMN_NAME);
3377
*alter_flags|= HA_ALTER_COLUMN_NAME;
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;
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))
3388
3388
*table_changes= IS_EQUAL_NO;
3389
alter_flags->set(HA_ALTER_COLUMN_NULLABLE);
3389
*alter_flags|= HA_ALTER_COLUMN_NULLABLE;
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;
3438
alter_flags->set(HA_DROP_UNIQUE_INDEX);
3438
*alter_flags|= HA_DROP_UNIQUE_INDEX;
3441
alter_flags->set(HA_DROP_INDEX);
3441
*alter_flags|= HA_DROP_INDEX;
3442
3442
*table_changes= IS_EQUAL_NO;
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;
3458
alter_flags->set(HA_ALTER_UNIQUE_INDEX);
3458
*alter_flags|= HA_ALTER_UNIQUE_INDEX;
3461
alter_flags->set(HA_ALTER_INDEX);
3461
*alter_flags|= HA_ALTER_INDEX;
3462
3462
goto index_changed;
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;
3487
alter_flags->set(HA_ALTER_UNIQUE_INDEX);
3487
*alter_flags|= HA_ALTER_UNIQUE_INDEX;
3490
alter_flags->set(HA_ALTER_INDEX);
3490
*alter_flags|= HA_ALTER_INDEX;
3491
3491
goto index_changed;
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;
3549
alter_flags->set(HA_ADD_UNIQUE_INDEX);
3549
*alter_flags|= HA_ADD_UNIQUE_INDEX;
3552
alter_flags->set(HA_ADD_INDEX);
3552
*alter_flags|= HA_ADD_INDEX;
3553
3553
*table_changes= IS_EQUAL_NO;