~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_insert.cc

  • Committer: Stewart Smith
  • Date: 2010-11-03 03:29:48 UTC
  • mto: (1902.1.1 build) (1910.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1903.
  • Revision ID: stewart@flamingspork.com-20101103032948-ocaksrku0oqxw8aa
fix more docs warnings: underline/overline too short

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
      }
130
130
      else
131
131
      {
132
 
        table->setWriteSet(table->timestamp_field->position());
 
132
        table->setWriteSet(table->timestamp_field->field_index);
133
133
      }
134
134
    }
135
135
  }
170
170
      Unmark the timestamp field so that we can check if this is modified
171
171
      by update_fields
172
172
    */
173
 
    timestamp_mark= table->write_set->test(table->timestamp_field->position());
174
 
    table->write_set->reset(table->timestamp_field->position());
 
173
    timestamp_mark= table->write_set->test(table->timestamp_field->field_index);
 
174
    table->write_set->reset(table->timestamp_field->field_index);
175
175
  }
176
176
 
177
177
  /* Check the fields we are going to modify */
189
189
 
190
190
    if (timestamp_mark)
191
191
    {
192
 
      table->setWriteSet(table->timestamp_field->position());
 
192
      table->setWriteSet(table->timestamp_field->field_index);
193
193
    }
194
194
  }
195
195
  return 0;
846
846
          table->cursor->adjust_next_insert_id_after_explicit_value(
847
847
            table->next_number_field->val_int());
848
848
        info->touched++;
849
 
 
850
 
        if (! table->records_are_comparable() || table->compare_records())
 
849
        if ((table->cursor->getEngine()->check_flag(HTON_BIT_PARTIAL_COLUMN_READ) &&
 
850
            ! table->write_set->is_subset_of(*table->read_set)) ||
 
851
            table->compare_record())
851
852
        {
852
853
          if ((error=table->cursor->updateRecord(table->getUpdateRecord(),
853
854
                                                table->getInsertRecord())) &&
1275
1276
  store_values(values);
1276
1277
  session->count_cuted_fields= CHECK_FIELD_IGNORE;
1277
1278
  if (session->is_error())
 
1279
  {
 
1280
    /*
 
1281
     * If we fail mid-way through INSERT..SELECT, we need to remove any
 
1282
     * records that we added to the current Statement message. We can
 
1283
     * use session->row_count to know how many records we have already added.
 
1284
     */
 
1285
    TransactionServices &ts= TransactionServices::singleton();
 
1286
    ts.removeStatementRecords(session, (session->row_count - 1));
1278
1287
    return(1);
 
1288
  }
1279
1289
 
1280
1290
  // Release latches in case bulk insert takes a long time
1281
1291
  plugin::TransactionalStorageEngine::releaseTemporaryLatches(session);
1598
1608
 
1599
1609
      if (not identifier.isTmp())
1600
1610
      {
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());
 
1611
        LOCK_open.lock(); /* CREATE TABLE... has found that the table already exists for insert and is adapting to use it */
1603
1612
 
1604
1613
        if (create_table->table)
1605
1614
        {
1607
1616
 
1608
1617
          if (concurrent_table->reopen_name_locked_table(create_table, session))
1609
1618
          {
1610
 
            plugin::StorageEngine::dropTable(*session, identifier);
 
1619
            quick_rm_table(*session, identifier);
1611
1620
          }
1612
1621
          else
1613
1622
          {
1616
1625
        }
1617
1626
        else
1618
1627
        {
1619
 
          plugin::StorageEngine::dropTable(*session, identifier);
 
1628
          quick_rm_table(*session, identifier);
1620
1629
        }
 
1630
 
 
1631
        LOCK_open.unlock();
1621
1632
      }
1622
1633
      else
1623
1634
      {
1639
1650
  }
1640
1651
 
1641
1652
  table->reginfo.lock_type=TL_WRITE;
1642
 
  if (! ((*lock)= session->lockTables(&table, 1, DRIZZLE_LOCK_IGNORE_FLUSH, &not_used)))
 
1653
  if (! ((*lock)= mysql_lock_tables(session, &table, 1,
 
1654
                                    DRIZZLE_LOCK_IGNORE_FLUSH, &not_used)))
1643
1655
  {
1644
1656
    if (*lock)
1645
1657
    {
1646
 
      session->unlockTables(*lock);
 
1658
      mysql_unlock_tables(session, *lock);
1647
1659
      *lock= 0;
1648
1660
    }
1649
1661
 
1704
1716
 
1705
1717
  /* Mark all fields that are given values */
1706
1718
  for (Field **f= field ; *f ; f++)
1707
 
  {
1708
 
    table->setWriteSet((*f)->position());
1709
 
  }
 
1719
    table->setWriteSet((*f)->field_index);
1710
1720
 
1711
1721
  /* Don't set timestamp if used */
1712
1722
  table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
1777
1787
    table->cursor->extra(HA_EXTRA_WRITE_CANNOT_REPLACE);
1778
1788
    if (m_plock)
1779
1789
    {
1780
 
      session->unlockTables(*m_plock);
 
1790
      mysql_unlock_tables(session, *m_plock);
1781
1791
      *m_plock= NULL;
1782
1792
      m_plock= NULL;
1783
1793
    }
1807
1817
 
1808
1818
  if (m_plock)
1809
1819
  {
1810
 
    session->unlockTables(*m_plock);
 
1820
    mysql_unlock_tables(session, *m_plock);
1811
1821
    *m_plock= NULL;
1812
1822
    m_plock= NULL;
1813
1823
  }