390.1.2
by Monty Taylor
Fixed copyright headers in drizzled/ |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Sun Microsystems
|
|
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 |
*/
|
|
1
by brian
clean slate |
19 |
|
1185
by Brian Aker
Merge Engine changes. |
20 |
#ifndef DRIZZLED_CURSOR_H
|
21 |
#define DRIZZLED_CURSOR_H
|
|
1
by brian
clean slate |
22 |
|
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
23 |
#include <drizzled/xid.h> |
844
by Brian Aker
Added drizzled/discrete_interval.h |
24 |
#include <drizzled/discrete_interval.h> |
520.4.31
by Monty Taylor
Removed server_id from common_includes. |
25 |
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
26 |
/* Definitions for parameters to do with Cursor-routines */
|
1
by brian
clean slate |
27 |
|
520.6.4
by Monty Taylor
Moved thr_lock.h out of common_includes. |
28 |
#include <mysys/thr_lock.h> |
520.8.3
by Monty Taylor
Moved hash back to mysys. |
29 |
#include <mysys/hash.h> |
520.8.5
by Monty Taylor
Removed sql_string and sql_list from common_includes. |
30 |
#include <drizzled/sql_string.h> |
31 |
#include <drizzled/sql_list.h> |
|
960.2.23
by Monty Taylor
Moved handlerton to plugin/storage_engine.h. |
32 |
#include <drizzled/plugin/storage_engine.h> |
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
33 |
#include <drizzled/handler_structs.h> |
34 |
#include <drizzled/ha_statistics.h> |
|
1046.1.8
by Brian Aker
Remove race condition around refresh (aka... multi-thread writeable global |
35 |
#include <drizzled/atomics.h> |
520.6.4
by Monty Taylor
Moved thr_lock.h out of common_includes. |
36 |
|
1008.3.20
by Stewart Smith
Put table_name into table proto in parser, and use that when creating table proto file. |
37 |
#include <drizzled/message/table.pb.h> |
38 |
||
520.6.4
by Monty Taylor
Moved thr_lock.h out of common_includes. |
39 |
/* Bits to show what an alter table will do */
|
40 |
#include <drizzled/sql_bitmap.h> |
|
982.1.9
by Padraig O'Sullivan
Changed HA_ALTER_FLAGS to be of type std::bitset instead of being of type |
41 |
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
42 |
#include <drizzled/cursor.h> |
1109.1.4
by Brian Aker
More Table refactor |
43 |
|
1067.4.4
by Nathan Williams
The rest of the files in the drizzled directory were purged of the cmin macro and replace with std::min (except for the definition in globals.h and 1 usage in stacktrace.cc). |
44 |
#include <bitset> |
45 |
#include <algorithm> |
|
1005.2.6
by Monty Taylor
Re-added bitset<> as a replacement for Bitmap<> |
46 |
|
520.6.4
by Monty Taylor
Moved thr_lock.h out of common_includes. |
47 |
#define HA_MAX_ALTER_FLAGS 40
|
1130.1.5
by Monty Taylor
Split StorageEngine into slot. This completes the plugin-slot-reorg. Woot. |
48 |
|
49 |
||
1005.2.6
by Monty Taylor
Re-added bitset<> as a replacement for Bitmap<> |
50 |
typedef std::bitset<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS; |
1
by brian
clean slate |
51 |
|
1046.1.8
by Brian Aker
Remove race condition around refresh (aka... multi-thread writeable global |
52 |
extern drizzled::atomic<uint32_t> refresh_version; /* Increments on each reload */ |
53 |
||
1
by brian
clean slate |
54 |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
55 |
typedef bool (*qc_engine_callback)(Session *session, char *table_key, |
482
by Brian Aker
Remove uint. |
56 |
uint32_t key_length, |
243.1.1
by Jay Pipes
* Pulled Object_creation_ctx and Default_creation_ctx out of mysql_priv.h |
57 |
uint64_t *engine_data); |
58 |
||
1
by brian
clean slate |
59 |
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
60 |
/* The Cursor for a table type. Will be included in the Table structure */
|
1
by brian
clean slate |
61 |
|
327.1.1
by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure). |
62 |
class Table; |
561.1.3
by Monty Taylor
Split some more things out of common_includes.h. |
63 |
class TableList; |
1000.1.3
by Brian Aker
Renamed TABLE_SHARE to TableShare |
64 |
class TableShare; |
848
by Brian Aker
typdef class removal (just... use the name of the class). |
65 |
class Select_Lex_Unit; |
1
by brian
clean slate |
66 |
struct st_foreign_key_info; |
67 |
typedef struct st_foreign_key_info FOREIGN_KEY_INFO; |
|
584.1.13
by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes. |
68 |
struct order_st; |
1
by brian
clean slate |
69 |
|
70 |
class Item; |
|
71 |
struct st_table_log_memory_entry; |
|
72 |
||
575.4.7
by Monty Taylor
More header cleanup. |
73 |
class LEX; |
846
by Brian Aker
Removing on typedeffed class. |
74 |
class Select_Lex; |
1126.3.3
by Jay Pipes
Moves Alter_info out into its own header and source file, cleans up some related include mess in sql_lex.h, and renames Alter_info to AlterInfo. |
75 |
class AlterInfo; |
575.4.7
by Monty Taylor
More header cleanup. |
76 |
class select_result; |
1052.2.3
by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards. |
77 |
class CreateField; |
575.4.7
by Monty Taylor
More header cleanup. |
78 |
class sys_var_str; |
79 |
class Item_ident; |
|
80 |
typedef struct st_sort_field SORT_FIELD; |
|
81 |
||
82 |
typedef List<Item> List_item; |
|
83 |
||
1
by brian
clean slate |
84 |
typedef struct st_savepoint SAVEPOINT; |
61
by Brian Aker
Conversion of handler type. |
85 |
extern uint32_t savepoint_alloc_size; |
1
by brian
clean slate |
86 |
extern KEY_CREATE_INFO default_key_create_info; |
87 |
||
88 |
/* Forward declaration for condition pushdown to storage engine */
|
|
89 |
typedef class Item COND; |
|
90 |
||
91 |
typedef struct system_status_var SSV; |
|
92 |
||
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
93 |
class COST_VECT; |
94 |
||
482
by Brian Aker
Remove uint. |
95 |
uint32_t calculate_key_len(Table *, uint, const unsigned char *, key_part_map); |
1
by brian
clean slate |
96 |
/*
|
97 |
bitmap with first N+1 bits set
|
|
98 |
(keypart_map for a key prefix of [0..N] keyparts)
|
|
99 |
*/
|
|
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
100 |
template<class T> |
101 |
inline key_part_map make_keypart_map(T a) |
|
102 |
{
|
|
103 |
return (((key_part_map)2 << a) - 1); |
|
104 |
}
|
|
105 |
||
1
by brian
clean slate |
106 |
/*
|
107 |
bitmap with first N bits set
|
|
108 |
(keypart_map for a key prefix of [0..N-1] keyparts)
|
|
109 |
*/
|
|
575.1.3
by Monty Taylor
Moved some stuff out of handler.h. |
110 |
template<class T> |
111 |
inline key_part_map make_prev_keypart_map(T a) |
|
112 |
{
|
|
113 |
return (((key_part_map)1 << a) - 1); |
|
114 |
}
|
|
1
by brian
clean slate |
115 |
|
116 |
/**
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
117 |
The Cursor class is the interface for dynamically loadable
|
1
by brian
clean slate |
118 |
storage engines. Do not add ifdefs and take care when adding or
|
119 |
changing virtual functions to avoid vtable confusion
|
|
120 |
||
121 |
Functions in this class accept and return table columns data. Two data
|
|
122 |
representation formats are used:
|
|
123 |
1. TableRecordFormat - Used to pass [partial] table records to/from
|
|
124 |
storage engine
|
|
125 |
||
126 |
2. KeyTupleFormat - used to pass index search tuples (aka "keys") to
|
|
127 |
storage engine. See opt_range.cc for description of this format.
|
|
128 |
||
129 |
TableRecordFormat
|
|
130 |
=================
|
|
131 |
[Warning: this description is work in progress and may be incomplete]
|
|
132 |
The table record is stored in a fixed-size buffer:
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
133 |
|
1
by brian
clean slate |
134 |
record: null_bytes, column1_data, column2_data, ...
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
135 |
|
136 |
The offsets of the parts of the buffer are also fixed: every column has
|
|
1
by brian
clean slate |
137 |
an offset to its column{i}_data, and if it is nullable it also has its own
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
138 |
bit in null_bytes.
|
1
by brian
clean slate |
139 |
|
140 |
The record buffer only includes data about columns that are marked in the
|
|
141 |
relevant column set (table->read_set and/or table->write_set, depending on
|
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
142 |
the situation).
|
1
by brian
clean slate |
143 |
<not-sure>It could be that it is required that null bits of non-present
|
144 |
columns are set to 1</not-sure>
|
|
145 |
||
146 |
VARIOUS EXCEPTIONS AND SPECIAL CASES
|
|
147 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
148 |
f the table has no nullable columns, then null_bytes is still
|
149 |
present, its length is one byte <not-sure> which must be set to 0xFF
|
|
1
by brian
clean slate |
150 |
at all times. </not-sure>
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
151 |
|
1
by brian
clean slate |
152 |
If the table has columns of type BIT, then certain bits from those columns
|
153 |
may be stored in null_bytes as well. Grep around for Field_bit for
|
|
154 |
details.
|
|
155 |
||
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
156 |
For blob columns (see Field_blob), the record buffer stores length of the
|
157 |
data, following by memory pointer to the blob data. The pointer is owned
|
|
1
by brian
clean slate |
158 |
by the storage engine and is valid until the next operation.
|
159 |
||
160 |
If a blob column has NULL value, then its length and blob data pointer
|
|
161 |
must be set to 0.
|
|
162 |
*/
|
|
163 |
||
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
164 |
class Cursor :public Sql_alloc |
1
by brian
clean slate |
165 |
{
|
166 |
public: |
|
167 |
typedef uint64_t Table_flags; |
|
796
by Brian Aker
Test case fixes + TABLE_CACHE to class (will rename in manner which is NOT |
168 |
|
1
by brian
clean slate |
169 |
protected: |
1000.1.3
by Brian Aker
Renamed TABLE_SHARE to TableShare |
170 |
TableShare *table_share; /* The table definition */ |
327.1.1
by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure). |
171 |
Table *table; /* The current open table */ |
1
by brian
clean slate |
172 |
Table_flags cached_table_flags; /* Set on init() and open() */ |
173 |
||
174 |
ha_rows estimation_rows_to_insert; |
|
175 |
public: |
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
176 |
drizzled::plugin::StorageEngine *engine; /* storage engine of this Cursor */ |
960.2.37
by Monty Taylor
More naming fixes. |
177 |
unsigned char *ref; /* Pointer to current row */ |
481
by Brian Aker
Remove all of uchar. |
178 |
unsigned char *dup_ref; /* Pointer to duplicate row */ |
1
by brian
clean slate |
179 |
|
180 |
ha_statistics stats; |
|
181 |
/** MultiRangeRead-related members: */
|
|
182 |
range_seq_t mrr_iter; /* Interator to traverse the range sequence */ |
|
183 |
RANGE_SEQ_IF mrr_funcs; /* Range sequence traversal functions */ |
|
184 |
HANDLER_BUFFER *multi_range_buffer; /* MRR buffer info */ |
|
482
by Brian Aker
Remove uint. |
185 |
uint32_t ranges_in_seq; /* Total number of ranges in the traversed sequence */ |
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
186 |
/* true <=> source MRR ranges and the output are ordered */
|
1
by brian
clean slate |
187 |
bool mrr_is_output_sorted; |
188 |
||
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
189 |
/** true <=> we're currently traversing a range in mrr_cur_range. */
|
1
by brian
clean slate |
190 |
bool mrr_have_range; |
1030.1.1
by Brian Aker
Straighten out structures (remove some some dead bits). |
191 |
|
192 |
bool eq_range; |
|
193 |
/*
|
|
194 |
true <=> the engine guarantees that returned records are within the range
|
|
195 |
being scanned.
|
|
196 |
*/
|
|
197 |
bool in_range_check_pushed_down; |
|
198 |
||
1
by brian
clean slate |
199 |
/** Current range (the one we're now returning rows from) */
|
200 |
KEY_MULTI_RANGE mrr_cur_range; |
|
201 |
||
202 |
/** The following are for read_range() */
|
|
203 |
key_range save_end_range, *end_range; |
|
204 |
KEY_PART_INFO *range_key_part; |
|
205 |
int key_compare_result_on_equal; |
|
206 |
||
482
by Brian Aker
Remove uint. |
207 |
uint32_t errkey; /* Last dup key */ |
208 |
uint32_t key_used_on_scan; |
|
209 |
uint32_t active_index; |
|
1
by brian
clean slate |
210 |
/** Length of ref (1-8 or the clustered key length) */
|
482
by Brian Aker
Remove uint. |
211 |
uint32_t ref_length; |
1
by brian
clean slate |
212 |
enum {NONE=0, INDEX, RND} inited; |
213 |
bool locked; |
|
214 |
bool implicit_emptied; /* Can be !=0 only if HEAP */ |
|
215 |
||
216 |
/**
|
|
217 |
next_insert_id is the next value which should be inserted into the
|
|
218 |
auto_increment column: in a inserting-multi-row statement (like INSERT
|
|
219 |
SELECT), for the first row where the autoinc value is not specified by the
|
|
220 |
statement, get_auto_increment() called and asked to generate a value,
|
|
221 |
next_insert_id is set to the next value, then for all other rows
|
|
222 |
next_insert_id is used (and increased each time) without calling
|
|
223 |
get_auto_increment().
|
|
224 |
*/
|
|
225 |
uint64_t next_insert_id; |
|
226 |
/**
|
|
227 |
insert id for the current row (*autogenerated*; if not
|
|
228 |
autogenerated, it's 0).
|
|
229 |
At first successful insertion, this variable is stored into
|
|
520.1.21
by Brian Aker
THD -> Session rename |
230 |
Session::first_successful_insert_id_in_cur_stmt.
|
1
by brian
clean slate |
231 |
*/
|
232 |
uint64_t insert_id_for_cur_row; |
|
233 |
/**
|
|
234 |
Interval returned by get_auto_increment() and being consumed by the
|
|
235 |
inserter.
|
|
236 |
*/
|
|
237 |
Discrete_interval auto_inc_interval_for_cur_row; |
|
238 |
||
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
239 |
Cursor(drizzled::plugin::StorageEngine *engine_arg, TableShare *share_arg) |
1
by brian
clean slate |
240 |
:table_share(share_arg), table(0), |
960.2.37
by Monty Taylor
More naming fixes. |
241 |
estimation_rows_to_insert(0), engine(engine_arg), |
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
242 |
ref(0), in_range_check_pushed_down(false), |
1
by brian
clean slate |
243 |
key_used_on_scan(MAX_KEY), active_index(MAX_KEY), |
244 |
ref_length(sizeof(my_off_t)), |
|
137
by Brian Aker
Removed dead FT bits. Small refactoring in sql_plugin.cc |
245 |
inited(NONE), |
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
246 |
locked(false), implicit_emptied(0), |
1
by brian
clean slate |
247 |
next_insert_id(0), insert_id_for_cur_row(0) |
248 |
{}
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
249 |
virtual ~Cursor(void); |
250 |
virtual Cursor *clone(MEM_ROOT *mem_root); |
|
1
by brian
clean slate |
251 |
/** This is called after create to allow us to set up cached variables */
|
252 |
void init() |
|
253 |
{
|
|
254 |
cached_table_flags= table_flags(); |
|
255 |
}
|
|
575.1.4
by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h. |
256 |
|
1
by brian
clean slate |
257 |
/* ha_ methods: pubilc wrappers for private virtual API */
|
258 |
||
327.1.5
by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h |
259 |
int ha_open(Table *table, const char *name, int mode, int test_if_locked); |
575.1.4
by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h. |
260 |
int ha_index_init(uint32_t idx, bool sorted); |
261 |
int ha_index_end(); |
|
262 |
int ha_rnd_init(bool scan); |
|
263 |
int ha_rnd_end(); |
|
1
by brian
clean slate |
264 |
int ha_reset(); |
575.1.4
by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h. |
265 |
|
1
by brian
clean slate |
266 |
/* this is necessary in many places, e.g. in HANDLER command */
|
575.1.4
by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h. |
267 |
int ha_index_or_rnd_end(); |
268 |
Table_flags ha_table_flags() const; |
|
269 |
||
1
by brian
clean slate |
270 |
/**
|
271 |
These functions represent the public interface to *users* of the
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
272 |
Cursor class, hence they are *not* virtual. For the inheritance
|
1
by brian
clean slate |
273 |
interface, see the (private) functions write_row(), update_row(),
|
274 |
and delete_row() below.
|
|
275 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
276 |
int ha_external_lock(Session *session, int lock_type); |
481
by Brian Aker
Remove all of uchar. |
277 |
int ha_write_row(unsigned char * buf); |
278 |
int ha_update_row(const unsigned char * old_data, unsigned char * new_data); |
|
279 |
int ha_delete_row(const unsigned char * buf); |
|
1
by brian
clean slate |
280 |
void ha_release_auto_increment(); |
281 |
||
282 |
/** to be actually called to get 'check()' functionality*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
283 |
int ha_check(Session *session, HA_CHECK_OPT *check_opt); |
1063.1.1
by Stewart Smith
remove REPAIR TABLE. Is very useful to have, but should be implemented in a much different way (or external to server). |
284 |
|
575.1.4
by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h. |
285 |
void ha_start_bulk_insert(ha_rows rows); |
286 |
int ha_end_bulk_insert(); |
|
481
by Brian Aker
Remove all of uchar. |
287 |
int ha_bulk_update_row(const unsigned char *old_data, unsigned char *new_data, |
482
by Brian Aker
Remove uint. |
288 |
uint32_t *dup_key_found); |
1
by brian
clean slate |
289 |
int ha_delete_all_rows(); |
290 |
int ha_reset_auto_increment(uint64_t value); |
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
291 |
int ha_optimize(Session* session, HA_CHECK_OPT* check_opt); |
292 |
int ha_analyze(Session* session, HA_CHECK_OPT* check_opt); |
|
1063.3.1
by Stewart Smith
remove ha_check_and_repair. Engines should take care of this themselves. |
293 |
|
482
by Brian Aker
Remove uint. |
294 |
int ha_disable_indexes(uint32_t mode); |
295 |
int ha_enable_indexes(uint32_t mode); |
|
200
by Brian Aker
my_bool from handler and set_var |
296 |
int ha_discard_or_import_tablespace(bool discard); |
1166.3.2
by Brian Aker
Remove ha_drop_table and modify it just to be a signal for the one case |
297 |
void closeMarkForDelete(const char *name); |
1
by brian
clean slate |
298 |
|
299 |
void adjust_next_insert_id_after_explicit_value(uint64_t nr); |
|
300 |
int update_auto_increment(); |
|
482
by Brian Aker
Remove uint. |
301 |
void print_keydup_error(uint32_t key_nr, const char *msg); |
1
by brian
clean slate |
302 |
virtual void print_error(int error, myf errflag); |
303 |
virtual bool get_error_message(int error, String *buf); |
|
482
by Brian Aker
Remove uint. |
304 |
uint32_t get_dup_key(int error); |
1000.1.3
by Brian Aker
Renamed TABLE_SHARE to TableShare |
305 |
virtual void change_table_ptr(Table *table_arg, TableShare *share); |
575.1.4
by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h. |
306 |
|
1
by brian
clean slate |
307 |
/* Estimates calculation */
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
308 |
virtual double scan_time(void) |
151
by Brian Aker
Ulonglong to uint64_t |
309 |
{ return uint64_t2double(stats.data_file_length) / IO_SIZE + 2; } |
645
by Brian Aker
Cleanup unused attribute |
310 |
virtual double read_time(uint32_t, uint32_t ranges, ha_rows rows) |
1
by brian
clean slate |
311 |
{ return rows2double(ranges+rows); } |
312 |
||
482
by Brian Aker
Remove uint. |
313 |
virtual double index_only_read_time(uint32_t keynr, double records); |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
314 |
|
482
by Brian Aker
Remove uint. |
315 |
virtual ha_rows multi_range_read_info_const(uint32_t keyno, RANGE_SEQ_IF *seq, |
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
316 |
void *seq_init_param, |
482
by Brian Aker
Remove uint. |
317 |
uint32_t n_ranges, uint32_t *bufsz, |
318 |
uint32_t *flags, COST_VECT *cost); |
|
319 |
virtual int multi_range_read_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys, |
|
320 |
uint32_t *bufsz, uint32_t *flags, COST_VECT *cost); |
|
1
by brian
clean slate |
321 |
virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, |
482
by Brian Aker
Remove uint. |
322 |
uint32_t n_ranges, uint32_t mode, |
1
by brian
clean slate |
323 |
HANDLER_BUFFER *buf); |
324 |
virtual int multi_range_read_next(char **range_info); |
|
325 |
||
326 |
||
575.1.4
by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h. |
327 |
virtual const key_map *keys_to_use_for_scanning(); |
328 |
bool has_transactions(); |
|
1
by brian
clean slate |
329 |
|
330 |
/**
|
|
331 |
This method is used to analyse the error to see whether the error
|
|
332 |
is ignorable or not, certain handlers can have more error that are
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
333 |
ignorable than others. E.g. the partition Cursor can get inserts
|
1
by brian
clean slate |
334 |
into a range where there is no partition and this is an ignorable
|
335 |
error.
|
|
336 |
HA_ERR_FOUND_DUP_UNIQUE is a special case in MyISAM that means the
|
|
337 |
same thing as HA_ERR_FOUND_DUP_KEY but can in some cases lead to
|
|
338 |
a slightly different error message.
|
|
339 |
*/
|
|
575.1.4
by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h. |
340 |
virtual bool is_fatal_error(int error, uint32_t flags); |
1
by brian
clean slate |
341 |
|
342 |
/**
|
|
343 |
Number of rows in table. It will only be called if
|
|
344 |
(table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0
|
|
345 |
*/
|
|
575.1.5
by Monty Taylor
Moved stuff to handlerton.cc |
346 |
virtual ha_rows records(); |
1
by brian
clean slate |
347 |
/**
|
348 |
Return upper bound of current number of records in the table
|
|
349 |
(max. of how many records one will retrieve when doing a full table scan)
|
|
350 |
If upper bound is not known, HA_POS_ERROR should be returned as a max
|
|
351 |
possible upper bound.
|
|
352 |
*/
|
|
353 |
virtual ha_rows estimate_rows_upper_bound() |
|
354 |
{ return stats.records+EXTRA_RECORDS; } |
|
355 |
||
356 |
/**
|
|
357 |
Get the row type from the storage engine. If this method returns
|
|
358 |
ROW_TYPE_NOT_USED, the information in HA_CREATE_INFO should be used.
|
|
359 |
*/
|
|
360 |
virtual enum row_type get_row_type() const { return ROW_TYPE_NOT_USED; } |
|
361 |
||
645
by Brian Aker
Cleanup unused attribute |
362 |
virtual const char *index_type(uint32_t) |
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
363 |
{ assert(0); return "";} |
1
by brian
clean slate |
364 |
|
365 |
||
482
by Brian Aker
Remove uint. |
366 |
uint32_t get_index(void) const { return active_index; } |
1
by brian
clean slate |
367 |
virtual int close(void)=0; |
368 |
||
369 |
/**
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
370 |
@retval 0 Bulk update used by Cursor
|
1
by brian
clean slate |
371 |
@retval 1 Bulk update not used, normal operation used
|
372 |
*/
|
|
373 |
virtual bool start_bulk_update() { return 1; } |
|
374 |
/**
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
375 |
@retval 0 Bulk delete used by Cursor
|
1
by brian
clean slate |
376 |
@retval 1 Bulk delete not used, normal operation used
|
377 |
*/
|
|
378 |
virtual bool start_bulk_delete() { return 1; } |
|
379 |
/**
|
|
380 |
After this call all outstanding updates must be performed. The number
|
|
381 |
of duplicate key errors are reported in the duplicate key parameter.
|
|
382 |
It is allowed to continue to the batched update after this call, the
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
383 |
Cursor has to wait until end_bulk_update with changing state.
|
1
by brian
clean slate |
384 |
|
385 |
@param dup_key_found Number of duplicate keys found
|
|
386 |
||
387 |
@retval 0 Success
|
|
388 |
@retval >0 Error code
|
|
389 |
*/
|
|
645
by Brian Aker
Cleanup unused attribute |
390 |
virtual int exec_bulk_update(uint32_t *) |
1
by brian
clean slate |
391 |
{
|
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
392 |
assert(false); |
1
by brian
clean slate |
393 |
return HA_ERR_WRONG_COMMAND; |
394 |
}
|
|
395 |
/**
|
|
396 |
Perform any needed clean-up, no outstanding updates are there at the
|
|
397 |
moment.
|
|
398 |
*/
|
|
399 |
virtual void end_bulk_update() { return; } |
|
400 |
/**
|
|
401 |
Execute all outstanding deletes and close down the bulk delete.
|
|
402 |
||
403 |
@retval 0 Success
|
|
404 |
@retval >0 Error code
|
|
405 |
*/
|
|
406 |
virtual int end_bulk_delete() |
|
407 |
{
|
|
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
408 |
assert(false); |
1
by brian
clean slate |
409 |
return HA_ERR_WRONG_COMMAND; |
410 |
}
|
|
411 |
/**
|
|
412 |
@brief
|
|
413 |
Positions an index cursor to the index specified in the handle. Fetches the
|
|
414 |
row if available. If the key value is null, begin at the first key of the
|
|
415 |
index.
|
|
416 |
*/
|
|
481
by Brian Aker
Remove all of uchar. |
417 |
virtual int index_read_map(unsigned char * buf, const unsigned char * key, |
1
by brian
clean slate |
418 |
key_part_map keypart_map, |
419 |
enum ha_rkey_function find_flag) |
|
420 |
{
|
|
482
by Brian Aker
Remove uint. |
421 |
uint32_t key_len= calculate_key_len(table, active_index, key, keypart_map); |
1
by brian
clean slate |
422 |
return index_read(buf, key, key_len, find_flag); |
423 |
}
|
|
424 |
/**
|
|
425 |
@brief
|
|
426 |
Positions an index cursor to the index specified in the handle. Fetches the
|
|
427 |
row if available. If the key value is null, begin at the first key of the
|
|
428 |
index.
|
|
429 |
*/
|
|
656.1.1
by Monty Taylor
OOOh doggie. Got rid of my_alloca. |
430 |
virtual int index_read_idx_map(unsigned char * buf, uint32_t index, |
431 |
const unsigned char * key, |
|
1
by brian
clean slate |
432 |
key_part_map keypart_map, |
433 |
enum ha_rkey_function find_flag); |
|
645
by Brian Aker
Cleanup unused attribute |
434 |
virtual int index_next(unsigned char *) |
435 |
{ return HA_ERR_WRONG_COMMAND; } |
|
436 |
virtual int index_prev(unsigned char *) |
|
437 |
{ return HA_ERR_WRONG_COMMAND; } |
|
438 |
virtual int index_first(unsigned char *) |
|
439 |
{ return HA_ERR_WRONG_COMMAND; } |
|
440 |
virtual int index_last(unsigned char *) |
|
441 |
{ return HA_ERR_WRONG_COMMAND; } |
|
442 |
virtual int index_next_same(unsigned char *, const unsigned char *, uint32_t); |
|
1
by brian
clean slate |
443 |
/**
|
444 |
@brief
|
|
445 |
The following functions works like index_read, but it find the last
|
|
446 |
row with the current key value or prefix.
|
|
447 |
*/
|
|
481
by Brian Aker
Remove all of uchar. |
448 |
virtual int index_read_last_map(unsigned char * buf, const unsigned char * key, |
1
by brian
clean slate |
449 |
key_part_map keypart_map) |
450 |
{
|
|
482
by Brian Aker
Remove uint. |
451 |
uint32_t key_len= calculate_key_len(table, active_index, key, keypart_map); |
1
by brian
clean slate |
452 |
return index_read_last(buf, key, key_len); |
453 |
}
|
|
454 |
virtual int read_range_first(const key_range *start_key, |
|
455 |
const key_range *end_key, |
|
456 |
bool eq_range, bool sorted); |
|
457 |
virtual int read_range_next(); |
|
458 |
int compare_key(key_range *range); |
|
459 |
int compare_key2(key_range *range); |
|
645
by Brian Aker
Cleanup unused attribute |
460 |
virtual int rnd_next(unsigned char *)=0; |
461 |
virtual int rnd_pos(unsigned char *, unsigned char *)=0; |
|
1
by brian
clean slate |
462 |
/**
|
463 |
One has to use this method when to find
|
|
464 |
random position by record as the plain
|
|
465 |
position() call doesn't work for some
|
|
466 |
handlers for random position.
|
|
467 |
*/
|
|
481
by Brian Aker
Remove all of uchar. |
468 |
virtual int rnd_pos_by_record(unsigned char *record); |
482
by Brian Aker
Remove uint. |
469 |
virtual int read_first_row(unsigned char *buf, uint32_t primary_key); |
1
by brian
clean slate |
470 |
/**
|
471 |
The following function is only needed for tables that may be temporary
|
|
472 |
tables during joins.
|
|
473 |
*/
|
|
645
by Brian Aker
Cleanup unused attribute |
474 |
virtual int restart_rnd_next(unsigned char *, unsigned char *) |
475 |
{ return HA_ERR_WRONG_COMMAND; } |
|
476 |
virtual int rnd_same(unsigned char *, uint32_t) |
|
477 |
{ return HA_ERR_WRONG_COMMAND; } |
|
478 |
virtual ha_rows records_in_range(uint32_t, key_range *, key_range *) |
|
1
by brian
clean slate |
479 |
{ return (ha_rows) 10; } |
481
by Brian Aker
Remove all of uchar. |
480 |
virtual void position(const unsigned char *record)=0; |
895
by Brian Aker
Completion (?) of uint conversion. |
481 |
virtual int info(uint32_t)=0; // see my_base.h for full description |
645
by Brian Aker
Cleanup unused attribute |
482 |
virtual uint32_t calculate_key_hash_value(Field **) |
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
483 |
{ assert(0); return 0; } |
645
by Brian Aker
Cleanup unused attribute |
484 |
virtual int extra(enum ha_extra_function) |
1
by brian
clean slate |
485 |
{ return 0; } |
645
by Brian Aker
Cleanup unused attribute |
486 |
virtual int extra_opt(enum ha_extra_function operation, uint32_t) |
1
by brian
clean slate |
487 |
{ return extra(operation); } |
488 |
||
489 |
/**
|
|
490 |
In an UPDATE or DELETE, if the row under the cursor was locked by another
|
|
491 |
transaction, and the engine used an optimistic read of the last
|
|
492 |
committed row value under the cursor, then the engine returns 1 from this
|
|
493 |
function. MySQL must NOT try to update this optimistic value. If the
|
|
494 |
optimistic value does not match the WHERE condition, MySQL can decide to
|
|
495 |
skip over this row. Currently only works for InnoDB. This can be used to
|
|
496 |
avoid unnecessary lock waits.
|
|
497 |
||
498 |
If this method returns nonzero, it will also signal the storage
|
|
499 |
engine that the next read will be a locking re-read of the row.
|
|
500 |
*/
|
|
501 |
virtual bool was_semi_consistent_read() { return 0; } |
|
502 |
/**
|
|
503 |
Tell the engine whether it should avoid unnecessary lock waits.
|
|
504 |
If yes, in an UPDATE or DELETE, if the row under the cursor was locked
|
|
505 |
by another transaction, the engine may try an optimistic read of
|
|
506 |
the last committed row value under the cursor.
|
|
507 |
*/
|
|
508 |
virtual void try_semi_consistent_read(bool) {} |
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
509 |
virtual void unlock_row(void) {} |
645
by Brian Aker
Cleanup unused attribute |
510 |
virtual int start_stmt(Session *, thr_lock_type) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
511 |
{return 0;} |
1
by brian
clean slate |
512 |
virtual void get_auto_increment(uint64_t offset, uint64_t increment, |
513 |
uint64_t nb_desired_values, |
|
514 |
uint64_t *first_value, |
|
515 |
uint64_t *nb_reserved_values); |
|
516 |
void set_next_insert_id(uint64_t id) |
|
517 |
{
|
|
518 |
next_insert_id= id; |
|
519 |
}
|
|
520 |
void restore_auto_increment(uint64_t prev_insert_id) |
|
521 |
{
|
|
522 |
/*
|
|
523 |
Insertion of a row failed, re-use the lastly generated auto_increment
|
|
524 |
id, for the next row. This is achieved by resetting next_insert_id to
|
|
525 |
what it was before the failed insertion (that old value is provided by
|
|
526 |
the caller). If that value was 0, it was the first row of the INSERT;
|
|
527 |
then if insert_id_for_cur_row contains 0 it means no id was generated
|
|
528 |
for this first row, so no id was generated since the INSERT started, so
|
|
529 |
we should set next_insert_id to 0; if insert_id_for_cur_row is not 0, it
|
|
530 |
is the generated id of the first and failed row, so we use it.
|
|
531 |
*/
|
|
532 |
next_insert_id= (prev_insert_id > 0) ? prev_insert_id : |
|
533 |
insert_id_for_cur_row; |
|
534 |
}
|
|
535 |
||
645
by Brian Aker
Cleanup unused attribute |
536 |
virtual void update_create_info(HA_CREATE_INFO *) {} |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
537 |
int check_old_types(void); |
1
by brian
clean slate |
538 |
/* end of the list of admin commands */
|
539 |
||
540 |
virtual int indexes_are_disabled(void) {return 0;} |
|
645
by Brian Aker
Cleanup unused attribute |
541 |
virtual void append_create_info(String *) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
542 |
{}
|
1
by brian
clean slate |
543 |
/**
|
544 |
If index == MAX_KEY then a check for table is made and if index <
|
|
545 |
MAX_KEY then a check is made if the table has foreign keys and if
|
|
546 |
a foreign key uses this index (and thus the index cannot be dropped).
|
|
547 |
||
548 |
@param index Index to check if foreign key uses it
|
|
549 |
||
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
550 |
@retval true Foreign key defined on table or index
|
551 |
@retval false No foreign key defined
|
|
1
by brian
clean slate |
552 |
*/
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
553 |
virtual char* get_foreign_key_create_info(void) |
1019.1.6
by Brian Aker
A number of random cleanups. |
554 |
{ return NULL;} /* gets foreign key create string from InnoDB */ |
1008.3.25
by Stewart Smith
slight semantic improvement in handler::can_switch_engines |
555 |
/** used in ALTER Table; if changing storage engine is allowed.
|
556 |
e.g. not be allowed if table has foreign key constraints in engine.
|
|
557 |
*/
|
|
558 |
virtual bool can_switch_engines(void) { return true; } |
|
1
by brian
clean slate |
559 |
/** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
|
645
by Brian Aker
Cleanup unused attribute |
560 |
virtual int get_foreign_key_list(Session *, List<FOREIGN_KEY_INFO> *) |
1
by brian
clean slate |
561 |
{ return 0; } |
482
by Brian Aker
Remove uint. |
562 |
virtual uint32_t referenced_by_foreign_key() { return 0;} |
645
by Brian Aker
Cleanup unused attribute |
563 |
virtual void free_foreign_key_create_info(char *) {} |
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
564 |
/** The following can be called without an open Cursor */
|
1008.3.26
by Stewart Smith
remove handler::table_type() as same information can be retrieved from handler::engine->getName() |
565 |
|
482
by Brian Aker
Remove uint. |
566 |
virtual uint32_t index_flags(uint32_t idx, uint32_t part, bool all_parts) const =0; |
1
by brian
clean slate |
567 |
|
645
by Brian Aker
Cleanup unused attribute |
568 |
virtual int add_index(Table *, KEY *, uint32_t) |
569 |
{ return (HA_ERR_WRONG_COMMAND); } |
|
570 |
virtual int prepare_drop_index(Table *, uint32_t *, uint32_t) |
|
571 |
{ return (HA_ERR_WRONG_COMMAND); } |
|
572 |
virtual int final_drop_index(Table *) |
|
1
by brian
clean slate |
573 |
{ return (HA_ERR_WRONG_COMMAND); } |
574 |
||
482
by Brian Aker
Remove uint. |
575 |
uint32_t max_record_length() const |
1067.4.4
by Nathan Williams
The rest of the files in the drizzled directory were purged of the cmin macro and replace with std::min (except for the definition in globals.h and 1 usage in stacktrace.cc). |
576 |
{ return std::min((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); } |
482
by Brian Aker
Remove uint. |
577 |
uint32_t max_keys() const |
1067.4.4
by Nathan Williams
The rest of the files in the drizzled directory were purged of the cmin macro and replace with std::min (except for the definition in globals.h and 1 usage in stacktrace.cc). |
578 |
{ return std::min((unsigned int)MAX_KEY, max_supported_keys()); } |
482
by Brian Aker
Remove uint. |
579 |
uint32_t max_key_parts() const |
1067.4.4
by Nathan Williams
The rest of the files in the drizzled directory were purged of the cmin macro and replace with std::min (except for the definition in globals.h and 1 usage in stacktrace.cc). |
580 |
{ return std::min((unsigned int)MAX_REF_PARTS, max_supported_key_parts()); } |
482
by Brian Aker
Remove uint. |
581 |
uint32_t max_key_length() const |
1067.4.4
by Nathan Williams
The rest of the files in the drizzled directory were purged of the cmin macro and replace with std::min (except for the definition in globals.h and 1 usage in stacktrace.cc). |
582 |
{ return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_length()); } |
482
by Brian Aker
Remove uint. |
583 |
uint32_t max_key_part_length(void) const |
1067.4.4
by Nathan Williams
The rest of the files in the drizzled directory were purged of the cmin macro and replace with std::min (except for the definition in globals.h and 1 usage in stacktrace.cc). |
584 |
{ return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_part_length()); } |
1
by brian
clean slate |
585 |
|
482
by Brian Aker
Remove uint. |
586 |
virtual uint32_t max_supported_record_length(void) const |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
587 |
{ return HA_MAX_REC_LENGTH; } |
482
by Brian Aker
Remove uint. |
588 |
virtual uint32_t max_supported_keys(void) const { return 0; } |
589 |
virtual uint32_t max_supported_key_parts(void) const { return MAX_REF_PARTS; } |
|
590 |
virtual uint32_t max_supported_key_length(void) const { return MAX_KEY_LENGTH; } |
|
591 |
virtual uint32_t max_supported_key_part_length(void) const { return 255; } |
|
1
by brian
clean slate |
592 |
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
593 |
virtual bool low_byte_first(void) const { return 1; } |
482
by Brian Aker
Remove uint. |
594 |
virtual uint32_t checksum(void) const { return 0; } |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
595 |
virtual bool is_crashed(void) const { return 0; } |
596 |
virtual bool auto_repair(void) const { return 0; } |
|
1
by brian
clean slate |
597 |
|
598 |
/**
|
|
599 |
Is not invoked for non-transactional temporary tables.
|
|
600 |
||
601 |
@note store_lock() can return more than one lock if the table is MERGE
|
|
602 |
or partitioned.
|
|
603 |
||
604 |
@note that one can NOT rely on table->in_use in store_lock(). It may
|
|
605 |
refer to a different thread if called from mysql_lock_abort_for_thread().
|
|
606 |
||
607 |
@note If the table is MERGE, store_lock() can return less locks
|
|
608 |
than lock_count() claimed. This can happen when the MERGE children
|
|
609 |
are not attached when this is called from another thread.
|
|
610 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
611 |
virtual THR_LOCK_DATA **store_lock(Session *session, |
1
by brian
clean slate |
612 |
THR_LOCK_DATA **to, |
613 |
enum thr_lock_type lock_type)=0; |
|
614 |
||
615 |
/*
|
|
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
616 |
@retval true Primary key (if there is one) is clustered
|
1
by brian
clean slate |
617 |
key covering all fields
|
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
618 |
@retval false otherwise
|
1
by brian
clean slate |
619 |
*/
|
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
620 |
virtual bool primary_key_is_clustered() { return false; } |
481
by Brian Aker
Remove all of uchar. |
621 |
virtual int cmp_ref(const unsigned char *ref1, const unsigned char *ref2) |
1
by brian
clean slate |
622 |
{
|
623 |
return memcmp(ref1, ref2, ref_length); |
|
624 |
}
|
|
625 |
||
626 |
/**
|
|
627 |
Lock table.
|
|
628 |
||
520.1.22
by Brian Aker
Second pass of thd cleanup |
629 |
@param session Thread handle
|
1
by brian
clean slate |
630 |
@param lock_type HA_LOCK_IN_SHARE_MODE (F_RDLCK)
|
631 |
HA_LOCK_IN_EXCLUSIVE_MODE (F_WRLCK)
|
|
632 |
@param lock_timeout -1 default timeout
|
|
633 |
0 no wait
|
|
634 |
>0 wait timeout in milliseconds.
|
|
635 |
||
636 |
@note
|
|
637 |
lock_timeout >0 is not used by MySQL currently. If the storage
|
|
638 |
engine does not support NOWAIT (lock_timeout == 0) it should
|
|
639 |
return an error. But if it does not support WAIT X (lock_timeout
|
|
640 |
>0) it should treat it as lock_timeout == -1 and wait a default
|
|
641 |
(or even hard-coded) timeout.
|
|
642 |
||
643 |
@retval HA_ERR_WRONG_COMMAND Storage engine does not support
|
|
644 |
lock_table()
|
|
645 |
@retval HA_ERR_UNSUPPORTED Storage engine does not support NOWAIT
|
|
646 |
@retval HA_ERR_LOCK_WAIT_TIMEOUT Lock request timed out or
|
|
647 |
lock conflict with NOWAIT option
|
|
648 |
@retval HA_ERR_LOCK_DEADLOCK Deadlock detected
|
|
649 |
*/
|
|
645
by Brian Aker
Cleanup unused attribute |
650 |
virtual int lock_table(Session *, int, int) |
1
by brian
clean slate |
651 |
{
|
652 |
return HA_ERR_WRONG_COMMAND; |
|
653 |
}
|
|
654 |
||
655 |
protected: |
|
656 |
/* Service methods for use by storage engines. */
|
|
657 |
void ha_statistic_increment(ulong SSV::*offset) const; |
|
520.1.21
by Brian Aker
THD -> Session rename |
658 |
void **ha_data(Session *) const; |
520.1.22
by Brian Aker
Second pass of thd cleanup |
659 |
Session *ha_session(void) const; |
1
by brian
clean slate |
660 |
|
661 |
private: |
|
662 |
/* Private helpers */
|
|
663 |
inline void mark_trx_read_write(); |
|
664 |
private: |
|
665 |
/*
|
|
666 |
Low-level primitives for storage engines. These should be
|
|
667 |
overridden by the storage engine class. To call these methods, use
|
|
668 |
the corresponding 'ha_*' method above.
|
|
669 |
*/
|
|
670 |
||
482
by Brian Aker
Remove uint. |
671 |
virtual int open(const char *name, int mode, uint32_t test_if_locked)=0; |
645
by Brian Aker
Cleanup unused attribute |
672 |
virtual int index_init(uint32_t idx, bool) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
673 |
{ active_index= idx; return 0; } |
1
by brian
clean slate |
674 |
virtual int index_end() { active_index= MAX_KEY; return 0; } |
675 |
/**
|
|
676 |
rnd_init() can be called two times without rnd_end() in between
|
|
677 |
(it only makes sense if scan=1).
|
|
678 |
then the second call should prepare for the new table scan (e.g
|
|
679 |
if rnd_init allocates the cursor, second call should position it
|
|
680 |
to the start of the table, no need to deallocate and allocate it again
|
|
681 |
*/
|
|
682 |
virtual int rnd_init(bool scan)= 0; |
|
683 |
virtual int rnd_end() { return 0; } |
|
645
by Brian Aker
Cleanup unused attribute |
684 |
virtual int write_row(unsigned char *) |
685 |
{
|
|
686 |
return HA_ERR_WRONG_COMMAND; |
|
687 |
}
|
|
688 |
||
689 |
virtual int update_row(const unsigned char *, unsigned char *) |
|
690 |
{
|
|
691 |
return HA_ERR_WRONG_COMMAND; |
|
692 |
}
|
|
693 |
||
694 |
virtual int delete_row(const unsigned char *) |
|
1
by brian
clean slate |
695 |
{
|
696 |
return HA_ERR_WRONG_COMMAND; |
|
697 |
}
|
|
698 |
/**
|
|
699 |
Reset state of file to after 'open'.
|
|
700 |
This function is called after every statement for all tables used
|
|
701 |
by that statement.
|
|
702 |
*/
|
|
703 |
virtual int reset() { return 0; } |
|
704 |
virtual Table_flags table_flags(void) const= 0; |
|
705 |
||
706 |
/**
|
|
707 |
Is not invoked for non-transactional temporary tables.
|
|
708 |
||
709 |
Tells the storage engine that we intend to read or write data
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
710 |
from the table. This call is prefixed with a call to Cursor::store_lock()
|
711 |
and is invoked only for those Cursor instances that stored the lock.
|
|
1
by brian
clean slate |
712 |
|
713 |
Calls to rnd_init/index_init are prefixed with this call. When table
|
|
714 |
IO is complete, we call external_lock(F_UNLCK).
|
|
715 |
A storage engine writer should expect that each call to
|
|
716 |
::external_lock(F_[RD|WR]LOCK is followed by a call to
|
|
717 |
::external_lock(F_UNLCK). If it is not, it is a bug in MySQL.
|
|
718 |
||
719 |
The name and signature originate from the first implementation
|
|
720 |
in MyISAM, which would call fcntl to set/clear an advisory
|
|
721 |
lock on the data file in this method.
|
|
722 |
||
723 |
@param lock_type F_RDLCK, F_WRLCK, F_UNLCK
|
|
724 |
||
725 |
@return non-0 in case of failure, 0 in case of success.
|
|
726 |
When lock_type is F_UNLCK, the return value is ignored.
|
|
727 |
*/
|
|
645
by Brian Aker
Cleanup unused attribute |
728 |
virtual int external_lock(Session *, int) |
1
by brian
clean slate |
729 |
{
|
730 |
return 0; |
|
731 |
}
|
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
732 |
virtual void release_auto_increment(void) { return; }; |
1
by brian
clean slate |
733 |
/** admin commands - called from mysql_admin_table */
|
645
by Brian Aker
Cleanup unused attribute |
734 |
virtual int check(Session *, HA_CHECK_OPT *) |
1
by brian
clean slate |
735 |
{ return HA_ADMIN_NOT_IMPLEMENTED; } |
736 |
||
645
by Brian Aker
Cleanup unused attribute |
737 |
virtual void start_bulk_insert(ha_rows) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
738 |
{}
|
739 |
virtual int end_bulk_insert(void) { return 0; } |
|
660.1.3
by Eric Herman
removed trailing whitespace with simple script: |
740 |
virtual int index_read(unsigned char *, const unsigned char *, |
645
by Brian Aker
Cleanup unused attribute |
741 |
uint32_t, enum ha_rkey_function) |
1
by brian
clean slate |
742 |
{ return HA_ERR_WRONG_COMMAND; } |
645
by Brian Aker
Cleanup unused attribute |
743 |
virtual int index_read_last(unsigned char *, const unsigned char *, uint32_t) |
1
by brian
clean slate |
744 |
{ return (my_errno= HA_ERR_WRONG_COMMAND); } |
745 |
/**
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
746 |
This method is similar to update_row, however the Cursor doesn't need
|
747 |
to execute the updates at this point in time. The Cursor can be certain
|
|
1
by brian
clean slate |
748 |
that another call to bulk_update_row will occur OR a call to
|
749 |
exec_bulk_update before the set of updates in this query is concluded.
|
|
750 |
||
751 |
@param old_data Old record
|
|
752 |
@param new_data New record
|
|
753 |
@param dup_key_found Number of duplicate keys found
|
|
754 |
||
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
755 |
@retval 0 Bulk delete used by Cursor
|
1
by brian
clean slate |
756 |
@retval 1 Bulk delete not used, normal operation used
|
757 |
*/
|
|
645
by Brian Aker
Cleanup unused attribute |
758 |
virtual int bulk_update_row(const unsigned char *, unsigned char *, uint32_t *) |
1
by brian
clean slate |
759 |
{
|
51.1.77
by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols |
760 |
assert(false); |
1
by brian
clean slate |
761 |
return HA_ERR_WRONG_COMMAND; |
762 |
}
|
|
763 |
/**
|
|
764 |
This is called to delete all rows in a table
|
|
1183.1.2
by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted |
765 |
If the Cursor don't support this, then this function will
|
1
by brian
clean slate |
766 |
return HA_ERR_WRONG_COMMAND and MySQL will delete the rows one
|
767 |
by one.
|
|
768 |
*/
|
|
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
769 |
virtual int delete_all_rows(void) |
1
by brian
clean slate |
770 |
{ return (my_errno=HA_ERR_WRONG_COMMAND); } |
771 |
/**
|
|
772 |
Reset the auto-increment counter to the given value, i.e. the next row
|
|
773 |
inserted will get the given value. This is called e.g. after TRUNCATE
|
|
774 |
is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
|
|
775 |
returned by storage engines that don't support this operation.
|
|
776 |
*/
|
|
645
by Brian Aker
Cleanup unused attribute |
777 |
virtual int reset_auto_increment(uint64_t) |
53.2.32
by Monty Taylor
First large swath at getting handler stuff clean. |
778 |
{ return HA_ERR_WRONG_COMMAND; } |
645
by Brian Aker
Cleanup unused attribute |
779 |
virtual int optimize(Session *, HA_CHECK_OPT *) |
780 |
{ return HA_ADMIN_NOT_IMPLEMENTED; } |
|
781 |
virtual int analyze(Session *, HA_CHECK_OPT *) |
|
782 |
{ return HA_ADMIN_NOT_IMPLEMENTED; } |
|
1063.3.1
by Stewart Smith
remove ha_check_and_repair. Engines should take care of this themselves. |
783 |
|
645
by Brian Aker
Cleanup unused attribute |
784 |
virtual int disable_indexes(uint32_t) |
785 |
{ return HA_ERR_WRONG_COMMAND; } |
|
786 |
virtual int enable_indexes(uint32_t) |
|
787 |
{ return HA_ERR_WRONG_COMMAND; } |
|
788 |
virtual int discard_or_import_tablespace(bool) |
|
1
by brian
clean slate |
789 |
{ return (my_errno=HA_ERR_WRONG_COMMAND); } |
790 |
virtual void drop_table(const char *name); |
|
791 |
};
|
|
792 |
||
793 |
extern const char *ha_row_type[]; |
|
794 |
extern const char *tx_isolation_names[]; |
|
795 |
extern const char *binlog_format_names[]; |
|
796 |
extern TYPELIB tx_isolation_typelib; |
|
61
by Brian Aker
Conversion of handler type. |
797 |
extern uint32_t total_ha, total_ha_2pc; |
1
by brian
clean slate |
798 |
|
799 |
/* Wrapper functions */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
800 |
#define ha_commit(session) (ha_commit_trans((session), true))
|
801 |
#define ha_rollback(session) (ha_rollback_trans((session), true))
|
|
1
by brian
clean slate |
802 |
|
803 |
/* basic stuff */
|
|
804 |
int ha_init_errors(void); |
|
805 |
int ha_init(void); |
|
806 |
int ha_end(void); |
|
971.1.52
by Monty Taylor
Did the finalizers. Renamed plugin_registry. |
807 |
|
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
808 |
/* transactions: interface to plugin::StorageEngine functions */
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
809 |
int ha_commit_one_phase(Session *session, bool all); |
810 |
int ha_rollback_trans(Session *session, bool all); |
|
1
by brian
clean slate |
811 |
|
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
812 |
/* transactions: these functions never call plugin::StorageEngine functions directly */
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
813 |
int ha_commit_trans(Session *session, bool all); |
814 |
int ha_autocommit_or_rollback(Session *session, int error); |
|
815 |
int ha_enable_transaction(Session *session, bool on); |
|
1
by brian
clean slate |
816 |
|
817 |
/* savepoints */
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
818 |
int ha_rollback_to_savepoint(Session *session, SAVEPOINT *sv); |
819 |
int ha_savepoint(Session *session, SAVEPOINT *sv); |
|
820 |
int ha_release_savepoint(Session *session, SAVEPOINT *sv); |
|
1
by brian
clean slate |
821 |
|
822 |
/* these are called by storage engines */
|
|
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
823 |
void trans_register_ha(Session *session, bool all, drizzled::plugin::StorageEngine *engine); |
1
by brian
clean slate |
824 |
|
520.6.7
by Monty Taylor
Moved a bunch of crap out of common_includes. |
825 |
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length); |
1054.2.20
by Monty Taylor
Made tablename_to_filename available across the server now. |
826 |
bool tablename_to_filename(const char *from, char *to, size_t to_length); |
520.6.7
by Monty Taylor
Moved a bunch of crap out of common_includes. |
827 |
|
828 |
||
1
by brian
clean slate |
829 |
/*
|
830 |
Storage engine has to assume the transaction will end up with 2pc if
|
|
831 |
- there is more than one 2pc-capable storage engine available
|
|
832 |
- in the current transaction 2pc was not disabled yet
|
|
833 |
*/
|
|
520.1.22
by Brian Aker
Second pass of thd cleanup |
834 |
#define trans_need_2pc(session, all) ((total_ha_2pc > 1) && \
|
835 |
!((all ? &session->transaction.all : &session->transaction.stmt)->no_2pc))
|
|
520.6.4
by Monty Taylor
Moved thr_lock.h out of common_includes. |
836 |
|
575.4.7
by Monty Taylor
More header cleanup. |
837 |
|
838 |
bool mysql_xa_recover(Session *session); |
|
839 |
||
840 |
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length, |
|
841 |
SORT_FIELD *sortorder); |
|
842 |
int setup_order(Session *session, Item **ref_pointer_array, TableList *tables, |
|
843 |
List<Item> &fields, List <Item> &all_fields, order_st *order); |
|
844 |
int setup_group(Session *session, Item **ref_pointer_array, TableList *tables, |
|
845 |
List<Item> &fields, List<Item> &all_fields, order_st *order, |
|
846 |
bool *hidden_group_fields); |
|
846
by Brian Aker
Removing on typedeffed class. |
847 |
bool fix_inner_refs(Session *session, List<Item> &all_fields, Select_Lex *select, |
575.4.7
by Monty Taylor
More header cleanup. |
848 |
Item **ref_pointer_array); |
849 |
||
850 |
bool handle_select(Session *session, LEX *lex, select_result *result, |
|
892.2.2
by Monty Taylor
More solaris warnings. |
851 |
uint64_t setup_tables_done_option); |
575.4.7
by Monty Taylor
More header cleanup. |
852 |
bool mysql_select(Session *session, Item ***rref_pointer_array, |
853 |
TableList *tables, uint32_t wild_num, List<Item> &list, |
|
854 |
COND *conds, uint32_t og_num, order_st *order, order_st *group, |
|
923.1.10
by Brian Aker
Remove dead code around old procedures. |
855 |
Item *having, uint64_t select_type, |
848
by Brian Aker
typdef class removal (just... use the name of the class). |
856 |
select_result *result, Select_Lex_Unit *unit, |
846
by Brian Aker
Removing on typedeffed class. |
857 |
Select_Lex *select_lex); |
858 |
void free_underlaid_joins(Session *session, Select_Lex *select); |
|
848
by Brian Aker
typdef class removal (just... use the name of the class). |
859 |
bool mysql_explain_union(Session *session, Select_Lex_Unit *unit, |
575.4.7
by Monty Taylor
More header cleanup. |
860 |
select_result *result); |
846
by Brian Aker
Removing on typedeffed class. |
861 |
int mysql_explain_select(Session *session, Select_Lex *sl, char const *type, |
575.4.7
by Monty Taylor
More header cleanup. |
862 |
select_result *result); |
1008.3.22
by Stewart Smith
s/mysql_union/drizzle_union/ |
863 |
|
575.4.7
by Monty Taylor
More header cleanup. |
864 |
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session, |
865 |
LEX *lex, |
|
866 |
TableList *table)); |
|
867 |
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t); |
|
868 |
bool mysql_derived_filling(Session *session, LEX *lex, TableList *t); |
|
1052.2.3
by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards. |
869 |
int prepare_create_field(CreateField *sql_field, |
575.4.7
by Monty Taylor
More header cleanup. |
870 |
uint32_t *blob_columns, |
871 |
int *timestamps, int *timestamps_with_niladic, |
|
872 |
int64_t table_flags); |
|
873 |
bool mysql_create_table(Session *session,const char *db, const char *table_name, |
|
874 |
HA_CREATE_INFO *create_info, |
|
1008.3.20
by Stewart Smith
Put table_name into table proto in parser, and use that when creating table proto file. |
875 |
drizzled::message::Table *table_proto, |
1126.3.3
by Jay Pipes
Moves Alter_info out into its own header and source file, cleans up some related include mess in sql_lex.h, and renames Alter_info to AlterInfo. |
876 |
AlterInfo *alter_info, |
575.4.7
by Monty Taylor
More header cleanup. |
877 |
bool tmp_table, uint32_t select_field_count); |
878 |
bool mysql_create_table_no_lock(Session *session, const char *db, |
|
879 |
const char *table_name, |
|
880 |
HA_CREATE_INFO *create_info, |
|
1008.3.20
by Stewart Smith
Put table_name into table proto in parser, and use that when creating table proto file. |
881 |
drizzled::message::Table *table_proto, |
1126.3.3
by Jay Pipes
Moves Alter_info out into its own header and source file, cleans up some related include mess in sql_lex.h, and renames Alter_info to AlterInfo. |
882 |
AlterInfo *alter_info, |
1039.1.11
by Brian Aker
Refactor function to make sense. |
883 |
bool tmp_table, uint32_t select_field_count); |
575.4.7
by Monty Taylor
More header cleanup. |
884 |
|
885 |
bool mysql_recreate_table(Session *session, TableList *table_list); |
|
1172.1.1
by Brian Aker
Add in support for ENGINE= in create table like. |
886 |
bool mysql_create_like_table(Session* session, TableList* table, TableList* src_table, |
887 |
drizzled::message::Table& create_table_proto, |
|
575.4.7
by Monty Taylor
More header cleanup. |
888 |
HA_CREATE_INFO *create_info); |
1130.1.4
by Monty Taylor
Moved StorageEngine into plugin namespace. |
889 |
bool mysql_rename_table(drizzled::plugin::StorageEngine *base, const char *old_db, |
575.4.7
by Monty Taylor
More header cleanup. |
890 |
const char * old_name, const char *new_db, |
891 |
const char * new_name, uint32_t flags); |
|
892 |
bool mysql_prepare_update(Session *session, TableList *table_list, |
|
893 |
Item **conds, uint32_t order_num, order_st *order); |
|
894 |
int mysql_update(Session *session,TableList *tables,List<Item> &fields, |
|
895 |
List<Item> &values,COND *conds, |
|
896 |
uint32_t order_num, order_st *order, ha_rows limit, |
|
897 |
enum enum_duplicates handle_duplicates, bool ignore); |
|
898 |
bool mysql_prepare_insert(Session *session, TableList *table_list, Table *table, |
|
899 |
List<Item> &fields, List_item *values, |
|
900 |
List<Item> &update_fields, |
|
901 |
List<Item> &update_values, enum_duplicates duplic, |
|
902 |
COND **where, bool select_insert, |
|
903 |
bool check_fields, bool abort_on_warning); |
|
904 |
bool mysql_insert(Session *session,TableList *table,List<Item> &fields, |
|
905 |
List<List_item> &values, List<Item> &update_fields, |
|
906 |
List<Item> &update_values, enum_duplicates flag, |
|
907 |
bool ignore); |
|
908 |
int check_that_all_fields_are_given_values(Session *session, Table *entry, |
|
909 |
TableList *table_list); |
|
910 |
int mysql_prepare_delete(Session *session, TableList *table_list, Item **conds); |
|
911 |
bool mysql_delete(Session *session, TableList *table_list, COND *conds, |
|
912 |
SQL_LIST *order, ha_rows rows, uint64_t options, |
|
913 |
bool reset_auto_increment); |
|
1183.1.29
by Brian Aker
Clean up interface so that Truncate sets the propper engine when |
914 |
bool mysql_truncate(Session& session, TableList *table_list, bool dont_send_ok); |
1000.1.3
by Brian Aker
Renamed TABLE_SHARE to TableShare |
915 |
TableShare *get_table_share(Session *session, TableList *table_list, char *key, |
575.4.7
by Monty Taylor
More header cleanup. |
916 |
uint32_t key_length, uint32_t db_flags, int *error); |
1000.1.3
by Brian Aker
Renamed TABLE_SHARE to TableShare |
917 |
TableShare *get_cached_table_share(const char *db, const char *table_name); |
575.4.7
by Monty Taylor
More header cleanup. |
918 |
bool reopen_name_locked_table(Session* session, TableList* table_list, bool link_in); |
919 |
Table *table_cache_insert_placeholder(Session *session, const char *key, |
|
920 |
uint32_t key_length); |
|
921 |
bool lock_table_name_if_not_cached(Session *session, const char *db, |
|
922 |
const char *table_name, Table **table); |
|
923 |
bool reopen_table(Table *table); |
|
924 |
bool reopen_tables(Session *session,bool get_locks,bool in_refresh); |
|
925 |
void close_data_files_and_morph_locks(Session *session, const char *db, |
|
926 |
const char *table_name); |
|
927 |
void close_handle_and_leave_table_as_lock(Table *table); |
|
928 |
bool wait_for_tables(Session *session); |
|
929 |
bool table_is_used(Table *table, bool wait_for_name_lock); |
|
930 |
Table *drop_locked_tables(Session *session,const char *db, const char *table_name); |
|
931 |
void abort_locked_tables(Session *session,const char *db, const char *table_name); |
|
932 |
extern Field *not_found_field; |
|
933 |
extern Field *view_ref_found; |
|
934 |
||
935 |
Field * |
|
936 |
find_field_in_tables(Session *session, Item_ident *item, |
|
937 |
TableList *first_table, TableList *last_table, |
|
938 |
Item **ref, find_item_error_report_type report_error, |
|
1113.1.1
by Brian Aker
Dead code removal around LCOV finds. |
939 |
bool register_tree_change); |
575.4.7
by Monty Taylor
More header cleanup. |
940 |
Field * |
941 |
find_field_in_table_ref(Session *session, TableList *table_list, |
|
942 |
const char *name, uint32_t length, |
|
943 |
const char *item_name, const char *db_name, |
|
944 |
const char *table_name, Item **ref, |
|
1113.1.1
by Brian Aker
Dead code removal around LCOV finds. |
945 |
bool allow_rowid, |
575.4.7
by Monty Taylor
More header cleanup. |
946 |
uint32_t *cached_field_index_ptr, |
947 |
bool register_tree_change, TableList **actual_table); |
|
948 |
Field * |
|
949 |
find_field_in_table(Session *session, Table *table, const char *name, uint32_t length, |
|
950 |
bool allow_rowid, uint32_t *cached_field_index_ptr); |
|
951 |
Field * |
|
952 |
find_field_in_table_sef(Table *table, const char *name); |
|
953 |
||
954 |
||
1185
by Brian Aker
Merge Engine changes. |
955 |
#endif /* DRIZZLED_CURSOR_H */ |