~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cursor.cc

Merged in move of status variables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
** General Cursor functions
55
55
****************************************************************************/
56
56
Cursor::Cursor(plugin::StorageEngine &engine_arg,
57
 
               Table &arg)
58
 
  : table(arg),
59
 
    engine(engine_arg),
60
 
    estimation_rows_to_insert(0),
 
57
               TableShare &share_arg)
 
58
  : table_share(&share_arg), table(0),
 
59
    estimation_rows_to_insert(0), engine(&engine_arg),
61
60
    ref(0),
62
61
    key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
63
62
    ref_length(sizeof(internal::my_off_t)),
73
72
}
74
73
 
75
74
 
76
 
/*
77
 
 * @note this only used in
78
 
 * optimizer::QuickRangeSelect::init_ror_merged_scan(bool reuse_handler) as
79
 
 * of the writing of this comment. -Brian
80
 
 */
81
75
Cursor *Cursor::clone(memory::Root *mem_root)
82
76
{
83
 
  Cursor *new_handler= getTable()->getMutableShare()->db_type()->getCursor(*getTable());
 
77
  Cursor *new_handler= table->getMutableShare()->db_type()->getCursor(*table->getMutableShare(), mem_root);
84
78
 
85
79
  /*
86
80
    Allocate Cursor->ref here because otherwise ha_open will allocate it
90
84
  if (!(new_handler->ref= (unsigned char*) mem_root->alloc_root(ALIGN_SIZE(ref_length)*2)))
91
85
    return NULL;
92
86
 
93
 
  TableIdentifier identifier(getTable()->getShare()->getSchemaName(),
94
 
                             getTable()->getShare()->getTableName(),
95
 
                             getTable()->getShare()->getType());
96
 
 
97
 
  if (new_handler && !new_handler->ha_open(identifier,
98
 
                                           getTable()->getDBStat(),
 
87
  if (new_handler && !new_handler->ha_open(table,
 
88
                                           table->getMutableShare()->getNormalizedPath(),
 
89
                                           table->getDBStat(),
99
90
                                           HA_OPEN_IGNORE_IF_LOCKED))
100
91
    return new_handler;
101
92
  return NULL;
111
102
  /* works only with key prefixes */
112
103
  assert(((keypart_map_arg + 1) & keypart_map_arg) == 0);
113
104
 
114
 
  const KeyPartInfo *key_part_found= getTable()->getShare()->getKeyInfo(key_position).key_part;
115
 
  const KeyPartInfo *end_key_part_found= key_part_found + getTable()->getShare()->getKeyInfo(key_position).key_parts;
 
105
  const KeyPartInfo *key_part_found= table->getShare()->getKeyInfo(key_position).key_part;
 
106
  const KeyPartInfo *end_key_part_found= key_part_found + table->getShare()->getKeyInfo(key_position).key_parts;
116
107
  uint32_t length= 0;
117
108
 
118
109
  while (key_part_found < end_key_part_found && keypart_map_arg)
175
166
  return end_bulk_insert();
176
167
}
177
168
 
 
169
void Cursor::change_table_ptr(Table *table_arg, TableShare *share)
 
170
{
 
171
  table= table_arg;
 
172
  table_share= share;
 
173
}
 
174
 
178
175
const key_map *Cursor::keys_to_use_for_scanning()
179
176
{
180
177
  return &key_map_empty;
182
179
 
183
180
bool Cursor::has_transactions()
184
181
{
185
 
  return (getTable()->getShare()->db_type()->check_flag(HTON_BIT_DOES_TRANSACTIONS));
 
182
  return (table->getShare()->db_type()->check_flag(HTON_BIT_DOES_TRANSACTIONS));
186
183
}
187
184
 
188
185
void Cursor::ha_statistic_increment(uint64_t system_status_var::*offset) const
189
186
{
190
 
  (getTable()->in_use->status_var.*offset)++;
 
187
  status_var_increment(table->in_use->status_var.*offset);
191
188
}
192
189
 
193
190
void **Cursor::ha_data(Session *session) const
194
191
{
195
 
  return session->getEngineData(getEngine());
 
192
  return session->getEngineData(engine);
196
193
}
197
194
 
198
195
bool Cursor::is_fatal_error(int error, uint32_t flags)
208
205
 
209
206
ha_rows Cursor::records() { return stats.records; }
210
207
uint64_t Cursor::tableSize() { return stats.index_file_length + stats.data_file_length; }
211
 
uint64_t Cursor::rowSize() { return getTable()->getRecordLength() + getTable()->sizeFields(); }
212
 
 
213
 
int Cursor::doOpen(const TableIdentifier &identifier, int mode, uint32_t test_if_locked)
214
 
{
215
 
  return open(identifier.getPath().c_str(), mode, test_if_locked);
216
 
}
 
208
uint64_t Cursor::rowSize() { return table->getRecordLength() + table->sizeFields(); }
217
209
 
218
210
/**
219
211
  Open database-Cursor.
221
213
  Try O_RDONLY if cannot open as O_RDWR
222
214
  Don't wait for locks if not HA_OPEN_WAIT_IF_LOCKED is set
223
215
*/
224
 
int Cursor::ha_open(const TableIdentifier &identifier,
225
 
                    int mode,
226
 
                    int test_if_locked)
 
216
int Cursor::ha_open(Table *table_arg, const char *name, int mode,
 
217
                     int test_if_locked)
227
218
{
228
219
  int error;
229
220
 
230
 
  if ((error= doOpen(identifier, mode, test_if_locked)))
 
221
  table= table_arg;
 
222
  assert(table->getShare() == table_share);
 
223
 
 
224
  if ((error=open(name, mode, test_if_locked)))
231
225
  {
232
226
    if ((error == EACCES || error == EROFS) && mode == O_RDWR &&
233
 
        (getTable()->db_stat & HA_TRY_READ_ONLY))
 
227
        (table->db_stat & HA_TRY_READ_ONLY))
234
228
    {
235
 
      getTable()->db_stat|=HA_READ_ONLY;
236
 
      error= doOpen(identifier, O_RDONLY,test_if_locked);
 
229
      table->db_stat|=HA_READ_ONLY;
 
230
      error=open(name,O_RDONLY,test_if_locked);
237
231
    }
238
232
  }
239
233
  if (error)
242
236
  }
243
237
  else
244
238
  {
245
 
    if (getTable()->getShare()->db_options_in_use & HA_OPTION_READ_ONLY_DATA)
246
 
      getTable()->db_stat|=HA_READ_ONLY;
 
239
    if (table->getShare()->db_options_in_use & HA_OPTION_READ_ONLY_DATA)
 
240
      table->db_stat|=HA_READ_ONLY;
247
241
    (void) extra(HA_EXTRA_NO_READCHECK);        // Not needed in SQL
248
242
 
249
243
    /* ref is already allocated for us if we're called from Cursor::clone() */
250
 
    if (!ref && !(ref= (unsigned char*) getTable()->alloc_root(ALIGN_SIZE(ref_length)*2)))
 
244
    if (!ref && !(ref= (unsigned char*) table->alloc_root(ALIGN_SIZE(ref_length)*2)))
251
245
    {
252
246
      close();
253
247
      error=HA_ERR_OUT_OF_MEM;
276
270
    TODO remove the test for HA_READ_ORDER
277
271
  */
278
272
  if (stats.deleted < 10 || primary_key >= MAX_KEY ||
279
 
      !(getTable()->index_flags(primary_key) & HA_READ_ORDER))
 
273
      !(table->index_flags(primary_key) & HA_READ_ORDER))
280
274
  {
281
275
    (void) startTableScan(1);
282
276
    while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
304
298
  @verbatim 1,5,15,25,35,... @endverbatim
305
299
*/
306
300
inline uint64_t
307
 
compute_next_insert_id(uint64_t nr, drizzle_system_variables *variables)
 
301
compute_next_insert_id(uint64_t nr,struct system_variables *variables)
308
302
{
309
303
  if (variables->auto_increment_increment == 1)
310
304
    return (nr+1); // optimization of the formula below
324
318
    Session::next_insert_id to be greater than the explicit value.
325
319
  */
326
320
  if ((next_insert_id > 0) && (nr >= next_insert_id))
327
 
    set_next_insert_id(compute_next_insert_id(nr, &getTable()->in_use->variables));
 
321
    set_next_insert_id(compute_next_insert_id(nr, &table->in_use->variables));
328
322
}
329
323
 
330
324
 
344
338
    The number X if it exists, "nr" otherwise.
345
339
*/
346
340
inline uint64_t
347
 
prev_insert_id(uint64_t nr, drizzle_system_variables *variables)
 
341
prev_insert_id(uint64_t nr, struct system_variables *variables)
348
342
{
349
343
  if (unlikely(nr < variables->auto_increment_offset))
350
344
  {
441
435
{
442
436
  uint64_t nr, nb_reserved_values;
443
437
  bool append= false;
444
 
  Session *session= getTable()->in_use;
445
 
  drizzle_system_variables *variables= &session->variables;
 
438
  Session *session= table->in_use;
 
439
  struct system_variables *variables= &session->variables;
446
440
 
447
441
  /*
448
442
    next_insert_id is a "cursor" into the reserved interval, it may go greater
454
448
     for an auto increment column, not a magic value like NULL is.
455
449
     same as sql_mode=NO_AUTO_VALUE_ON_ZERO */
456
450
 
457
 
  if ((nr= getTable()->next_number_field->val_int()) != 0
458
 
      || getTable()->auto_increment_field_not_null)
 
451
  if ((nr= table->next_number_field->val_int()) != 0
 
452
      || table->auto_increment_field_not_null)
459
453
  {
460
454
    /*
461
455
      Update next_insert_id if we had already generated a value in this
533
527
      nr= compute_next_insert_id(nr-1, variables);
534
528
    }
535
529
 
536
 
    if (getTable()->getShare()->next_number_keypart == 0)
 
530
    if (table->getShare()->next_number_keypart == 0)
537
531
    {
538
532
      /* We must defer the appending until "nr" has been possibly truncated */
539
533
      append= true;
540
534
    }
541
535
  }
542
536
 
543
 
  if (unlikely(getTable()->next_number_field->store((int64_t) nr, true)))
 
537
  if (unlikely(table->next_number_field->store((int64_t) nr, true)))
544
538
  {
545
539
    /*
546
540
      first test if the query was aborted due to strict mode constraints
547
541
    */
548
 
    if (session->getKilled() == Session::KILL_BAD_DATA)
 
542
    if (session->killed == Session::KILL_BAD_DATA)
549
543
      return HA_ERR_AUTOINC_ERANGE;
550
544
 
551
545
    /*
556
550
      bother shifting the right bound (anyway any other value from this
557
551
      interval will cause a duplicate key).
558
552
    */
559
 
    nr= prev_insert_id(getTable()->next_number_field->val_int(), variables);
560
 
    if (unlikely(getTable()->next_number_field->store((int64_t) nr, true)))
561
 
      nr= getTable()->next_number_field->val_int();
 
553
    nr= prev_insert_id(table->next_number_field->val_int(), variables);
 
554
    if (unlikely(table->next_number_field->store((int64_t) nr, true)))
 
555
      nr= table->next_number_field->val_int();
562
556
  }
563
557
  if (append)
564
558
  {
612
606
      this statement used forced auto_increment values if there were some,
613
607
      wipe them away for other statements.
614
608
    */
615
 
    getTable()->in_use->auto_inc_intervals_forced.empty();
 
609
    table->in_use->auto_inc_intervals_forced.empty();
616
610
  }
617
611
}
618
612
 
658
652
   * possible resource to gain (and if there is... then there is a bug such
659
653
   * that in_use should have been set.
660
654
 */
661
 
  if (not getTable()->in_use)
 
655
  if (not table || not table->in_use)
662
656
    return;
663
657
 
664
 
  resource_context= getTable()->in_use->getResourceContext(getEngine());
 
658
  resource_context= table->in_use->getResourceContext(engine);
665
659
  /*
666
660
    When a storage engine method is called, the transaction must
667
661
    have been started, unless it's a DDL call, for which the
702
696
     * @todo Make TransactionServices generic to AfterTriggerServices
703
697
     * or similar...
704
698
     */
705
 
    Session *const session= getTable()->in_use;
 
699
    Session *const session= table->in_use;
706
700
    TransactionServices &transaction_services= TransactionServices::singleton();
707
 
    transaction_services.truncateTable(session, getTable());
 
701
    transaction_services.truncateTable(session, table);
708
702
  }
709
703
 
710
704
  return result;
803
797
  int error;
804
798
  if (!(error=index_next(buf)))
805
799
  {
806
 
    ptrdiff_t ptrdiff= buf - getTable()->getInsertRecord();
 
800
    ptrdiff_t ptrdiff= buf - table->record[0];
807
801
    unsigned char *save_record_0= NULL;
808
802
    KeyInfo *key_info= NULL;
809
803
    KeyPartInfo *key_part;
810
804
    KeyPartInfo *key_part_end= NULL;
811
805
 
812
806
    /*
813
 
      key_cmp_if_same() compares table->getInsertRecord() against 'key'.
814
 
      In parts it uses table->getInsertRecord() directly, in parts it uses
815
 
      field objects with their local pointers into table->getInsertRecord().
816
 
      If 'buf' is distinct from table->getInsertRecord(), we need to move
817
 
      all record references. This is table->getInsertRecord() itself and
 
807
      key_cmp_if_same() compares table->record[0] against 'key'.
 
808
      In parts it uses table->record[0] directly, in parts it uses
 
809
      field objects with their local pointers into table->record[0].
 
810
      If 'buf' is distinct from table->record[0], we need to move
 
811
      all record references. This is table->record[0] itself and
818
812
      the field pointers of the fields used in this key.
819
813
    */
820
814
    if (ptrdiff)
821
815
    {
822
 
      save_record_0= getTable()->getInsertRecord();
823
 
      getTable()->record[0]= buf;
824
 
      key_info= getTable()->key_info + active_index;
 
816
      save_record_0= table->record[0];
 
817
      table->record[0]= buf;
 
818
      key_info= table->key_info + active_index;
825
819
      key_part= key_info->key_part;
826
820
      key_part_end= key_part + key_info->key_parts;
827
821
      for (; key_part < key_part_end; key_part++)
831
825
      }
832
826
    }
833
827
 
834
 
    if (key_cmp_if_same(getTable(), key, active_index, keylen))
 
828
    if (key_cmp_if_same(table, key, active_index, keylen))
835
829
    {
836
 
      getTable()->status=STATUS_NOT_FOUND;
 
830
      table->status=STATUS_NOT_FOUND;
837
831
      error=HA_ERR_END_OF_FILE;
838
832
    }
839
833
 
840
834
    /* Move back if necessary. */
841
835
    if (ptrdiff)
842
836
    {
843
 
      getTable()->record[0]= save_record_0;
 
837
      table->record[0]= save_record_0;
844
838
      for (key_part= key_info->key_part; key_part < key_part_end; key_part++)
845
839
        key_part->field->move_field_offset(-ptrdiff);
846
840
    }
877
871
double Cursor::index_only_read_time(uint32_t keynr, double key_records)
878
872
{
879
873
  uint32_t keys_per_block= (stats.block_size/2/
880
 
                        (getTable()->key_info[keynr].key_length + ref_length) + 1);
 
874
                        (table->key_info[keynr].key_length + ref_length) + 1);
881
875
  return ((double) (key_records + keys_per_block-1) /
882
876
          (double) keys_per_block);
883
877
}
906
900
 
907
901
  @note
908
902
    This method (or an overriding one in a derived class) must check for
909
 
    session->getKilled() and return HA_POS_ERROR if it is not zero. This is required
 
903
    session->killed and return HA_POS_ERROR if it is not zero. This is required
910
904
    for a user to be able to interrupt the calculation by killing the
911
905
    connection/query.
912
906
 
1159
1153
  @param sorted         Set to 1 if result should be sorted per key
1160
1154
 
1161
1155
  @note
1162
 
    Record is read into table->getInsertRecord()
 
1156
    Record is read into table->record[0]
1163
1157
 
1164
1158
  @retval
1165
1159
    0                   Found row
1184
1178
    key_compare_result_on_equal= ((end_key->flag == HA_READ_BEFORE_KEY) ? 1 :
1185
1179
                                  (end_key->flag == HA_READ_AFTER_KEY) ? -1 : 0);
1186
1180
  }
1187
 
  range_key_part= getTable()->key_info[active_index].key_part;
 
1181
  range_key_part= table->key_info[active_index].key_part;
1188
1182
 
1189
1183
  if (!start_key)                       // Read first record
1190
 
    result= index_first(getTable()->getInsertRecord());
 
1184
    result= index_first(table->record[0]);
1191
1185
  else
1192
 
    result= index_read_map(getTable()->getInsertRecord(),
 
1186
    result= index_read_map(table->record[0],
1193
1187
                           start_key->key,
1194
1188
                           start_key->keypart_map,
1195
1189
                           start_key->flag);
1206
1200
  Read next row between two endpoints.
1207
1201
 
1208
1202
  @note
1209
 
    Record is read into table->getInsertRecord()
 
1203
    Record is read into table->record[0]
1210
1204
 
1211
1205
  @retval
1212
1206
    0                   Found row
1222
1216
  if (eq_range)
1223
1217
  {
1224
1218
    /* We trust that index_next_same always gives a row in range */
1225
 
    return(index_next_same(getTable()->getInsertRecord(),
 
1219
    return(index_next_same(table->record[0],
1226
1220
                                end_range->key,
1227
1221
                                end_range->length));
1228
1222
  }
1229
 
  result= index_next(getTable()->getInsertRecord());
 
1223
  result= index_next(table->record[0]);
1230
1224
  if (result)
1231
1225
    return result;
1232
1226
  return(compare_key(end_range) <= 0 ? 0 : HA_ERR_END_OF_FILE);
1316
1310
     * called.  If it fails, then a call to deleteRecord()
1317
1311
     * is called, followed by a repeat of the original
1318
1312
     * call to insertRecord().  So, log_row_for_replication
1319
 
     * could be called multiple times for a REPLACE
 
1313
     * could be called either once or twice for a REPLACE
1320
1314
     * statement.  The below looks at the values of before_record
1321
1315
     * and after_record to determine which call to this
1322
1316
     * function is for the delete or the insert, since NULL
1329
1323
     */
1330
1324
    if (after_record == NULL)
1331
1325
    {
1332
 
      /*
1333
 
       * The storage engine is passed the record in table->record[1]
1334
 
       * as the row to delete (this is the conflicting row), so
1335
 
       * we need to notify TransactionService to use that row.
1336
 
       */
1337
 
      transaction_services.deleteRecord(session, table, true);
 
1326
      transaction_services.deleteRecord(session, table);
1338
1327
      /* 
1339
1328
       * We set the "current" statement message to NULL.  This triggers
1340
1329
       * the replication services component to generate a new statement
1352
1341
    break;
1353
1342
  case SQLCOM_INSERT:
1354
1343
  case SQLCOM_INSERT_SELECT:
1355
 
  case SQLCOM_LOAD:
1356
1344
    /*
1357
1345
     * The else block below represents an 
1358
1346
     * INSERT ... ON DUPLICATE KEY UPDATE that
1394
1382
  {
1395
1383
    if (lock_type == F_RDLCK)
1396
1384
    {
1397
 
      DRIZZLE_CURSOR_RDLOCK_START(getTable()->getShare()->getSchemaName(),
1398
 
                                  getTable()->getShare()->getTableName());
 
1385
      DRIZZLE_CURSOR_RDLOCK_START(table_share->getSchemaName(),
 
1386
                                  table_share->getTableName());
1399
1387
    }
1400
1388
    else if (lock_type == F_WRLCK)
1401
1389
    {
1402
 
      DRIZZLE_CURSOR_WRLOCK_START(getTable()->getShare()->getSchemaName(),
1403
 
                                  getTable()->getShare()->getTableName());
 
1390
      DRIZZLE_CURSOR_WRLOCK_START(table_share->getSchemaName(),
 
1391
                                  table_share->getTableName());
1404
1392
    }
1405
1393
    else if (lock_type == F_UNLCK)
1406
1394
    {
1407
 
      DRIZZLE_CURSOR_UNLOCK_START(getTable()->getShare()->getSchemaName(),
1408
 
                                  getTable()->getShare()->getTableName());
 
1395
      DRIZZLE_CURSOR_UNLOCK_START(table_share->getSchemaName(),
 
1396
                                  table_share->getTableName());
1409
1397
    }
1410
1398
  }
1411
1399
 
1444
1432
int Cursor::ha_reset()
1445
1433
{
1446
1434
  /* Check that we have called all proper deallocation functions */
1447
 
  assert(! getTable()->getShare()->all_set.none());
1448
 
  assert(getTable()->key_read == 0);
 
1435
  assert((unsigned char*) table->def_read_set.getBitmap() +
 
1436
              table->getShare()->column_bitmap_size ==
 
1437
              (unsigned char*) table->def_write_set.getBitmap());
 
1438
  assert(table->getShare()->all_set.isSetAll());
 
1439
  assert(table->key_read == 0);
1449
1440
  /* ensure that ha_index_end / endTableScan has been called */
1450
1441
  assert(inited == NONE);
1451
1442
  /* Free cache used by filesort */
1452
 
  getTable()->free_io_cache();
 
1443
  table->free_io_cache();
1453
1444
  /* reset the bitmaps to point to defaults */
1454
 
  getTable()->default_column_bitmaps();
 
1445
  table->default_column_bitmaps();
1455
1446
  return(reset());
1456
1447
}
1457
1448
 
1466
1457
   * @TODO Technically, the below two lines can be take even further out of the
1467
1458
   * Cursor interface and into the fill_record() method.
1468
1459
   */
1469
 
  if (getTable()->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
 
1460
  if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
1470
1461
  {
1471
 
    getTable()->timestamp_field->set_time();
 
1462
    table->timestamp_field->set_time();
1472
1463
  }
1473
1464
 
1474
 
  DRIZZLE_INSERT_ROW_START(getTable()->getShare()->getSchemaName(), getTable()->getShare()->getTableName());
 
1465
  DRIZZLE_INSERT_ROW_START(table_share->getSchemaName(), table_share->getTableName());
1475
1466
  setTransactionReadWrite();
1476
1467
  
1477
 
  if (unlikely(plugin::EventObserver::beforeInsertRecord(*getTable(), buf)))
 
1468
  if (unlikely(plugin::EventObserver::beforeInsertRecord(*table, buf)))
1478
1469
  {
1479
1470
    error= ER_EVENT_OBSERVER_PLUGIN;
1480
1471
  }
1481
1472
  else
1482
1473
  {
1483
1474
    error= doInsertRecord(buf);
1484
 
    if (unlikely(plugin::EventObserver::afterInsertRecord(*getTable(), buf, error))) 
 
1475
    if (unlikely(plugin::EventObserver::afterInsertRecord(*table, buf, error))) 
1485
1476
    {
1486
1477
      error= ER_EVENT_OBSERVER_PLUGIN;
1487
1478
    }
1496
1487
    return error;
1497
1488
  }
1498
1489
 
1499
 
  if (unlikely(log_row_for_replication(getTable(), NULL, buf)))
 
1490
  if (unlikely(log_row_for_replication(table, NULL, buf)))
1500
1491
    return HA_ERR_RBR_LOGGING_FAILED;
1501
1492
 
1502
1493
  return 0;
1508
1499
  int error;
1509
1500
 
1510
1501
  /*
1511
 
    Some storage engines require that the new record is in getInsertRecord()
1512
 
    (and the old record is in getUpdateRecord()).
 
1502
    Some storage engines require that the new record is in record[0]
 
1503
    (and the old record is in record[1]).
1513
1504
   */
1514
 
  assert(new_data == getTable()->getInsertRecord());
 
1505
  assert(new_data == table->record[0]);
1515
1506
 
1516
 
  DRIZZLE_UPDATE_ROW_START(getTable()->getShare()->getSchemaName(), getTable()->getShare()->getTableName());
 
1507
  DRIZZLE_UPDATE_ROW_START(table_share->getSchemaName(), table_share->getTableName());
1517
1508
  setTransactionReadWrite();
1518
 
  if (unlikely(plugin::EventObserver::beforeUpdateRecord(*getTable(), old_data, new_data)))
 
1509
  if (unlikely(plugin::EventObserver::beforeUpdateRecord(*table, old_data, new_data)))
1519
1510
  {
1520
1511
    error= ER_EVENT_OBSERVER_PLUGIN;
1521
1512
  }
1522
1513
  else
1523
1514
  {
1524
 
    if (getTable()->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
 
1515
    if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
1525
1516
    {
1526
 
      getTable()->timestamp_field->set_time();
 
1517
      table->timestamp_field->set_time();
1527
1518
    }
1528
1519
 
1529
1520
    error= doUpdateRecord(old_data, new_data);
1530
 
    if (unlikely(plugin::EventObserver::afterUpdateRecord(*getTable(), old_data, new_data, error)))
 
1521
    if (unlikely(plugin::EventObserver::afterUpdateRecord(*table, old_data, new_data, error)))
1531
1522
    {
1532
1523
      error= ER_EVENT_OBSERVER_PLUGIN;
1533
1524
    }
1542
1533
    return error;
1543
1534
  }
1544
1535
 
1545
 
  if (unlikely(log_row_for_replication(getTable(), old_data, new_data)))
 
1536
  if (unlikely(log_row_for_replication(table, old_data, new_data)))
1546
1537
    return HA_ERR_RBR_LOGGING_FAILED;
1547
1538
 
1548
1539
  return 0;
1549
1540
}
1550
 
TableShare *Cursor::getShare()
1551
 
{
1552
 
  return getTable()->getMutableShare();
1553
 
}
1554
1541
 
1555
1542
int Cursor::deleteRecord(const unsigned char *buf)
1556
1543
{
1557
1544
  int error;
1558
1545
 
1559
 
  DRIZZLE_DELETE_ROW_START(getTable()->getShare()->getSchemaName(), getTable()->getShare()->getTableName());
 
1546
  DRIZZLE_DELETE_ROW_START(table_share->getSchemaName(), table_share->getTableName());
1560
1547
  setTransactionReadWrite();
1561
 
  if (unlikely(plugin::EventObserver::beforeDeleteRecord(*getTable(), buf)))
 
1548
  if (unlikely(plugin::EventObserver::beforeDeleteRecord(*table, buf)))
1562
1549
  {
1563
1550
    error= ER_EVENT_OBSERVER_PLUGIN;
1564
1551
  }
1565
1552
  else
1566
1553
  {
1567
1554
    error= doDeleteRecord(buf);
1568
 
    if (unlikely(plugin::EventObserver::afterDeleteRecord(*getTable(), buf, error)))
 
1555
    if (unlikely(plugin::EventObserver::afterDeleteRecord(*table, buf, error)))
1569
1556
    {
1570
1557
      error= ER_EVENT_OBSERVER_PLUGIN;
1571
1558
    }
1578
1565
  if (unlikely(error))
1579
1566
    return error;
1580
1567
 
1581
 
  if (unlikely(log_row_for_replication(getTable(), buf, NULL)))
 
1568
  if (unlikely(log_row_for_replication(table, buf, NULL)))
1582
1569
    return HA_ERR_RBR_LOGGING_FAILED;
1583
1570
 
1584
1571
  return 0;