97
91
if (create_info.db_type == NULL)
99
93
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0),
100
create_table_message.engine().name().c_str());
94
create_table_message.name().c_str());
106
101
/* Must be set in the parser */
107
102
assert(select_lex->db);
109
104
/* Chicken/Egg... we need to search for the table, to know if the table exists, so we can build a full identifier from it */
110
message::table::shared_ptr original_table_message;
105
message::Table original_table_message;
112
TableIdentifier identifier(first_table->getSchemaName(), first_table->getTableName());
107
TableIdentifier identifier(first_table->db, first_table->table_name);
113
108
if (plugin::StorageEngine::getTableDefinition(*session, identifier, original_table_message) != EEXIST)
116
identifier.getSQLPath(path);
117
my_error(ER_BAD_TABLE_ERROR, MYF(0), path.c_str());
110
my_error(ER_BAD_TABLE_ERROR, MYF(0), identifier.getSQLPath().c_str());
121
if (not create_info.db_type)
124
plugin::StorageEngine::findByName(*session, original_table_message->engine().name());
126
if (not create_info.db_type)
129
identifier.getSQLPath(path);
130
my_error(ER_BAD_TABLE_ERROR, MYF(0), path.c_str());
136
if (not validateCreateTableOption())
139
115
/* ALTER TABLE ends previous transaction */
140
116
if (not session->endActiveTransaction())
143
if (not (need_start_waiting= not session->wait_if_global_read_lock(0, 1)))
121
if (not (need_start_waiting= ! wait_if_global_read_lock(session, 0, 1)))
147
if (original_table_message->type() == message::Table::STANDARD )
127
if (original_table_message.type() == message::Table::STANDARD )
149
TableIdentifier identifier(first_table->getSchemaName(), first_table->getTableName());
150
TableIdentifier new_identifier(select_lex->db ? select_lex->db : first_table->getSchemaName(),
151
session->lex->name.str ? session->lex->name.str : first_table->getTableName());
129
TableIdentifier identifier(first_table->db, first_table->table_name);
130
TableIdentifier new_identifier(select_lex->db ? select_lex->db : first_table->db,
131
session->lex->name.str ? session->lex->name.str : first_table->table_name);
153
133
res= alter_table(session,
157
*original_table_message,
158
137
create_table_message,
161
140
select_lex->order_list.elements,
162
(Order *) select_lex->order_list.first,
141
(order_st *) select_lex->order_list.first,
163
142
session->lex->ignore);
167
TableIdentifier catch22(first_table->getSchemaName(), first_table->getTableName());
168
Table *table= session->find_temporary_table(catch22);
146
Table *table= session->find_temporary_table(first_table);
171
TableIdentifier identifier(first_table->getSchemaName(), first_table->getTableName(), table->getMutableShare()->getPath());
172
TableIdentifier new_identifier(select_lex->db ? select_lex->db : first_table->getSchemaName(),
173
session->lex->name.str ? session->lex->name.str : first_table->getTableName(),
174
table->getMutableShare()->getPath());
149
TableIdentifier identifier(first_table->db, first_table->table_name, table->s->path.str);
150
TableIdentifier new_identifier(select_lex->db ? select_lex->db : first_table->db,
151
session->lex->name.str ? session->lex->name.str : first_table->table_name,
176
154
res= alter_table(session,
180
*original_table_message,
181
158
create_table_message,
184
161
select_lex->order_list.elements,
185
(Order *) select_lex->order_list.first,
162
(order_st *) select_lex->order_list.first,
186
163
session->lex->ignore);
256
231
List_iterator<CreateField> field_it(new_create_list);
257
232
List<Key_part_spec> key_parts;
258
233
uint32_t used_fields= create_info->used_fields;
259
KeyInfo *key_info= table->key_info;
234
KEY *key_info= table->key_info;
262
237
/* Let new create options override the old ones */
263
238
message::Table::TableOptions *table_options;
264
239
table_options= table_message.mutable_options();
241
if (! (used_fields & HA_CREATE_USED_BLOCK_SIZE))
242
table_options->set_block_size(table->s->block_size);
266
243
if (! (used_fields & HA_CREATE_USED_DEFAULT_CHARSET))
267
create_info->default_table_charset= table->getShare()->table_charset;
244
create_info->default_table_charset= table->s->table_charset;
268
245
if (! (used_fields & HA_CREATE_USED_AUTO) &&
269
246
table->found_next_number_field)
271
248
/* Table has an autoincrement, copy value to new table */
272
249
table->cursor->info(HA_STATUS_AUTO);
273
250
create_info->auto_increment_value= table->cursor->stats.auto_increment_value;
274
if (create_info->auto_increment_value != original_proto.options().auto_increment_value())
275
table_options->set_has_user_set_auto_increment_value(false);
252
if (! (used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)
253
&& table->s->hasKeyBlockSize())
254
table_options->set_key_block_size(table->s->getKeyBlockSize());
256
if ((used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)
257
&& table_options->key_block_size() == 0)
258
table_options->clear_key_block_size();
277
260
table->restoreRecordAsDefault(); /* Empty record for DEFAULT */
278
261
CreateField *def;
280
263
/* First collect all fields from table which isn't in drop_list */
283
for (f_ptr= table->getFields(); (field= *f_ptr); f_ptr++)
266
for (f_ptr= table->field; (field= *f_ptr); f_ptr++)
285
268
/* Check if field should be dropped */
368
349
if (def->change && ! def->field)
370
my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change, table->getMutableShare()->getTableName());
351
my_error(ER_BAD_FIELD_ERROR, MYF(0), def->change, table->s->table_name.str);
374
If we have been given a field which has no default value, and is not null then we need to bail.
355
Check that the DATE/DATETIME not null field we are going to add is
356
either has a default value or the '0000-00-00' is allowed by the
358
If the '0000-00-00' value isn't allowed then raise the error_if_not_empty
359
flag to allow ALTER Table only if the table to be altered is empty.
376
if (not (~def->flags & (NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG)) and not def->change)
361
if ((def->sql_type == DRIZZLE_TYPE_DATE ||
362
def->sql_type == DRIZZLE_TYPE_DATETIME) &&
363
! alter_info->datetime_field &&
364
! (~def->flags & (NO_DEFAULT_VALUE_FLAG | NOT_NULL_FLAG)) &&
365
session->variables.sql_mode & MODE_NO_ZERO_DATE)
367
alter_info->datetime_field= def;
378
368
alter_info->error_if_not_empty= true;
380
370
if (! def->after)
382
371
new_create_list.push_back(def);
384
372
else if (def->after == first_keyword)
386
373
new_create_list.push_front(def);
390
376
CreateField *find;
423
409
my_error(ER_BAD_FIELD_ERROR,
425
411
alter_info->alter_list.head()->name,
426
table->getMutableShare()->getTableName());
412
table->s->table_name.str);
429
415
if (! new_create_list.elements)
431
417
my_message(ER_CANT_REMOVE_ALL_FIELDS,
432
418
ER(ER_CANT_REMOVE_ALL_FIELDS),
438
424
Collect all keys which isn't in drop list. Add only those
439
425
for which some fields exists.
441
for (uint32_t i= 0; i < table->getShare()->sizeKeys(); i++, key_info++)
427
for (uint32_t i= 0; i < table->s->keys; i++, key_info++)
443
429
char *key_name= key_info->name;
537
523
new_key_list.push_back(key);
541
/* Copy over existing foreign keys */
542
for (int j= 0; j < original_proto.fk_constraint_size(); j++)
546
while ((drop= drop_it++))
548
if (drop->type == AlterDrop::FOREIGN_KEY &&
549
! my_strcasecmp(system_charset_info, original_proto.fk_constraint(j).name().c_str(), drop->name))
560
message::Table::ForeignKeyConstraint *pfkey= table_message.add_fk_constraint();
561
*pfkey= original_proto.fk_constraint(j);
566
528
while ((key= key_it++)) /* Add new keys */
568
if (key->type == Key::FOREIGN_KEY)
570
if (((Foreign_key *)key)->validate(new_create_list))
575
Foreign_key *fkey= (Foreign_key*)key;
576
add_foreign_key_to_table_message(&table_message,
530
if (key->type == Key::FOREIGN_KEY &&
531
((Foreign_key *)key)->validate(new_create_list))
586
533
if (key->type != Key::FOREIGN_KEY)
587
534
new_key_list.push_back(key);
589
535
if (key->name.str && is_primary_key_name(key->name.str))
591
537
my_error(ER_WRONG_NAME_FOR_INDEX,
599
/* Fix names of foreign keys being added */
600
for (int j= 0; j < table_message.fk_constraint_size(); j++)
602
if (! table_message.fk_constraint(j).has_name())
604
std::string name(table->getMutableShare()->getTableName());
607
name.append("_ibfk_");
608
snprintf(number, sizeof(number), "%d", j+1);
611
message::Table::ForeignKeyConstraint *pfkey= table_message.mutable_fk_constraint(j);
612
pfkey->set_name(name);
616
545
if (alter_info->drop_list.elements)
618
547
my_error(ER_CANT_DROP_FIELD_OR_KEY,
620
549
alter_info->drop_list.head()->name);
623
552
if (alter_info->alter_list.elements)
625
554
my_error(ER_CANT_DROP_FIELD_OR_KEY,
627
556
alter_info->alter_list.head()->name);
631
560
if (not table_message.options().has_comment()
632
&& table->getMutableShare()->hasComment())
633
table_options->set_comment(table->getMutableShare()->getComment());
561
&& table->s->hasComment())
562
table_options->set_comment(table->s->getComment());
635
if (table->getShare()->getType())
564
if (table->s->tmp_table)
637
566
table_message.set_type(message::Table::TEMPORARY);
640
569
table_message.set_creation_timestamp(table->getShare()->getTableProto()->creation_timestamp());
641
table_message.set_version(table->getShare()->getTableProto()->version());
642
table_message.set_uuid(table->getShare()->getTableProto()->uuid());
571
table_message.set_update_timestamp(time(NULL));
573
if (not table_message.options().has_comment()
574
&& table->s->hasComment())
575
table_options->set_comment(table->s->getComment());
645
578
alter_info->create_list.swap(new_create_list);
646
579
alter_info->key_list.swap(new_key_list);
648
size_t num_engine_options= table_message.engine().options_size();
649
size_t original_num_engine_options= original_proto.engine().options_size();
650
for (size_t x= 0; x < original_num_engine_options; ++x)
654
for (size_t y= 0; y < num_engine_options; ++y)
656
found= not table_message.engine().options(y).name().compare(original_proto.engine().options(x).name());
664
message::Engine::Option *opt= table_message.mutable_engine()->add_options();
666
opt->set_name(original_proto.engine().options(x).name());
667
opt->set_state(original_proto.engine().options(x).state());
671
drizzled::message::update(table_message);
676
584
/* table_list should contain just one table */
713
621
/* The ALTER Table is always in its own transaction */
714
error= transaction_services.autocommitOrRollback(session, false);
715
if (not session->endActiveTransaction())
622
error= transaction_services.ha_autocommit_or_rollback(session, false);
623
if (! session->endActiveTransaction())
721
write_bin_log(session, *session->getQueryString());
627
write_bin_log(session, session->query.c_str());
724
(void) transaction_services.autocommitOrRollback(session, error);
630
(void) transaction_services.ha_autocommit_or_rollback(session, error);
725
631
session->tablespace_op=false;
807
710
if (not name_lock)
810
new_table_identifier.getSQLPath(path);
811
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), path.c_str());
712
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_table_identifier.getSQLPath().c_str());
815
716
if (plugin::StorageEngine::doesTableExist(session, new_table_identifier))
818
new_table_identifier.getSQLPath(path);
820
718
/* Table will be closed by Session::executeCommand() */
821
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), path.c_str());
719
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_table_identifier.getSQLPath().c_str());
823
table::Cache::singleton().mutex().lock(); /* ALTER TABLe */
721
pthread_mutex_lock(&LOCK_open); /* ALTER TABLe */
824
722
session.unlink_open_table(name_lock);
825
table::Cache::singleton().mutex().unlock();
723
pthread_mutex_unlock(&LOCK_open);
879
777
TableIdentifier &original_table_identifier,
880
778
TableIdentifier &new_table_identifier,
881
779
HA_CREATE_INFO *create_info,
882
const message::Table &original_proto,
883
780
message::Table &create_proto,
884
781
TableList *table_list,
885
782
AlterInfo *alter_info,
886
783
uint32_t order_num,
787
Table *new_table= NULL;
891
789
char tmp_name[80];
892
790
char old_name[32];
893
791
ha_rows copied= 0;
894
792
ha_rows deleted= 0;
896
if (not original_table_identifier.isValid())
899
if (not new_table_identifier.isValid())
794
message::Table *original_table_definition= table->s->getTableProto();
902
796
session->set_proc_info("init");
934
828
if (original_engine->check_flag(HTON_BIT_ALTER_NOT_SUPPORTED) ||
935
829
new_engine->check_flag(HTON_BIT_ALTER_NOT_SUPPORTED))
938
new_table_identifier.getSQLPath(path);
939
my_error(ER_ILLEGAL_HA, MYF(0), path.c_str());
831
my_error(ER_ILLEGAL_HA, MYF(0), new_table_identifier.getSQLPath().c_str());
836
if (create_info->row_type == ROW_TYPE_NOT_USED)
838
message::Table::TableOptions *table_options;
839
table_options= create_proto.mutable_options();
841
create_info->row_type= table->s->row_type;
842
table_options->set_row_type(original_table_definition->options().row_type());
944
845
session->set_proc_info("setup");
970
871
while the fact that the table is still open gives us protection
971
872
from concurrent DDL statements.
973
table::Cache::singleton().mutex().lock(); /* DDL wait for/blocker */
874
pthread_mutex_lock(&LOCK_open); /* DDL wait for/blocker */
974
875
wait_while_table_is_used(session, table, HA_EXTRA_FORCE_REOPEN);
975
table::Cache::singleton().mutex().unlock();
876
pthread_mutex_unlock(&LOCK_open);
976
877
error= table->cursor->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
977
878
/* COND_refresh will be signaled in close_thread_tables() */
980
table::Cache::singleton().mutex().lock(); /* DDL wait for/blocker */
881
pthread_mutex_lock(&LOCK_open); /* DDL wait for/blocker */
981
882
wait_while_table_is_used(session, table, HA_EXTRA_FORCE_REOPEN);
982
table::Cache::singleton().mutex().unlock();
883
pthread_mutex_unlock(&LOCK_open);
983
884
error=table->cursor->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE);
984
885
/* COND_refresh will be signaled in close_thread_tables() */
995
896
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
996
897
ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA),
1000
table::Cache::singleton().mutex().lock(); /* Lock to remove all instances of table from table cache before ALTER */
901
pthread_mutex_lock(&LOCK_open); /* Lock to remove all instances of table from table cache before ALTER */
1002
903
Unlike to the above case close_cached_table() below will remove ALL
1003
904
instances of Table from table cache (it will also remove table lock
1004
905
held by this thread). So to make actual table renaming and writing
1005
906
to binlog atomic we have to put them into the same critical section
1006
protected by table::Cache::singleton().mutex() mutex. This also removes gap for races between
907
protected by LOCK_open mutex. This also removes gap for races between
1007
908
access() and mysql_rename_table() calls.
1026
927
if (plugin::StorageEngine::doesTableExist(*session, new_table_identifier))
1029
new_table_identifier.getSQLPath(path);
1030
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), path.c_str());
929
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_table_identifier.getSQLPath().c_str());
1035
if (mysql_rename_table(*session, original_engine, original_table_identifier, new_table_identifier))
934
if (mysql_rename_table(original_engine, original_table_identifier, new_table_identifier, 0))
1102
999
/* Open the table so we need to copy the data to it. */
1103
Table *new_table= open_alter_table(session, table, new_table_as_temporary);
1000
new_table= open_alter_table(session, table, new_table_as_temporary);
1106
1002
if (not new_table)
1108
plugin::StorageEngine::dropTable(*session, new_table_as_temporary);
1004
quick_rm_table(*session, new_table_as_temporary);
1112
1008
/* Copy the data if necessary. */
1114
/* We must not ignore bad input! */
1115
session->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; // calc cuted fields
1010
session->count_cuted_fields= CHECK_FIELD_WARN; // calc cuted fields
1116
1011
session->cuted_fields= 0L;
1117
1012
session->set_proc_info("copy to tmp table");
1118
1013
copied= deleted= 0;
1150
1044
if (alter_info->error_if_not_empty && session->row_count)
1152
my_error(ER_INVALID_ALTER_TABLE_FOR_NOT_NULL, MYF(0));
1046
const char *f_val= 0;
1047
enum enum_drizzle_timestamp_type t_type= DRIZZLE_TIMESTAMP_DATE;
1049
switch (alter_info->datetime_field->sql_type)
1051
case DRIZZLE_TYPE_DATE:
1052
f_val= "0000-00-00";
1053
t_type= DRIZZLE_TIMESTAMP_DATE;
1055
case DRIZZLE_TYPE_DATETIME:
1056
f_val= "0000-00-00 00:00:00";
1057
t_type= DRIZZLE_TIMESTAMP_DATETIME;
1060
/* Shouldn't get here. */
1063
bool save_abort_on_warning= session->abort_on_warning;
1064
session->abort_on_warning= true;
1065
make_truncated_value_warning(session, DRIZZLE_ERROR::WARN_LEVEL_ERROR,
1066
f_val, internal::strlength(f_val), t_type,
1067
alter_info->datetime_field->field_name);
1068
session->abort_on_warning= save_abort_on_warning;
1155
1071
if (original_table_identifier.isTmp())
1175
1091
Note that MERGE tables do not have their children attached here.
1177
1093
new_table->intern_close_table();
1178
if (new_table->hasShare())
1180
delete new_table->getMutableShare();
1186
table::Cache::singleton().mutex().lock(); /* ALTER TABLE */
1097
pthread_mutex_lock(&LOCK_open); /* ALTER TABLE */
1188
plugin::StorageEngine::dropTable(*session, new_table_as_temporary);
1189
table::Cache::singleton().mutex().unlock();
1099
quick_rm_table(*session, new_table_as_temporary);
1100
pthread_mutex_unlock(&LOCK_open);
1205
1116
session->close_temporary_table(table);
1207
1118
/* Should pass the 'new_name' as we store table name in the cache */
1208
new_table->getMutableShare()->setIdentifier(new_table_identifier);
1119
if (new_table->renameAlterTemporaryTable(new_table_identifier))
1121
session->close_temporary_table(new_table);
1210
1126
new_table_identifier.setPath(new_table_as_temporary.getPath());
1212
if (mysql_rename_table(*session, new_engine, new_table_as_temporary, new_table_identifier) != 0)
1128
if (mysql_rename_table(new_engine, new_table_as_temporary, new_table_identifier, FN_FROM_IS_TMP) != 0)
1272
1182
compare_table(). Then, we need one additional call to
1274
1184
TableIdentifier original_table_to_drop(original_table_identifier.getSchemaName(),
1275
old_name, create_proto.type() != message::Table::TEMPORARY ? message::Table::INTERNAL :
1276
message::Table::TEMPORARY);
1185
old_name, message::Table::TEMPORARY);
1278
if (mysql_rename_table(*session, original_engine, original_table_identifier, original_table_to_drop))
1187
if (mysql_rename_table(original_engine, original_table_identifier, original_table_to_drop, FN_TO_IS_TMP))
1281
plugin::StorageEngine::dropTable(*session, new_table_as_temporary);
1190
quick_rm_table(*session, new_table_as_temporary);
1285
if (mysql_rename_table(*session, new_engine, new_table_as_temporary, new_table_identifier) != 0)
1194
if (mysql_rename_table(new_engine, new_table_as_temporary, new_table_identifier, FN_FROM_IS_TMP) != 0)
1287
1196
/* Try to get everything back. */
1290
plugin::StorageEngine::dropTable(*session, new_table_identifier);
1292
plugin::StorageEngine::dropTable(*session, new_table_as_temporary);
1294
mysql_rename_table(*session, original_engine, original_table_to_drop, original_table_identifier);
1199
quick_rm_table(*session, new_table_identifier);
1201
quick_rm_table(*session, new_table_as_temporary);
1203
mysql_rename_table(original_engine, original_table_to_drop, original_table_identifier, FN_FROM_IS_TMP);
1298
plugin::StorageEngine::dropTable(*session, original_table_to_drop);
1207
quick_rm_table(*session, original_table_to_drop);
1438
1345
TransactionServices &transaction_services= TransactionServices::singleton();
1443
* Since open_temporary_table() doesn't invoke lockTables(), we
1444
* don't get the usual automatic call to StorageEngine::startStatement(), so
1445
* we manually call it here...
1447
to->getMutableShare()->getEngine()->startStatement(session);
1449
if (!(copy= new CopyField[to->getShare()->sizeFields()]))
1347
if (!(copy= new CopyField[to->s->fields]))
1452
1350
if (to->cursor->ha_external_lock(session, F_WRLCK))
1455
1353
/* We need external lock before we can disable/enable keys */
1456
alter_table_manage_keys(session, to, from->cursor->indexes_are_disabled(), keys_onoff);
1354
alter_table_manage_keys(to, from->cursor->indexes_are_disabled(), keys_onoff);
1458
1356
/* We can abort alter table for any table type */
1459
1357
session->abort_on_warning= !ignore;
1484
if (to->getShare()->hasPrimaryKey() && to->cursor->primary_key_is_clustered())
1382
if (to->s->primary_key != MAX_KEY && to->cursor->primary_key_is_clustered())
1486
1384
char warn_buff[DRIZZLE_ERRMSG_SIZE];
1487
1385
snprintf(warn_buff, sizeof(warn_buff),
1488
1386
_("order_st BY ignored because there is a user-defined clustered "
1489
1387
"index in the table '%-.192s'"),
1490
from->getMutableShare()->getTableName());
1388
from->s->table_name.str);
1491
1389
push_warning(session, DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
1496
FileSort filesort(*session);
1497
1394
from->sort.io_cache= new internal::IO_CACHE;
1395
memset(from->sort.io_cache, 0, sizeof(internal::IO_CACHE));
1499
1397
memset(&tables, 0, sizeof(tables));
1500
1398
tables.table= from;
1501
tables.setTableName(const_cast<char *>(from->getMutableShare()->getTableName()));
1502
tables.alias= const_cast<char *>(tables.getTableName());
1503
tables.setSchemaName(const_cast<char *>(from->getMutableShare()->getSchemaName()));
1399
tables.alias= tables.table_name= from->s->table_name.str;
1400
tables.db= const_cast<char *>(from->s->getSchemaName());
1506
1403
if (session->lex->select_lex.setup_ref_array(session, order_num) ||
1507
1404
setup_order(session, session->lex->select_lex.ref_pointer_array,
1508
1405
&tables, fields, all_fields, order) ||
1509
1406
!(sortorder= make_unireg_sortorder(order, &length, NULL)) ||
1510
(from->sort.found_records= filesort.run(from, sortorder, length,
1511
(optimizer::SqlSelect *) 0, HA_POS_ERROR,
1512
1, examined_rows)) == HA_POS_ERROR)
1407
(from->sort.found_records= filesort(session, from, sortorder, length,
1408
(optimizer::SqlSelect *) 0, HA_POS_ERROR,
1409
1, &examined_rows)) ==
1519
1417
/* Tell handler that we have values for all columns in the to table */
1520
1418
to->use_all_columns();
1521
info.init_read_record(session, from, (optimizer::SqlSelect *) 0, 1, true);
1419
init_read_record(&info, session, from, (optimizer::SqlSelect *) 0, 1,1);
1523
1421
to->cursor->extra(HA_EXTRA_IGNORE_DUP_KEY);
1524
1422
session->row_count= 0;
1525
1423
to->restoreRecordAsDefault(); // Create empty record
1526
1424
while (!(error=info.read_record(&info)))
1528
if (session->getKilled())
1426
if (session->killed)
1530
1428
session->send_kill_message();
1546
1444
to->next_number_field->reset();
1549
for (CopyField *copy_ptr= copy; copy_ptr != copy_end ; copy_ptr++)
1447
for (CopyField *copy_ptr=copy ; copy_ptr != copy_end ; copy_ptr++)
1551
if (not copy->to_field->hasDefault() and copy->from_null_ptr and *copy->from_null_ptr & copy->from_bit)
1553
copy->to_field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN,
1554
ER_WARN_DATA_TRUNCATED, 1);
1555
copy->to_field->reset();
1560
1449
copy_ptr->do_copy(copy_ptr);
1568
1451
prev_insert_id= to->cursor->next_insert_id;
1569
error= to->cursor->insertRecord(to->record[0]);
1452
error= to->cursor->ha_write_row(to->record[0]);
1570
1453
to->auto_increment_field_not_null= false;
1574
if (!ignore || to->cursor->is_fatal_error(error, HA_CHECK_DUP))
1457
to->cursor->is_fatal_error(error, HA_CHECK_DUP))
1576
1459
to->print_error(error, MYF(0));