~drizzle-trunk/drizzle/development

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>
1660.1.1 by Brian Aker
Merge in move identifier work.
25
#include <drizzled/identifier.h>
520.4.31 by Monty Taylor
Removed server_id from common_includes.
26
1183.1.2 by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted
27
/* Definitions for parameters to do with Cursor-routines */
1 by brian
clean slate
28
1241.9.43 by Monty Taylor
Merged trunk. Also renamed thr_lock. Doh. I hate it when I do both.
29
#include <drizzled/thr_lock.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
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).
42
#include <bitset>
43
#include <algorithm>
1005.2.6 by Monty Taylor
Re-added bitset<> as a replacement for Bitmap<>
44
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
45
namespace drizzled
46
{
47
520.6.4 by Monty Taylor
Moved thr_lock.h out of common_includes.
48
#define HA_MAX_ALTER_FLAGS 40
1130.1.5 by Monty Taylor
Split StorageEngine into slot. This completes the plugin-slot-reorg. Woot.
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
1220.1.3 by Brian Aker
Remove atomic on refresh (go back to do it via lazy method).
52
extern uint64_t refresh_version;  /* Increments on each reload */
1046.1.8 by Brian Aker
Remove race condition around refresh (aka... multi-thread writeable global
53
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
54
class Table;
561.1.3 by Monty Taylor
Split some more things out of common_includes.h.
55
class TableList;
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
56
class TableShare;
848 by Brian Aker
typdef class removal (just... use the name of the class).
57
class Select_Lex_Unit;
1455.6.1 by Yanbo Wu
convert st_foreign_key_info to class ForeignKeyInfo
58
class ForeignKeyInfo;
584.1.13 by Monty Taylor
Split out a little more code. Removed table_list.h from common_includes.
59
struct order_st;
1 by brian
clean slate
60
61
class Item;
62
575.4.7 by Monty Taylor
More header cleanup.
63
class LEX;
846 by Brian Aker
Removing on typedeffed class.
64
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.
65
class AlterInfo;
575.4.7 by Monty Taylor
More header cleanup.
66
class select_result;
1052.2.3 by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards.
67
class CreateField;
575.4.7 by Monty Taylor
More header cleanup.
68
class sys_var_str;
69
class Item_ident;
70
typedef struct st_sort_field SORT_FIELD;
71
72
typedef List<Item> List_item;
1 by brian
clean slate
73
extern KEY_CREATE_INFO default_key_create_info;
74
75
/* Forward declaration for condition pushdown to storage engine */
76
typedef class Item COND;
77
1273.16.8 by Brian Aker
Remove typedef.
78
typedef struct system_status_var system_status_var;
1 by brian
clean slate
79
1336.3.1 by Djellel E. Difallah
Cleanup & Encapsulate the COST_VECT class, and remove ./drizzled/cursor.h self include
80
namespace optimizer
81
{
1336.3.2 by Djellel E. Difallah
rename class COST_VECT to CostVector and move it to ./drizzled/optimizer directory
82
  class CostVector;
1336.3.1 by Djellel E. Difallah
Cleanup & Encapsulate the COST_VECT class, and remove ./drizzled/cursor.h self include
83
}
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
84
1 by brian
clean slate
85
/*
86
  bitmap with first N+1 bits set
87
  (keypart_map for a key prefix of [0..N] keyparts)
88
*/
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
89
template<class T>
90
inline key_part_map make_keypart_map(T a)
91
{
92
  return (((key_part_map)2 << a) - 1);
93
}
94
1 by brian
clean slate
95
/*
96
  bitmap with first N bits set
97
  (keypart_map for a key prefix of [0..N-1] keyparts)
98
*/
575.1.3 by Monty Taylor
Moved some stuff out of handler.h.
99
template<class T>
100
inline key_part_map make_prev_keypart_map(T a)
101
{
102
  return (((key_part_map)1 << a) - 1);
103
}
1 by brian
clean slate
104
105
/**
1183.1.2 by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted
106
  The Cursor class is the interface for dynamically loadable
1 by brian
clean slate
107
  storage engines. Do not add ifdefs and take care when adding or
108
  changing virtual functions to avoid vtable confusion
109
110
  Functions in this class accept and return table columns data. Two data
111
  representation formats are used:
112
  1. TableRecordFormat - Used to pass [partial] table records to/from
113
     storage engine
114
115
  2. KeyTupleFormat - used to pass index search tuples (aka "keys") to
1237.9.2 by Padraig O'Sullivan
Moved opt_range.[cc,h] into the optimizer directory and namespace and renamed the files to
116
     storage engine. See optimizer/range.cc for description of this format.
1 by brian
clean slate
117
118
  TableRecordFormat
119
  =================
120
  [Warning: this description is work in progress and may be incomplete]
121
  The table record is stored in a fixed-size buffer:
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
122
1 by brian
clean slate
123
    record: null_bytes, column1_data, column2_data, ...
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
124
125
  The offsets of the parts of the buffer are also fixed: every column has
1 by brian
clean slate
126
  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:
127
  bit in null_bytes.
1 by brian
clean slate
128
129
  The record buffer only includes data about columns that are marked in the
130
  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:
131
  the situation).
1 by brian
clean slate
132
  <not-sure>It could be that it is required that null bits of non-present
133
  columns are set to 1</not-sure>
134
135
  VARIOUS EXCEPTIONS AND SPECIAL CASES
136
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
137
  f the table has no nullable columns, then null_bytes is still
138
  present, its length is one byte <not-sure> which must be set to 0xFF
1 by brian
clean slate
139
  at all times. </not-sure>
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
140
141
  For blob columns (see Field_blob), the record buffer stores length of the
142
  data, following by memory pointer to the blob data. The pointer is owned
1 by brian
clean slate
143
  by the storage engine and is valid until the next operation.
144
145
  If a blob column has NULL value, then its length and blob data pointer
146
  must be set to 0.
147
*/
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
148
class Cursor :public memory::SqlAlloc
1 by brian
clean slate
149
{
150
protected:
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
151
  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).
152
  Table *table;               /* The current open table */
1 by brian
clean slate
153
154
  ha_rows estimation_rows_to_insert;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
155
  plugin::StorageEngine *engine;      /* storage engine of this Cursor */
1506 by Brian Aker
encapsulate engine inside of cursor.
156
public:
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
157
  inline plugin::StorageEngine *getEngine() const	/* table_type for handler */
1233.1.2 by Brian Aker
Move stat read define into engine flags.
158
  {
159
    return engine;
160
  }
161
  unsigned char *ref;				/* Pointer to current row */
481 by Brian Aker
Remove all of uchar.
162
  unsigned char *dup_ref;			/* Pointer to duplicate row */
1 by brian
clean slate
163
1532.1.15 by Brian Aker
Partial encapsulation of TableShare from Table.
164
  TableShare *getShare() const
165
  {
166
    return table_share;
167
  }
168
1 by brian
clean slate
169
  ha_statistics stats;
170
  /** MultiRangeRead-related members: */
171
  range_seq_t mrr_iter;    /* Interator to traverse the range sequence */
172
  RANGE_SEQ_IF mrr_funcs;  /* Range sequence traversal functions */
173
  HANDLER_BUFFER *multi_range_buffer; /* MRR buffer info */
482 by Brian Aker
Remove uint.
174
  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
175
  /* true <=> source MRR ranges and the output are ordered */
1 by brian
clean slate
176
  bool mrr_is_output_sorted;
177
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
178
  /** true <=> we're currently traversing a range in mrr_cur_range. */
1 by brian
clean slate
179
  bool mrr_have_range;
1030.1.1 by Brian Aker
Straighten out structures (remove some some dead bits).
180
181
  bool eq_range;
182
1 by brian
clean slate
183
  /** Current range (the one we're now returning rows from) */
184
  KEY_MULTI_RANGE mrr_cur_range;
185
186
  /** The following are for read_range() */
187
  key_range save_end_range, *end_range;
1534 by Brian Aker
Remove of KeyPartInfo
188
  KeyPartInfo *range_key_part;
1 by brian
clean slate
189
  int key_compare_result_on_equal;
190
482 by Brian Aker
Remove uint.
191
  uint32_t errkey;				/* Last dup key */
192
  uint32_t key_used_on_scan;
193
  uint32_t active_index;
1 by brian
clean slate
194
  /** Length of ref (1-8 or the clustered key length) */
482 by Brian Aker
Remove uint.
195
  uint32_t ref_length;
1 by brian
clean slate
196
  enum {NONE=0, INDEX, RND} inited;
197
  bool locked;
198
199
  /**
200
    next_insert_id is the next value which should be inserted into the
201
    auto_increment column: in a inserting-multi-row statement (like INSERT
202
    SELECT), for the first row where the autoinc value is not specified by the
203
    statement, get_auto_increment() called and asked to generate a value,
204
    next_insert_id is set to the next value, then for all other rows
205
    next_insert_id is used (and increased each time) without calling
206
    get_auto_increment().
207
  */
208
  uint64_t next_insert_id;
1320.1.18 by Brian Aker
Overhaul of SHOW TABLE STATUS.
209
  uint64_t getNextInsertId()
210
  {
211
    return next_insert_id;
212
  }
213
1 by brian
clean slate
214
  /**
215
    insert id for the current row (*autogenerated*; if not
216
    autogenerated, it's 0).
217
    At first successful insertion, this variable is stored into
520.1.21 by Brian Aker
THD -> Session rename
218
    Session::first_successful_insert_id_in_cur_stmt.
1 by brian
clean slate
219
  */
220
  uint64_t insert_id_for_cur_row;
221
  /**
222
    Interval returned by get_auto_increment() and being consumed by the
223
    inserter.
224
  */
225
  Discrete_interval auto_inc_interval_for_cur_row;
226
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
227
  Cursor(plugin::StorageEngine &engine_arg, TableShare &share_arg);
1183.1.2 by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted
228
  virtual ~Cursor(void);
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
229
  virtual Cursor *clone(memory::Root *mem_root);
575.1.4 by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h.
230
1 by brian
clean slate
231
  /* ha_ methods: pubilc wrappers for private virtual API */
232
1626.3.1 by Brian Aker
Adding in TableIdentifier for ha_open; (first pass)
233
  int ha_open(const TableIdentifier &identifier, Table *table, const char *name, int mode, int test_if_locked);
1491.1.6 by Jay Pipes
Cursor::ha_index_init() -> Cursor::startIndexScan(). Cursor::ha_index_end() -> Cursor::endIndexScan()
234
  int startIndexScan(uint32_t idx, bool sorted);
235
  int endIndexScan();
1491.1.10 by Jay Pipes
ha_rnd_init -> startTableScan, rnd_init -> doStartTableScan, ha_rnd_end -> endTableScan, rnd_end -> doEndTableScan
236
  int startTableScan(bool scan);
237
  int endTableScan();
1 by brian
clean slate
238
  int ha_reset();
575.1.4 by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h.
239
1 by brian
clean slate
240
  /* 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.
241
  int ha_index_or_rnd_end();
242
1 by brian
clean slate
243
  /**
244
    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
245
    Cursor class, hence they are *not* virtual. For the inheritance
1491.1.3 by Jay Pipes
Cursor::update_row() changed to doUpdateRecord() and updateRecord()
246
    interface, see the (private) functions doInsertRecord(), doUpdateRecord(),
1491.1.4 by Jay Pipes
delete_row() is now deleteRecord() and doDeleteRecord() in Cursor
247
    and doDeleteRecord() below.
1 by brian
clean slate
248
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
249
  int ha_external_lock(Session *session, int lock_type);
1491.1.2 by Jay Pipes
Cursor::write_row() -> Cursor::doInsertRecord(). Cursor::ha_write_row() -> Cursor::insertRecord()
250
  int insertRecord(unsigned char * buf);
1491.1.3 by Jay Pipes
Cursor::update_row() changed to doUpdateRecord() and updateRecord()
251
  int updateRecord(const unsigned char * old_data, unsigned char * new_data);
1491.1.4 by Jay Pipes
delete_row() is now deleteRecord() and doDeleteRecord() in Cursor
252
  int deleteRecord(const unsigned char * buf);
1 by brian
clean slate
253
  void ha_release_auto_increment();
254
255
  /** to be actually called to get 'check()' functionality*/
520.1.22 by Brian Aker
Second pass of thd cleanup
256
  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).
257
575.1.4 by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h.
258
  void ha_start_bulk_insert(ha_rows rows);
259
  int ha_end_bulk_insert();
1 by brian
clean slate
260
  int ha_delete_all_rows();
261
  int ha_reset_auto_increment(uint64_t value);
520.1.22 by Brian Aker
Second pass of thd cleanup
262
  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.
263
482 by Brian Aker
Remove uint.
264
  int ha_disable_indexes(uint32_t mode);
265
  int ha_enable_indexes(uint32_t mode);
200 by Brian Aker
my_bool from handler and set_var
266
  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
267
  void closeMarkForDelete(const char *name);
1 by brian
clean slate
268
269
  void adjust_next_insert_id_after_explicit_value(uint64_t nr);
270
  int update_auto_increment();
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
271
  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.
272
1 by brian
clean slate
273
  /* Estimates calculation */
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
274
  virtual double scan_time(void)
151 by Brian Aker
Ulonglong to uint64_t
275
  { return uint64_t2double(stats.data_file_length) / IO_SIZE + 2; }
645 by Brian Aker
Cleanup unused attribute
276
  virtual double read_time(uint32_t, uint32_t ranges, ha_rows rows)
1 by brian
clean slate
277
  { return rows2double(ranges+rows); }
278
482 by Brian Aker
Remove uint.
279
  virtual double index_only_read_time(uint32_t keynr, double records);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
280
482 by Brian Aker
Remove uint.
281
  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:
282
                                              void *seq_init_param,
482 by Brian Aker
Remove uint.
283
                                              uint32_t n_ranges, uint32_t *bufsz,
1336.3.2 by Djellel E. Difallah
rename class COST_VECT to CostVector and move it to ./drizzled/optimizer directory
284
                                              uint32_t *flags, optimizer::CostVector *cost);
482 by Brian Aker
Remove uint.
285
  virtual int multi_range_read_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys,
1336.3.2 by Djellel E. Difallah
rename class COST_VECT to CostVector and move it to ./drizzled/optimizer directory
286
                                    uint32_t *bufsz, uint32_t *flags, optimizer::CostVector *cost);
1 by brian
clean slate
287
  virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
1491 by Brian Aker
Remove call bits in dead mrr caller.
288
                                    uint32_t n_ranges, uint32_t mode);
1 by brian
clean slate
289
  virtual int multi_range_read_next(char **range_info);
290
291
575.1.4 by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h.
292
  virtual const key_map *keys_to_use_for_scanning();
293
  bool has_transactions();
1 by brian
clean slate
294
295
  /**
296
    This method is used to analyse the error to see whether the error
297
    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
298
    ignorable than others. E.g. the partition Cursor can get inserts
1 by brian
clean slate
299
    into a range where there is no partition and this is an ignorable
300
    error.
301
    HA_ERR_FOUND_DUP_UNIQUE is a special case in MyISAM that means the
302
    same thing as HA_ERR_FOUND_DUP_KEY but can in some cases lead to
303
    a slightly different error message.
304
  */
575.1.4 by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h.
305
  virtual bool is_fatal_error(int error, uint32_t flags);
1 by brian
clean slate
306
307
  /**
308
    Number of rows in table. It will only be called if
309
    (table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0
310
  */
575.1.5 by Monty Taylor
Moved stuff to handlerton.cc
311
  virtual ha_rows records();
1320.1.18 by Brian Aker
Overhaul of SHOW TABLE STATUS.
312
  virtual uint64_t tableSize();
313
  virtual uint64_t rowSize();
1 by brian
clean slate
314
  /**
315
    Return upper bound of current number of records in the table
316
    (max. of how many records one will retrieve when doing a full table scan)
317
    If upper bound is not known, HA_POS_ERROR should be returned as a max
318
    possible upper bound.
319
  */
320
  virtual ha_rows estimate_rows_upper_bound()
321
  { return stats.records+EXTRA_RECORDS; }
322
323
  /**
324
    Get the row type from the storage engine.  If this method returns
325
    ROW_TYPE_NOT_USED, the information in HA_CREATE_INFO should be used.
326
  */
327
  virtual enum row_type get_row_type() const { return ROW_TYPE_NOT_USED; }
328
645 by Brian Aker
Cleanup unused attribute
329
  virtual const char *index_type(uint32_t)
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
330
  { assert(0); return "";}
1 by brian
clean slate
331
332
482 by Brian Aker
Remove uint.
333
  uint32_t get_index(void) const { return active_index; }
1 by brian
clean slate
334
  virtual int close(void)=0;
335
336
  /**
337
     @brief
338
     Positions an index cursor to the index specified in the handle. Fetches the
339
     row if available. If the key value is null, begin at the first key of the
340
     index.
341
  */
1483 by Brian Aker
Small change to move over call to cursor API.
342
  virtual int index_read_map(unsigned char * buf, const unsigned char *key,
1 by brian
clean slate
343
                             key_part_map keypart_map,
344
                             enum ha_rkey_function find_flag)
345
  {
1483 by Brian Aker
Small change to move over call to cursor API.
346
    uint32_t key_len= calculate_key_len(active_index, keypart_map);
1 by brian
clean slate
347
    return  index_read(buf, key, key_len, find_flag);
348
  }
349
  /**
350
     @brief
351
     Positions an index cursor to the index specified in the handle. Fetches the
352
     row if available. If the key value is null, begin at the first key of the
353
     index.
354
  */
656.1.1 by Monty Taylor
OOOh doggie. Got rid of my_alloca.
355
  virtual int index_read_idx_map(unsigned char * buf, uint32_t index,
356
                                 const unsigned char * key,
1 by brian
clean slate
357
                                 key_part_map keypart_map,
358
                                 enum ha_rkey_function find_flag);
645 by Brian Aker
Cleanup unused attribute
359
  virtual int index_next(unsigned char *)
360
   { return  HA_ERR_WRONG_COMMAND; }
361
  virtual int index_prev(unsigned char *)
362
   { return  HA_ERR_WRONG_COMMAND; }
363
  virtual int index_first(unsigned char *)
364
   { return  HA_ERR_WRONG_COMMAND; }
365
  virtual int index_last(unsigned char *)
366
   { return  HA_ERR_WRONG_COMMAND; }
367
  virtual int index_next_same(unsigned char *, const unsigned char *, uint32_t);
1483 by Brian Aker
Small change to move over call to cursor API.
368
369
private:
370
  uint32_t calculate_key_len(uint32_t key_position, key_part_map keypart_map_arg);
371
public:
372
1 by brian
clean slate
373
  /**
374
     @brief
375
     The following functions works like index_read, but it find the last
376
     row with the current key value or prefix.
377
  */
481 by Brian Aker
Remove all of uchar.
378
  virtual int index_read_last_map(unsigned char * buf, const unsigned char * key,
1 by brian
clean slate
379
                                  key_part_map keypart_map)
380
  {
1483 by Brian Aker
Small change to move over call to cursor API.
381
    uint32_t key_len= calculate_key_len(active_index, keypart_map);
1 by brian
clean slate
382
    return index_read_last(buf, key, key_len);
383
  }
384
  virtual int read_range_first(const key_range *start_key,
385
                               const key_range *end_key,
386
                               bool eq_range, bool sorted);
387
  virtual int read_range_next();
388
  int compare_key(key_range *range);
645 by Brian Aker
Cleanup unused attribute
389
  virtual int rnd_next(unsigned char *)=0;
390
  virtual int rnd_pos(unsigned char *, unsigned char *)=0;
482 by Brian Aker
Remove uint.
391
  virtual int read_first_row(unsigned char *buf, uint32_t primary_key);
645 by Brian Aker
Cleanup unused attribute
392
  virtual int rnd_same(unsigned char *, uint32_t)
393
    { return HA_ERR_WRONG_COMMAND; }
394
  virtual ha_rows records_in_range(uint32_t, key_range *, key_range *)
1 by brian
clean slate
395
    { return (ha_rows) 10; }
481 by Brian Aker
Remove all of uchar.
396
  virtual void position(const unsigned char *record)=0;
895 by Brian Aker
Completion (?) of uint conversion.
397
  virtual int info(uint32_t)=0; // see my_base.h for full description
645 by Brian Aker
Cleanup unused attribute
398
  virtual uint32_t calculate_key_hash_value(Field **)
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
399
  { assert(0); return 0; }
645 by Brian Aker
Cleanup unused attribute
400
  virtual int extra(enum ha_extra_function)
1 by brian
clean slate
401
  { return 0; }
645 by Brian Aker
Cleanup unused attribute
402
  virtual int extra_opt(enum ha_extra_function operation, uint32_t)
1 by brian
clean slate
403
  { return extra(operation); }
404
405
  /**
406
    In an UPDATE or DELETE, if the row under the cursor was locked by another
407
    transaction, and the engine used an optimistic read of the last
408
    committed row value under the cursor, then the engine returns 1 from this
409
    function. MySQL must NOT try to update this optimistic value. If the
410
    optimistic value does not match the WHERE condition, MySQL can decide to
411
    skip over this row. Currently only works for InnoDB. This can be used to
412
    avoid unnecessary lock waits.
413
414
    If this method returns nonzero, it will also signal the storage
415
    engine that the next read will be a locking re-read of the row.
416
  */
417
  virtual bool was_semi_consistent_read() { return 0; }
418
  /**
419
    Tell the engine whether it should avoid unnecessary lock waits.
420
    If yes, in an UPDATE or DELETE, if the row under the cursor was locked
421
    by another transaction, the engine may try an optimistic read of
422
    the last committed row value under the cursor.
423
  */
424
  virtual void try_semi_consistent_read(bool) {}
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
425
  virtual void unlock_row(void) {}
1 by brian
clean slate
426
  virtual void get_auto_increment(uint64_t offset, uint64_t increment,
427
                                  uint64_t nb_desired_values,
428
                                  uint64_t *first_value,
1377.7.2 by Stewart Smith
make get_auto_increment pure virtual and force engines not supporting auto_increment to be explicit about it
429
                                  uint64_t *nb_reserved_values)= 0;
1377.7.1 by Stewart Smith
remove default get_auto_increment() implementation from Cursor. It's not safe when you don't have full table locks (it does a read of the MAX value for the column and then allocates after that). Instead leave a empty implementation that engines supporting auto_increment should implement.
430
1 by brian
clean slate
431
  void set_next_insert_id(uint64_t id)
432
  {
433
    next_insert_id= id;
434
  }
435
  void restore_auto_increment(uint64_t prev_insert_id)
436
  {
437
    /*
438
      Insertion of a row failed, re-use the lastly generated auto_increment
439
      id, for the next row. This is achieved by resetting next_insert_id to
440
      what it was before the failed insertion (that old value is provided by
441
      the caller). If that value was 0, it was the first row of the INSERT;
442
      then if insert_id_for_cur_row contains 0 it means no id was generated
443
      for this first row, so no id was generated since the INSERT started, so
444
      we should set next_insert_id to 0; if insert_id_for_cur_row is not 0, it
445
      is the generated id of the first and failed row, so we use it.
446
    */
447
    next_insert_id= (prev_insert_id > 0) ? prev_insert_id :
448
      insert_id_for_cur_row;
449
  }
450
451
  /* end of the list of admin commands */
452
453
  virtual int indexes_are_disabled(void) {return 0;}
645 by Brian Aker
Cleanup unused attribute
454
  virtual void append_create_info(String *)
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
455
  {}
1 by brian
clean slate
456
  /**
457
      If index == MAX_KEY then a check for table is made and if index <
458
      MAX_KEY then a check is made if the table has foreign keys and if
459
      a foreign key uses this index (and thus the index cannot be dropped).
460
461
    @param  index            Index to check if foreign key uses it
462
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
463
    @retval   true            Foreign key defined on table or index
464
    @retval   false           No foreign key defined
1 by brian
clean slate
465
  */
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
466
  virtual char* get_foreign_key_create_info(void)
1019.1.6 by Brian Aker
A number of random cleanups.
467
  { return NULL;}  /* gets foreign key create string from InnoDB */
1008.3.25 by Stewart Smith
slight semantic improvement in handler::can_switch_engines
468
  /** used in ALTER Table; if changing storage engine is allowed.
469
      e.g. not be allowed if table has foreign key constraints in engine.
470
   */
471
  virtual bool can_switch_engines(void) { return true; }
1 by brian
clean slate
472
  /** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
1455.6.1 by Yanbo Wu
convert st_foreign_key_info to class ForeignKeyInfo
473
  virtual int get_foreign_key_list(Session *, List<ForeignKeyInfo> *)
1 by brian
clean slate
474
  { return 0; }
482 by Brian Aker
Remove uint.
475
  virtual uint32_t referenced_by_foreign_key() { return 0;}
645 by Brian Aker
Cleanup unused attribute
476
  virtual void free_foreign_key_create_info(char *) {}
1 by brian
clean slate
477
478
  /**
479
    Is not invoked for non-transactional temporary tables.
480
481
    @note store_lock() can return more than one lock if the table is MERGE
482
    or partitioned.
483
484
    @note that one can NOT rely on table->in_use in store_lock().  It may
485
    refer to a different thread if called from mysql_lock_abort_for_thread().
486
487
    @note If the table is MERGE, store_lock() can return less locks
488
    than lock_count() claimed. This can happen when the MERGE children
489
    are not attached when this is called from another thread.
490
  */
1222.1.11 by Brian Aker
Remove dead store_lock() path.
491
  virtual THR_LOCK_DATA **store_lock(Session *,
1 by brian
clean slate
492
                                     THR_LOCK_DATA **to,
1222.1.11 by Brian Aker
Remove dead store_lock() path.
493
                                     enum thr_lock_type)
494
  {
1222.1.12 by Brian Aker
Fix for Solaris build.
495
    assert(0); // Impossible programming situation
1222.1.11 by Brian Aker
Remove dead store_lock() path.
496
497
    return(to);
498
  }
1 by brian
clean slate
499
500
 /*
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
501
   @retval true   Primary key (if there is one) is clustered
1 by brian
clean slate
502
                  key covering all fields
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
503
   @retval false  otherwise
1 by brian
clean slate
504
 */
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
505
 virtual bool primary_key_is_clustered() { return false; }
481 by Brian Aker
Remove all of uchar.
506
 virtual int cmp_ref(const unsigned char *ref1, const unsigned char *ref2)
1 by brian
clean slate
507
 {
508
   return memcmp(ref1, ref2, ref_length);
509
 }
510
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
511
  virtual bool isOrdered(void)
1 by brian
clean slate
512
  {
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
513
    return false;
1 by brian
clean slate
514
  }
515
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
516
1 by brian
clean slate
517
protected:
518
  /* Service methods for use by storage engines. */
1561.3.12 by Joe Daly
add missing header file, and change ha_statistic_increment from ulong to uint64_t
519
  void ha_statistic_increment(uint64_t system_status_var::*offset) const;
520.1.21 by Brian Aker
THD -> Session rename
520
  void **ha_data(Session *) const;
1 by brian
clean slate
521
522
private:
523
  /* Private helpers */
1273.1.12 by Jay Pipes
Cleanup style and documentation for ResourceContext and setTransactionReadWrite
524
  inline void setTransactionReadWrite();
1 by brian
clean slate
525
private:
526
  /*
527
    Low-level primitives for storage engines.  These should be
528
    overridden by the storage engine class. To call these methods, use
529
    the corresponding 'ha_*' method above.
530
  */
531
1633.4.2 by Brian Aker
Merge up changes to ha_innodb
532
  virtual int open(const char *, int , uint32_t ) { assert(0); return -1; };
1626.3.3 by Brian Aker
Additional checks on path.
533
  virtual int doOpen(const TableIdentifier &identifier, int mode, uint32_t test_if_locked);
1491.1.6 by Jay Pipes
Cursor::ha_index_init() -> Cursor::startIndexScan(). Cursor::ha_index_end() -> Cursor::endIndexScan()
534
  virtual int doStartIndexScan(uint32_t idx, bool)
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
535
  { active_index= idx; return 0; }
1491.1.6 by Jay Pipes
Cursor::ha_index_init() -> Cursor::startIndexScan(). Cursor::ha_index_end() -> Cursor::endIndexScan()
536
  virtual int doEndIndexScan() { active_index= MAX_KEY; return 0; }
1 by brian
clean slate
537
  /**
1491.1.10 by Jay Pipes
ha_rnd_init -> startTableScan, rnd_init -> doStartTableScan, ha_rnd_end -> endTableScan, rnd_end -> doEndTableScan
538
    doStartTableScan() can be called two times without doEndTableScan() in between
1 by brian
clean slate
539
    (it only makes sense if scan=1).
540
    then the second call should prepare for the new table scan (e.g
541
    if rnd_init allocates the cursor, second call should position it
542
    to the start of the table, no need to deallocate and allocate it again
543
  */
1491.1.10 by Jay Pipes
ha_rnd_init -> startTableScan, rnd_init -> doStartTableScan, ha_rnd_end -> endTableScan, rnd_end -> doEndTableScan
544
  virtual int doStartTableScan(bool scan)= 0;
545
  virtual int doEndTableScan() { return 0; }
1491.1.2 by Jay Pipes
Cursor::write_row() -> Cursor::doInsertRecord(). Cursor::ha_write_row() -> Cursor::insertRecord()
546
  virtual int doInsertRecord(unsigned char *)
645 by Brian Aker
Cleanup unused attribute
547
  {
548
    return HA_ERR_WRONG_COMMAND;
549
  }
550
1491.1.3 by Jay Pipes
Cursor::update_row() changed to doUpdateRecord() and updateRecord()
551
  virtual int doUpdateRecord(const unsigned char *, unsigned char *)
645 by Brian Aker
Cleanup unused attribute
552
  {
553
    return HA_ERR_WRONG_COMMAND;
554
  }
555
1491.1.4 by Jay Pipes
delete_row() is now deleteRecord() and doDeleteRecord() in Cursor
556
  virtual int doDeleteRecord(const unsigned char *)
1 by brian
clean slate
557
  {
558
    return HA_ERR_WRONG_COMMAND;
559
  }
560
  /**
561
    Reset state of file to after 'open'.
562
    This function is called after every statement for all tables used
563
    by that statement.
564
  */
565
  virtual int reset() { return 0; }
566
567
  /**
568
    Is not invoked for non-transactional temporary tables.
569
570
    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
571
    from the table. This call is prefixed with a call to Cursor::store_lock()
572
    and is invoked only for those Cursor instances that stored the lock.
1 by brian
clean slate
573
574
    Calls to rnd_init/index_init are prefixed with this call. When table
575
    IO is complete, we call external_lock(F_UNLCK).
576
    A storage engine writer should expect that each call to
577
    ::external_lock(F_[RD|WR]LOCK is followed by a call to
578
    ::external_lock(F_UNLCK). If it is not, it is a bug in MySQL.
579
580
    The name and signature originate from the first implementation
581
    in MyISAM, which would call fcntl to set/clear an advisory
582
    lock on the data file in this method.
583
584
    @param   lock_type    F_RDLCK, F_WRLCK, F_UNLCK
585
586
    @return  non-0 in case of failure, 0 in case of success.
587
    When lock_type is F_UNLCK, the return value is ignored.
588
  */
645 by Brian Aker
Cleanup unused attribute
589
  virtual int external_lock(Session *, int)
1 by brian
clean slate
590
  {
591
    return 0;
592
  }
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
593
  virtual void release_auto_increment(void) { return; };
1 by brian
clean slate
594
  /** admin commands - called from mysql_admin_table */
1222.1.10 by Brian Aker
Removes options from DDL left in Cursor for admin operations (they were
595
  virtual int check(Session *)
1 by brian
clean slate
596
  { return HA_ADMIN_NOT_IMPLEMENTED; }
597
645 by Brian Aker
Cleanup unused attribute
598
  virtual void start_bulk_insert(ha_rows)
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
599
  {}
600
  virtual int end_bulk_insert(void) { return 0; }
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
601
  virtual int index_read(unsigned char *, const unsigned char *,
645 by Brian Aker
Cleanup unused attribute
602
                         uint32_t, enum ha_rkey_function)
1 by brian
clean slate
603
   { return  HA_ERR_WRONG_COMMAND; }
645 by Brian Aker
Cleanup unused attribute
604
  virtual int index_read_last(unsigned char *, const unsigned char *, uint32_t)
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
605
   { return (errno= HA_ERR_WRONG_COMMAND); }
1 by brian
clean slate
606
  /**
607
    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
608
    If the Cursor don't support this, then this function will
1 by brian
clean slate
609
    return HA_ERR_WRONG_COMMAND and MySQL will delete the rows one
610
    by one.
611
  */
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
612
  virtual int delete_all_rows(void)
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
613
  { return (errno=HA_ERR_WRONG_COMMAND); }
1 by brian
clean slate
614
  /**
615
    Reset the auto-increment counter to the given value, i.e. the next row
616
    inserted will get the given value. This is called e.g. after TRUNCATE
617
    is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
618
    returned by storage engines that don't support this operation.
619
  */
645 by Brian Aker
Cleanup unused attribute
620
  virtual int reset_auto_increment(uint64_t)
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
621
  { return HA_ERR_WRONG_COMMAND; }
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
622
1222.1.10 by Brian Aker
Removes options from DDL left in Cursor for admin operations (they were
623
  virtual int analyze(Session *)
645 by Brian Aker
Cleanup unused attribute
624
  { return HA_ADMIN_NOT_IMPLEMENTED; }
1063.3.1 by Stewart Smith
remove ha_check_and_repair. Engines should take care of this themselves.
625
645 by Brian Aker
Cleanup unused attribute
626
  virtual int disable_indexes(uint32_t)
627
  { return HA_ERR_WRONG_COMMAND; }
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
628
645 by Brian Aker
Cleanup unused attribute
629
  virtual int enable_indexes(uint32_t)
630
  { return HA_ERR_WRONG_COMMAND; }
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
631
645 by Brian Aker
Cleanup unused attribute
632
  virtual int discard_or_import_tablespace(bool)
1241.9.57 by Monty Taylor
Oy. Bigger change than I normally like - but this stuff is all intertwined.
633
  { return (errno=HA_ERR_WRONG_COMMAND); }
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
634
635
  /* 
636
    @todo this is just for the HEAP engine, it should
637
    be removed at some point in the future (and
638
    no new engine should ever use it). Right
639
    now HEAP does rely on it, so we cannot remove it.
640
  */
1 by brian
clean slate
641
  virtual void drop_table(const char *name);
642
};
643
644
extern const char *ha_row_type[];
645
646
/* basic stuff */
1271.7.22 by Monty Taylor
Cleaned up merge errors.
647
void ha_init_errors(void);
971.1.52 by Monty Taylor
Did the finalizers. Renamed plugin_registry.
648
575.4.7 by Monty Taylor
More header cleanup.
649
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
650
                                   SORT_FIELD *sortorder);
651
int setup_order(Session *session, Item **ref_pointer_array, TableList *tables,
652
                List<Item> &fields, List <Item> &all_fields, order_st *order);
653
int setup_group(Session *session, Item **ref_pointer_array, TableList *tables,
654
                List<Item> &fields, List<Item> &all_fields, order_st *order,
655
                bool *hidden_group_fields);
846 by Brian Aker
Removing on typedeffed class.
656
bool fix_inner_refs(Session *session, List<Item> &all_fields, Select_Lex *select,
575.4.7 by Monty Taylor
More header cleanup.
657
                    Item **ref_pointer_array);
658
659
bool handle_select(Session *session, LEX *lex, select_result *result,
892.2.2 by Monty Taylor
More solaris warnings.
660
                   uint64_t setup_tables_done_option);
846 by Brian Aker
Removing on typedeffed class.
661
void free_underlaid_joins(Session *session, Select_Lex *select);
1008.3.22 by Stewart Smith
s/mysql_union/drizzle_union/
662
575.4.7 by Monty Taylor
More header cleanup.
663
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
664
                                                      LEX *lex,
665
                                                      TableList *table));
666
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t);
667
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.
668
int prepare_create_field(CreateField *sql_field,
575.4.7 by Monty Taylor
More header cleanup.
669
                         uint32_t *blob_columns,
1233.1.8 by Brian Aker
Final removal table_flag().
670
                         int *timestamps, int *timestamps_with_niladic);
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
671
1223.4.1 by Brian Aker
Table Identifier patch.
672
bool mysql_create_table(Session *session,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
673
                        TableIdentifier &identifier,
575.4.7 by Monty Taylor
More header cleanup.
674
                        HA_CREATE_INFO *create_info,
1320.1.2 by Brian Aker
More reference counting.
675
                        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.
676
                        AlterInfo *alter_info,
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
677
                        bool tmp_table, uint32_t select_field_count,
678
                        bool is_if_not_exists);
679
1223.4.2 by Brian Aker
Extended mysql_create_table_no_lock to use TableIdentifier
680
bool mysql_create_table_no_lock(Session *session,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
681
                                TableIdentifier &identifier,
575.4.7 by Monty Taylor
More header cleanup.
682
                                HA_CREATE_INFO *create_info,
1320.1.1 by Brian Aker
Light cleanup for references.
683
                                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.
684
                                AlterInfo *alter_info,
1372.1.2 by Brian Aker
Rework to remove goto in the create table path.
685
                                bool tmp_table, uint32_t select_field_count,
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
686
                                bool is_if_not_exists);
575.4.7 by Monty Taylor
More header cleanup.
687
1320.1.2 by Brian Aker
More reference counting.
688
bool mysql_create_like_table(Session* session,
1340.1.1 by Brian Aker
Length usage of identifier down the tree.
689
                             TableIdentifier &destination_identifier,
1320.1.2 by Brian Aker
More reference counting.
690
                             TableList* table, TableList* src_table,
691
                             message::Table &create_table_proto,
1222.1.3 by Brian Aker
Remove used flag for engine.
692
                             bool is_if_not_exists,
693
                             bool is_engine_set);
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
694
1578.4.11 by Brian Aker
PAss through the code removing current_session
695
bool mysql_rename_table(Session &session,
696
                        plugin::StorageEngine *base,
1389 by Brian Aker
Large reord in ALTER TABLE for RENAME.
697
                        TableIdentifier &old_identifier,
1481 by Brian Aker
Remove dead code.
698
                        TableIdentifier &new_identifier);
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
699
575.4.7 by Monty Taylor
More header cleanup.
700
bool mysql_prepare_update(Session *session, TableList *table_list,
701
                          Item **conds, uint32_t order_num, order_st *order);
702
int mysql_update(Session *session,TableList *tables,List<Item> &fields,
703
                 List<Item> &values,COND *conds,
704
                 uint32_t order_num, order_st *order, ha_rows limit,
705
                 enum enum_duplicates handle_duplicates, bool ignore);
706
bool mysql_prepare_insert(Session *session, TableList *table_list, Table *table,
707
                          List<Item> &fields, List_item *values,
708
                          List<Item> &update_fields,
709
                          List<Item> &update_values, enum_duplicates duplic,
710
                          COND **where, bool select_insert,
711
                          bool check_fields, bool abort_on_warning);
712
bool mysql_insert(Session *session,TableList *table,List<Item> &fields,
713
                  List<List_item> &values, List<Item> &update_fields,
714
                  List<Item> &update_values, enum_duplicates flag,
715
                  bool ignore);
716
int check_that_all_fields_are_given_values(Session *session, Table *entry,
717
                                           TableList *table_list);
718
int mysql_prepare_delete(Session *session, TableList *table_list, Item **conds);
719
bool mysql_delete(Session *session, TableList *table_list, COND *conds,
720
                  SQL_LIST *order, ha_rows rows, uint64_t options,
721
                  bool reset_auto_increment);
1208.2.2 by Brian Aker
Merge Truncate patch. This fixes all of the "half setup" of Truncate. Still
722
bool mysql_truncate(Session& session, TableList *table_list);
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
723
TableShare *get_table_share(Session *session, TableList *table_list, char *key,
575.4.7 by Monty Taylor
More header cleanup.
724
                             uint32_t key_length, uint32_t db_flags, int *error);
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
725
TableShare *get_cached_table_share(const char *db, const char *table_name);
575.4.7 by Monty Taylor
More header cleanup.
726
bool reopen_name_locked_table(Session* session, TableList* table_list, bool link_in);
727
bool reopen_tables(Session *session,bool get_locks,bool in_refresh);
728
void close_handle_and_leave_table_as_lock(Table *table);
729
bool wait_for_tables(Session *session);
730
bool table_is_used(Table *table, bool wait_for_name_lock);
731
Table *drop_locked_tables(Session *session,const char *db, const char *table_name);
732
void abort_locked_tables(Session *session,const char *db, const char *table_name);
733
extern Field *not_found_field;
734
extern Field *view_ref_found;
735
736
Field *
737
find_field_in_tables(Session *session, Item_ident *item,
738
                     TableList *first_table, TableList *last_table,
739
                     Item **ref, find_item_error_report_type report_error,
1113.1.1 by Brian Aker
Dead code removal around LCOV finds.
740
                     bool register_tree_change);
575.4.7 by Monty Taylor
More header cleanup.
741
Field *
742
find_field_in_table_ref(Session *session, TableList *table_list,
743
                        const char *name, uint32_t length,
744
                        const char *item_name, const char *db_name,
745
                        const char *table_name, Item **ref,
1113.1.1 by Brian Aker
Dead code removal around LCOV finds.
746
                        bool allow_rowid,
575.4.7 by Monty Taylor
More header cleanup.
747
                        uint32_t *cached_field_index_ptr,
748
                        bool register_tree_change, TableList **actual_table);
749
Field *
750
find_field_in_table(Session *session, Table *table, const char *name, uint32_t length,
751
                    bool allow_rowid, uint32_t *cached_field_index_ptr);
752
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
753
} /* namespace drizzled */
575.4.7 by Monty Taylor
More header cleanup.
754
1185 by Brian Aker
Merge Engine changes.
755
#endif /* DRIZZLED_CURSOR_H */