~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cursor.cc

Reverted changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
}
73
73
 
74
74
 
 
75
/*
 
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
 
79
 */
75
80
Cursor *Cursor::clone(memory::Root *mem_root)
76
81
{
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)))
85
90
    return NULL;
86
91
 
87
 
  if (new_handler && !new_handler->ha_open(table,
 
92
  TableIdentifier identifier(table->getShare()->getSchemaName(),
 
93
                             table->getShare()->getTableName(),
 
94
                             table->getShare()->getType());
 
95
 
 
96
  if (new_handler && !new_handler->ha_open(identifier,
 
97
                                           table,
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(); }
209
219
 
 
220
int Cursor::doOpen(const TableIdentifier &identifier, int mode, uint32_t test_if_locked)
 
221
{
 
222
  return open(identifier.getPath().c_str(), mode, test_if_locked);
 
223
}
 
224
 
210
225
/**
211
226
  Open database-Cursor.
212
227
 
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
215
230
*/
216
 
int Cursor::ha_open(Table *table_arg, const char *name, int mode,
217
 
                     int test_if_locked)
 
231
int Cursor::ha_open(const TableIdentifier &identifier,
 
232
                    Table *table_arg, const char *name, int mode,
 
233
                    int test_if_locked)
218
234
{
219
235
  int error;
220
236
 
221
237
  table= table_arg;
222
238
  assert(table->getShare() == table_share);
223
239
 
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)))
225
242
  {
226
243
    if ((error == EACCES || error == EROFS) && mode == O_RDWR &&
227
244
        (table->db_stat & HA_TRY_READ_ONLY))
228
245
    {
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);
231
248
    }
232
249
  }
233
250
  if (error)