315
297
if (values->elements != value_count)
317
299
my_error(ER_WRONG_VALUE_COUNT_ON_ROW, MYF(0), counter);
320
table->cursor->ha_release_auto_increment();
322
free_underlaid_joins(session, &session->lex->select_lex);
323
session->abort_on_warning= 0;
324
DRIZZLE_INSERT_DONE(1, 0);
328
302
if (setup_fields(session, 0, *values, MARK_COLUMNS_READ, 0, 0))
331
table->cursor->ha_release_auto_increment();
333
free_underlaid_joins(session, &session->lex->select_lex);
334
session->abort_on_warning= 0;
335
DRIZZLE_INSERT_DONE(1, 0);
508
468
session->my_ok((ulong) session->row_count_func,
509
469
info.copied + info.deleted + info.touched, id, buff);
511
session->status_var.inserted_row_count+= session->row_count_func;
512
471
session->abort_on_warning= 0;
513
472
DRIZZLE_INSERT_DONE(0, session->row_count_func);
477
table->cursor->ha_release_auto_increment();
479
free_underlaid_joins(session, &session->lex->select_lex);
480
session->abort_on_warning= 0;
481
DRIZZLE_INSERT_DONE(1, 0);
743
int write_record(Session *session, Table *table,CopyInfo *info)
710
int write_record(Session *session, Table *table,COPY_INFO *info)
746
std::vector<unsigned char> key;
747
boost::dynamic_bitset<> *save_read_set, *save_write_set;
714
MyBitmap *save_read_set, *save_write_set;
748
715
uint64_t prev_insert_id= table->cursor->next_insert_id;
749
716
uint64_t insert_id_for_cur_row= 0;
819
key.resize(table->getShare()->max_unique_length);
786
if (!(key=(char*) malloc(table->getShare()->max_unique_length)))
821
key_copy(&key[0], table->getInsertRecord(), table->key_info+key_nr, 0);
822
if ((error=(table->cursor->index_read_idx_map(table->getUpdateRecord(),key_nr,
823
&key[0], HA_WHOLE_KEY,
792
key_copy((unsigned char*) key,table->record[0],table->key_info+key_nr,0);
793
if ((error=(table->cursor->index_read_idx_map(table->record[1],key_nr,
794
(unsigned char*) key, HA_WHOLE_KEY,
824
795
HA_READ_KEY_EXACT))))
846
817
table->cursor->adjust_next_insert_id_after_explicit_value(
847
818
table->next_number_field->val_int());
850
if (! table->records_are_comparable() || table->compare_records())
820
if ((table->cursor->getEngine()->check_flag(HTON_BIT_PARTIAL_COLUMN_READ) &&
821
!bitmap_is_subset(table->write_set, table->read_set)) ||
822
table->compare_record())
852
if ((error=table->cursor->updateRecord(table->getUpdateRecord(),
853
table->getInsertRecord())) &&
824
if ((error=table->cursor->updateRecord(table->record[1],
825
table->record[0])) &&
854
826
error != HA_ERR_RECORD_IS_THE_SAME)
856
828
if (info->ignore &&
1068
1044
List<Item> *update_fields,
1069
1045
List<Item> *update_values,
1070
1046
enum_duplicates duplic,
1071
bool ignore_check_option_errors) :
1072
table_list(table_list_par), table(table_par), fields(fields_par),
1073
autoinc_value_of_last_inserted_row(0),
1074
insert_into_view(table_list_par && 0 != 0)
1047
bool ignore_check_option_errors)
1048
:table_list(table_list_par), table(table_par), fields(fields_par),
1049
autoinc_value_of_last_inserted_row(0),
1050
insert_into_view(table_list_par && 0 != 0)
1052
memset(&info, 0, sizeof(info));
1076
1053
info.handle_duplicates= duplic;
1077
1054
info.ignore= ignore_check_option_errors;
1078
1055
info.update_fields= update_fields;
1503
1481
create_info->table_existed= 1; // Mark that table existed
1504
1482
push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
1505
1483
ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR),
1506
create_table->getTableName());
1484
create_table->table_name);
1507
1485
return create_table->table;
1510
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), create_table->getTableName());
1488
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), create_table->table_name);
1493
tmp_table.timestamp_field= 0;
1494
tmp_table.setShare(&share);
1496
tmp_table.getMutableShare()->db_create_options= 0;
1497
tmp_table.getMutableShare()->blob_ptr_size= portable_sizeof_char_ptr;
1499
if (not table_proto.engine().name().compare("MyISAM"))
1500
tmp_table.getMutableShare()->db_low_byte_first= true;
1501
else if (not table_proto.engine().name().compare("MEMORY"))
1502
tmp_table.getMutableShare()->db_low_byte_first= true;
1504
tmp_table.null_row= false;
1505
tmp_table.maybe_null= false;
1515
table::Shell tmp_table(share); // Used during 'CreateField()'
1516
tmp_table.timestamp_field= 0;
1518
tmp_table.getMutableShare()->db_create_options= 0;
1519
tmp_table.getMutableShare()->blob_ptr_size= portable_sizeof_char_ptr;
1521
if (not table_proto.engine().name().compare("MyISAM"))
1522
tmp_table.getMutableShare()->db_low_byte_first= true;
1523
else if (not table_proto.engine().name().compare("MEMORY"))
1524
tmp_table.getMutableShare()->db_low_byte_first= true;
1526
tmp_table.null_row= false;
1527
tmp_table.maybe_null= false;
1529
tmp_table.in_use= session;
1533
CreateField *cr_field;
1534
Field *field, *def_field;
1535
if (item->type() == Item::FUNC_ITEM)
1537
if (item->result_type() != STRING_RESULT)
1539
field= item->tmp_table_field(&tmp_table);
1543
field= item->tmp_table_field_from_field_type(&tmp_table, 0);
1509
CreateField *cr_field;
1510
Field *field, *def_field;
1511
if (item->type() == Item::FUNC_ITEM)
1512
if (item->result_type() != STRING_RESULT)
1513
field= item->tmp_table_field(&tmp_table);
1548
field= create_tmp_field(session, &tmp_table, item, item->type(),
1549
(Item ***) 0, &tmp_field, &def_field, false,
1554
!(cr_field=new CreateField(field,(item->type() == Item::FIELD_ITEM ?
1555
((Item_field *)item)->field :
1561
if (item->maybe_null)
1563
cr_field->flags &= ~NOT_NULL_FLAG;
1566
alter_info->create_list.push_back(cr_field);
1515
field= item->tmp_table_field_from_field_type(&tmp_table, 0);
1517
field= create_tmp_field(session, &tmp_table, item, item->type(),
1518
(Item ***) 0, &tmp_field, &def_field, false,
1521
!(cr_field=new CreateField(field,(item->type() == Item::FIELD_ITEM ?
1522
((Item_field *)item)->field :
1525
if (item->maybe_null)
1526
cr_field->flags &= ~NOT_NULL_FLAG;
1527
alter_info->create_list.push_back(cr_field);
1592
1551
or it was created via different mysqld front-end to the
1593
1552
cluster. We don't have much options but throw an error.
1595
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), create_table->getTableName());
1554
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), create_table->table_name);
1599
1558
if (not identifier.isTmp())
1601
/* CREATE TABLE... has found that the table already exists for insert and is adapting to use it */
1602
boost::mutex::scoped_lock scopedLock(table::Cache::singleton().mutex());
1604
if (create_table->table)
1560
pthread_mutex_lock(&LOCK_open); /* CREATE TABLE... has found that the table already exists for insert and is adapting to use it */
1561
if (session->reopen_name_locked_table(create_table, false))
1606
table::Concurrent *concurrent_table= static_cast<table::Concurrent *>(create_table->table);
1608
if (concurrent_table->reopen_name_locked_table(create_table, session))
1610
plugin::StorageEngine::dropTable(*session, identifier);
1614
table= create_table->table;
1563
quick_rm_table(*session, identifier);
1619
plugin::StorageEngine::dropTable(*session, identifier);
1566
table= create_table->table;
1567
pthread_mutex_unlock(&LOCK_open);
1630
1577
it preparable for open. But let us do close_temporary_table() here
1633
session->drop_temporary_table(identifier);
1580
session->drop_temporary_table(create_table);
1637
if (not table) // open failed
1584
if (!table) // open failed
1641
1588
table->reginfo.lock_type=TL_WRITE;
1642
if (! ((*lock)= session->lockTables(&table, 1, DRIZZLE_LOCK_IGNORE_FLUSH, ¬_used)))
1589
if (! ((*lock)= mysql_lock_tables(session, &table, 1,
1590
DRIZZLE_LOCK_IGNORE_FLUSH, ¬_used)))
1646
session->unlockTables(*lock);
1594
mysql_unlock_tables(session, *lock);