~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_insert.cc

Merge trunk:

Show diffs side-by-side

added added

removed removed

Lines of Context:
359
359
    }
360
360
    else
361
361
    {
362
 
      if (session->used_tables)                 // Column used in values()
363
 
        table->restoreRecordAsDefault();        // Get empty record
364
 
      else
365
 
      {
366
 
        /*
367
 
          Fix delete marker. No need to restore rest of record since it will
368
 
          be overwritten by fill_record() anyway (and fill_record() does not
369
 
          use default values in this case).
370
 
        */
371
 
        table->record[0][0]= table->s->default_values[0];
372
 
      }
 
362
      table->restoreRecordAsDefault();  // Get empty record
 
363
 
373
364
      if (fill_record(session, table->field, *values, 0))
374
365
      {
375
366
        if (values_list.elements != 1 && ! session->is_error())
1458
1449
                                      message::Table *table_proto,
1459
1450
                                      AlterInfo *alter_info,
1460
1451
                                      List<Item> *items,
 
1452
                                      bool is_if_not_exists,
1461
1453
                                      DRIZZLE_LOCK **lock)
1462
1454
{
1463
1455
  Table tmp_table;              // Used during 'CreateField()'
1470
1462
  Field *tmp_field;
1471
1463
  bool not_used;
1472
1464
 
1473
 
  if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE) &&
 
1465
  bool lex_identified_temp_table= (table_proto->type() == drizzled::message::Table::TEMPORARY);
 
1466
 
 
1467
  if (!(lex_identified_temp_table) &&
1474
1468
      create_table->table->db_stat)
1475
1469
  {
1476
1470
    /* Table already exists and was open at openTablesLock() stage. */
1477
 
    if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
 
1471
    if (is_if_not_exists)
1478
1472
    {
1479
1473
      create_info->table_existed= 1;            // Mark that table existed
1480
1474
      push_warning_printf(session, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
1535
1529
                                    create_info,
1536
1530
                                    table_proto,
1537
1531
                                    alter_info, false,
1538
 
                                    select_field_count))
 
1532
                                    select_field_count,
 
1533
                                    is_if_not_exists))
1539
1534
    {
1540
1535
      if (create_info->table_existed &&
1541
 
          !(create_info->options & HA_LEX_CREATE_TMP_TABLE))
 
1536
          !(lex_identified_temp_table))
1542
1537
      {
1543
1538
        /*
1544
1539
          This means that someone created table underneath server
1549
1544
        return NULL;
1550
1545
      }
1551
1546
 
1552
 
      if (!(create_info->options & HA_LEX_CREATE_TMP_TABLE))
 
1547
      if (!(lex_identified_temp_table))
1553
1548
      {
1554
1549
        pthread_mutex_lock(&LOCK_open); /* CREATE TABLE... has found that the table already exists for insert and is adapting to use it */
1555
1550
        if (session->reopen_name_locked_table(create_table, false))
1602
1597
int
1603
1598
select_create::prepare(List<Item> &values, Select_Lex_Unit *u)
1604
1599
{
 
1600
  bool lex_identified_temp_table= (table_proto->type() == drizzled::message::Table::TEMPORARY);
 
1601
 
1605
1602
  DRIZZLE_LOCK *extra_lock= NULL;
1606
1603
  /*
1607
1604
    For row-based replication, the CREATE-SELECT statement is written
1633
1630
  if (!(table= create_table_from_items(session, create_info, create_table,
1634
1631
                                       table_proto,
1635
1632
                                       alter_info, &values,
 
1633
                                       is_if_not_exists,
1636
1634
                                       &extra_lock)))
1637
1635
    return(-1);                         // abort() deletes table
1638
1636
 
1640
1638
  {
1641
1639
    assert(m_plock == NULL);
1642
1640
 
1643
 
    if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
 
1641
    if (lex_identified_temp_table)
1644
1642
      m_plock= &m_lock;
1645
1643
    else
1646
1644
      m_plock= &session->extra_lock;