185
185
table->found_next_number_field)
187
187
/* Table has an autoincrement, copy value to new table */
188
table->file->info(HA_STATUS_AUTO);
189
create_info->auto_increment_value= table->file->stats.auto_increment_value;
188
table->cursor->info(HA_STATUS_AUTO);
189
create_info->auto_increment_value= table->cursor->stats.auto_increment_value;
191
191
if (! (used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)
192
192
&& table->s->hasKeyBlockSize())
590
590
switch (keys_onoff) {
592
error= table->file->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
592
error= table->cursor->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
594
594
case LEAVE_AS_IS:
595
595
if (!indexes_were_disabled)
597
597
/* fall-through: disabled indexes */
599
error= table->file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
599
error= table->cursor->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
602
602
if (error == HA_ERR_WRONG_COMMAND)
808
808
new_db_type= create_info->db_type;
810
810
if (new_db_type != old_db_type &&
811
!table->file->can_switch_engines())
811
!table->cursor->can_switch_engines())
814
814
my_error(ER_ROW_IS_REFERENCED, MYF(0));
854
854
pthread_mutex_lock(&LOCK_open); /* DDL wait for/blocker */
855
855
wait_while_table_is_used(session, table, HA_EXTRA_FORCE_REOPEN);
856
856
pthread_mutex_unlock(&LOCK_open);
857
error= table->file->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
857
error= table->cursor->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
858
858
/* COND_refresh will be signaled in close_thread_tables() */
861
861
pthread_mutex_lock(&LOCK_open); /* DDL wait for/blocker */
862
862
wait_while_table_is_used(session, table, HA_EXTRA_FORCE_REOPEN);
863
863
pthread_mutex_unlock(&LOCK_open);
864
error=table->file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
864
error=table->cursor->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
865
865
/* COND_refresh will be signaled in close_thread_tables() */
1284
1284
if (!(copy= new CopyField[to->s->fields]))
1287
if (to->file->ha_external_lock(session, F_WRLCK))
1287
if (to->cursor->ha_external_lock(session, F_WRLCK))
1290
1290
/* We need external lock before we can disable/enable keys */
1291
alter_table_manage_keys(to, from->file->indexes_are_disabled(), keys_onoff);
1291
alter_table_manage_keys(to, from->cursor->indexes_are_disabled(), keys_onoff);
1293
1293
/* We can abort alter table for any table type */
1294
1294
session->abort_on_warning= !ignore;
1296
from->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
1297
to->file->ha_start_bulk_insert(from->file->stats.records);
1296
from->cursor->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
1297
to->cursor->ha_start_bulk_insert(from->cursor->stats.records);
1299
1299
List_iterator<CreateField> it(create);
1300
1300
CreateField *def;
1319
if (to->s->primary_key != MAX_KEY && to->file->primary_key_is_clustered())
1319
if (to->s->primary_key != MAX_KEY && to->cursor->primary_key_is_clustered())
1321
1321
char warn_buff[DRIZZLE_ERRMSG_SIZE];
1322
1322
snprintf(warn_buff, sizeof(warn_buff),
1353
1353
to->use_all_columns();
1354
1354
init_read_record(&info, session, from, (SQL_SELECT *) 0, 1,1);
1356
to->file->extra(HA_EXTRA_IGNORE_DUP_KEY);
1356
to->cursor->extra(HA_EXTRA_IGNORE_DUP_KEY);
1357
1357
session->row_count= 0;
1358
1358
to->restoreRecordAsDefault(); // Create empty record
1359
1359
while (!(error=info.read_record(&info)))
1384
1384
copy_ptr->do_copy(copy_ptr);
1386
prev_insert_id= to->file->next_insert_id;
1387
error=to->file->ha_write_row(to->record[0]);
1386
prev_insert_id= to->cursor->next_insert_id;
1387
error= to->cursor->ha_write_row(to->record[0]);
1388
1388
to->auto_increment_field_not_null= false;
1392
to->file->is_fatal_error(error, HA_CHECK_DUP))
1392
to->cursor->is_fatal_error(error, HA_CHECK_DUP))
1394
if (!to->file->is_fatal_error(error, HA_CHECK_DUP))
1396
uint32_t key_nr= to->file->get_dup_key(error);
1397
if ((int) key_nr >= 0)
1399
const char *err_msg= ER(ER_DUP_ENTRY_WITH_KEY_NAME);
1401
(to->key_info[0].key_part[0].field->flags &
1402
AUTO_INCREMENT_FLAG))
1403
err_msg= ER(ER_DUP_ENTRY_AUTOINCREMENT_CASE);
1404
to->file->print_keydup_error(key_nr, err_msg);
1394
if (!to->cursor->is_fatal_error(error, HA_CHECK_DUP))
1396
uint32_t key_nr= to->cursor->get_dup_key(error);
1397
if ((int) key_nr >= 0)
1399
const char *err_msg= ER(ER_DUP_ENTRY_WITH_KEY_NAME);
1401
(to->key_info[0].key_part[0].field->flags &
1402
AUTO_INCREMENT_FLAG))
1403
err_msg= ER(ER_DUP_ENTRY_AUTOINCREMENT_CASE);
1404
to->cursor->print_keydup_error(key_nr, err_msg);
1409
to->file->print_error(error,MYF(0));
1409
to->cursor->print_error(error,MYF(0));
1412
to->file->restore_auto_increment(prev_insert_id);
1412
to->cursor->restore_auto_increment(prev_insert_id);
1413
1413
delete_count++;
1419
1419
from->free_io_cache();
1420
1420
delete [] copy; // This is never 0
1422
if (to->file->ha_end_bulk_insert() && error <= 0)
1422
if (to->cursor->ha_end_bulk_insert() && error <= 0)
1424
to->file->print_error(my_errno,MYF(0));
1424
to->cursor->print_error(my_errno,MYF(0));
1427
to->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
1427
to->cursor->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
1429
1429
if (ha_enable_transaction(session, true))
1446
1446
from->free_io_cache();
1447
1447
*copied= found_count;
1448
1448
*deleted=delete_count;
1449
to->file->ha_release_auto_increment();
1450
if (to->file->ha_external_lock(session,F_UNLCK))
1449
to->cursor->ha_release_auto_increment();
1450
if (to->cursor->ha_external_lock(session,F_UNLCK))
1452
1452
return(error > 0 ? -1 : 0);
1514
1514
if (mysql_prepare_create_table(session, &local_create_info, table_proto,
1516
1516
tmp_table, &db_options,
1517
schema_table->table->file,
1517
schema_table->table->cursor,
1518
1518
&schema_table->table->s->key_info, &keys, 0))