~drizzle-trunk/drizzle/development

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