~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cursor.cc

  • Committer: Brian Aker
  • Date: 2010-05-05 18:28:18 UTC
  • mfrom: (1491.1.10 cleanup-cursor)
  • Revision ID: brian@gaz-20100505182818-zrswe2jqrps52f71
Merge name changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
    key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
61
61
    ref_length(sizeof(internal::my_off_t)),
62
62
    inited(NONE),
63
 
    locked(false), implicit_emptied(0),
 
63
    locked(false),
64
64
    next_insert_id(0), insert_id_for_cur_row(0)
65
65
{ }
66
66
 
114
114
  return length;
115
115
}
116
116
 
117
 
int Cursor::ha_index_init(uint32_t idx, bool sorted)
 
117
int Cursor::startIndexScan(uint32_t idx, bool sorted)
118
118
{
119
119
  int result;
120
120
  assert(inited == NONE);
121
 
  if (!(result= index_init(idx, sorted)))
 
121
  if (!(result= doStartIndexScan(idx, sorted)))
122
122
    inited=INDEX;
123
123
  end_range= NULL;
124
124
  return result;
125
125
}
126
126
 
127
 
int Cursor::ha_index_end()
 
127
int Cursor::endIndexScan()
128
128
{
129
129
  assert(inited==INDEX);
130
130
  inited=NONE;
131
131
  end_range= NULL;
132
 
  return(index_end());
 
132
  return(doEndIndexScan());
133
133
}
134
134
 
135
 
int Cursor::ha_rnd_init(bool scan)
 
135
int Cursor::startTableScan(bool scan)
136
136
{
137
137
  int result;
138
138
  assert(inited==NONE || (inited==RND && scan));
139
 
  inited= (result= rnd_init(scan)) ? NONE: RND;
 
139
  inited= (result= doStartTableScan(scan)) ? NONE: RND;
140
140
 
141
141
  return result;
142
142
}
143
143
 
144
 
int Cursor::ha_rnd_end()
 
144
int Cursor::endTableScan()
145
145
{
146
146
  assert(inited==RND);
147
147
  inited=NONE;
148
 
  return(rnd_end());
 
148
  return(doEndTableScan());
149
149
}
150
150
 
151
151
int Cursor::ha_index_or_rnd_end()
152
152
{
153
 
  return inited == INDEX ? ha_index_end() : inited == RND ? ha_rnd_end() : 0;
 
153
  return inited == INDEX ? endIndexScan() : inited == RND ? endTableScan() : 0;
154
154
}
155
155
 
156
156
void Cursor::ha_start_bulk_insert(ha_rows rows)
271
271
  register int error;
272
272
 
273
273
  position(record);
274
 
  if (inited && (error= ha_index_end()))
 
274
  if (inited && (error= endIndexScan()))
275
275
    return error;
276
 
  if ((error= ha_rnd_init(false)))
 
276
  if ((error= startTableScan(false)))
277
277
    return error;
278
278
 
279
279
  return rnd_pos(record, ref);
299
299
  if (stats.deleted < 10 || primary_key >= MAX_KEY ||
300
300
      !(table->index_flags(primary_key) & HA_READ_ORDER))
301
301
  {
302
 
    (void) ha_rnd_init(1);
 
302
    (void) startTableScan(1);
303
303
    while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
304
 
    (void) ha_rnd_end();
 
304
    (void) endTableScan();
305
305
  }
306
306
  else
307
307
  {
308
308
    /* Find the first row through the primary key */
309
 
    (void) ha_index_init(primary_key, 0);
 
309
    (void) startIndexScan(primary_key, 0);
310
310
    error=index_first(buf);
311
 
    (void) ha_index_end();
 
311
    (void) endIndexScan();
312
312
  }
313
313
  return error;
314
314
}
1059
1059
  @param buf             INOUT: memory buffer to be used
1060
1060
 
1061
1061
  @note
1062
 
    One must have called index_init() before calling this function. Several
 
1062
    One must have called doStartIndexScan() before calling this function. Several
1063
1063
    multi_range_read_init() calls may be made in course of one query.
1064
1064
 
1065
1065
    Until WL#2623 is done (see its text, section 3.2), the following will
1074
1074
    The callee consumes all or some fraction of the provided buffer space, and
1075
1075
    sets the HANDLER_BUFFER members accordingly.
1076
1076
    The callee may use the buffer memory until the next multi_range_read_init()
1077
 
    call is made, all records have been read, or until index_end() call is
 
1077
    call is made, all records have been read, or until doEndIndexScan() call is
1078
1078
    made, whichever comes first.
1079
1079
 
1080
1080
  @retval 0  OK
1280
1280
                                enum ha_rkey_function find_flag)
1281
1281
{
1282
1282
  int error, error1;
1283
 
  error= index_init(index, 0);
 
1283
  error= doStartIndexScan(index, 0);
1284
1284
  if (!error)
1285
1285
  {
1286
1286
    error= index_read_map(buf, key, keypart_map, find_flag);
1287
 
    error1= index_end();
 
1287
    error1= doEndIndexScan();
1288
1288
  }
1289
1289
  return error ?  error : error1;
1290
1290
}
1458
1458
              (unsigned char*) table->def_write_set.getBitmap());
1459
1459
  assert(table->s->all_set.isSetAll());
1460
1460
  assert(table->key_read == 0);
1461
 
  /* ensure that ha_index_end / ha_rnd_end has been called */
 
1461
  /* ensure that ha_index_end / endTableScan has been called */
1462
1462
  assert(inited == NONE);
1463
1463
  /* Free cache used by filesort */
1464
1464
  table->free_io_cache();