461
snprintf(buff, sizeof(buff), ER(ER_INSERT_INFO), (ulong) info.records,
461
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
462
462
(ulong) (info.records - info.copied), (ulong) session->cuted_fields);
464
snprintf(buff, sizeof(buff), ER(ER_INSERT_INFO), (ulong) info.records,
464
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
465
465
(ulong) (info.deleted + info.updated), (ulong) session->cuted_fields);
466
466
session->row_count_func= info.copied + info.deleted + info.updated;
467
467
session->my_ok((ulong) session->row_count_func,
1344
1344
char buff[160];
1345
1345
if (info.ignore)
1346
snprintf(buff, sizeof(buff), ER(ER_INSERT_INFO), (ulong) info.records,
1346
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
1347
1347
(ulong) (info.records - info.copied), (ulong) session->cuted_fields);
1349
snprintf(buff, sizeof(buff), ER(ER_INSERT_INFO), (ulong) info.records,
1349
sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records,
1350
1350
(ulong) (info.deleted+info.updated), (ulong) session->cuted_fields);
1351
1351
session->row_count_func= info.copied + info.deleted + info.updated;
1455
1455
static Table *create_table_from_items(Session *session, HA_CREATE_INFO *create_info,
1456
1456
TableList *create_table,
1457
message::Table &table_proto,
1457
message::Table *table_proto,
1458
1458
AlterInfo *alter_info,
1459
1459
List<Item> *items,
1460
1460
bool is_if_not_exists,
1461
DRIZZLE_LOCK **lock,
1462
TableIdentifier &identifier)
1461
DRIZZLE_LOCK **lock)
1464
1463
Table tmp_table; // Used during 'CreateField()'
1465
1464
TableShare share;
1471
1470
Field *tmp_field;
1474
if (not (identifier.isTmp()) && create_table->table->db_stat)
1473
bool lex_identified_temp_table= (table_proto->type() == message::Table::TEMPORARY);
1475
if (!(lex_identified_temp_table) &&
1476
create_table->table->db_stat)
1476
1478
/* Table already exists and was open at openTablesLock() stage. */
1477
1479
if (is_if_not_exists)
1494
1496
tmp_table.s->db_create_options=0;
1495
1497
tmp_table.s->blob_ptr_size= portable_sizeof_char_ptr;
1497
if (not table_proto.engine().name().compare("MyISAM"))
1498
tmp_table.s->db_low_byte_first= true;
1499
else if (not table_proto.engine().name().compare("MEMORY"))
1500
tmp_table.s->db_low_byte_first= true;
1498
tmp_table.s->db_low_byte_first=
1499
test(create_info->db_type == myisam_engine ||
1500
create_info->db_type == heap_engine);
1502
1501
tmp_table.null_row= false;
1503
1502
tmp_table.maybe_null= false;
1533
1538
should not cause deadlocks or races.
1536
if (not mysql_create_table_no_lock(session,
1541
if (!mysql_create_table_no_lock(session,
1545
if (create_info->table_existed && not identifier.isTmp())
1550
if (create_info->table_existed &&
1551
!(lex_identified_temp_table))
1548
1554
This means that someone created table underneath server
1569
if (not (table= session->openTable(create_table, (bool*) 0,
1570
DRIZZLE_OPEN_TEMPORARY_ONLY)) &&
1571
not create_info->table_existed)
1575
if (!(table= session->openTable(create_table, (bool*) 0,
1576
DRIZZLE_OPEN_TEMPORARY_ONLY)) &&
1577
!create_info->table_existed)
1574
1580
This shouldn't happen as creation of temporary table should make
1596
if (not create_info->table_existed)
1597
session->drop_open_table(table, identifier);
1602
if (!create_info->table_existed)
1603
session->drop_open_table(table, create_table->db, create_table->table_name);
1606
1612
select_create::prepare(List<Item> &values, Select_Lex_Unit *u)
1614
bool lex_identified_temp_table= (table_proto->type() == message::Table::TEMPORARY);
1608
1616
DRIZZLE_LOCK *extra_lock= NULL;
1610
For replication, the CREATE-SELECT statement is written
1611
in two pieces: the first transaction messsage contains
1612
the CREATE TABLE statement as a CreateTableStatement message
1613
necessary to create the table.
1615
The second transaction message contains all the InsertStatement
1616
and associated InsertRecords that should go into the table.
1618
For row-based replication, the CREATE-SELECT statement is written
1619
in two pieces: the first one contain the CREATE TABLE statement
1620
necessary to create the table and the second part contain the rows
1621
that should go into the table.
1623
For non-temporary tables, the start of the CREATE-SELECT
1624
implicitly commits the previous transaction, and all events
1625
forming the statement will be stored the transaction cache. At end
1626
of the statement, the entire statement is committed as a
1627
transaction, and all events are written to the binary log.
1629
On the master, the table is locked for the duration of the
1630
statement, but since the CREATE part is replicated as a simple
1631
statement, there is no way to lock the table for accesses on the
1632
slave. Hence, we have to hold on to the CREATE part of the
1633
statement until the statement has finished.
1621
if (not (table= create_table_from_items(session, create_info, create_table,
1623
alter_info, &values,
1625
&extra_lock, identifier)))
1639
Start a statement transaction before the create if we are using
1640
row-based replication for the statement. If we are creating a
1641
temporary table, we need to start a statement transaction.
1644
if (!(table= create_table_from_items(session, create_info, create_table,
1646
alter_info, &values,
1626
1649
return(-1); // abort() deletes table
1628
1651
if (extra_lock)
1630
1653
assert(m_plock == NULL);
1632
if (identifier.isTmp())
1655
if (lex_identified_temp_table)
1633
1656
m_plock= &m_lock;
1635
1658
m_plock= &session->extra_lock;
1759
1782
table->cursor->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
1760
1783
table->cursor->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
1761
if (not create_info->table_existed)
1762
session->drop_open_table(table, identifier);
1784
if (!create_info->table_existed)
1785
session->drop_open_table(table, create_table->db, create_table->table_name);
1763
1786
table= NULL; // Safety