83
83
Cursor *Cursor::clone(memory::Root *mem_root)
85
85
Cursor *new_handler= getTable()->getMutableShare()->db_type()->getCursor(*getTable());
87
88
Allocate Cursor->ref here because otherwise ha_open will allocate it
88
89
on this->table->mem_root and we will not be able to reclaim that memory
89
90
when the clone Cursor object is destroyed.
91
92
new_handler->ref= mem_root->alloc(ALIGN_SIZE(ref_length)*2);
92
identifier::Table identifier(getTable()->getShare()->getSchemaName(), getTable()->getShare()->getTableName(), getTable()->getShare()->getType());
93
return new_handler->ha_open(identifier, getTable()->getDBStat(), HA_OPEN_IGNORE_IF_LOCKED) ? NULL : new_handler;
94
identifier::Table identifier(getTable()->getShare()->getSchemaName(),
95
getTable()->getShare()->getTableName(),
96
getTable()->getShare()->getType());
98
if (new_handler && !new_handler->ha_open(identifier,
99
getTable()->getDBStat(),
100
HA_OPEN_IGNORE_IF_LOCKED))
589
598
next_insert_id= 0;
592
void Cursor::drop_table()
601
void Cursor::drop_table(const char *)
597
int Cursor::ha_check(Session*)
608
Performs checks upon the table.
610
@param session thread doing CHECK Table operation
613
HA_ADMIN_OK Successful upgrade
615
HA_ADMIN_NEEDS_UPGRADE Table has structures requiring upgrade
617
HA_ADMIN_NEEDS_ALTER Table has structures requiring ALTER Table
619
HA_ADMIN_NOT_IMPLEMENTED
621
int Cursor::ha_check(Session *)
599
623
return HA_ADMIN_OK;
740
766
@sa Cursor::drop_table()
743
void Cursor::closeMarkForDelete()
770
Cursor::closeMarkForDelete(const char *name)
745
772
setTransactionReadWrite();
774
return drop_table(name);
749
777
int Cursor::index_next_same(unsigned char *buf, const unsigned char *key, uint32_t keylen)
751
int error= index_next(buf);
755
ptrdiff_t ptrdiff= buf - getTable()->getInsertRecord();
756
unsigned char *save_record_0= NULL;
757
KeyInfo *key_info= NULL;
758
KeyPartInfo *key_part;
759
KeyPartInfo *key_part_end= NULL;
762
key_cmp_if_same() compares table->getInsertRecord() against 'key'.
763
In parts it uses table->getInsertRecord() directly, in parts it uses
764
field objects with their local pointers into table->getInsertRecord().
765
If 'buf' is distinct from table->getInsertRecord(), we need to move
766
all record references. This is table->getInsertRecord() itself and
767
the field pointers of the fields used in this key.
771
save_record_0= getTable()->getInsertRecord();
772
getTable()->record[0]= buf;
773
key_info= getTable()->key_info + active_index;
774
key_part= key_info->key_part;
775
key_part_end= key_part + key_info->key_parts;
776
for (; key_part < key_part_end; key_part++)
778
assert(key_part->field);
779
key_part->field->move_field_offset(ptrdiff);
783
if (key_cmp_if_same(getTable(), key, active_index, keylen))
785
getTable()->status=STATUS_NOT_FOUND;
786
error= HA_ERR_END_OF_FILE;
789
/* Move back if necessary. */
792
getTable()->record[0]= save_record_0;
793
for (key_part= key_info->key_part; key_part < key_part_end; key_part++)
794
key_part->field->move_field_offset(-ptrdiff);
780
if (!(error=index_next(buf)))
782
ptrdiff_t ptrdiff= buf - getTable()->getInsertRecord();
783
unsigned char *save_record_0= NULL;
784
KeyInfo *key_info= NULL;
785
KeyPartInfo *key_part;
786
KeyPartInfo *key_part_end= NULL;
789
key_cmp_if_same() compares table->getInsertRecord() against 'key'.
790
In parts it uses table->getInsertRecord() directly, in parts it uses
791
field objects with their local pointers into table->getInsertRecord().
792
If 'buf' is distinct from table->getInsertRecord(), we need to move
793
all record references. This is table->getInsertRecord() itself and
794
the field pointers of the fields used in this key.
798
save_record_0= getTable()->getInsertRecord();
799
getTable()->record[0]= buf;
800
key_info= getTable()->key_info + active_index;
801
key_part= key_info->key_part;
802
key_part_end= key_part + key_info->key_parts;
803
for (; key_part < key_part_end; key_part++)
805
assert(key_part->field);
806
key_part->field->move_field_offset(ptrdiff);
810
if (key_cmp_if_same(getTable(), key, active_index, keylen))
812
getTable()->status=STATUS_NOT_FOUND;
813
error=HA_ERR_END_OF_FILE;
816
/* Move back if necessary. */
819
getTable()->record[0]= save_record_0;
820
for (key_part= key_info->key_part; key_part < key_part_end; key_part++)
821
key_part->field->move_field_offset(-ptrdiff);