~posulliv/drizzle/optimizer-style-cleanup

« back to all changes in this revision

Viewing changes to drizzled/cursor.cc

  • Committer: Padraig O'Sullivan
  • Date: 2010-03-15 14:05:26 UTC
  • mfrom: (1237.9.99 staging)
  • Revision ID: osullivan.padraig@gmail.com-20100315140526-opbgwdwn6tfecdkq
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
158
158
  return (table->s->db_type()->check_flag(HTON_BIT_DOES_TRANSACTIONS));
159
159
}
160
160
 
161
 
void Cursor::ha_statistic_increment(ulong SSV::*offset) const
 
161
void Cursor::ha_statistic_increment(ulong system_status_var::*offset) const
162
162
{
163
163
  status_var_increment(table->in_use->status_var.*offset);
164
164
}
187
187
 
188
188
 
189
189
ha_rows Cursor::records() { return stats.records; }
 
190
uint64_t Cursor::tableSize() { return stats.index_file_length + stats.data_file_length; }
 
191
uint64_t Cursor::rowSize() { return table->getRecordLength() + table->sizeFields(); }
190
192
 
191
193
/**
192
194
  Open database-Cursor.
265
267
{
266
268
  register int error;
267
269
 
268
 
  ha_statistic_increment(&SSV::ha_read_first_count);
 
270
  ha_statistic_increment(&system_status_var::ha_read_first_count);
269
271
 
270
272
  /*
271
273
    If there is very few deleted rows in the table, find the first row by
696
698
 
697
699
inline
698
700
void
699
 
Cursor::mark_trx_read_write()
 
701
Cursor::setTransactionReadWrite()
700
702
{
701
 
  Ha_trx_info *ha_info= ha_session()->getEngineInfo(engine);
 
703
  ResourceContext *resource_context= ha_session()->getResourceContext(engine);
702
704
  /*
703
705
    When a storage engine method is called, the transaction must
704
706
    have been started, unless it's a DDL call, for which the
707
709
    Unfortunately here we can't know know for sure if the engine
708
710
    has registered the transaction or not, so we must check.
709
711
  */
710
 
  if (ha_info->is_started())
 
712
  if (resource_context->isStarted())
711
713
  {
712
 
      ha_info->set_trx_read_write();
 
714
    resource_context->markModifiedData();
713
715
  }
714
716
}
715
717
 
727
729
int
728
730
Cursor::ha_delete_all_rows()
729
731
{
730
 
  mark_trx_read_write();
 
732
  setTransactionReadWrite();
731
733
 
732
734
  int result= delete_all_rows();
733
735
 
757
759
int
758
760
Cursor::ha_reset_auto_increment(uint64_t value)
759
761
{
760
 
  mark_trx_read_write();
 
762
  setTransactionReadWrite();
761
763
 
762
764
  return reset_auto_increment(value);
763
765
}
772
774
int
773
775
Cursor::ha_analyze(Session* session, HA_CHECK_OPT*)
774
776
{
775
 
  mark_trx_read_write();
 
777
  setTransactionReadWrite();
776
778
 
777
779
  return analyze(session);
778
780
}
786
788
int
787
789
Cursor::ha_disable_indexes(uint32_t mode)
788
790
{
789
 
  mark_trx_read_write();
 
791
  setTransactionReadWrite();
790
792
 
791
793
  return disable_indexes(mode);
792
794
}
801
803
int
802
804
Cursor::ha_enable_indexes(uint32_t mode)
803
805
{
804
 
  mark_trx_read_write();
 
806
  setTransactionReadWrite();
805
807
 
806
808
  return enable_indexes(mode);
807
809
}
816
818
int
817
819
Cursor::ha_discard_or_import_tablespace(bool discard)
818
820
{
819
 
  mark_trx_read_write();
 
821
  setTransactionReadWrite();
820
822
 
821
823
  return discard_or_import_tablespace(discard);
822
824
}
830
832
void
831
833
Cursor::closeMarkForDelete(const char *name)
832
834
{
833
 
  mark_trx_read_write();
 
835
  setTransactionReadWrite();
834
836
 
835
837
  return drop_table(name);
836
838
}
1353
1355
 
1354
1356
  switch (session->lex->sql_command)
1355
1357
  {
 
1358
  case SQLCOM_CREATE_TABLE:
 
1359
    /*
 
1360
     * We are in a CREATE TABLE ... SELECT statement
 
1361
     * and the kernel has already created the table
 
1362
     * and put a CreateTableStatement in the active
 
1363
     * Transaction message.  Here, we add a new InsertRecord
 
1364
     * to a new Transaction message (because the above
 
1365
     * CREATE TABLE will commit the transaction containing
 
1366
     * it).
 
1367
     */
 
1368
    result= replication_services.insertRecord(session, table);
 
1369
    break;
1356
1370
  case SQLCOM_REPLACE:
1357
1371
  case SQLCOM_REPLACE_SELECT:
1358
1372
    /*
1513
1527
    table->timestamp_field->set_time();
1514
1528
 
1515
1529
  DRIZZLE_INSERT_ROW_START(table_share->db.str, table_share->table_name.str);
1516
 
  mark_trx_read_write();
 
1530
  setTransactionReadWrite();
1517
1531
  error= write_row(buf);
1518
1532
  DRIZZLE_INSERT_ROW_DONE(error);
1519
1533
 
1540
1554
  assert(new_data == table->record[0]);
1541
1555
 
1542
1556
  DRIZZLE_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
1543
 
  mark_trx_read_write();
 
1557
  setTransactionReadWrite();
1544
1558
  error= update_row(old_data, new_data);
1545
1559
  DRIZZLE_UPDATE_ROW_DONE(error);
1546
1560
 
1560
1574
  int error;
1561
1575
 
1562
1576
  DRIZZLE_DELETE_ROW_START(table_share->db.str, table_share->table_name.str);
1563
 
  mark_trx_read_write();
 
1577
  setTransactionReadWrite();
1564
1578
  error= delete_row(buf);
1565
1579
  DRIZZLE_DELETE_ROW_DONE(error);
1566
1580