76
* @note this only used in
77
* optimizer::QuickRangeSelect::init_ror_merged_scan(bool reuse_handler) as
78
* of the writing of this comment. -Brian
75
80
Cursor *Cursor::clone(memory::Root *mem_root)
77
82
Cursor *new_handler= table->getMutableShare()->db_type()->getCursor(*table->getMutableShare(), mem_root);
84
89
if (!(new_handler->ref= (unsigned char*) mem_root->alloc_root(ALIGN_SIZE(ref_length)*2)))
87
if (new_handler && !new_handler->ha_open(table,
92
TableIdentifier identifier(table->getShare()->getSchemaName(),
93
table->getShare()->getTableName(),
94
table->getShare()->getType());
96
if (new_handler && !new_handler->ha_open(identifier,
88
98
table->getMutableShare()->getNormalizedPath(),
89
99
table->getDBStat(),
90
100
HA_OPEN_IGNORE_IF_LOCKED))
207
217
uint64_t Cursor::tableSize() { return stats.index_file_length + stats.data_file_length; }
208
218
uint64_t Cursor::rowSize() { return table->getRecordLength() + table->sizeFields(); }
220
int Cursor::doOpen(const TableIdentifier &identifier, int mode, uint32_t test_if_locked)
222
return open(identifier.getPath().c_str(), mode, test_if_locked);
211
226
Open database-Cursor.
213
228
Try O_RDONLY if cannot open as O_RDWR
214
229
Don't wait for locks if not HA_OPEN_WAIT_IF_LOCKED is set
216
int Cursor::ha_open(Table *table_arg, const char *name, int mode,
231
int Cursor::ha_open(const TableIdentifier &identifier,
232
Table *table_arg, const char *name, int mode,
221
237
table= table_arg;
222
238
assert(table->getShare() == table_share);
224
if ((error=open(name, mode, test_if_locked)))
240
assert(identifier.getPath().compare(name) == 0);
241
if ((error= doOpen(identifier, mode, test_if_locked)))
226
243
if ((error == EACCES || error == EROFS) && mode == O_RDWR &&
227
244
(table->db_stat & HA_TRY_READ_ONLY))
229
246
table->db_stat|=HA_READ_ONLY;
230
error=open(name,O_RDONLY,test_if_locked);
247
error= doOpen(identifier, O_RDONLY,test_if_locked);