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