~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_insert.cc

Merge of HA_CREATE_INFO simplifications.

AKA... proto now working better!

You start these things... and then you wonder. What problem did I start out
today to solve? Was the store_lock() issues, or was it related to 
TableIdentifiers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1458
1458
                                      message::Table *table_proto,
1459
1459
                                      AlterInfo *alter_info,
1460
1460
                                      List<Item> *items,
 
1461
                                      bool is_if_not_exists,
1461
1462
                                      DRIZZLE_LOCK **lock)
1462
1463
{
1463
1464
  Table tmp_table;              // Used during 'CreateField()'
1470
1471
  Field *tmp_field;
1471
1472
  bool not_used;
1472
1473
 
1473
 
  if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE) &&
 
1474
  bool lex_identified_temp_table= (table_proto->type() == drizzled::message::Table::TEMPORARY);
 
1475
 
 
1476
  if (!(lex_identified_temp_table) &&
1474
1477
      create_table->table->db_stat)
1475
1478
  {
1476
1479
    /* Table already exists and was open at openTablesLock() stage. */
1477
 
    if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
 
1480
    if (is_if_not_exists)
1478
1481
    {
1479
1482
      create_info->table_existed= 1;            // Mark that table existed
1480
1483
      push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
1535
1538
                                    create_info,
1536
1539
                                    table_proto,
1537
1540
                                    alter_info, false,
1538
 
                                    select_field_count))
 
1541
                                    select_field_count,
 
1542
                                    is_if_not_exists))
1539
1543
    {
1540
1544
      if (create_info->table_existed &&
1541
 
          !(create_info->options & HA_LEX_CREATE_TMP_TABLE))
 
1545
          !(lex_identified_temp_table))
1542
1546
      {
1543
1547
        /*
1544
1548
          This means that someone created table underneath server
1549
1553
        return NULL;
1550
1554
      }
1551
1555
 
1552
 
      if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
 
1556
      if (!(lex_identified_temp_table))
1553
1557
      {
1554
1558
        pthread_mutex_lock(&LOCK_open); /* CREATE TABLE... has found that the table already exists for insert and is adapting to use it */
1555
1559
        if (session->reopen_name_locked_table(create_table, false))
1602
1606
int
1603
1607
select_create::prepare(List<Item> &values, Select_Lex_Unit *u)
1604
1608
{
 
1609
  bool lex_identified_temp_table= (table_proto->type() == drizzled::message::Table::TEMPORARY);
 
1610
 
1605
1611
  DRIZZLE_LOCK *extra_lock= NULL;
1606
1612
  /*
1607
1613
    For row-based replication, the CREATE-SELECT statement is written
1633
1639
  if (!(table= create_table_from_items(session, create_info, create_table,
1634
1640
                                       table_proto,
1635
1641
                                       alter_info, &values,
 
1642
                                       is_if_not_exists,
1636
1643
                                       &extra_lock)))
1637
1644
    return(-1);                         // abort() deletes table
1638
1645
 
1640
1647
  {
1641
1648
    assert(m_plock == NULL);
1642
1649
 
1643
 
    if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
 
1650
    if (lex_identified_temp_table)
1644
1651
      m_plock= &m_lock;
1645
1652
    else
1646
1653
      m_plock= &session->extra_lock;