~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/cursor.cc

  • Committer: mordred
  • Date: 2010-04-20 00:04:22 UTC
  • mfrom: (1491 bad-staging)
  • mto: This revision was merged to the branch mainline in revision 1498.
  • Revision ID: mordred@orisndriz09-20100420000422-if6mil1596804mrj
Merged up with build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
    on this->table->mem_root and we will not be able to reclaim that memory
81
81
    when the clone Cursor object is destroyed.
82
82
  */
83
 
  if (!(new_handler->ref= (unsigned char*) alloc_root(mem_root, ALIGN_SIZE(ref_length)*2)))
 
83
  if (!(new_handler->ref= (unsigned char*) mem_root->alloc_root(ALIGN_SIZE(ref_length)*2)))
84
84
    return NULL;
85
85
  if (new_handler && !new_handler->ha_open(table,
86
86
                                           table->s->normalized_path.str,
90
90
  return NULL;
91
91
}
92
92
 
 
93
/*
 
94
  DESCRIPTION
 
95
    given a buffer with a key value, and a map of keyparts
 
96
    that are present in this value, returns the length of the value
 
97
*/
 
98
uint32_t Cursor::calculate_key_len(uint32_t key_position, key_part_map keypart_map_arg)
 
99
{
 
100
  /* works only with key prefixes */
 
101
  assert(((keypart_map_arg + 1) & keypart_map_arg) == 0);
 
102
 
 
103
  KEY *key_info_found= table->s->key_info + key_position;
 
104
  KEY_PART_INFO *key_part_found= key_info_found->key_part;
 
105
  KEY_PART_INFO *end_key_part_found= key_part_found + key_info_found->key_parts;
 
106
  uint32_t length= 0;
 
107
 
 
108
  while (key_part_found < end_key_part_found && keypart_map_arg)
 
109
  {
 
110
    length+= key_part_found->store_length;
 
111
    keypart_map_arg >>= 1;
 
112
    key_part_found++;
 
113
  }
 
114
  return length;
 
115
}
 
116
 
93
117
int Cursor::ha_index_init(uint32_t idx, bool sorted)
94
118
{
95
119
  int result;
202
226
 
203
227
  table= table_arg;
204
228
  assert(table->s == table_share);
205
 
  assert(alloc_root_inited(&table->mem_root));
 
229
  assert(table->mem_root.alloc_root_inited());
206
230
 
207
231
  if ((error=open(name, mode, test_if_locked)))
208
232
  {
224
248
    (void) extra(HA_EXTRA_NO_READCHECK);        // Not needed in SQL
225
249
 
226
250
    /* ref is already allocated for us if we're called from Cursor::clone() */
227
 
    if (!ref && !(ref= (unsigned char*) alloc_root(&table->mem_root,
228
 
                                          ALIGN_SIZE(ref_length)*2)))
 
251
    if (!ref && !(ref= (unsigned char*) table->mem_root.alloc_root(ALIGN_SIZE(ref_length)*2)))
229
252
    {
230
253
      close();
231
254
      error=HA_ERR_OUT_OF_MEM;
1060
1083
 
1061
1084
int
1062
1085
Cursor::multi_range_read_init(RANGE_SEQ_IF *seq_funcs, void *seq_init_param,
1063
 
                               uint32_t n_ranges, uint32_t mode,
1064
 
                               HANDLER_BUFFER *)
 
1086
                               uint32_t n_ranges, uint32_t mode)
1065
1087
{
1066
1088
  mrr_iter= seq_funcs->init(seq_init_param, n_ranges, mode);
1067
1089
  mrr_funcs= *seq_funcs;
1068
1090
  mrr_is_output_sorted= test(mode & HA_MRR_SORTED);
1069
1091
  mrr_have_range= false;
 
1092
 
1070
1093
  return 0;
1071
1094
}
1072
1095