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