~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/records.cc

  • Committer: Brian Aker
  • Date: 2011-02-17 10:09:00 UTC
  • mfrom: (2173.2.1 clean-include-usuage)
  • Revision ID: brian@tangent.org-20110217100900-4tpuxxzdl1sj00sh
Merge Monty for headers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
  @brief
20
20
  Functions for easy reading of records, possible through a cache
21
21
*/
22
 
#include "config.h"
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"
29
 
#include "drizzled/internal/iocache.h"
30
 
#include "drizzled/drizzled.h"
 
22
#include <config.h>
 
23
 
 
24
#include <drizzled/drizzled.h>
 
25
#include <drizzled/error.h>
 
26
#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>
31
33
 
32
34
namespace drizzled
33
35
{
48
50
  read_record= rr_sequential;
49
51
}
50
52
 
51
 
void ReadRecord::init_read_record_idx(Session *, 
52
 
                                      Table *table_arg,
53
 
                                      bool print_error_arg, 
54
 
                                      uint32_t idx)
 
53
int ReadRecord::init_read_record_idx(Session *,
 
54
                                     Table *table_arg,
 
55
                                     bool print_error_arg,
 
56
                                     uint32_t idx)
55
57
{
56
58
  table_arg->emptyRecord();
57
59
  table= table_arg;
61
63
 
62
64
  table->status=0;                      /* And it's always found */
63
65
  if (not table->cursor->inited)
64
 
    table->cursor->startIndexScan(idx, 1);
 
66
  {
 
67
    int error= table->cursor->startIndexScan(idx, 1);
 
68
    if (error != 0)
 
69
      return error;
 
70
  }
65
71
  /* read_record will be changed to rr_index in rr_index_first */
66
72
  read_record= rr_index_first;
 
73
 
 
74
  return 0;
67
75
}
68
76
 
69
77
 
70
 
void ReadRecord::init_read_record(Session *session_arg, 
71
 
                                  Table *table_arg,
72
 
                                  optimizer::SqlSelect *select_arg,
73
 
                                  int use_record_cache, 
74
 
                                  bool print_error_arg)
 
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)
75
83
{
76
84
  internal::IO_CACHE *tempfile;
 
85
  int error= 0;
77
86
 
78
87
  session= session_arg;
79
88
  table= table_arg;
114
123
    io_cache->reinit_io_cache(internal::READ_CACHE,0L,0,0);
115
124
    ref_pos=table->cursor->ref;
116
125
    if (!table->cursor->inited)
117
 
      table->cursor->startTableScan(0);
 
126
    {
 
127
      error= table->cursor->startTableScan(0);
 
128
      if (error != 0)
 
129
        return error;
 
130
    }
118
131
 
119
132
    /*
120
133
      table->sort.addon_field is checked because if we use addon fields,
146
159
  }
147
160
  else if (table->sort.record_pointers)
148
161
  {
149
 
    table->cursor->startTableScan(0);
 
162
    error= table->cursor->startTableScan(0);
 
163
    if (error != 0)
 
164
      return error;
 
165
 
150
166
    cache_pos=table->sort.record_pointers;
151
167
    cache_end= cache_pos+ table->sort.found_records * ref_length;
152
168
    read_record= (table->sort.addon_field ?  rr_unpack_from_buffer : rr_from_pointers);
154
170
  else
155
171
  {
156
172
    read_record= rr_sequential;
157
 
    table->cursor->startTableScan(1);
 
173
    error= table->cursor->startTableScan(1);
 
174
    if (error != 0)
 
175
      return error;
 
176
 
158
177
    /* We can use record cache if we don't update dynamic length tables */
159
178
    if (!table->no_cache &&
160
179
        (use_record_cache > 0 ||
165
184
    }
166
185
  }
167
186
 
168
 
  return;
 
187
  return 0;
169
188
} /* init_read_record */
170
189
 
171
190