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 |
|
2252.1.16
by Olaf van der Spek
Common fwd |
22 |
#include <drizzled/common_fwd.h> |
23 |
||
2239.1.10
by Olaf van der Spek
Refactor includes |
24 |
namespace drizzled { |
25 |
||
2252.1.17
by Olaf van der Spek
Common fwd |
26 |
|
1539.1.3
by Brian Aker
Additional function -> method for readrecord |
27 |
struct ReadRecord { /* Parameter to read_record */ |
28 |
Table *table; /* Head-form */ |
|
29 |
Cursor *cursor; |
|
30 |
Table **forms; /* head and ref forms */ |
|
31 |
int (*read_record)(ReadRecord *); |
|
32 |
Session *session; |
|
33 |
optimizer::SqlSelect *select; |
|
34 |
uint32_t cache_records; |
|
35 |
uint32_t ref_length; |
|
36 |
uint32_t struct_length; |
|
37 |
uint32_t reclength; |
|
38 |
uint32_t rec_cache_size; |
|
39 |
uint32_t error_offset; |
|
40 |
uint32_t index; |
|
41 |
unsigned char *ref_pos; /* pointer to form->refpos */ |
|
42 |
unsigned char *record; |
|
43 |
unsigned char *rec_buf; /* to read field values after filesort */ |
|
1578.4.6
by Brian Aker
Modify cache to be a vector. |
44 |
private: |
1578.4.13
by Brian Aker
Revert records |
45 |
unsigned char *cache; |
1578.4.6
by Brian Aker
Modify cache to be a vector. |
46 |
public: |
47 |
unsigned char *getCache() |
|
48 |
{
|
|
1578.4.13
by Brian Aker
Revert records |
49 |
return cache; |
1578.4.6
by Brian Aker
Modify cache to be a vector. |
50 |
}
|
1539.1.3
by Brian Aker
Additional function -> method for readrecord |
51 |
unsigned char *cache_pos; |
52 |
unsigned char *cache_end; |
|
53 |
unsigned char *read_positions; |
|
54 |
internal::IO_CACHE *io_cache; |
|
55 |
bool print_error; |
|
56 |
bool ignore_not_found_rows; |
|
57 |
JoinTable *do_insideout_scan; |
|
58 |
ReadRecord() : |
|
59 |
table(NULL), |
|
60 |
cursor(NULL), |
|
61 |
forms(0), |
|
62 |
read_record(0), |
|
63 |
session(0), |
|
64 |
select(0), |
|
65 |
cache_records(0), |
|
66 |
ref_length(0), |
|
67 |
struct_length(0), |
|
68 |
reclength(0), |
|
69 |
rec_cache_size(0), |
|
70 |
error_offset(0), |
|
71 |
index(0), |
|
72 |
ref_pos(0), |
|
73 |
record(0), |
|
74 |
rec_buf(0), |
|
75 |
cache(0), |
|
76 |
cache_pos(0), |
|
77 |
cache_end(0), |
|
78 |
read_positions(0), |
|
79 |
io_cache(0), |
|
80 |
print_error(0), |
|
81 |
ignore_not_found_rows(0), |
|
82 |
do_insideout_scan(0) |
|
83 |
{
|
|
84 |
}
|
|
85 |
||
1711.6.5
by Brian Aker
Updating so that structures have constructor (removed memset calls). |
86 |
void init() |
87 |
{
|
|
88 |
table= NULL; |
|
89 |
cursor= NULL; |
|
90 |
forms= 0; |
|
91 |
read_record= 0; |
|
92 |
session= 0; |
|
93 |
select= 0; |
|
94 |
cache_records= 0; |
|
95 |
ref_length= 0; |
|
96 |
struct_length= 0; |
|
97 |
reclength= 0; |
|
98 |
rec_cache_size= 0; |
|
99 |
error_offset= 0; |
|
100 |
index= 0; |
|
101 |
ref_pos= 0; |
|
102 |
record= 0; |
|
103 |
rec_buf= 0; |
|
104 |
cache= 0; |
|
105 |
cache_pos= 0; |
|
106 |
cache_end= 0; |
|
107 |
read_positions= 0; |
|
108 |
io_cache= 0; |
|
109 |
print_error= 0; |
|
110 |
ignore_not_found_rows= 0; |
|
111 |
do_insideout_scan= 0; |
|
112 |
}
|
|
113 |
||
1539.1.3
by Brian Aker
Additional function -> method for readrecord |
114 |
virtual ~ReadRecord() |
115 |
{ } |
|
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
116 |
|
117 |
/*
|
|
118 |
init_read_record is used to scan by using a number of different methods.
|
|
119 |
Which method to use is set-up in this call so that later calls to
|
|
120 |
the info->read_record will call the appropriate method using a function
|
|
121 |
pointer.
|
|
122 |
||
123 |
There are five methods that relate completely to the sort function
|
|
124 |
filesort. The result of a filesort is retrieved using read_record
|
|
125 |
calls. The other two methods are used for normal table access.
|
|
126 |
||
127 |
The filesort will produce references to the records sorted, these
|
|
128 |
references can be stored in memory or in a temporary cursor.
|
|
129 |
||
130 |
The temporary cursor is normally used when the references doesn't fit into
|
|
131 |
a properly sized memory buffer. For most small queries the references
|
|
132 |
are stored in the memory buffer.
|
|
133 |
||
134 |
The temporary cursor is also used when performing an update where a key is
|
|
135 |
modified.
|
|
136 |
||
137 |
Methods used when ref's are in memory (using rr_from_pointers):
|
|
138 |
rr_unpack_from_buffer:
|
|
139 |
----------------------
|
|
140 |
This method is used when table->sort.addon_field is allocated.
|
|
141 |
This is allocated for most SELECT queries not involving any BLOB's.
|
|
142 |
In this case the records are fetched from a memory buffer.
|
|
143 |
rr_from_pointers:
|
|
144 |
-----------------
|
|
145 |
Used when the above is not true, UPDATE, DELETE and so forth and
|
|
146 |
SELECT's involving BLOB's. It is also used when the addon_field
|
|
147 |
buffer is not allocated due to that its size was bigger than the
|
|
148 |
session variable max_length_for_sort_data.
|
|
149 |
In this case the record data is fetched from the handler using the
|
|
150 |
saved reference using the rnd_pos handler call.
|
|
151 |
||
152 |
Methods used when ref's are in a temporary cursor (using rr_from_tempfile)
|
|
153 |
rr_unpack_from_tempfile:
|
|
154 |
------------------------
|
|
155 |
Same as rr_unpack_from_buffer except that references are fetched from
|
|
156 |
temporary cursor. Should obviously not really happen other than in
|
|
157 |
strange configurations.
|
|
158 |
||
159 |
rr_from_tempfile:
|
|
160 |
-----------------
|
|
161 |
Same as rr_from_pointers except that references are fetched from
|
|
162 |
temporary cursor instead of from
|
|
163 |
rr_from_cache:
|
|
164 |
--------------
|
|
165 |
This is a special variant of rr_from_tempfile that can be used for
|
|
166 |
handlers that is not using the HA_FAST_KEY_READ table flag. Instead
|
|
167 |
of reading the references one by one from the temporary cursor it reads
|
|
168 |
a set of them, sorts them and reads all of them into a buffer which
|
|
169 |
is then used for a number of subsequent calls to rr_from_cache.
|
|
170 |
It is only used for SELECT queries and a number of other conditions
|
|
171 |
on table size.
|
|
172 |
||
173 |
All other accesses use either index access methods (rr_quick) or a full
|
|
174 |
table scan (rr_sequential).
|
|
175 |
rr_quick:
|
|
176 |
---------
|
|
177 |
rr_quick uses one of the QUICK_SELECT classes in optimizer/range.cc to
|
|
178 |
perform an index scan. There are loads of functionality hidden
|
|
179 |
in these quick classes. It handles all index scans of various kinds.
|
|
180 |
rr_sequential:
|
|
181 |
--------------
|
|
182 |
This is the most basic access method of a table using rnd_init,
|
|
183 |
rnd_next and rnd_end. No indexes are used.
|
|
184 |
*/
|
|
2049.2.1
by Stewart Smith
doStartTableScan() result not checked. |
185 |
int init_read_record(Session *session, |
186 |
Table *reg_form, |
|
187 |
optimizer::SqlSelect *select, |
|
188 |
int use_record_cache, |
|
189 |
bool print_errors) __attribute__ ((warn_unused_result)); |
|
1538
by Brian Aker
Code shuffle on ReadRecord |
190 |
|
191 |
void end_read_record(); |
|
1539.1.3
by Brian Aker
Additional function -> method for readrecord |
192 |
|
193 |
||
194 |
/**
|
|
195 |
Initialize ReadRecord structure to perform full index scan (in forward
|
|
196 |
direction) using read_record.read_record() interface.
|
|
197 |
||
198 |
This function has been added at late stage and is used only by
|
|
199 |
UPDATE/DELETE. Other statements perform index scans using
|
|
200 |
join_read_first/next functions.
|
|
201 |
||
202 |
@param info ReadRecord structure to initialize.
|
|
203 |
@param session Thread handle
|
|
204 |
@param table Table to be accessed
|
|
205 |
@param print_error If true, call table->print_error() if an error
|
|
206 |
occurs (except for end-of-records error)
|
|
207 |
@param idx index to scan
|
|
208 |
*/
|
|
2049.2.7
by Stewart Smith
init_read_record_idx return result should be checked now that it checks startIndexScan result. |
209 |
int init_read_record_idx(Session *session, |
210 |
Table *table, |
|
211 |
bool print_error, |
|
212 |
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 |
213 |
|
214 |
void init_reard_record_sequential(); |
|
215 |
||
1539.1.4
by Brian Aker
More RR encapsulation. |
216 |
bool init_rr_cache(); |
1538
by Brian Aker
Code shuffle on ReadRecord |
217 |
};
|
1237.9.4
by Padraig O'Sullivan
Removed the inclusion of drizzled/field.h in the server_includes header file. |
218 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
219 |
} /* namespace drizzled */ |
220 |