1
/* Copyright (C) 2000-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
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.
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.
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
20
#ifndef DRIZZLED_HANDLER_H
21
#define DRIZZLED_HANDLER_H
23
#include <drizzled/xid.h>
17
25
/* Definitions for parameters to do with handler-routines */
19
#ifdef USE_PRAGMA_INTERFACE
20
#pragma interface /* gcc class implementation */
23
#include <mysys/my_handler.h>
24
27
#include <storage/myisam/keycache.h>
27
#define NO_HASH /* Not yet implemented */
30
// the following is for checking tables
32
#define HA_ADMIN_ALREADY_DONE 1
34
#define HA_ADMIN_NOT_IMPLEMENTED -1
35
#define HA_ADMIN_FAILED -2
36
#define HA_ADMIN_CORRUPT -3
37
#define HA_ADMIN_INTERNAL_ERROR -4
38
#define HA_ADMIN_INVALID -5
39
#define HA_ADMIN_REJECT -6
40
#define HA_ADMIN_TRY_ALTER -7
41
#define HA_ADMIN_WRONG_CHECKSUM -8
42
#define HA_ADMIN_NOT_BASE_TABLE -9
43
#define HA_ADMIN_NEEDS_UPGRADE -10
44
#define HA_ADMIN_NEEDS_ALTER -11
45
#define HA_ADMIN_NEEDS_CHECK -12
28
#include <mysys/thr_lock.h>
29
#include <mysys/hash.h>
30
#include <drizzled/sql_string.h>
31
#include <drizzled/sql_list.h>
32
#include <drizzled/handlerton.h>
33
#include <drizzled/handler_structs.h>
34
#include <drizzled/ha_statistics.h>
47
36
/* Bits to show what an alter table will do */
48
37
#include <drizzled/sql_bitmap.h>
50
#define HA_MAX_ALTER_FLAGS 39
39
#define HA_MAX_ALTER_FLAGS 40
51
40
typedef Bitmap<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
53
#define HA_ADD_INDEX (0)
54
#define HA_DROP_INDEX (1)
55
#define HA_ALTER_INDEX (2)
56
#define HA_RENAME_INDEX (3)
57
#define HA_ADD_UNIQUE_INDEX (4)
58
#define HA_DROP_UNIQUE_INDEX (5)
59
#define HA_ALTER_UNIQUE_INDEX (6)
60
#define HA_RENAME_UNIQUE_INDEX (7)
61
#define HA_ADD_PK_INDEX (8)
62
#define HA_DROP_PK_INDEX (9)
63
#define HA_ALTER_PK_INDEX (10)
64
#define HA_ADD_COLUMN (11)
65
#define HA_DROP_COLUMN (12)
66
#define HA_CHANGE_COLUMN (13)
67
#define HA_ALTER_COLUMN_NAME (14)
68
#define HA_ALTER_COLUMN_TYPE (15)
69
#define HA_ALTER_COLUMN_ORDER (16)
70
#define HA_ALTER_COLUMN_NULLABLE (17)
71
#define HA_COLUMN_DEFAULT_VALUE (18)
72
#define HA_COLUMN_STORAGE (19)
73
#define HA_COLUMN_FORMAT (20)
74
#define HA_ADD_FOREIGN_KEY (21)
75
#define HA_DROP_FOREIGN_KEY (22)
76
#define HA_ALTER_FOREIGN_KEY (23)
77
#define HA_ADD_CONSTRAINT (24)
78
#define HA_CHANGE_CHARACTER_SET (30)
79
#define HA_SET_DEFAULT_CHARACTER_SET (31)
80
#define HA_CHANGE_AUTOINCREMENT_VALUE (32)
81
#define HA_ALTER_STORAGE (33)
82
#define HA_ALTER_TABLESPACE (34)
83
#define HA_ALTER_ROW_FORMAT (35)
84
#define HA_RENAME_TABLE (36)
85
#define HA_ALTER_STORAGE_ENGINE (37)
86
#define HA_RECREATE (38)
87
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
89
/* Return values for check_if_supported_alter */
91
#define HA_ALTER_ERROR -1
92
#define HA_ALTER_SUPPORTED_WAIT_LOCK 0
93
#define HA_ALTER_SUPPORTED_NO_LOCK 1
94
#define HA_ALTER_NOT_SUPPORTED 2
96
/* Bits in table_flags() to show what database can do */
98
#define HA_NO_TRANSACTIONS (1 << 0) /* Doesn't support transactions */
99
#define HA_PARTIAL_COLUMN_READ (1 << 1) /* read may not return all columns */
100
#define HA_TABLE_SCAN_ON_INDEX (1 << 2) /* No separate data/index file */
102
The following should be set if the following is not true when scanning
103
a table with rnd_next()
104
- We will see all rows (including deleted ones)
105
- Row positions are 'table->s->db_record_offset' apart
106
If this flag is not set, filesort will do a postion() call for each matched
107
row to be able to find the row later.
109
#define HA_REC_NOT_IN_SEQ (1 << 3)
110
/* This is now a dead option, just left for compatibility */
111
#define HA_CAN_GEOMETRY (1 << 4)
113
Reading keys in random order is as fast as reading keys in sort order
114
(Used in records.cc to decide if we should use a record cache and by
115
filesort to decide if we should sort key + data or key + pointer-to-row
117
#define HA_FAST_KEY_READ (1 << 5)
119
Set the following flag if we on delete should force all key to be read
120
and on update read all keys that changes
122
#define HA_REQUIRES_KEY_COLUMNS_FOR_DELETE (1 << 6)
123
#define HA_NULL_IN_KEY (1 << 7) /* One can have keys with NULL */
124
#define HA_DUPLICATE_POS (1 << 8) /* ha_position() gives dup row */
125
#define HA_NO_BLOBS (1 << 9) /* Doesn't support blobs */
126
#define HA_CAN_INDEX_BLOBS (1 << 10)
127
#define HA_AUTO_PART_KEY (1 << 11) /* auto-increment in multi-part key */
128
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
129
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
131
INSERT_DELAYED only works with handlers that uses MySQL internal table
134
#define HA_CAN_INSERT_DELAYED (1 << 14)
136
If we get the primary key columns for free when we do an index read
137
It also implies that we have to retrive the primary key when using
138
position() and rnd_pos().
140
#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15)
142
If HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is set, it means that to position()
143
uses a primary key. Without primary key, we can't call position().
145
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16)
146
#define HA_CAN_RTREEKEYS (1 << 17) /* Historical, no longer supported */
147
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
149
The following is we need to a primary key to delete (and update) a row.
150
If there is no primary key, all columns needs to be read on update and delete
152
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
153
#define HA_NO_PREFIX_CHAR_KEYS (1 << 20)
154
#define HA_CAN_FULLTEXT (1 << 21) /* Historical, no longer supported */
155
#define HA_CAN_SQL_HANDLER (1 << 22) /* Historical, no longer supported */
156
#define HA_NO_AUTO_INCREMENT (1 << 23)
157
#define HA_HAS_CHECKSUM (1 << 24)
158
/* Table data are stored in separate files (for lower_case_table_names) */
159
#define HA_FILE_BASED (1 << 26)
160
#define HA_NO_VARCHAR (1 << 27) /* Historical, no longer supported */
161
#define HA_CAN_BIT_FIELD (1 << 28) /* Historical, no longer supported */
162
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
163
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
164
#define HA_NO_COPY_ON_ALTER (1LL << 31)
165
#define HA_HAS_RECORDS (1LL << 32) /* records() gives exact count*/
166
/* Has it's own method of binlog logging */
167
#define HA_HAS_OWN_BINLOGGING (1LL << 33) /* Historical, no longer supported */
168
#define HA_MRR_CANT_SORT (1LL << 34)
171
Engine is capable of row-format and statement-format logging,
174
#define HA_BINLOG_ROW_CAPABLE (1LL << 35)
175
#define HA_BINLOG_STMT_CAPABLE (1LL << 36)
177
#define HA_ONLINE_ALTER (1LL << 37)
180
Set of all binlog flags. Currently only contain the capabilities
183
#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE)
185
/* bits in index_flags(index_number) for what you can do with index */
186
#define HA_READ_NEXT 1 /* TODO really use this flag */
187
#define HA_READ_PREV 2 /* supports ::index_prev */
188
#define HA_READ_ORDER 4 /* index_next/prev follow sort order */
189
#define HA_READ_RANGE 8 /* can find all records in a range */
190
#define HA_ONLY_WHOLE_INDEX 16 /* Can't use part key searches */
191
#define HA_KEYREAD_ONLY 64 /* Support HA_EXTRA_KEYREAD */
193
Index scan will not return records in rowid order. Not guaranteed to be
194
set for unordered (e.g. HASH) indexes.
196
#define HA_KEY_SCAN_NOT_ROR 128
197
#define HA_DO_INDEX_COND_PUSHDOWN 256 /* Supports Index Condition Pushdown */
202
HA_PARTITION_FUNCTION_SUPPORTED indicates that the function is
204
HA_FAST_CHANGE_PARTITION means that optimised variants of the changes
205
exists but they are not necessarily done online.
207
HA_ONLINE_DOUBLE_WRITE means that the handler supports writing to both
208
the new partition and to the old partitions when updating through the
209
old partitioning schema while performing a change of the partitioning.
210
This means that we can support updating of the table while performing
211
the copy phase of the change. For no lock at all also a double write
212
from new to old must exist and this is not required when this flag is
214
This is actually removed even before it was introduced the first time.
215
The new idea is that handlers will handle the lock level already in
216
store_lock for ALTER TABLE partitions.
218
HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take
219
care of changing the partitions online and in one phase. Thus all phases
220
needed to handle the change are implemented inside the storage engine.
221
The storage engine must also support auto-discovery since the frm file
222
is changed as part of the change and this change must be controlled by
223
the storage engine. A typical engine to support this is NDB (through
226
#define HA_PARTITION_FUNCTION_SUPPORTED (1L << 1)
227
#define HA_FAST_CHANGE_PARTITION (1L << 2)
228
#define HA_PARTITION_ONE_PHASE (1L << 3)
230
/* operations for disable/enable indexes */
231
#define HA_KEY_SWITCH_NONUNIQ 0
232
#define HA_KEY_SWITCH_ALL 1
233
#define HA_KEY_SWITCH_NONUNIQ_SAVE 2
234
#define HA_KEY_SWITCH_ALL_SAVE 3
237
Note: the following includes binlog and closing 0.
238
so: innodb + bdb + ndb + binlog + myisam + myisammrg + archive +
239
example + csv + heap + blackhole + federated + 0
240
(yes, the sum is deliberately inaccurate)
241
TODO remove the limit, use dynarrays
246
Parameters for open() (in register form->filestat)
247
HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED
250
#define HA_OPEN_KEYFILE 1
251
#define HA_OPEN_RNDFILE 2
252
#define HA_GET_INDEX 4
253
#define HA_GET_INFO 8 /* do a ha_info() after open */
254
#define HA_READ_ONLY 16 /* File opened as readonly */
255
/* Try readonly if can't open with read and write */
256
#define HA_TRY_READ_ONLY 32
257
#define HA_WAIT_IF_LOCKED 64 /* Wait if locked on open */
258
#define HA_ABORT_IF_LOCKED 128 /* skip if locked on open.*/
259
#define HA_BLOCK_LOCK 256 /* unlock when reading some records */
260
#define HA_OPEN_TEMPORARY 512
262
/* For transactional LOCK TABLE. handler::lock_table() */
263
#define HA_LOCK_IN_SHARE_MODE F_RDLCK
264
#define HA_LOCK_IN_EXCLUSIVE_MODE F_WRLCK
266
/* Some key definitions */
267
#define HA_KEY_NULL_LENGTH 1
268
#define HA_KEY_BLOB_LENGTH 2
270
#define HA_LEX_CREATE_TMP_TABLE 1
271
#define HA_LEX_CREATE_IF_NOT_EXISTS 2
272
#define HA_LEX_CREATE_TABLE_LIKE 4
273
#define HA_OPTION_NO_CHECKSUM (1L << 17)
274
#define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18)
275
#define HA_MAX_REC_LENGTH 65535
277
/* Table caching type */
278
#define HA_CACHE_TBL_NONTRANSACT 0
279
#define HA_CACHE_TBL_NOCACHE 1
280
#define HA_CACHE_TBL_ASKTRANSACT 2
281
#define HA_CACHE_TBL_TRANSACT 4
283
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
284
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
286
/* Flags for method is_fatal_error */
287
#define HA_CHECK_DUP_KEY 1
288
#define HA_CHECK_DUP_UNIQUE 2
289
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
293
DB_TYPE_UNKNOWN=0,DB_TYPE_DIAB_ISAM=1,
294
DB_TYPE_HASH,DB_TYPE_MISAM,DB_TYPE_PISAM,
295
DB_TYPE_RMS_ISAM, DB_TYPE_HEAP, DB_TYPE_ISAM,
296
DB_TYPE_MRG_ISAM, DB_TYPE_MYISAM, DB_TYPE_MRG_MYISAM,
297
DB_TYPE_BERKELEY_DB, DB_TYPE_INNODB,
298
DB_TYPE_GEMINI, DB_TYPE_NDBCLUSTER,
299
DB_TYPE_EXAMPLE_DB, DB_TYPE_ARCHIVE_DB, DB_TYPE_CSV_DB,
300
DB_TYPE_FEDERATED_DB,
301
DB_TYPE_BLACKHOLE_DB,
302
DB_TYPE_PARTITION_DB,
306
DB_TYPE_TABLE_FUNCTION,
310
DB_TYPE_FIRST_DYNAMIC=42,
311
DB_TYPE_DEFAULT=127 // Must be last
314
enum row_type { ROW_TYPE_NOT_USED=-1, ROW_TYPE_DEFAULT, ROW_TYPE_FIXED,
315
ROW_TYPE_DYNAMIC, ROW_TYPE_COMPRESSED,
316
ROW_TYPE_REDUNDANT, ROW_TYPE_COMPACT, ROW_TYPE_PAGE };
318
enum column_format_type { COLUMN_FORMAT_TYPE_NOT_USED= -1,
319
COLUMN_FORMAT_TYPE_DEFAULT= 0,
320
COLUMN_FORMAT_TYPE_FIXED= 1,
321
COLUMN_FORMAT_TYPE_DYNAMIC= 2 };
323
enum enum_binlog_func {
328
BFN_BINLOG_PURGE_FILE= 5
331
enum enum_binlog_command {
341
/* struct to hold information about the table that should be created */
343
/* Bits in used_fields */
344
#define HA_CREATE_USED_AUTO (1L << 0)
346
#define HA_CREATE_USED_RAID (1L << 1) /* Historical, no longer supported */
347
#define HA_CREATE_USED_UNION (1L << 2)
348
#define HA_CREATE_USED_PASSWORD (1L << 17)
350
#define HA_CREATE_USED_INSERT_METHOD (1L << 3)
351
#define HA_CREATE_USED_MIN_ROWS (1L << 4)
352
#define HA_CREATE_USED_MAX_ROWS (1L << 5)
353
#define HA_CREATE_USED_AVG_ROW_LENGTH (1L << 6)
354
#define HA_CREATE_USED_PACK_KEYS (1L << 7)
355
#define HA_CREATE_USED_CHARSET (1L << 8)
356
#define HA_CREATE_USED_DEFAULT_CHARSET (1L << 9)
357
#define HA_CREATE_USED_DATADIR (1L << 10)
358
#define HA_CREATE_USED_INDEXDIR (1L << 11)
359
#define HA_CREATE_USED_ENGINE (1L << 12)
360
#define HA_CREATE_USED_CHECKSUM (1L << 13)
361
#define HA_CREATE_USED_DELAY_KEY_WRITE (1L << 14)
362
#define HA_CREATE_USED_ROW_FORMAT (1L << 15)
363
#define HA_CREATE_USED_COMMENT (1L << 16)
364
#define HA_CREATE_USED_CONNECTION (1L << 18)
365
#define HA_CREATE_USED_KEY_BLOCK_SIZE (1L << 19)
366
#define HA_CREATE_USED_TRANSACTIONAL (1L << 20)
367
#define HA_CREATE_USED_PAGE_CHECKSUM (1L << 21)
368
#define HA_CREATE_USED_BLOCK_SIZE (1L << 22)
370
typedef uint64_t my_xid; // this line is the same as in log_event.h
371
#define DRIZZLE_XID_PREFIX "MySQLXid"
372
#define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
373
#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
374
#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
376
#define XIDDATASIZE DRIZZLE_XIDDATASIZE
377
#define MAXGTRIDSIZE 64
378
#define MAXBQUALSIZE 64
380
#define COMPATIBLE_DATA_YES 0
381
#define COMPATIBLE_DATA_NO 1
383
typedef bool (*qc_engine_callback)(THD *thd, char *table_key,
43
typedef bool (*qc_engine_callback)(Session *session, char *table_key,
385
45
uint64_t *engine_data);
388
struct xid_t is binary compatible with the XID structure as
389
in the X/Open CAE Specification, Distributed Transaction Processing:
390
The XA Specification, X/Open Company Ltd., 1991.
391
http://www.opengroup.org/bookstore/catalog/c193.htm
393
@see DRIZZLE_XID in mysql/plugin.h
399
char data[XIDDATASIZE]; // not \0-terminated !
401
xid_t() {} /* Remove gcc warning */
402
bool eq(struct xid_t *xid)
403
{ return eq(xid->gtrid_length, xid->bqual_length, xid->data); }
404
bool eq(long g, long b, const char *d)
405
{ return g == gtrid_length && b == bqual_length && !memcmp(d, data, g+b); }
406
void set(struct xid_t *xid)
407
{ memcpy(this, xid, xid->length()); }
408
void set(long f, const char *g, long gl, const char *b, long bl)
411
memcpy(data, g, gtrid_length= gl);
412
memcpy(data+gl, b, bqual_length= bl);
414
void set(uint64_t xid)
418
set(DRIZZLE_XID_PREFIX_LEN, 0, DRIZZLE_XID_PREFIX);
419
memcpy(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id));
421
memcpy(data+DRIZZLE_XID_OFFSET, &tmp, sizeof(tmp));
422
gtrid_length=DRIZZLE_XID_GTRID_LEN;
424
void set(long g, long b, const char *d)
429
memcpy(data, d, g+b);
431
bool is_null() { return formatID == -1; }
432
void null() { formatID= -1; }
433
my_xid quick_get_my_xid()
436
memcpy(&tmp, data+DRIZZLE_XID_OFFSET, sizeof(tmp));
441
return gtrid_length == DRIZZLE_XID_GTRID_LEN && bqual_length == 0 &&
442
!memcmp(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id)) &&
443
!memcmp(data, DRIZZLE_XID_PREFIX, DRIZZLE_XID_PREFIX_LEN) ?
444
quick_get_my_xid() : 0;
448
return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+
449
gtrid_length+bqual_length;
453
return (uchar *)>rid_length;
457
return sizeof(gtrid_length)+sizeof(bqual_length)+gtrid_length+bqual_length;
460
typedef struct xid_t XID;
462
/* for recover() handlerton call */
463
#define MIN_XID_LIST_SIZE 128
464
#define MAX_XID_LIST_SIZE (1024*128)
468
/* The handler for a table type. Will be included in the TABLE structure */
471
typedef struct st_table TABLE;
48
/* The handler for a table type. Will be included in the Table structure */
472
52
typedef struct st_table_share TABLE_SHARE;
473
53
struct st_foreign_key_info;
474
54
typedef struct st_foreign_key_info FOREIGN_KEY_INFO;
475
typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len,
476
const char *file, uint file_len,
477
const char *status, uint status_len);
478
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
479
extern st_plugin_int *hton2plugin[MAX_HA];
482
handlerton is a singleton structure - one instance per storage engine -
483
to provide access to storage engine functionality that works on the
484
"global" level (unlike handler class that works on a per-table basis)
486
usually handlerton instance is defined statically in ha_xxx.cc as
488
static handlerton { ... } xxx_hton;
490
savepoint_*, prepare, recover, and *_by_xid pointers can be 0.
495
Historical marker for if the engine is available of not
497
SHOW_COMP_OPTION state;
500
Historical number used for frm file to determine the correct storage engine.
501
This is going away and new engines will just use "name" for this.
503
enum legacy_db_type db_type;
505
each storage engine has it's own memory area (actually a pointer)
506
in the thd, for storing per-connection information.
509
thd->ha_data[xxx_hton.slot]
511
slot number is initialized by MySQL after xxx_init() is called.
515
to store per-savepoint data storage engine is provided with an area
516
of a requested size (0 is ok here).
517
savepoint_offset must be initialized statically to the size of
518
the needed memory to store per-savepoint information.
519
After xxx_init it is changed to be an offset to savepoint storage
520
area and need not be used by storage engine.
521
see binlog_hton and binlog_savepoint_set/rollback for an example.
523
uint savepoint_offset;
527
close_connection is only called if
528
thd->ha_data[xxx_hton.slot] is non-zero, so even if you don't need
529
this storage area - set it to something, so that MySQL would know
530
this storage engine was accessed in this connection
532
int (*close_connection)(handlerton *hton, THD *thd);
534
sv points to an uninitialized storage area of requested size
535
(see savepoint_offset description)
537
int (*savepoint_set)(handlerton *hton, THD *thd, void *sv);
539
sv points to a storage area, that was earlier passed
540
to the savepoint_set call
542
int (*savepoint_rollback)(handlerton *hton, THD *thd, void *sv);
543
int (*savepoint_release)(handlerton *hton, THD *thd, void *sv);
545
'all' is true if it's a real commit, that makes persistent changes
546
'all' is false if it's not in fact a commit but an end of the
547
statement that is part of the transaction.
548
NOTE 'all' is also false in auto-commit mode where 'end of statement'
549
and 'real commit' mean the same event.
551
int (*commit)(handlerton *hton, THD *thd, bool all);
552
int (*rollback)(handlerton *hton, THD *thd, bool all);
553
int (*prepare)(handlerton *hton, THD *thd, bool all);
554
int (*recover)(handlerton *hton, XID *xid_list, uint len);
555
int (*commit_by_xid)(handlerton *hton, XID *xid);
556
int (*rollback_by_xid)(handlerton *hton, XID *xid);
557
void *(*create_cursor_read_view)(handlerton *hton, THD *thd);
558
void (*set_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
559
void (*close_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
560
handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
561
void (*drop_database)(handlerton *hton, char* path);
562
int (*start_consistent_snapshot)(handlerton *hton, THD *thd);
563
bool (*flush_logs)(handlerton *hton);
564
bool (*show_status)(handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat);
565
int (*fill_files_table)(handlerton *hton, THD *thd,
568
uint32_t flags; /* global handler flags */
569
int (*release_temporary_latches)(handlerton *hton, THD *thd);
571
int (*discover)(handlerton *hton, THD* thd, const char *db,
575
int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
577
uint32_t license; /* Flag for Engine License */
578
void *data; /* Location for engines to keep personal structures */
582
/* Possible flags of a handlerton (there can be 32 of them) */
583
#define HTON_NO_FLAGS 0
584
#define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0)
585
#define HTON_ALTER_NOT_SUPPORTED (1 << 1) //Engine does not support alter
586
#define HTON_CAN_RECREATE (1 << 2) //Delete all is used fro truncate
587
#define HTON_HIDDEN (1 << 3) //Engine does not appear in lists
588
#define HTON_FLUSH_AFTER_RENAME (1 << 4)
589
#define HTON_NOT_USER_SELECTABLE (1 << 5)
590
#define HTON_TEMPORARY_NOT_SUPPORTED (1 << 6) //Having temporary tables not supported
591
#define HTON_SUPPORT_LOG_TABLES (1 << 7) //Engine supports log tables
592
#define HTON_NO_PARTITION (1 << 8) //You can not partition these tables
598
/* true is not all entries in the ht[] support 2pc */
600
/* storage engines that registered in this transaction */
601
Ha_trx_info *ha_list;
603
The purpose of this flag is to keep track of non-transactional
604
tables that were modified in scope of:
605
- transaction, when the variable is a member of
607
- top-level statement or sub-statement, when the variable is a
608
member of THD::transaction.stmt
609
This member has the following life cycle:
610
* stmt.modified_non_trans_table is used to keep track of
611
modified non-transactional tables of top-level statements. At
612
the end of the previous statement and at the beginning of the session,
613
it is reset to false. If such functions
614
as mysql_insert, mysql_update, mysql_delete etc modify a
615
non-transactional table, they set this flag to true. At the
616
end of the statement, the value of stmt.modified_non_trans_table
617
is merged with all.modified_non_trans_table and gets reset.
618
* all.modified_non_trans_table is reset at the end of transaction
620
* Since we do not have a dedicated context for execution of a
621
sub-statement, to keep track of non-transactional changes in a
622
sub-statement, we re-use stmt.modified_non_trans_table.
623
At entrance into a sub-statement, a copy of the value of
624
stmt.modified_non_trans_table (containing the changes of the
625
outer statement) is saved on stack. Then
626
stmt.modified_non_trans_table is reset to false and the
627
substatement is executed. Then the new value is merged with the
630
bool modified_non_trans_table;
632
void reset() { no_2pc= false; modified_non_trans_table= false; }
637
Either statement transaction or normal transaction - related
638
thread-specific storage engine data.
640
If a storage engine participates in a statement/transaction,
641
an instance of this class is present in
642
thd->transaction.{stmt|all}.ha_list. The addition to
643
{stmt|all}.ha_list is made by trans_register_ha().
645
When it's time to commit or rollback, each element of ha_list
646
is used to access storage engine's prepare()/commit()/rollback()
647
methods, and also to evaluate if a full two phase commit is
650
@sa General description of transaction handling in handler.cc.
656
/** Register this storage engine in the given transaction context. */
657
void register_ha(THD_TRANS *trans, handlerton *ht_arg)
659
assert(m_flags == 0);
660
assert(m_ht == NULL);
661
assert(m_next == NULL);
664
m_flags= (int) TRX_READ_ONLY; /* Assume read-only at start. */
666
m_next= trans->ha_list;
667
trans->ha_list= this;
670
/** Clear, prepare for reuse. */
678
Ha_trx_info() { reset(); }
680
void set_trx_read_write()
682
assert(is_started());
683
m_flags|= (int) TRX_READ_WRITE;
685
bool is_trx_read_write() const
687
assert(is_started());
688
return m_flags & (int) TRX_READ_WRITE;
690
bool is_started() const { return m_ht != NULL; }
691
/** Mark this transaction read-write if the argument is read-write. */
692
void coalesce_trx_with(const Ha_trx_info *stmt_trx)
695
Must be called only after the transaction has been started.
696
Can be called many times, e.g. when we have many
697
read-write statements in a transaction.
699
assert(is_started());
700
if (stmt_trx->is_trx_read_write())
701
set_trx_read_write();
703
Ha_trx_info *next() const
705
assert(is_started());
708
handlerton *ht() const
710
assert(is_started());
714
enum { TRX_READ_ONLY= 0, TRX_READ_WRITE= 1 };
715
/** Auxiliary, used for ha_list management */
718
Although a given Ha_trx_info instance is currently always used
719
for the same storage engine, 'ht' is not-NULL only when the
720
corresponding storage is a part of a transaction.
724
Transaction flags related to this engine.
725
Not-null only if this instance is a part of transaction.
726
May assume a combination of enum values above.
732
enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
733
ISO_REPEATABLE_READ, ISO_SERIALIZABLE};
736
uint64_t data_file_length;
737
uint64_t max_data_file_length;
738
uint64_t index_file_length;
739
uint64_t delete_length;
741
uint32_t mean_rec_length;
748
#define UNDEF_NODEGROUP 65535
750
58
struct st_table_log_memory_entry;
752
#define NOT_A_PARTITION_ID ((uint32_t)-1)
754
enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES };
756
typedef struct st_ha_create_information
758
const CHARSET_INFO *table_charset, *default_table_charset;
759
LEX_STRING connect_string;
761
const char *data_file_name, *index_file_name;
763
uint64_t max_rows,min_rows;
764
uint64_t auto_increment_value;
765
uint32_t table_options;
766
uint32_t avg_row_length;
767
uint32_t used_fields;
768
uint32_t key_block_size;
772
enum row_type row_type;
773
uint null_bits; /* NULL bits at start of record */
774
uint options; /* OR of HA_CREATE_ options */
775
uint merge_insert_method;
776
uint extra_size; /* length of extra data segment */
777
/* 0 not used, 1 if not transactional, 2 if transactional */
778
enum ha_choice transactional;
779
bool table_existed; /* 1 in create if table existed */
780
bool frm_only; /* 1 if no ha_create_table() */
781
bool varchar; /* 1 if table has a VARCHAR */
782
enum ha_choice page_checksum; /* If we have page_checksums */
785
typedef struct st_ha_alter_information
787
KEY *key_info_buffer;
789
uint index_drop_count;
790
uint *index_drop_buffer;
791
uint index_add_count;
792
uint *index_add_buffer;
797
typedef struct st_key_create_information
799
enum ha_key_alg algorithm;
801
LEX_STRING parser_name;
807
Class for maintaining hooks used inside operations on tables such
808
as: create table functions, delete table functions, and alter table
811
Class is using the Template Method pattern to separate the public
812
usage interface from the private inheritance interface. This
813
imposes no overhead, since the public non-virtual function is small
814
enough to be inlined.
816
The hooks are usually used for functions that does several things,
817
e.g., create_table_from_items(), which both create a table and lock
824
virtual ~TABLEOP_HOOKS() {}
826
inline void prelock(TABLE **tables, uint count)
828
do_prelock(tables, count);
831
inline int postlock(TABLE **tables, uint count)
833
return do_postlock(tables, count);
836
/* Function primitive that is called prior to locking tables */
837
virtual void do_prelock(TABLE **tables __attribute__((unused)),
838
uint count __attribute__((unused)))
840
/* Default is to do nothing */
844
Primitive called after tables are locked.
846
If an error is returned, the tables will be unlocked and error
849
@return Error code or zero.
851
virtual int do_postlock(TABLE **tables __attribute__((unused)),
852
uint count __attribute__((unused)))
854
return 0; /* Default is to do nothing */
61
typedef class st_select_lex SELECT_LEX;
62
typedef class st_select_lex_unit SELECT_LEX_UNIT;
68
typedef struct st_sort_field SORT_FIELD;
70
typedef List<Item> List_item;
858
72
typedef struct st_savepoint SAVEPOINT;
859
73
extern uint32_t savepoint_alloc_size;
1221
251
cached_table_flags= table_flags();
1223
254
/* ha_ methods: pubilc wrappers for private virtual API */
1225
int ha_open(TABLE *table, const char *name, int mode, int test_if_locked);
1226
int ha_index_init(uint idx, bool sorted)
1229
assert(inited==NONE);
1230
if (!(result= index_init(idx, sorted)))
1237
assert(inited==INDEX);
1240
return(index_end());
1242
int ha_rnd_init(bool scan)
1245
assert(inited==NONE || (inited==RND && scan));
1246
inited= (result= rnd_init(scan)) ? NONE: RND;
1251
assert(inited==RND);
256
int ha_open(Table *table, const char *name, int mode, int test_if_locked);
257
int ha_index_init(uint32_t idx, bool sorted);
259
int ha_rnd_init(bool scan);
1256
263
/* this is necessary in many places, e.g. in HANDLER command */
1257
int ha_index_or_rnd_end()
1259
return inited == INDEX ? ha_index_end() : inited == RND ? ha_rnd_end() : 0;
1261
Table_flags ha_table_flags() const { return cached_table_flags; }
264
int ha_index_or_rnd_end();
265
Table_flags ha_table_flags() const;
1263
268
These functions represent the public interface to *users* of the
1264
269
handler class, hence they are *not* virtual. For the inheritance
1265
270
interface, see the (private) functions write_row(), update_row(),
1266
271
and delete_row() below.
1268
int ha_external_lock(THD *thd, int lock_type);
1269
int ha_write_row(uchar * buf);
1270
int ha_update_row(const uchar * old_data, uchar * new_data);
1271
int ha_delete_row(const uchar * buf);
273
int ha_external_lock(Session *session, int lock_type);
274
int ha_write_row(unsigned char * buf);
275
int ha_update_row(const unsigned char * old_data, unsigned char * new_data);
276
int ha_delete_row(const unsigned char * buf);
1272
277
void ha_release_auto_increment();
1274
279
int ha_check_for_upgrade(HA_CHECK_OPT *check_opt);
1275
280
/** to be actually called to get 'check()' functionality*/
1276
int ha_check(THD *thd, HA_CHECK_OPT *check_opt);
1277
int ha_repair(THD* thd, HA_CHECK_OPT* check_opt);
1278
void ha_start_bulk_insert(ha_rows rows)
1280
estimation_rows_to_insert= rows;
1281
start_bulk_insert(rows);
1283
int ha_end_bulk_insert()
1285
estimation_rows_to_insert= 0;
1286
return end_bulk_insert();
1288
int ha_bulk_update_row(const uchar *old_data, uchar *new_data,
1289
uint *dup_key_found);
281
int ha_check(Session *session, HA_CHECK_OPT *check_opt);
282
int ha_repair(Session* session, HA_CHECK_OPT* check_opt);
283
void ha_start_bulk_insert(ha_rows rows);
284
int ha_end_bulk_insert();
285
int ha_bulk_update_row(const unsigned char *old_data, unsigned char *new_data,
286
uint32_t *dup_key_found);
1290
287
int ha_delete_all_rows();
1291
288
int ha_reset_auto_increment(uint64_t value);
1292
int ha_optimize(THD* thd, HA_CHECK_OPT* check_opt);
1293
int ha_analyze(THD* thd, HA_CHECK_OPT* check_opt);
1294
bool ha_check_and_repair(THD *thd);
1295
int ha_disable_indexes(uint mode);
1296
int ha_enable_indexes(uint mode);
289
int ha_optimize(Session* session, HA_CHECK_OPT* check_opt);
290
int ha_analyze(Session* session, HA_CHECK_OPT* check_opt);
291
bool ha_check_and_repair(Session *session);
292
int ha_disable_indexes(uint32_t mode);
293
int ha_enable_indexes(uint32_t mode);
1297
294
int ha_discard_or_import_tablespace(bool discard);
1298
295
void ha_prepare_for_alter();
1299
296
int ha_rename_table(const char *from, const char *to);
1300
297
int ha_delete_table(const char *name);
1301
298
void ha_drop_table(const char *name);
1303
int ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info);
300
int ha_create(const char *name, Table *form, HA_CREATE_INFO *info);
1305
302
int ha_create_handler_files(const char *name, const char *old_name,
1306
303
int action_flag, HA_CREATE_INFO *info);
1308
305
void adjust_next_insert_id_after_explicit_value(uint64_t nr);
1309
306
int update_auto_increment();
1310
void print_keydup_error(uint key_nr, const char *msg);
307
void print_keydup_error(uint32_t key_nr, const char *msg);
1311
308
virtual void print_error(int error, myf errflag);
1312
309
virtual bool get_error_message(int error, String *buf);
1313
uint get_dup_key(int error);
1314
virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share)
310
uint32_t get_dup_key(int error);
311
virtual void change_table_ptr(Table *table_arg, TABLE_SHARE *share);
1319
313
/* Estimates calculation */
1320
314
virtual double scan_time(void)
1321
315
{ return uint64_t2double(stats.data_file_length) / IO_SIZE + 2; }
1322
virtual double read_time(uint index __attribute__((unused)),
1323
uint ranges, ha_rows rows)
316
virtual double read_time(uint32_t, uint32_t ranges, ha_rows rows)
1324
317
{ return rows2double(ranges+rows); }
1326
virtual double index_only_read_time(uint keynr, double records);
1328
virtual ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
1329
void *seq_init_param,
1330
uint n_ranges, uint *bufsz,
1331
uint *flags, COST_VECT *cost);
1332
virtual int multi_range_read_info(uint keyno, uint n_ranges, uint keys,
1333
uint *bufsz, uint *flags, COST_VECT *cost);
319
virtual double index_only_read_time(uint32_t keynr, double records);
321
virtual ha_rows multi_range_read_info_const(uint32_t keyno, RANGE_SEQ_IF *seq,
322
void *seq_init_param,
323
uint32_t n_ranges, uint32_t *bufsz,
324
uint32_t *flags, COST_VECT *cost);
325
virtual int multi_range_read_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys,
326
uint32_t *bufsz, uint32_t *flags, COST_VECT *cost);
1334
327
virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
1335
uint n_ranges, uint mode,
328
uint32_t n_ranges, uint32_t mode,
1336
329
HANDLER_BUFFER *buf);
1337
330
virtual int multi_range_read_next(char **range_info);
1340
virtual const key_map *keys_to_use_for_scanning() { return &key_map_empty; }
1341
bool has_transactions()
1342
{ return (ha_table_flags() & HA_NO_TRANSACTIONS) == 0; }
1343
virtual uint extra_rec_buf_length() const { return 0; }
333
virtual const key_map *keys_to_use_for_scanning();
334
bool has_transactions();
335
virtual uint32_t extra_rec_buf_length() const { return 0; }
1346
338
This method is used to analyse the error to see whether the error
2269
1175
int ha_end_key_cache(KEY_CACHE *key_cache);
2271
1177
/* report to InnoDB that control passes to the client */
2272
int ha_release_temporary_latches(THD *thd);
1178
int ha_release_temporary_latches(Session *session);
2274
1180
/* transactions: interface to handlerton functions */
2275
int ha_start_consistent_snapshot(THD *thd);
1181
int ha_start_consistent_snapshot(Session *session);
2276
1182
int ha_commit_or_rollback_by_xid(XID *xid, bool commit);
2277
int ha_commit_one_phase(THD *thd, bool all);
2278
int ha_rollback_trans(THD *thd, bool all);
2279
int ha_prepare(THD *thd);
1183
int ha_commit_one_phase(Session *session, bool all);
1184
int ha_rollback_trans(Session *session, bool all);
1185
int ha_prepare(Session *session);
2280
1186
int ha_recover(HASH *commit_list);
2282
1188
/* transactions: these functions never call handlerton functions directly */
2283
int ha_commit_trans(THD *thd, bool all);
2284
int ha_autocommit_or_rollback(THD *thd, int error);
2285
int ha_enable_transaction(THD *thd, bool on);
1189
int ha_commit_trans(Session *session, bool all);
1190
int ha_autocommit_or_rollback(Session *session, int error);
1191
int ha_enable_transaction(Session *session, bool on);
2287
1193
/* savepoints */
2288
int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv);
2289
int ha_savepoint(THD *thd, SAVEPOINT *sv);
2290
int ha_release_savepoint(THD *thd, SAVEPOINT *sv);
1194
int ha_rollback_to_savepoint(Session *session, SAVEPOINT *sv);
1195
int ha_savepoint(Session *session, SAVEPOINT *sv);
1196
int ha_release_savepoint(Session *session, SAVEPOINT *sv);
2292
1198
/* these are called by storage engines */
2293
void trans_register_ha(THD *thd, bool all, handlerton *ht);
1199
void trans_register_ha(Session *session, bool all, handlerton *ht);
1201
void table_case_convert(char * name, uint32_t length);
1202
const char *table_case_name(HA_CREATE_INFO *info, const char *name);
1204
extern char reg_ext[FN_EXTLEN];
1205
extern uint32_t reg_ext_length;
1206
extern ulong specialflag;
1207
extern uint32_t lower_case_table_names;
1208
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
1209
uint32_t tablename_to_filename(const char *from, char *to, uint32_t to_length);
1212
bool mysql_ha_open(Session *session, TableList *tables, bool reopen);
1213
bool mysql_ha_close(Session *session, TableList *tables);
1214
bool mysql_ha_read(Session *, TableList *,enum enum_ha_read_modes,char *,
1215
List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
1216
void mysql_ha_flush(Session *session);
1217
void mysql_ha_rm_tables(Session *session, TableList *tables, bool is_locked);
1218
void mysql_ha_cleanup(Session *session);
2296
1221
Storage engine has to assume the transaction will end up with 2pc if
2297
1222
- there is more than one 2pc-capable storage engine available
2298
1223
- in the current transaction 2pc was not disabled yet
2300
#define trans_need_2pc(thd, all) ((total_ha_2pc > 1) && \
2301
!((all ? &thd->transaction.all : &thd->transaction.stmt)->no_2pc))
2303
#ifdef HAVE_NDB_BINLOG
2304
int ha_reset_logs(THD *thd);
2305
int ha_binlog_index_purge_file(THD *thd, const char *file);
2306
void ha_reset_slave(THD *thd);
2307
void ha_binlog_log_query(THD *thd, handlerton *db_type,
2308
enum_binlog_command binlog_command,
2309
const char *query, uint query_length,
2310
const char *db, const char *table_name);
2311
void ha_binlog_wait(THD *thd);
2312
int ha_binlog_end(THD *thd);
2314
#define ha_reset_logs(a) do {} while (0)
2315
#define ha_binlog_index_purge_file(a,b) do {} while (0)
2316
#define ha_reset_slave(a) do {} while (0)
2317
#define ha_binlog_log_query(a,b,c,d,e,f,g) do {} while (0)
2318
#define ha_binlog_wait(a) do {} while (0)
2319
#define ha_binlog_end(a) do {} while (0)
1225
#define trans_need_2pc(session, all) ((total_ha_2pc > 1) && \
1226
!((all ? &session->transaction.all : &session->transaction.stmt)->no_2pc))
1229
bool mysql_xa_recover(Session *session);
1231
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
1232
SORT_FIELD *sortorder);
1233
int setup_order(Session *session, Item **ref_pointer_array, TableList *tables,
1234
List<Item> &fields, List <Item> &all_fields, order_st *order);
1235
int setup_group(Session *session, Item **ref_pointer_array, TableList *tables,
1236
List<Item> &fields, List<Item> &all_fields, order_st *order,
1237
bool *hidden_group_fields);
1238
bool fix_inner_refs(Session *session, List<Item> &all_fields, SELECT_LEX *select,
1239
Item **ref_pointer_array);
1241
bool handle_select(Session *session, LEX *lex, select_result *result,
1242
ulong setup_tables_done_option);
1243
bool mysql_select(Session *session, Item ***rref_pointer_array,
1244
TableList *tables, uint32_t wild_num, List<Item> &list,
1245
COND *conds, uint32_t og_num, order_st *order, order_st *group,
1246
Item *having, order_st *proc_param, uint64_t select_type,
1247
select_result *result, SELECT_LEX_UNIT *unit,
1248
SELECT_LEX *select_lex);
1249
void free_underlaid_joins(Session *session, SELECT_LEX *select);
1250
bool mysql_explain_union(Session *session, SELECT_LEX_UNIT *unit,
1251
select_result *result);
1252
int mysql_explain_select(Session *session, SELECT_LEX *sl, char const *type,
1253
select_result *result);
1254
bool mysql_union(Session *session, LEX *lex, select_result *result,
1255
SELECT_LEX_UNIT *unit, ulong setup_tables_done_option);
1256
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
1259
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t);
1260
bool mysql_derived_filling(Session *session, LEX *lex, TableList *t);
1261
void sp_prepare_create_field(Session *session, Create_field *sql_field);
1262
int prepare_create_field(Create_field *sql_field,
1263
uint32_t *blob_columns,
1264
int *timestamps, int *timestamps_with_niladic,
1265
int64_t table_flags);
1266
bool mysql_create_table(Session *session,const char *db, const char *table_name,
1267
HA_CREATE_INFO *create_info,
1268
Alter_info *alter_info,
1269
bool tmp_table, uint32_t select_field_count);
1270
bool mysql_create_table_no_lock(Session *session, const char *db,
1271
const char *table_name,
1272
HA_CREATE_INFO *create_info,
1273
Alter_info *alter_info,
1274
bool tmp_table, uint32_t select_field_count,
1275
bool lock_open_lock);
1277
bool mysql_alter_table(Session *session, char *new_db, char *new_name,
1278
HA_CREATE_INFO *create_info,
1279
TableList *table_list,
1280
Alter_info *alter_info,
1281
uint32_t order_num, order_st *order, bool ignore);
1282
bool mysql_recreate_table(Session *session, TableList *table_list);
1283
bool mysql_create_like_table(Session *session, TableList *table,
1284
TableList *src_table,
1285
HA_CREATE_INFO *create_info);
1286
bool mysql_rename_table(handlerton *base, const char *old_db,
1287
const char * old_name, const char *new_db,
1288
const char * new_name, uint32_t flags);
1289
bool mysql_prepare_update(Session *session, TableList *table_list,
1290
Item **conds, uint32_t order_num, order_st *order);
1291
int mysql_update(Session *session,TableList *tables,List<Item> &fields,
1292
List<Item> &values,COND *conds,
1293
uint32_t order_num, order_st *order, ha_rows limit,
1294
enum enum_duplicates handle_duplicates, bool ignore);
1295
bool mysql_multi_update(Session *session, TableList *table_list,
1296
List<Item> *fields, List<Item> *values,
1297
COND *conds, uint64_t options,
1298
enum enum_duplicates handle_duplicates, bool ignore,
1299
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex);
1300
bool mysql_prepare_insert(Session *session, TableList *table_list, Table *table,
1301
List<Item> &fields, List_item *values,
1302
List<Item> &update_fields,
1303
List<Item> &update_values, enum_duplicates duplic,
1304
COND **where, bool select_insert,
1305
bool check_fields, bool abort_on_warning);
1306
bool mysql_insert(Session *session,TableList *table,List<Item> &fields,
1307
List<List_item> &values, List<Item> &update_fields,
1308
List<Item> &update_values, enum_duplicates flag,
1310
int check_that_all_fields_are_given_values(Session *session, Table *entry,
1311
TableList *table_list);
1312
void prepare_triggers_for_insert_stmt(Table *table);
1313
int mysql_prepare_delete(Session *session, TableList *table_list, Item **conds);
1314
bool mysql_delete(Session *session, TableList *table_list, COND *conds,
1315
SQL_LIST *order, ha_rows rows, uint64_t options,
1316
bool reset_auto_increment);
1317
bool mysql_truncate(Session *session, TableList *table_list, bool dont_send_ok);
1318
uint32_t create_table_def_key(Session *session, char *key, TableList *table_list,
1320
TABLE_SHARE *get_table_share(Session *session, TableList *table_list, char *key,
1321
uint32_t key_length, uint32_t db_flags, int *error);
1322
void release_table_share(TABLE_SHARE *share, enum release_type type);
1323
TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
1324
Table *open_ltable(Session *session, TableList *table_list, thr_lock_type update,
1325
uint32_t lock_flags);
1326
Table *open_table(Session *session, TableList *table_list, bool *refresh, uint32_t flags);
1327
bool name_lock_locked_table(Session *session, TableList *tables);
1328
bool reopen_name_locked_table(Session* session, TableList* table_list, bool link_in);
1329
Table *table_cache_insert_placeholder(Session *session, const char *key,
1330
uint32_t key_length);
1331
bool lock_table_name_if_not_cached(Session *session, const char *db,
1332
const char *table_name, Table **table);
1333
Table *find_locked_table(Session *session, const char *db,const char *table_name);
1334
void detach_merge_children(Table *table, bool clear_refs);
1335
bool fix_merge_after_open(TableList *old_child_list, TableList **old_last,
1336
TableList *new_child_list, TableList **new_last);
1337
bool reopen_table(Table *table);
1338
bool reopen_tables(Session *session,bool get_locks,bool in_refresh);
1339
void close_data_files_and_morph_locks(Session *session, const char *db,
1340
const char *table_name);
1341
void close_handle_and_leave_table_as_lock(Table *table);
1342
bool open_new_frm(Session *session, TABLE_SHARE *share, const char *alias,
1343
uint32_t db_stat, uint32_t prgflag,
1344
uint32_t ha_open_flags, Table *outparam,
1345
TableList *table_desc, MEM_ROOT *mem_root);
1346
bool wait_for_tables(Session *session);
1347
bool table_is_used(Table *table, bool wait_for_name_lock);
1348
Table *drop_locked_tables(Session *session,const char *db, const char *table_name);
1349
void abort_locked_tables(Session *session,const char *db, const char *table_name);
1350
void execute_init_command(Session *session, sys_var_str *init_command_var,
1351
pthread_rwlock_t *var_mutex);
1352
extern Field *not_found_field;
1353
extern Field *view_ref_found;
1356
find_field_in_tables(Session *session, Item_ident *item,
1357
TableList *first_table, TableList *last_table,
1358
Item **ref, find_item_error_report_type report_error,
1359
bool check_privileges, bool register_tree_change);
1361
find_field_in_table_ref(Session *session, TableList *table_list,
1362
const char *name, uint32_t length,
1363
const char *item_name, const char *db_name,
1364
const char *table_name, Item **ref,
1365
bool check_privileges, bool allow_rowid,
1366
uint32_t *cached_field_index_ptr,
1367
bool register_tree_change, TableList **actual_table);
1369
find_field_in_table(Session *session, Table *table, const char *name, uint32_t length,
1370
bool allow_rowid, uint32_t *cached_field_index_ptr);
1372
find_field_in_table_sef(Table *table, const char *name);
1373
int update_virtual_fields_marked_for_write(Table *table,
1374
bool ignore_stored=true);
1377
#endif /* DRIZZLED_HANDLER_H */