~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>
1223.4.1 by Brian Aker
Table Identifier patch.
25
#include <drizzled/table_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
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
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
47
namespace drizzled
48
{
49
520.6.4 by Monty Taylor
Moved thr_lock.h out of common_includes.
50
#define HA_MAX_ALTER_FLAGS 40
1130.1.5 by Monty Taylor
Split StorageEngine into slot. This completes the plugin-slot-reorg. Woot.
51
52
1005.2.6 by Monty Taylor
Re-added bitset<> as a replacement for Bitmap<>
53
typedef std::bitset<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
1 by brian
clean slate
54
1220.1.3 by Brian Aker
Remove atomic on refresh (go back to do it via lazy method).
55
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
56
1 by brian
clean slate
57
520.1.22 by Brian Aker
Second pass of thd cleanup
58
typedef bool (*qc_engine_callback)(Session *session, char *table_key,
482 by Brian Aker
Remove uint.
59
                                      uint32_t key_length,
243.1.1 by Jay Pipes
* Pulled Object_creation_ctx and Default_creation_ctx out of mysql_priv.h
60
                                      uint64_t *engine_data);
61
1 by brian
clean slate
62
1183.1.2 by Brian Aker
Rename of handler to Cursor. You would not believe how long I have wanted
63
/* The Cursor for a table type.  Will be included in the Table structure */
1 by brian
clean slate
64
327.1.1 by Brian Aker
First pass in encapsulating table (it is now an object, no longer a structure).
65
class Table;
561.1.3 by Monty Taylor
Split some more things out of common_includes.h.
66
class TableList;
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
67
class TableShare;
848 by Brian Aker
typdef class removal (just... use the name of the class).
68
class Select_Lex_Unit;
1 by brian
clean slate
69
struct st_foreign_key_info;
70
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.
71
struct order_st;
1 by brian
clean slate
72
73
class Item;
74
struct st_table_log_memory_entry;
75
575.4.7 by Monty Taylor
More header cleanup.
76
class LEX;
846 by Brian Aker
Removing on typedeffed class.
77
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.
78
class AlterInfo;
575.4.7 by Monty Taylor
More header cleanup.
79
class select_result;
1052.2.3 by Nathan Williams
No actual code changes. Changed Create_field to CreateField to be consistent with coding standards.
80
class CreateField;
575.4.7 by Monty Taylor
More header cleanup.
81
class sys_var_str;
82
class Item_ident;
83
typedef struct st_sort_field SORT_FIELD;
84
85
typedef List<Item> List_item;
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
1273.16.8 by Brian Aker
Remove typedef.
91
typedef struct system_status_var system_status_var;
1 by brian
clean slate
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
1237.9.2 by Padraig O'Sullivan
Moved opt_range.[cc,h] into the optimizer directory and namespace and renamed the files to
127
     storage engine. See optimizer/range.cc for description of this format.
1 by brian
clean slate
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
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
164
class Cursor :public memory::SqlAlloc
1 by brian
clean slate
165
{
166
protected:
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
167
  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).
168
  Table *table;               /* The current open table */
1 by brian
clean slate
169
170
  ha_rows estimation_rows_to_insert;
171
public:
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
172
  plugin::StorageEngine *engine;      /* storage engine of this Cursor */
173
  inline plugin::StorageEngine *getEngine() const	/* table_type for handler */
1233.1.2 by Brian Aker
Move stat read define into engine flags.
174
  {
175
    return engine;
176
  }
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
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
239
  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
240
  virtual ~Cursor(void);
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
241
  virtual Cursor *clone(memory::Root *mem_root);
575.1.4 by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h.
242
1 by brian
clean slate
243
  /* ha_ methods: pubilc wrappers for private virtual API */
244
327.1.5 by Brian Aker
Refactor around classes. TABLE_LIST has been factored out of table.h
245
  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.
246
  int ha_index_init(uint32_t idx, bool sorted);
247
  int ha_index_end();
248
  int ha_rnd_init(bool scan);
249
  int ha_rnd_end();
1 by brian
clean slate
250
  int ha_reset();
575.1.4 by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h.
251
1 by brian
clean slate
252
  /* 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.
253
  int ha_index_or_rnd_end();
254
1 by brian
clean slate
255
  /**
256
    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
257
    Cursor class, hence they are *not* virtual. For the inheritance
1 by brian
clean slate
258
    interface, see the (private) functions write_row(), update_row(),
259
    and delete_row() below.
260
  */
520.1.22 by Brian Aker
Second pass of thd cleanup
261
  int ha_external_lock(Session *session, int lock_type);
481 by Brian Aker
Remove all of uchar.
262
  int ha_write_row(unsigned char * buf);
263
  int ha_update_row(const unsigned char * old_data, unsigned char * new_data);
264
  int ha_delete_row(const unsigned char * buf);
1 by brian
clean slate
265
  void ha_release_auto_increment();
266
267
  /** to be actually called to get 'check()' functionality*/
520.1.22 by Brian Aker
Second pass of thd cleanup
268
  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).
269
575.1.4 by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h.
270
  void ha_start_bulk_insert(ha_rows rows);
271
  int ha_end_bulk_insert();
1 by brian
clean slate
272
  int ha_delete_all_rows();
273
  int ha_reset_auto_increment(uint64_t value);
520.1.22 by Brian Aker
Second pass of thd cleanup
274
  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.
275
482 by Brian Aker
Remove uint.
276
  int ha_disable_indexes(uint32_t mode);
277
  int ha_enable_indexes(uint32_t mode);
200 by Brian Aker
my_bool from handler and set_var
278
  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
279
  void closeMarkForDelete(const char *name);
1 by brian
clean slate
280
281
  void adjust_next_insert_id_after_explicit_value(uint64_t nr);
282
  int update_auto_increment();
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
283
  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.
284
1 by brian
clean slate
285
  /* Estimates calculation */
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
286
  virtual double scan_time(void)
151 by Brian Aker
Ulonglong to uint64_t
287
  { return uint64_t2double(stats.data_file_length) / IO_SIZE + 2; }
645 by Brian Aker
Cleanup unused attribute
288
  virtual double read_time(uint32_t, uint32_t ranges, ha_rows rows)
1 by brian
clean slate
289
  { return rows2double(ranges+rows); }
290
482 by Brian Aker
Remove uint.
291
  virtual double index_only_read_time(uint32_t keynr, double records);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
292
482 by Brian Aker
Remove uint.
293
  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:
294
                                              void *seq_init_param,
482 by Brian Aker
Remove uint.
295
                                              uint32_t n_ranges, uint32_t *bufsz,
296
                                              uint32_t *flags, COST_VECT *cost);
297
  virtual int multi_range_read_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys,
298
                                    uint32_t *bufsz, uint32_t *flags, COST_VECT *cost);
1 by brian
clean slate
299
  virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
482 by Brian Aker
Remove uint.
300
                                    uint32_t n_ranges, uint32_t mode,
1 by brian
clean slate
301
                                    HANDLER_BUFFER *buf);
302
  virtual int multi_range_read_next(char **range_info);
303
304
575.1.4 by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h.
305
  virtual const key_map *keys_to_use_for_scanning();
306
  bool has_transactions();
1 by brian
clean slate
307
308
  /**
309
    This method is used to analyse the error to see whether the error
310
    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
311
    ignorable than others. E.g. the partition Cursor can get inserts
1 by brian
clean slate
312
    into a range where there is no partition and this is an ignorable
313
    error.
314
    HA_ERR_FOUND_DUP_UNIQUE is a special case in MyISAM that means the
315
    same thing as HA_ERR_FOUND_DUP_KEY but can in some cases lead to
316
    a slightly different error message.
317
  */
575.1.4 by Monty Taylor
Moved implementation of some methods into handler.cc from handler.h.
318
  virtual bool is_fatal_error(int error, uint32_t flags);
1 by brian
clean slate
319
320
  /**
321
    Number of rows in table. It will only be called if
322
    (table_flags() & (HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT)) != 0
323
  */
575.1.5 by Monty Taylor
Moved stuff to handlerton.cc
324
  virtual ha_rows records();
1 by brian
clean slate
325
  /**
326
    Return upper bound of current number of records in the table
327
    (max. of how many records one will retrieve when doing a full table scan)
328
    If upper bound is not known, HA_POS_ERROR should be returned as a max
329
    possible upper bound.
330
  */
331
  virtual ha_rows estimate_rows_upper_bound()
332
  { return stats.records+EXTRA_RECORDS; }
333
334
  /**
335
    Get the row type from the storage engine.  If this method returns
336
    ROW_TYPE_NOT_USED, the information in HA_CREATE_INFO should be used.
337
  */
338
  virtual enum row_type get_row_type() const { return ROW_TYPE_NOT_USED; }
339
645 by Brian Aker
Cleanup unused attribute
340
  virtual const char *index_type(uint32_t)
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
341
  { assert(0); return "";}
1 by brian
clean slate
342
343
482 by Brian Aker
Remove uint.
344
  uint32_t get_index(void) const { return active_index; }
1 by brian
clean slate
345
  virtual int close(void)=0;
346
347
  /**
348
     @brief
349
     Positions an index cursor to the index specified in the handle. Fetches the
350
     row if available. If the key value is null, begin at the first key of the
351
     index.
352
  */
481 by Brian Aker
Remove all of uchar.
353
  virtual int index_read_map(unsigned char * buf, const unsigned char * key,
1 by brian
clean slate
354
                             key_part_map keypart_map,
355
                             enum ha_rkey_function find_flag)
356
  {
482 by Brian Aker
Remove uint.
357
    uint32_t key_len= calculate_key_len(table, active_index, key, keypart_map);
1 by brian
clean slate
358
    return  index_read(buf, key, key_len, find_flag);
359
  }
360
  /**
361
     @brief
362
     Positions an index cursor to the index specified in the handle. Fetches the
363
     row if available. If the key value is null, begin at the first key of the
364
     index.
365
  */
656.1.1 by Monty Taylor
OOOh doggie. Got rid of my_alloca.
366
  virtual int index_read_idx_map(unsigned char * buf, uint32_t index,
367
                                 const unsigned char * key,
1 by brian
clean slate
368
                                 key_part_map keypart_map,
369
                                 enum ha_rkey_function find_flag);
645 by Brian Aker
Cleanup unused attribute
370
  virtual int index_next(unsigned char *)
371
   { return  HA_ERR_WRONG_COMMAND; }
372
  virtual int index_prev(unsigned char *)
373
   { return  HA_ERR_WRONG_COMMAND; }
374
  virtual int index_first(unsigned char *)
375
   { return  HA_ERR_WRONG_COMMAND; }
376
  virtual int index_last(unsigned char *)
377
   { return  HA_ERR_WRONG_COMMAND; }
378
  virtual int index_next_same(unsigned char *, const unsigned char *, uint32_t);
1 by brian
clean slate
379
  /**
380
     @brief
381
     The following functions works like index_read, but it find the last
382
     row with the current key value or prefix.
383
  */
481 by Brian Aker
Remove all of uchar.
384
  virtual int index_read_last_map(unsigned char * buf, const unsigned char * key,
1 by brian
clean slate
385
                                  key_part_map keypart_map)
386
  {
482 by Brian Aker
Remove uint.
387
    uint32_t key_len= calculate_key_len(table, active_index, key, keypart_map);
1 by brian
clean slate
388
    return index_read_last(buf, key, key_len);
389
  }
390
  virtual int read_range_first(const key_range *start_key,
391
                               const key_range *end_key,
392
                               bool eq_range, bool sorted);
393
  virtual int read_range_next();
394
  int compare_key(key_range *range);
395
  int compare_key2(key_range *range);
645 by Brian Aker
Cleanup unused attribute
396
  virtual int rnd_next(unsigned char *)=0;
397
  virtual int rnd_pos(unsigned char *, unsigned char *)=0;
1 by brian
clean slate
398
  /**
399
    One has to use this method when to find
400
    random position by record as the plain
401
    position() call doesn't work for some
402
    handlers for random position.
403
  */
481 by Brian Aker
Remove all of uchar.
404
  virtual int rnd_pos_by_record(unsigned char *record);
482 by Brian Aker
Remove uint.
405
  virtual int read_first_row(unsigned char *buf, uint32_t primary_key);
1 by brian
clean slate
406
  /**
407
    The following function is only needed for tables that may be temporary
408
    tables during joins.
409
  */
645 by Brian Aker
Cleanup unused attribute
410
  virtual int restart_rnd_next(unsigned char *, unsigned char *)
411
    { return HA_ERR_WRONG_COMMAND; }
412
  virtual int rnd_same(unsigned char *, uint32_t)
413
    { return HA_ERR_WRONG_COMMAND; }
414
  virtual ha_rows records_in_range(uint32_t, key_range *, key_range *)
1 by brian
clean slate
415
    { return (ha_rows) 10; }
481 by Brian Aker
Remove all of uchar.
416
  virtual void position(const unsigned char *record)=0;
895 by Brian Aker
Completion (?) of uint conversion.
417
  virtual int info(uint32_t)=0; // see my_base.h for full description
645 by Brian Aker
Cleanup unused attribute
418
  virtual uint32_t calculate_key_hash_value(Field **)
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
419
  { assert(0); return 0; }
645 by Brian Aker
Cleanup unused attribute
420
  virtual int extra(enum ha_extra_function)
1 by brian
clean slate
421
  { return 0; }
645 by Brian Aker
Cleanup unused attribute
422
  virtual int extra_opt(enum ha_extra_function operation, uint32_t)
1 by brian
clean slate
423
  { return extra(operation); }
424
425
  /**
426
    In an UPDATE or DELETE, if the row under the cursor was locked by another
427
    transaction, and the engine used an optimistic read of the last
428
    committed row value under the cursor, then the engine returns 1 from this
429
    function. MySQL must NOT try to update this optimistic value. If the
430
    optimistic value does not match the WHERE condition, MySQL can decide to
431
    skip over this row. Currently only works for InnoDB. This can be used to
432
    avoid unnecessary lock waits.
433
434
    If this method returns nonzero, it will also signal the storage
435
    engine that the next read will be a locking re-read of the row.
436
  */
437
  virtual bool was_semi_consistent_read() { return 0; }
438
  /**
439
    Tell the engine whether it should avoid unnecessary lock waits.
440
    If yes, in an UPDATE or DELETE, if the row under the cursor was locked
441
    by another transaction, the engine may try an optimistic read of
442
    the last committed row value under the cursor.
443
  */
444
  virtual void try_semi_consistent_read(bool) {}
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
445
  virtual void unlock_row(void) {}
1 by brian
clean slate
446
  virtual void get_auto_increment(uint64_t offset, uint64_t increment,
447
                                  uint64_t nb_desired_values,
448
                                  uint64_t *first_value,
449
                                  uint64_t *nb_reserved_values);
450
  void set_next_insert_id(uint64_t id)
451
  {
452
    next_insert_id= id;
453
  }
454
  void restore_auto_increment(uint64_t prev_insert_id)
455
  {
456
    /*
457
      Insertion of a row failed, re-use the lastly generated auto_increment
458
      id, for the next row. This is achieved by resetting next_insert_id to
459
      what it was before the failed insertion (that old value is provided by
460
      the caller). If that value was 0, it was the first row of the INSERT;
461
      then if insert_id_for_cur_row contains 0 it means no id was generated
462
      for this first row, so no id was generated since the INSERT started, so
463
      we should set next_insert_id to 0; if insert_id_for_cur_row is not 0, it
464
      is the generated id of the first and failed row, so we use it.
465
    */
466
    next_insert_id= (prev_insert_id > 0) ? prev_insert_id :
467
      insert_id_for_cur_row;
468
  }
469
645 by Brian Aker
Cleanup unused attribute
470
  virtual void update_create_info(HA_CREATE_INFO *) {}
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
471
  int check_old_types(void);
1 by brian
clean slate
472
  /* end of the list of admin commands */
473
474
  virtual int indexes_are_disabled(void) {return 0;}
645 by Brian Aker
Cleanup unused attribute
475
  virtual void append_create_info(String *)
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
476
  {}
1 by brian
clean slate
477
  /**
478
      If index == MAX_KEY then a check for table is made and if index <
479
      MAX_KEY then a check is made if the table has foreign keys and if
480
      a foreign key uses this index (and thus the index cannot be dropped).
481
482
    @param  index            Index to check if foreign key uses it
483
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
484
    @retval   true            Foreign key defined on table or index
485
    @retval   false           No foreign key defined
1 by brian
clean slate
486
  */
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
487
  virtual char* get_foreign_key_create_info(void)
1019.1.6 by Brian Aker
A number of random cleanups.
488
  { return NULL;}  /* gets foreign key create string from InnoDB */
1008.3.25 by Stewart Smith
slight semantic improvement in handler::can_switch_engines
489
  /** used in ALTER Table; if changing storage engine is allowed.
490
      e.g. not be allowed if table has foreign key constraints in engine.
491
   */
492
  virtual bool can_switch_engines(void) { return true; }
1 by brian
clean slate
493
  /** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
645 by Brian Aker
Cleanup unused attribute
494
  virtual int get_foreign_key_list(Session *, List<FOREIGN_KEY_INFO> *)
1 by brian
clean slate
495
  { return 0; }
482 by Brian Aker
Remove uint.
496
  virtual uint32_t referenced_by_foreign_key() { return 0;}
645 by Brian Aker
Cleanup unused attribute
497
  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
498
  /** 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()
499
645 by Brian Aker
Cleanup unused attribute
500
  virtual int add_index(Table *, KEY *, uint32_t)
501
  { return (HA_ERR_WRONG_COMMAND); }
502
  virtual int prepare_drop_index(Table *, uint32_t *, uint32_t)
503
  { return (HA_ERR_WRONG_COMMAND); }
504
  virtual int final_drop_index(Table *)
1 by brian
clean slate
505
  { return (HA_ERR_WRONG_COMMAND); }
506
482 by Brian Aker
Remove uint.
507
  virtual uint32_t checksum(void) const { return 0; }
1 by brian
clean slate
508
509
  /**
510
    Is not invoked for non-transactional temporary tables.
511
512
    @note store_lock() can return more than one lock if the table is MERGE
513
    or partitioned.
514
515
    @note that one can NOT rely on table->in_use in store_lock().  It may
516
    refer to a different thread if called from mysql_lock_abort_for_thread().
517
518
    @note If the table is MERGE, store_lock() can return less locks
519
    than lock_count() claimed. This can happen when the MERGE children
520
    are not attached when this is called from another thread.
521
  */
1222.1.11 by Brian Aker
Remove dead store_lock() path.
522
  virtual THR_LOCK_DATA **store_lock(Session *,
1 by brian
clean slate
523
                                     THR_LOCK_DATA **to,
1222.1.11 by Brian Aker
Remove dead store_lock() path.
524
                                     enum thr_lock_type)
525
  {
1222.1.12 by Brian Aker
Fix for Solaris build.
526
    assert(0); // Impossible programming situation
1222.1.11 by Brian Aker
Remove dead store_lock() path.
527
528
    return(to);
529
  }
1 by brian
clean slate
530
531
 /*
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
532
   @retval true   Primary key (if there is one) is clustered
1 by brian
clean slate
533
                  key covering all fields
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
534
   @retval false  otherwise
1 by brian
clean slate
535
 */
51.1.77 by Jay Pipes
Standardized TRUE/FALSE, removed/replaced DBUG symbols
536
 virtual bool primary_key_is_clustered() { return false; }
481 by Brian Aker
Remove all of uchar.
537
 virtual int cmp_ref(const unsigned char *ref1, const unsigned char *ref2)
1 by brian
clean slate
538
 {
539
   return memcmp(ref1, ref2, ref_length);
540
 }
541
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
542
  virtual bool isOrdered(void)
1 by brian
clean slate
543
  {
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
544
    return false;
1 by brian
clean slate
545
  }
546
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
547
1 by brian
clean slate
548
protected:
549
  /* Service methods for use by storage engines. */
1273.16.8 by Brian Aker
Remove typedef.
550
  void ha_statistic_increment(ulong system_status_var::*offset) const;
520.1.21 by Brian Aker
THD -> Session rename
551
  void **ha_data(Session *) const;
520.1.22 by Brian Aker
Second pass of thd cleanup
552
  Session *ha_session(void) const;
1 by brian
clean slate
553
554
private:
555
  /* Private helpers */
1273.1.12 by Jay Pipes
Cleanup style and documentation for ResourceContext and setTransactionReadWrite
556
  inline void setTransactionReadWrite();
1 by brian
clean slate
557
private:
558
  /*
559
    Low-level primitives for storage engines.  These should be
560
    overridden by the storage engine class. To call these methods, use
561
    the corresponding 'ha_*' method above.
562
  */
563
482 by Brian Aker
Remove uint.
564
  virtual int open(const char *name, int mode, uint32_t test_if_locked)=0;
645 by Brian Aker
Cleanup unused attribute
565
  virtual int index_init(uint32_t idx, bool)
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
566
  { active_index= idx; return 0; }
1 by brian
clean slate
567
  virtual int index_end() { active_index= MAX_KEY; return 0; }
568
  /**
569
    rnd_init() can be called two times without rnd_end() in between
570
    (it only makes sense if scan=1).
571
    then the second call should prepare for the new table scan (e.g
572
    if rnd_init allocates the cursor, second call should position it
573
    to the start of the table, no need to deallocate and allocate it again
574
  */
575
  virtual int rnd_init(bool scan)= 0;
576
  virtual int rnd_end() { return 0; }
645 by Brian Aker
Cleanup unused attribute
577
  virtual int write_row(unsigned char *)
578
  {
579
    return HA_ERR_WRONG_COMMAND;
580
  }
581
582
  virtual int update_row(const unsigned char *, unsigned char *)
583
  {
584
    return HA_ERR_WRONG_COMMAND;
585
  }
586
587
  virtual int delete_row(const unsigned char *)
1 by brian
clean slate
588
  {
589
    return HA_ERR_WRONG_COMMAND;
590
  }
591
  /**
592
    Reset state of file to after 'open'.
593
    This function is called after every statement for all tables used
594
    by that statement.
595
  */
596
  virtual int reset() { return 0; }
597
598
  /**
599
    Is not invoked for non-transactional temporary tables.
600
601
    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
602
    from the table. This call is prefixed with a call to Cursor::store_lock()
603
    and is invoked only for those Cursor instances that stored the lock.
1 by brian
clean slate
604
605
    Calls to rnd_init/index_init are prefixed with this call. When table
606
    IO is complete, we call external_lock(F_UNLCK).
607
    A storage engine writer should expect that each call to
608
    ::external_lock(F_[RD|WR]LOCK is followed by a call to
609
    ::external_lock(F_UNLCK). If it is not, it is a bug in MySQL.
610
611
    The name and signature originate from the first implementation
612
    in MyISAM, which would call fcntl to set/clear an advisory
613
    lock on the data file in this method.
614
615
    @param   lock_type    F_RDLCK, F_WRLCK, F_UNLCK
616
617
    @return  non-0 in case of failure, 0 in case of success.
618
    When lock_type is F_UNLCK, the return value is ignored.
619
  */
645 by Brian Aker
Cleanup unused attribute
620
  virtual int external_lock(Session *, int)
1 by brian
clean slate
621
  {
622
    return 0;
623
  }
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
624
  virtual void release_auto_increment(void) { return; };
1 by brian
clean slate
625
  /** 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
626
  virtual int check(Session *)
1 by brian
clean slate
627
  { return HA_ADMIN_NOT_IMPLEMENTED; }
628
645 by Brian Aker
Cleanup unused attribute
629
  virtual void start_bulk_insert(ha_rows)
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
630
  {}
631
  virtual int end_bulk_insert(void) { return 0; }
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
632
  virtual int index_read(unsigned char *, const unsigned char *,
645 by Brian Aker
Cleanup unused attribute
633
                         uint32_t, enum ha_rkey_function)
1 by brian
clean slate
634
   { return  HA_ERR_WRONG_COMMAND; }
645 by Brian Aker
Cleanup unused attribute
635
  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.
636
   { return (errno= HA_ERR_WRONG_COMMAND); }
1 by brian
clean slate
637
  /**
638
    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
639
    If the Cursor don't support this, then this function will
1 by brian
clean slate
640
    return HA_ERR_WRONG_COMMAND and MySQL will delete the rows one
641
    by one.
642
  */
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
643
  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.
644
  { return (errno=HA_ERR_WRONG_COMMAND); }
1 by brian
clean slate
645
  /**
646
    Reset the auto-increment counter to the given value, i.e. the next row
647
    inserted will get the given value. This is called e.g. after TRUNCATE
648
    is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
649
    returned by storage engines that don't support this operation.
650
  */
645 by Brian Aker
Cleanup unused attribute
651
  virtual int reset_auto_increment(uint64_t)
53.2.32 by Monty Taylor
First large swath at getting handler stuff clean.
652
  { return HA_ERR_WRONG_COMMAND; }
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
653
1222.1.10 by Brian Aker
Removes options from DDL left in Cursor for admin operations (they were
654
  virtual int analyze(Session *)
645 by Brian Aker
Cleanup unused attribute
655
  { return HA_ADMIN_NOT_IMPLEMENTED; }
1063.3.1 by Stewart Smith
remove ha_check_and_repair. Engines should take care of this themselves.
656
645 by Brian Aker
Cleanup unused attribute
657
  virtual int disable_indexes(uint32_t)
658
  { return HA_ERR_WRONG_COMMAND; }
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
659
645 by Brian Aker
Cleanup unused attribute
660
  virtual int enable_indexes(uint32_t)
661
  { return HA_ERR_WRONG_COMMAND; }
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
662
645 by Brian Aker
Cleanup unused attribute
663
  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.
664
  { return (errno=HA_ERR_WRONG_COMMAND); }
1220.1.12 by Brian Aker
Small cleanup from something Jay noticed.
665
666
  /* 
667
    @todo this is just for the HEAP engine, it should
668
    be removed at some point in the future (and
669
    no new engine should ever use it). Right
670
    now HEAP does rely on it, so we cannot remove it.
671
  */
1 by brian
clean slate
672
  virtual void drop_table(const char *name);
673
};
674
675
extern const char *ha_row_type[];
676
extern const char *binlog_format_names[];
61 by Brian Aker
Conversion of handler type.
677
extern uint32_t total_ha, total_ha_2pc;
1 by brian
clean slate
678
679
/* basic stuff */
680
int ha_init_errors(void);
681
int ha_init(void);
682
int ha_end(void);
971.1.52 by Monty Taylor
Did the finalizers. Renamed plugin_registry.
683
1 by brian
clean slate
684
/*
685
  Storage engine has to assume the transaction will end up with 2pc if
686
   - there is more than one 2pc-capable storage engine available
687
   - in the current transaction 2pc was not disabled yet
688
*/
520.1.22 by Brian Aker
Second pass of thd cleanup
689
#define trans_need_2pc(session, all)                   ((total_ha_2pc > 1) && \
690
        !((all ? &session->transaction.all : &session->transaction.stmt)->no_2pc))
520.6.4 by Monty Taylor
Moved thr_lock.h out of common_includes.
691
575.4.7 by Monty Taylor
More header cleanup.
692
693
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
694
                                   SORT_FIELD *sortorder);
695
int setup_order(Session *session, Item **ref_pointer_array, TableList *tables,
696
                List<Item> &fields, List <Item> &all_fields, order_st *order);
697
int setup_group(Session *session, Item **ref_pointer_array, TableList *tables,
698
                List<Item> &fields, List<Item> &all_fields, order_st *order,
699
                bool *hidden_group_fields);
846 by Brian Aker
Removing on typedeffed class.
700
bool fix_inner_refs(Session *session, List<Item> &all_fields, Select_Lex *select,
575.4.7 by Monty Taylor
More header cleanup.
701
                    Item **ref_pointer_array);
702
703
bool handle_select(Session *session, LEX *lex, select_result *result,
892.2.2 by Monty Taylor
More solaris warnings.
704
                   uint64_t setup_tables_done_option);
846 by Brian Aker
Removing on typedeffed class.
705
void free_underlaid_joins(Session *session, Select_Lex *select);
1008.3.22 by Stewart Smith
s/mysql_union/drizzle_union/
706
575.4.7 by Monty Taylor
More header cleanup.
707
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
708
                                                      LEX *lex,
709
                                                      TableList *table));
710
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t);
711
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.
712
int prepare_create_field(CreateField *sql_field,
575.4.7 by Monty Taylor
More header cleanup.
713
                         uint32_t *blob_columns,
1233.1.8 by Brian Aker
Final removal table_flag().
714
                         int *timestamps, int *timestamps_with_niladic);
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
715
1223.4.1 by Brian Aker
Table Identifier patch.
716
bool mysql_create_table(Session *session,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
717
                        TableIdentifier &identifier,
575.4.7 by Monty Taylor
More header cleanup.
718
                        HA_CREATE_INFO *create_info,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
719
                        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.
720
                        AlterInfo *alter_info,
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
721
                        bool tmp_table, uint32_t select_field_count,
722
                        bool is_if_not_exists);
723
1223.4.2 by Brian Aker
Extended mysql_create_table_no_lock to use TableIdentifier
724
bool mysql_create_table_no_lock(Session *session,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
725
                                TableIdentifier &identifier,
575.4.7 by Monty Taylor
More header cleanup.
726
                                HA_CREATE_INFO *create_info,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
727
                                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.
728
                                AlterInfo *alter_info,
1223.4.2 by Brian Aker
Extended mysql_create_table_no_lock to use TableIdentifier
729
                                bool tmp_table,
730
                                uint32_t select_field_count,
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
731
                                bool is_if_not_exists);
575.4.7 by Monty Taylor
More header cleanup.
732
1172.1.1 by Brian Aker
Add in support for ENGINE= in create table like.
733
bool mysql_create_like_table(Session* session, TableList* table, TableList* src_table,
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
734
                             message::Table& create_table_proto,
735
                             plugin::StorageEngine*,
1222.1.3 by Brian Aker
Remove used flag for engine.
736
                             bool is_if_not_exists,
737
                             bool is_engine_set);
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
738
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
739
bool mysql_rename_table(plugin::StorageEngine *base, const char *old_db,
575.4.7 by Monty Taylor
More header cleanup.
740
                        const char * old_name, const char *new_db,
741
                        const char * new_name, uint32_t flags);
1222.2.3 by Brian Aker
Remove a few more options, from options in HA_CREATE_INFO.
742
575.4.7 by Monty Taylor
More header cleanup.
743
bool mysql_prepare_update(Session *session, TableList *table_list,
744
                          Item **conds, uint32_t order_num, order_st *order);
745
int mysql_update(Session *session,TableList *tables,List<Item> &fields,
746
                 List<Item> &values,COND *conds,
747
                 uint32_t order_num, order_st *order, ha_rows limit,
748
                 enum enum_duplicates handle_duplicates, bool ignore);
749
bool mysql_prepare_insert(Session *session, TableList *table_list, Table *table,
750
                          List<Item> &fields, List_item *values,
751
                          List<Item> &update_fields,
752
                          List<Item> &update_values, enum_duplicates duplic,
753
                          COND **where, bool select_insert,
754
                          bool check_fields, bool abort_on_warning);
755
bool mysql_insert(Session *session,TableList *table,List<Item> &fields,
756
                  List<List_item> &values, List<Item> &update_fields,
757
                  List<Item> &update_values, enum_duplicates flag,
758
                  bool ignore);
759
int check_that_all_fields_are_given_values(Session *session, Table *entry,
760
                                           TableList *table_list);
761
int mysql_prepare_delete(Session *session, TableList *table_list, Item **conds);
762
bool mysql_delete(Session *session, TableList *table_list, COND *conds,
763
                  SQL_LIST *order, ha_rows rows, uint64_t options,
764
                  bool reset_auto_increment);
1208.2.2 by Brian Aker
Merge Truncate patch. This fixes all of the "half setup" of Truncate. Still
765
bool mysql_truncate(Session& session, TableList *table_list);
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
766
TableShare *get_table_share(Session *session, TableList *table_list, char *key,
575.4.7 by Monty Taylor
More header cleanup.
767
                             uint32_t key_length, uint32_t db_flags, int *error);
1000.1.3 by Brian Aker
Renamed TABLE_SHARE to TableShare
768
TableShare *get_cached_table_share(const char *db, const char *table_name);
575.4.7 by Monty Taylor
More header cleanup.
769
bool reopen_name_locked_table(Session* session, TableList* table_list, bool link_in);
770
Table *table_cache_insert_placeholder(Session *session, const char *key,
771
                                      uint32_t key_length);
772
bool lock_table_name_if_not_cached(Session *session, const char *db,
773
                                   const char *table_name, Table **table);
774
bool reopen_table(Table *table);
775
bool reopen_tables(Session *session,bool get_locks,bool in_refresh);
776
void close_data_files_and_morph_locks(Session *session, const char *db,
777
                                      const char *table_name);
778
void close_handle_and_leave_table_as_lock(Table *table);
779
bool wait_for_tables(Session *session);
780
bool table_is_used(Table *table, bool wait_for_name_lock);
781
Table *drop_locked_tables(Session *session,const char *db, const char *table_name);
782
void abort_locked_tables(Session *session,const char *db, const char *table_name);
783
extern Field *not_found_field;
784
extern Field *view_ref_found;
785
786
Field *
787
find_field_in_tables(Session *session, Item_ident *item,
788
                     TableList *first_table, TableList *last_table,
789
                     Item **ref, find_item_error_report_type report_error,
1113.1.1 by Brian Aker
Dead code removal around LCOV finds.
790
                     bool register_tree_change);
575.4.7 by Monty Taylor
More header cleanup.
791
Field *
792
find_field_in_table_ref(Session *session, TableList *table_list,
793
                        const char *name, uint32_t length,
794
                        const char *item_name, const char *db_name,
795
                        const char *table_name, Item **ref,
1113.1.1 by Brian Aker
Dead code removal around LCOV finds.
796
                        bool allow_rowid,
575.4.7 by Monty Taylor
More header cleanup.
797
                        uint32_t *cached_field_index_ptr,
798
                        bool register_tree_change, TableList **actual_table);
799
Field *
800
find_field_in_table(Session *session, Table *table, const char *name, uint32_t length,
801
                    bool allow_rowid, uint32_t *cached_field_index_ptr);
802
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
803
} /* namespace drizzled */
575.4.7 by Monty Taylor
More header cleanup.
804
1185 by Brian Aker
Merge Engine changes.
805
#endif /* DRIZZLED_CURSOR_H */