~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/records.cc

  • Committer: Brian Aker
  • Date: 2010-10-27 21:00:49 UTC
  • mto: This revision was merged to the branch mainline in revision 1886.
  • Revision ID: brian@tangent.org-20101027210049-zfpgx2cfbrh8maq9
A couple of fixes to documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
  Functions for easy reading of records, possible through a cache
21
21
*/
22
22
#include "config.h"
23
 
 
24
 
#include "drizzled/drizzled.h"
25
23
#include "drizzled/error.h"
 
24
#include "drizzled/table.h"
 
25
#include "drizzled/session.h"
 
26
#include "drizzled/records.h"
 
27
#include "drizzled/optimizer/range.h"
 
28
#include "drizzled/internal/my_sys.h"
26
29
#include "drizzled/internal/iocache.h"
27
 
#include "drizzled/internal/my_sys.h"
28
 
#include "drizzled/optimizer/range.h"
29
 
#include "drizzled/plugin/storage_engine.h"
30
 
#include "drizzled/records.h"
31
 
#include "drizzled/session.h"
32
 
#include "drizzled/table.h"
33
30
 
34
31
namespace drizzled
35
32
{
50
47
  read_record= rr_sequential;
51
48
}
52
49
 
53
 
int ReadRecord::init_read_record_idx(Session *,
54
 
                                     Table *table_arg,
55
 
                                     bool print_error_arg,
56
 
                                     uint32_t idx)
 
50
void ReadRecord::init_read_record_idx(Session *, 
 
51
                                      Table *table_arg,
 
52
                                      bool print_error_arg, 
 
53
                                      uint32_t idx)
57
54
{
58
55
  table_arg->emptyRecord();
59
56
  table= table_arg;
63
60
 
64
61
  table->status=0;                      /* And it's always found */
65
62
  if (not table->cursor->inited)
66
 
  {
67
 
    int error= table->cursor->startIndexScan(idx, 1);
68
 
    if (error != 0)
69
 
      return error;
70
 
  }
 
63
    table->cursor->startIndexScan(idx, 1);
71
64
  /* read_record will be changed to rr_index in rr_index_first */
72
65
  read_record= rr_index_first;
73
 
 
74
 
  return 0;
75
66
}
76
67
 
77
68
 
78
 
int ReadRecord::init_read_record(Session *session_arg,
79
 
                                 Table *table_arg,
80
 
                                 optimizer::SqlSelect *select_arg,
81
 
                                 int use_record_cache,
82
 
                                 bool print_error_arg)
 
69
void ReadRecord::init_read_record(Session *session_arg, 
 
70
                                  Table *table_arg,
 
71
                                  optimizer::SqlSelect *select_arg,
 
72
                                  int use_record_cache, 
 
73
                                  bool print_error_arg)
83
74
{
84
75
  internal::IO_CACHE *tempfile;
85
 
  int error= 0;
86
76
 
87
77
  session= session_arg;
88
78
  table= table_arg;
120
110
                  rr_unpack_from_tempfile : rr_from_tempfile);
121
111
 
122
112
    io_cache=tempfile;
123
 
    io_cache->reinit_io_cache(internal::READ_CACHE,0L,0,0);
 
113
    reinit_io_cache(io_cache,internal::READ_CACHE,0L,0,0);
124
114
    ref_pos=table->cursor->ref;
125
115
    if (!table->cursor->inited)
126
 
    {
127
 
      error= table->cursor->startTableScan(0);
128
 
      if (error != 0)
129
 
        return error;
130
 
    }
 
116
      table->cursor->startTableScan(0);
131
117
 
132
118
    /*
133
119
      table->sort.addon_field is checked because if we use addon fields,
159
145
  }
160
146
  else if (table->sort.record_pointers)
161
147
  {
162
 
    error= table->cursor->startTableScan(0);
163
 
    if (error != 0)
164
 
      return error;
165
 
 
 
148
    table->cursor->startTableScan(0);
166
149
    cache_pos=table->sort.record_pointers;
167
150
    cache_end= cache_pos+ table->sort.found_records * ref_length;
168
151
    read_record= (table->sort.addon_field ?  rr_unpack_from_buffer : rr_from_pointers);
170
153
  else
171
154
  {
172
155
    read_record= rr_sequential;
173
 
    error= table->cursor->startTableScan(1);
174
 
    if (error != 0)
175
 
      return error;
176
 
 
 
156
    table->cursor->startTableScan(1);
177
157
    /* We can use record cache if we don't update dynamic length tables */
178
158
    if (!table->no_cache &&
179
159
        (use_record_cache > 0 ||
184
164
    }
185
165
  }
186
166
 
187
 
  return 0;
 
167
  return;
188
168
} /* init_read_record */
189
169
 
190
170
 
192
172
{                   /* free cache if used */
193
173
  if (cache)
194
174
  {
195
 
    global_read_rnd_buffer.sub(session->variables.read_rnd_buff_size);
196
175
    free((char*) cache);
197
176
    cache= NULL;
198
177
  }
227
206
  int tmp;
228
207
  while ((tmp= info->select->quick->get_next()))
229
208
  {
230
 
    if (info->session->getKilled())
 
209
    if (info->session->killed)
231
210
    {
232
211
      my_error(ER_SERVER_SHUTDOWN, MYF(0));
233
212
      return 1;
291
270
  int tmp;
292
271
  while ((tmp= info->cursor->rnd_next(info->record)))
293
272
  {
294
 
    if (info->session->getKilled())
 
273
    if (info->session->killed)
295
274
    {
296
275
      info->session->send_kill_message();
297
276
      return 1;
423
402
  local_rec_cache_size= cache_records * reclength;
424
403
  rec_cache_size= cache_records * ref_length;
425
404
 
426
 
  if (not global_read_rnd_buffer.add(session->variables.read_rnd_buff_size))
427
 
  {
428
 
    my_error(ER_OUT_OF_GLOBAL_READRNDMEMORY, MYF(ME_ERROR+ME_WAITTANG));
429
 
    return false;
430
 
  }
431
 
 
432
405
  // We have to allocate one more byte to use uint3korr (see comments for it)
433
406
  if (cache_records <= 2 ||
434
407
      !(cache=(unsigned char*) malloc(local_rec_cache_size + cache_records * struct_length + 1)))