~drizzle-trunk/drizzle/development

1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
1999.6.1 by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file
4
 *  Copyright (C) 2009 Sun Microsystems, Inc.
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
2234 by Brian Aker
Mass removal of ifdef/endif in favor of pragma once.
20
#pragma once
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
21
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
22
namespace drizzled
23
{
24
1539.1.3 by Brian Aker
Additional function -> method for readrecord
25
struct ReadRecord {			/* Parameter to read_record */
26
  Table *table;			/* Head-form */
27
  Cursor *cursor;
28
  Table **forms;			/* head and ref forms */
29
  int (*read_record)(ReadRecord *);
30
  Session *session;
31
  optimizer::SqlSelect *select;
32
  uint32_t cache_records;
33
  uint32_t ref_length;
34
  uint32_t struct_length;
35
  uint32_t reclength;
36
  uint32_t rec_cache_size;
37
  uint32_t error_offset;
38
  uint32_t index;
39
  unsigned char *ref_pos;				/* pointer to form->refpos */
40
  unsigned char *record;
41
  unsigned char *rec_buf;                /* to read field values  after filesort */
1578.4.6 by Brian Aker
Modify cache to be a vector.
42
private:
1578.4.13 by Brian Aker
Revert records
43
  unsigned char	*cache;
1578.4.6 by Brian Aker
Modify cache to be a vector.
44
public:
45
  unsigned char *getCache()
46
  {
1578.4.13 by Brian Aker
Revert records
47
    return cache;
1578.4.6 by Brian Aker
Modify cache to be a vector.
48
  }
1539.1.3 by Brian Aker
Additional function -> method for readrecord
49
  unsigned char *cache_pos;
50
  unsigned char *cache_end;
51
  unsigned char *read_positions;
52
  internal::IO_CACHE *io_cache;
53
  bool print_error;
54
  bool ignore_not_found_rows;
55
  JoinTable *do_insideout_scan;
56
  ReadRecord() :
57
    table(NULL),
58
    cursor(NULL),
59
    forms(0),
60
    read_record(0),
61
    session(0),
62
    select(0),
63
    cache_records(0),
64
    ref_length(0),
65
    struct_length(0),
66
    reclength(0),
67
    rec_cache_size(0),
68
    error_offset(0),
69
    index(0),
70
    ref_pos(0),
71
    record(0),
72
    rec_buf(0),
73
    cache(0),
74
    cache_pos(0),
75
    cache_end(0),
76
    read_positions(0),
77
    io_cache(0),
78
    print_error(0),
79
    ignore_not_found_rows(0),
80
    do_insideout_scan(0)
81
  {
82
  }
83
1711.6.5 by Brian Aker
Updating so that structures have constructor (removed memset calls).
84
  void init()
85
  {
86
    table= NULL;
87
    cursor= NULL;
88
    forms= 0;
89
    read_record= 0;
90
    session= 0;
91
    select= 0;
92
    cache_records= 0;
93
    ref_length= 0;
94
    struct_length= 0;
95
    reclength= 0;
96
    rec_cache_size= 0;
97
    error_offset= 0;
98
    index= 0;
99
    ref_pos= 0;
100
    record= 0;
101
    rec_buf= 0;
102
    cache= 0;
103
    cache_pos= 0;
104
    cache_end= 0;
105
    read_positions= 0;
106
    io_cache= 0;
107
    print_error= 0;
108
    ignore_not_found_rows= 0;
109
    do_insideout_scan= 0;
110
  }
111
1539.1.3 by Brian Aker
Additional function -> method for readrecord
112
  virtual ~ReadRecord()
113
  { }
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
114
115
/*
116
  init_read_record is used to scan by using a number of different methods.
117
  Which method to use is set-up in this call so that later calls to
118
  the info->read_record will call the appropriate method using a function
119
  pointer.
120
121
  There are five methods that relate completely to the sort function
122
  filesort. The result of a filesort is retrieved using read_record
123
  calls. The other two methods are used for normal table access.
124
125
  The filesort will produce references to the records sorted, these
126
  references can be stored in memory or in a temporary cursor.
127
128
  The temporary cursor is normally used when the references doesn't fit into
129
  a properly sized memory buffer. For most small queries the references
130
  are stored in the memory buffer.
131
132
  The temporary cursor is also used when performing an update where a key is
133
  modified.
134
135
  Methods used when ref's are in memory (using rr_from_pointers):
136
    rr_unpack_from_buffer:
137
    ----------------------
138
      This method is used when table->sort.addon_field is allocated.
139
      This is allocated for most SELECT queries not involving any BLOB's.
140
      In this case the records are fetched from a memory buffer.
141
    rr_from_pointers:
142
    -----------------
143
      Used when the above is not true, UPDATE, DELETE and so forth and
144
      SELECT's involving BLOB's. It is also used when the addon_field
145
      buffer is not allocated due to that its size was bigger than the
146
      session variable max_length_for_sort_data.
147
      In this case the record data is fetched from the handler using the
148
      saved reference using the rnd_pos handler call.
149
150
  Methods used when ref's are in a temporary cursor (using rr_from_tempfile)
151
    rr_unpack_from_tempfile:
152
    ------------------------
153
      Same as rr_unpack_from_buffer except that references are fetched from
154
      temporary cursor. Should obviously not really happen other than in
155
      strange configurations.
156
157
    rr_from_tempfile:
158
    -----------------
159
      Same as rr_from_pointers except that references are fetched from
160
      temporary cursor instead of from
161
    rr_from_cache:
162
    --------------
163
      This is a special variant of rr_from_tempfile that can be used for
164
      handlers that is not using the HA_FAST_KEY_READ table flag. Instead
165
      of reading the references one by one from the temporary cursor it reads
166
      a set of them, sorts them and reads all of them into a buffer which
167
      is then used for a number of subsequent calls to rr_from_cache.
168
      It is only used for SELECT queries and a number of other conditions
169
      on table size.
170
171
  All other accesses use either index access methods (rr_quick) or a full
172
  table scan (rr_sequential).
173
  rr_quick:
174
  ---------
175
    rr_quick uses one of the QUICK_SELECT classes in optimizer/range.cc to
176
    perform an index scan. There are loads of functionality hidden
177
    in these quick classes. It handles all index scans of various kinds.
178
  rr_sequential:
179
  --------------
180
    This is the most basic access method of a table using rnd_init,
181
    rnd_next and rnd_end. No indexes are used.
182
*/
2049.2.1 by Stewart Smith
doStartTableScan() result not checked.
183
  int init_read_record(Session *session,
184
                       Table *reg_form,
185
                       optimizer::SqlSelect *select,
186
                       int use_record_cache,
187
                       bool print_errors) __attribute__ ((warn_unused_result));
1538 by Brian Aker
Code shuffle on ReadRecord
188
189
  void end_read_record();
1539.1.3 by Brian Aker
Additional function -> method for readrecord
190
191
192
/**
193
  Initialize ReadRecord structure to perform full index scan (in forward
194
  direction) using read_record.read_record() interface.
195
196
    This function has been added at late stage and is used only by
197
    UPDATE/DELETE. Other statements perform index scans using
198
    join_read_first/next functions.
199
200
  @param info         ReadRecord structure to initialize.
201
  @param session          Thread handle
202
  @param table        Table to be accessed
203
  @param print_error  If true, call table->print_error() if an error
204
                      occurs (except for end-of-records error)
205
  @param idx          index to scan
206
                    */
2049.2.7 by Stewart Smith
init_read_record_idx return result should be checked now that it checks startIndexScan result.
207
  int init_read_record_idx(Session *session,
208
                           Table *table,
209
                           bool print_error,
210
                           uint32_t idx) __attribute__ ((warn_unused_result));
1578.4.1 by Brian Aker
Static/contain the only function that was seen outside of records.cc
211
212
  void init_reard_record_sequential();
213
1539.1.4 by Brian Aker
More RR encapsulation.
214
  bool init_rr_cache();
1538 by Brian Aker
Code shuffle on ReadRecord
215
};
1237.9.4 by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file.
216
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
217
} /* namespace drizzled */
218