~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/handler.h

  • Committer: Monty Taylor
  • Date: 2008-07-13 21:27:17 UTC
  • mto: (77.4.1 glibclient-merge)
  • mto: This revision was merged to the branch mainline in revision 153.
  • Revision ID: monty@inaugust.com-20080713212717-8r4dap6oqxopxrd6
Cleanup to hello_world Makefile.am

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
/* Copyright (C) 2000-2006 MySQL AB
 
2
 
 
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.
 
6
 
 
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.
 
11
 
 
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 */
19
15
 
20
16
 
21
17
/* Definitions for parameters to do with handler-routines */
22
18
 
 
19
#ifdef USE_PRAGMA_INTERFACE
 
20
#pragma interface                       /* gcc class implementation */
 
21
#endif
23
22
 
24
 
#include <mysys/my_handler.h>
25
 
#include <storage/myisam/keycache.h>
 
23
#include <my_handler.h>
 
24
#include <keycache.h>
26
25
 
27
26
#ifndef NO_HASH
28
27
#define NO_HASH                         /* Not yet implemented */
46
45
#define HA_ADMIN_NEEDS_CHECK    -12
47
46
 
48
47
/* Bits to show what an alter table will do */
49
 
#include <drizzled/sql_bitmap.h>
 
48
#include <sql_bitmap.h>
50
49
 
51
 
#define HA_MAX_ALTER_FLAGS 40
 
50
#define HA_MAX_ALTER_FLAGS 39
52
51
typedef Bitmap<HA_MAX_ALTER_FLAGS> HA_ALTER_FLAGS;
53
52
 
54
53
#define HA_ADD_INDEX                  (0)
85
84
#define HA_RENAME_TABLE               (36)
86
85
#define HA_ALTER_STORAGE_ENGINE       (37)
87
86
#define HA_RECREATE                   (38)
88
 
#define HA_ALTER_STORED_VCOL          (39)
89
87
/* Remember to increase HA_MAX_ALTER_FLAGS when adding more flags! */
90
88
 
91
89
/* Return values for check_if_supported_alter */
109
107
  row to be able to find the row later.
110
108
*/
111
109
#define HA_REC_NOT_IN_SEQ      (1 << 3)
112
 
 
 
110
/* This is now a dead option, just left for compatibility */
 
111
#define HA_CAN_GEOMETRY        (1 << 4)
113
112
/*
114
113
  Reading keys in random order is as fast as reading keys in sort order
115
114
  (Used in records.cc to decide if we should use a record cache and by
129
128
#define HA_REQUIRE_PRIMARY_KEY (1 << 12) /* .. and can't create a hidden one */
130
129
#define HA_STATS_RECORDS_IS_EXACT (1 << 13) /* stats.records is exact */
131
130
/*
 
131
  INSERT_DELAYED only works with handlers that uses MySQL internal table
 
132
  level locks
 
133
*/
 
134
#define HA_CAN_INSERT_DELAYED  (1 << 14)
 
135
/*
132
136
  If we get the primary key columns for free when we do an index read
133
137
  It also implies that we have to retrive the primary key when using
134
138
  position() and rnd_pos().
139
143
  uses a primary key. Without primary key, we can't call position().
140
144
*/ 
141
145
#define HA_PRIMARY_KEY_REQUIRED_FOR_POSITION (1 << 16) 
 
146
#define HA_CAN_RTREEKEYS       (1 << 17) /* Historical, no longer supported */
142
147
#define HA_NOT_DELETE_WITH_CACHE (1 << 18)
143
148
/*
144
149
  The following is we need to a primary key to delete (and update) a row.
146
151
*/
147
152
#define HA_PRIMARY_KEY_REQUIRED_FOR_DELETE (1 << 19)
148
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 */
149
156
#define HA_NO_AUTO_INCREMENT   (1 << 23)
150
157
#define HA_HAS_CHECKSUM        (1 << 24)
151
158
/* Table data are stored in separate files (for lower_case_table_names) */
152
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 */
153
162
#define HA_NEED_READ_RANGE_BUFFER (1 << 29) /* for read_multi_range */
154
163
#define HA_ANY_INDEX_MAY_BE_UNIQUE (1 << 30)
155
 
#define HA_NO_COPY_ON_ALTER    (INT64_C(1) << 31)
156
 
#define HA_HAS_RECORDS         (INT64_C(1) << 32) /* records() gives exact count*/
157
 
#define HA_MRR_CANT_SORT       (INT64_C(1) << 34)
 
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)
158
169
 
159
170
/*
160
171
  Engine is capable of row-format and statement-format logging,
161
172
  respectively
162
173
*/
163
 
#define HA_BINLOG_ROW_CAPABLE  (INT64_C(1) << 35)
164
 
#define HA_BINLOG_STMT_CAPABLE (INT64_C(1) << 36)
 
174
#define HA_BINLOG_ROW_CAPABLE  (1LL << 35)
 
175
#define HA_BINLOG_STMT_CAPABLE (1LL << 36)
165
176
 
166
 
#define HA_ONLINE_ALTER        (INT64_C(1) << 37)
 
177
#define HA_ONLINE_ALTER        (1LL << 37)
167
178
 
168
179
/*
169
180
  Set of all binlog flags. Currently only contain the capabilities
202
213
  set.
203
214
  This is actually removed even before it was introduced the first time.
204
215
  The new idea is that handlers will handle the lock level already in
205
 
  store_lock for ALTER Table partitions.
 
216
  store_lock for ALTER TABLE partitions.
206
217
 
207
218
  HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take
208
219
  care of changing the partitions online and in one phase. Thus all phases
248
259
#define HA_BLOCK_LOCK           256     /* unlock when reading some records */
249
260
#define HA_OPEN_TEMPORARY       512
250
261
 
251
 
/* For transactional LOCK Table. handler::lock_table() */
 
262
/* For transactional LOCK TABLE. handler::lock_table() */
252
263
#define HA_LOCK_IN_SHARE_MODE      F_RDLCK
253
264
#define HA_LOCK_IN_EXCLUSIVE_MODE  F_WRLCK
254
265
 
270
281
#define HA_CACHE_TBL_TRANSACT    4
271
282
 
272
283
/* Options of START TRANSACTION statement (and later of SET TRANSACTION stmt) */
273
 
#define DRIZZLE_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
 
284
#define MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT 1
274
285
 
275
286
/* Flags for method is_fatal_error */
276
287
#define HA_CHECK_DUP_KEY 1
279
290
 
280
291
enum legacy_db_type
281
292
{
282
 
  DB_TYPE_UNKNOWN=0,
 
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,
 
303
  DB_TYPE_BINLOG,
 
304
  DB_TYPE_SOLID,
 
305
  DB_TYPE_PBXT,
 
306
  DB_TYPE_TABLE_FUNCTION,
 
307
  DB_TYPE_MEMCACHE,
 
308
  DB_TYPE_FALCON,
 
309
  DB_TYPE_MARIA,
283
310
  DB_TYPE_FIRST_DYNAMIC=42,
284
311
  DB_TYPE_DEFAULT=127 // Must be last
285
312
};
315
342
 
316
343
/* Bits in used_fields */
317
344
#define HA_CREATE_USED_AUTO             (1L << 0)
318
 
#ifdef DEAD_OPTIONS
 
345
#define HA_CREATE_USED_RAID             (1L << 1) /* Historical, no longer supported */
319
346
#define HA_CREATE_USED_UNION            (1L << 2)
320
 
#define HA_CREATE_USED_PASSWORD         (1L << 17)
321
 
#endif
322
347
#define HA_CREATE_USED_INSERT_METHOD    (1L << 3)
323
348
#define HA_CREATE_USED_MIN_ROWS         (1L << 4)
324
349
#define HA_CREATE_USED_MAX_ROWS         (1L << 5)
333
358
#define HA_CREATE_USED_DELAY_KEY_WRITE  (1L << 14)
334
359
#define HA_CREATE_USED_ROW_FORMAT       (1L << 15)
335
360
#define HA_CREATE_USED_COMMENT          (1L << 16)
 
361
#define HA_CREATE_USED_PASSWORD         (1L << 17)
336
362
#define HA_CREATE_USED_CONNECTION       (1L << 18)
337
363
#define HA_CREATE_USED_KEY_BLOCK_SIZE   (1L << 19)
 
364
#define HA_CREATE_USED_TRANSACTIONAL    (1L << 20)
338
365
#define HA_CREATE_USED_PAGE_CHECKSUM    (1L << 21)
339
 
#define HA_CREATE_USED_BLOCK_SIZE       (1L << 22)
340
366
 
341
367
typedef uint64_t my_xid; // this line is the same as in log_event.h
342
 
#define DRIZZLE_XID_PREFIX "MySQLXid"
343
 
#define DRIZZLE_XID_PREFIX_LEN 8 // must be a multiple of 8
344
 
#define DRIZZLE_XID_OFFSET (DRIZZLE_XID_PREFIX_LEN+sizeof(server_id))
345
 
#define DRIZZLE_XID_GTRID_LEN (DRIZZLE_XID_OFFSET+sizeof(my_xid))
 
368
#define MYSQL_XID_PREFIX "MySQLXid"
 
369
#define MYSQL_XID_PREFIX_LEN 8 // must be a multiple of 8
 
370
#define MYSQL_XID_OFFSET (MYSQL_XID_PREFIX_LEN+sizeof(server_id))
 
371
#define MYSQL_XID_GTRID_LEN (MYSQL_XID_OFFSET+sizeof(my_xid))
346
372
 
347
 
#define XIDDATASIZE DRIZZLE_XIDDATASIZE
 
373
#define XIDDATASIZE MYSQL_XIDDATASIZE
348
374
#define MAXGTRIDSIZE 64
349
375
#define MAXBQUALSIZE 64
350
376
 
351
377
#define COMPATIBLE_DATA_YES 0
352
378
#define COMPATIBLE_DATA_NO  1
353
379
 
354
 
typedef bool (*qc_engine_callback)(THD *thd, char *table_key,
355
 
                                      uint32_t key_length,
356
 
                                      uint64_t *engine_data);
357
 
 
358
380
/**
359
381
  struct xid_t is binary compatible with the XID structure as
360
382
  in the X/Open CAE Specification, Distributed Transaction Processing:
361
383
  The XA Specification, X/Open Company Ltd., 1991.
362
384
  http://www.opengroup.org/bookstore/catalog/c193.htm
363
385
 
364
 
  @see DRIZZLE_XID in mysql/plugin.h
 
386
  @see MYSQL_XID in mysql/plugin.h
365
387
*/
366
388
struct xid_t {
367
389
  long formatID;
386
408
  {
387
409
    my_xid tmp;
388
410
    formatID= 1;
389
 
    set(DRIZZLE_XID_PREFIX_LEN, 0, DRIZZLE_XID_PREFIX);
390
 
    memcpy(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id));
 
411
    set(MYSQL_XID_PREFIX_LEN, 0, MYSQL_XID_PREFIX);
 
412
    memcpy(data+MYSQL_XID_PREFIX_LEN, &server_id, sizeof(server_id));
391
413
    tmp= xid;
392
 
    memcpy(data+DRIZZLE_XID_OFFSET, &tmp, sizeof(tmp));
393
 
    gtrid_length=DRIZZLE_XID_GTRID_LEN;
 
414
    memcpy(data+MYSQL_XID_OFFSET, &tmp, sizeof(tmp));
 
415
    gtrid_length=MYSQL_XID_GTRID_LEN;
394
416
  }
395
417
  void set(long g, long b, const char *d)
396
418
  {
404
426
  my_xid quick_get_my_xid()
405
427
  {
406
428
    my_xid tmp;
407
 
    memcpy(&tmp, data+DRIZZLE_XID_OFFSET, sizeof(tmp));
 
429
    memcpy(&tmp, data+MYSQL_XID_OFFSET, sizeof(tmp));
408
430
    return tmp;
409
431
  }
410
432
  my_xid get_my_xid()
411
433
  {
412
 
    return gtrid_length == DRIZZLE_XID_GTRID_LEN && bqual_length == 0 &&
413
 
           !memcmp(data+DRIZZLE_XID_PREFIX_LEN, &server_id, sizeof(server_id)) &&
414
 
           !memcmp(data, DRIZZLE_XID_PREFIX, DRIZZLE_XID_PREFIX_LEN) ?
 
434
    return gtrid_length == MYSQL_XID_GTRID_LEN && bqual_length == 0 &&
 
435
           !memcmp(data+MYSQL_XID_PREFIX_LEN, &server_id, sizeof(server_id)) &&
 
436
           !memcmp(data, MYSQL_XID_PREFIX, MYSQL_XID_PREFIX_LEN) ?
415
437
           quick_get_my_xid() : 0;
416
438
  }
417
 
  uint32_t length()
 
439
  uint length()
418
440
  {
419
441
    return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+
420
442
           gtrid_length+bqual_length;
421
443
  }
422
 
  unsigned char *key()
 
444
  uchar *key()
423
445
  {
424
 
    return (unsigned char *)&gtrid_length;
 
446
    return (uchar *)&gtrid_length;
425
447
  }
426
 
  uint32_t key_length()
 
448
  uint key_length()
427
449
  {
428
450
    return sizeof(gtrid_length)+sizeof(bqual_length)+gtrid_length+bqual_length;
429
451
  }
436
458
 
437
459
struct handlerton;
438
460
 
439
 
/* The handler for a table type.  Will be included in the Table structure */
 
461
/* The handler for a table type.  Will be included in the TABLE structure */
440
462
 
441
 
class Table;
 
463
struct st_table;
 
464
typedef struct st_table TABLE;
442
465
typedef struct st_table_share TABLE_SHARE;
443
466
struct st_foreign_key_info;
444
467
typedef struct st_foreign_key_info FOREIGN_KEY_INFO;
445
 
typedef bool (stat_print_fn)(THD *thd, const char *type, uint32_t type_len,
446
 
                             const char *file, uint32_t file_len,
447
 
                             const char *status, uint32_t status_len);
 
468
typedef bool (stat_print_fn)(THD *thd, const char *type, uint type_len,
 
469
                             const char *file, uint file_len,
 
470
                             const char *status, uint status_len);
448
471
enum ha_stat_type { HA_ENGINE_STATUS, HA_ENGINE_LOGS, HA_ENGINE_MUTEX };
449
472
extern st_plugin_int *hton2plugin[MAX_HA];
450
473
 
480
503
 
481
504
   slot number is initialized by MySQL after xxx_init() is called.
482
505
   */
483
 
   uint32_t slot;
 
506
   uint slot;
484
507
   /*
485
508
     to store per-savepoint data storage engine is provided with an area
486
509
     of a requested size (0 is ok here).
490
513
     area and need not be used by storage engine.
491
514
     see binlog_hton and binlog_savepoint_set/rollback for an example.
492
515
   */
493
 
   uint32_t savepoint_offset;
 
516
   uint savepoint_offset;
494
517
   /*
495
518
     handlerton methods:
496
519
 
521
544
   int  (*commit)(handlerton *hton, THD *thd, bool all);
522
545
   int  (*rollback)(handlerton *hton, THD *thd, bool all);
523
546
   int  (*prepare)(handlerton *hton, THD *thd, bool all);
524
 
   int  (*recover)(handlerton *hton, XID *xid_list, uint32_t len);
 
547
   int  (*recover)(handlerton *hton, XID *xid_list, uint len);
525
548
   int  (*commit_by_xid)(handlerton *hton, XID *xid);
526
549
   int  (*rollback_by_xid)(handlerton *hton, XID *xid);
527
550
   void *(*create_cursor_read_view)(handlerton *hton, THD *thd);
529
552
   void (*close_cursor_read_view)(handlerton *hton, THD *thd, void *read_view);
530
553
   handler *(*create)(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root);
531
554
   void (*drop_database)(handlerton *hton, char* path);
 
555
   int (*panic)(handlerton *hton, enum ha_panic_function flag);
532
556
   int (*start_consistent_snapshot)(handlerton *hton, THD *thd);
533
557
   bool (*flush_logs)(handlerton *hton);
534
558
   bool (*show_status)(handlerton *hton, THD *thd, stat_print_fn *print, enum ha_stat_type stat);
535
559
   int (*fill_files_table)(handlerton *hton, THD *thd,
536
 
                           TableList *tables,
 
560
                           TABLE_LIST *tables,
537
561
                           class Item *cond);
538
 
   uint32_t flags;                                /* global handler flags */
 
562
   uint32 flags;                                /* global handler flags */
539
563
   int (*release_temporary_latches)(handlerton *hton, THD *thd);
540
564
 
541
565
   int (*discover)(handlerton *hton, THD* thd, const char *db, 
542
566
                   const char *name,
543
 
                   unsigned char **frmblob, 
 
567
                   uchar **frmblob, 
544
568
                   size_t *frmlen);
545
569
   int (*table_exists_in_engine)(handlerton *hton, THD* thd, const char *db,
546
570
                                 const char *name);
547
 
   uint32_t license; /* Flag for Engine License */
 
571
   uint32 license; /* Flag for Engine License */
548
572
   void *data; /* Location for engines to keep personal structures */
549
573
};
550
574
 
695
719
    Not-null only if this instance is a part of transaction.
696
720
    May assume a combination of enum values above.
697
721
  */
698
 
  unsigned char       m_flags;
 
722
  uchar       m_flags;
699
723
};
700
724
 
701
725
 
702
726
enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED,
703
727
                         ISO_REPEATABLE_READ, ISO_SERIALIZABLE};
704
728
 
 
729
 
 
730
enum ndb_distribution { ND_KEYHASH= 0, ND_LINHASH= 1 };
 
731
 
 
732
 
705
733
typedef struct {
706
734
  uint64_t data_file_length;
707
735
  uint64_t max_data_file_length;
719
747
class Item;
720
748
struct st_table_log_memory_entry;
721
749
 
722
 
#define NOT_A_PARTITION_ID ((uint32_t)-1)
 
750
#define NOT_A_PARTITION_ID ((uint32)-1)
723
751
 
724
752
enum ha_choice { HA_CHOICE_UNDEF, HA_CHOICE_NO, HA_CHOICE_YES };
725
753
 
726
754
typedef struct st_ha_create_information
727
755
{
728
 
  const CHARSET_INFO *table_charset, *default_table_charset;
 
756
  CHARSET_INFO *table_charset, *default_table_charset;
729
757
  LEX_STRING connect_string;
730
758
  LEX_STRING comment;
731
759
  const char *data_file_name, *index_file_name;
736
764
  uint32_t avg_row_length;
737
765
  uint32_t used_fields;
738
766
  uint32_t key_block_size;
739
 
  uint32_t block_size;
 
767
  SQL_LIST merge_list;
740
768
  handlerton *db_type;
741
769
  enum row_type row_type;
742
 
  uint32_t null_bits;                       /* NULL bits at start of record */
743
 
  uint32_t options;                             /* OR of HA_CREATE_ options */
744
 
  uint32_t extra_size;                      /* length of extra data segment */
 
770
  uint null_bits;                       /* NULL bits at start of record */
 
771
  uint options;                         /* OR of HA_CREATE_ options */
 
772
  uint merge_insert_method;
 
773
  uint extra_size;                      /* length of extra data segment */
 
774
  /* 0 not used, 1 if not transactional, 2 if transactional */
 
775
  enum ha_choice transactional;
745
776
  bool table_existed;                   /* 1 in create if table existed */
746
777
  bool frm_only;                        /* 1 if no ha_create_table() */
747
778
  bool varchar;                         /* 1 if table has a VARCHAR */
751
782
typedef struct st_ha_alter_information
752
783
{
753
784
  KEY  *key_info_buffer;
754
 
  uint32_t key_count;
755
 
  uint32_t index_drop_count;
756
 
  uint32_t *index_drop_buffer;
757
 
  uint32_t index_add_count;
758
 
  uint32_t *index_add_buffer;
 
785
  uint key_count;
 
786
  uint index_drop_count;
 
787
  uint *index_drop_buffer;
 
788
  uint index_add_count;
 
789
  uint *index_add_buffer;
759
790
  void *data;
760
791
} HA_ALTER_INFO;
761
792
 
789
820
  TABLEOP_HOOKS() {}
790
821
  virtual ~TABLEOP_HOOKS() {}
791
822
 
792
 
  inline void prelock(Table **tables, uint32_t count)
 
823
  inline void prelock(TABLE **tables, uint count)
793
824
  {
794
825
    do_prelock(tables, count);
795
826
  }
796
827
 
797
 
  inline int postlock(Table **tables, uint32_t count)
 
828
  inline int postlock(TABLE **tables, uint count)
798
829
  {
799
830
    return do_postlock(tables, count);
800
831
  }
801
832
private:
802
833
  /* Function primitive that is called prior to locking tables */
803
 
  virtual void do_prelock(Table **tables __attribute__((unused)),
804
 
                          uint32_t count __attribute__((unused)))
 
834
  virtual void do_prelock(TABLE **tables __attribute__((__unused__)),
 
835
                          uint count __attribute__((__unused__)))
805
836
  {
806
837
    /* Default is to do nothing */
807
838
  }
814
845
 
815
846
     @return Error code or zero.
816
847
   */
817
 
  virtual int do_postlock(Table **tables __attribute__((unused)),
818
 
                          uint32_t count __attribute__((unused)))
 
848
  virtual int do_postlock(TABLE **tables __attribute__((__unused__)),
 
849
                          uint count __attribute__((__unused__)))
819
850
  {
820
851
    return 0;                           /* Default is to do nothing */
821
852
  }
832
863
{
833
864
  st_ha_check_opt() {}                        /* Remove gcc warning */
834
865
  uint32_t sort_buffer_size;
835
 
  uint32_t flags;       /* isam layer flags (e.g. for myisamchk) */
836
 
  uint32_t sql_flags;   /* sql layer flags - for something myisamchk cannot do */
 
866
  uint flags;       /* isam layer flags (e.g. for myisamchk) */
 
867
  uint sql_flags;   /* sql layer flags - for something myisamchk cannot do */
837
868
  KEY_CACHE *key_cache; /* new key cache when changing key cache */
838
869
  void init();
839
870
} HA_CHECK_OPT;
849
880
 
850
881
typedef struct st_handler_buffer
851
882
{
852
 
  unsigned char *buffer;         /* Buffer one can start using */
853
 
  unsigned char *buffer_end;     /* End of buffer */
854
 
  unsigned char *end_of_used_area;     /* End of area that was used by handler */
 
883
  uchar *buffer;         /* Buffer one can start using */
 
884
  uchar *buffer_end;     /* End of buffer */
 
885
  uchar *end_of_used_area;     /* End of area that was used by handler */
855
886
} HANDLER_BUFFER;
856
887
 
857
888
typedef struct system_status_var SSV;
873
904
    RETURN
874
905
      An opaque value to be used as RANGE_SEQ_IF::next() parameter
875
906
  */
876
 
  range_seq_t (*init)(void *init_params, uint32_t n_ranges, uint32_t flags);
 
907
  range_seq_t (*init)(void *init_params, uint n_ranges, uint flags);
877
908
 
878
909
 
879
910
  /*
888
919
      0 - Ok, the range structure filled with info about the next range
889
920
      1 - No more ranges
890
921
  */
891
 
  uint32_t (*next) (range_seq_t seq, KEY_MULTI_RANGE *range);
 
922
  uint (*next) (range_seq_t seq, KEY_MULTI_RANGE *range);
892
923
} RANGE_SEQ_IF;
893
924
 
894
 
uint16_t &mrr_persistent_flag_storage(range_seq_t seq, uint32_t idx);
895
 
char* &mrr_get_ptr_by_idx(range_seq_t seq, uint32_t idx);
 
925
uint16 &mrr_persistent_flag_storage(range_seq_t seq, uint idx);
 
926
char* &mrr_get_ptr_by_idx(range_seq_t seq, uint idx);
896
927
 
897
928
class COST_VECT
898
929
946
977
  }
947
978
};
948
979
 
949
 
void get_sweep_read_cost(Table *table, ha_rows nrows, bool interrupted, 
 
980
void get_sweep_read_cost(TABLE *table, ha_rows nrows, bool interrupted, 
950
981
                         COST_VECT *cost);
951
982
 
952
983
/*
1018
1049
  time_t create_time;                   /* When table was created */
1019
1050
  time_t check_time;
1020
1051
  time_t update_time;
1021
 
  uint32_t block_size;                  /* index block size */
 
1052
  uint block_size;                      /* index block size */
1022
1053
 
1023
1054
  ha_statistics():
1024
1055
    data_file_length(0), max_data_file_length(0),
1028
1059
  {}
1029
1060
};
1030
1061
 
1031
 
uint32_t calculate_key_len(Table *, uint, const unsigned char *, key_part_map);
 
1062
uint calculate_key_len(TABLE *, uint, const uchar *, key_part_map);
1032
1063
/*
1033
1064
  bitmap with first N+1 bits set
1034
1065
  (keypart_map for a key prefix of [0..N] keyparts)
1094
1125
  typedef uint64_t Table_flags;
1095
1126
protected:
1096
1127
  struct st_table_share *table_share;   /* The table definition */
1097
 
  Table *table;               /* The current open table */
 
1128
  struct st_table *table;               /* The current open table */
1098
1129
  Table_flags cached_table_flags;       /* Set on init() and open() */
1099
1130
 
1100
1131
  ha_rows estimation_rows_to_insert;
1101
1132
public:
1102
1133
  handlerton *ht;                 /* storage engine of this handler */
1103
 
  unsigned char *ref;                           /* Pointer to current row */
1104
 
  unsigned char *dup_ref;                       /* Pointer to duplicate row */
 
1134
  uchar *ref;                           /* Pointer to current row */
 
1135
  uchar *dup_ref;                       /* Pointer to duplicate row */
1105
1136
 
1106
1137
  ha_statistics stats;
1107
1138
  /** MultiRangeRead-related members: */
1108
1139
  range_seq_t mrr_iter;    /* Interator to traverse the range sequence */
1109
1140
  RANGE_SEQ_IF mrr_funcs;  /* Range sequence traversal functions */
1110
1141
  HANDLER_BUFFER *multi_range_buffer; /* MRR buffer info */
1111
 
  uint32_t ranges_in_seq; /* Total number of ranges in the traversed sequence */
 
1142
  uint ranges_in_seq; /* Total number of ranges in the traversed sequence */
1112
1143
  /* true <=> source MRR ranges and the output are ordered */
1113
1144
  bool mrr_is_output_sorted;
1114
1145
 
1128
1159
  */
1129
1160
  bool in_range_check_pushed_down;
1130
1161
 
1131
 
  uint32_t errkey;                              /* Last dup key */
1132
 
  uint32_t key_used_on_scan;
1133
 
  uint32_t active_index;
 
1162
  uint errkey;                          /* Last dup key */
 
1163
  uint key_used_on_scan;
 
1164
  uint active_index;
1134
1165
  /** Length of ref (1-8 or the clustered key length) */
1135
 
  uint32_t ref_length;
 
1166
  uint ref_length;
1136
1167
  enum {NONE=0, INDEX, RND} inited;
1137
1168
  bool locked;
1138
1169
  bool implicit_emptied;                /* Can be !=0 only if HEAP */
1139
1170
  const Item *pushed_cond;
1140
1171
 
1141
1172
  Item *pushed_idx_cond;
1142
 
  uint32_t pushed_idx_cond_keyno;  /* The index which the above condition is for */
 
1173
  uint pushed_idx_cond_keyno;  /* The index which the above condition is for */
1143
1174
 
1144
1175
  /**
1145
1176
    next_insert_id is the next value which should be inserted into the
1188
1219
  }
1189
1220
  /* ha_ methods: pubilc wrappers for private virtual API */
1190
1221
 
1191
 
  int ha_open(Table *table, const char *name, int mode, int test_if_locked);
1192
 
  int ha_index_init(uint32_t idx, bool sorted)
 
1222
  int ha_open(TABLE *table, const char *name, int mode, int test_if_locked);
 
1223
  int ha_index_init(uint idx, bool sorted)
1193
1224
  {
1194
1225
    int result;
1195
1226
    assert(inited==NONE);
1232
1263
    and delete_row() below.
1233
1264
  */
1234
1265
  int ha_external_lock(THD *thd, int lock_type);
1235
 
  int ha_write_row(unsigned char * buf);
1236
 
  int ha_update_row(const unsigned char * old_data, unsigned char * new_data);
1237
 
  int ha_delete_row(const unsigned char * buf);
 
1266
  int ha_write_row(uchar * buf);
 
1267
  int ha_update_row(const uchar * old_data, uchar * new_data);
 
1268
  int ha_delete_row(const uchar * buf);
1238
1269
  void ha_release_auto_increment();
1239
1270
 
1240
1271
  int ha_check_for_upgrade(HA_CHECK_OPT *check_opt);
1251
1282
    estimation_rows_to_insert= 0;
1252
1283
    return end_bulk_insert();
1253
1284
  }
1254
 
  int ha_bulk_update_row(const unsigned char *old_data, unsigned char *new_data,
1255
 
                         uint32_t *dup_key_found);
 
1285
  int ha_bulk_update_row(const uchar *old_data, uchar *new_data,
 
1286
                         uint *dup_key_found);
1256
1287
  int ha_delete_all_rows();
1257
1288
  int ha_reset_auto_increment(uint64_t value);
1258
1289
  int ha_optimize(THD* thd, HA_CHECK_OPT* check_opt);
1259
1290
  int ha_analyze(THD* thd, HA_CHECK_OPT* check_opt);
1260
1291
  bool ha_check_and_repair(THD *thd);
1261
 
  int ha_disable_indexes(uint32_t mode);
1262
 
  int ha_enable_indexes(uint32_t mode);
1263
 
  int ha_discard_or_import_tablespace(bool discard);
 
1292
  int ha_disable_indexes(uint mode);
 
1293
  int ha_enable_indexes(uint mode);
 
1294
  int ha_discard_or_import_tablespace(my_bool discard);
1264
1295
  void ha_prepare_for_alter();
1265
1296
  int ha_rename_table(const char *from, const char *to);
1266
1297
  int ha_delete_table(const char *name);
1267
1298
  void ha_drop_table(const char *name);
1268
1299
 
1269
 
  int ha_create(const char *name, Table *form, HA_CREATE_INFO *info);
 
1300
  int ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info);
1270
1301
 
1271
1302
  int ha_create_handler_files(const char *name, const char *old_name,
1272
1303
                              int action_flag, HA_CREATE_INFO *info);
1273
1304
 
1274
1305
  void adjust_next_insert_id_after_explicit_value(uint64_t nr);
1275
1306
  int update_auto_increment();
1276
 
  void print_keydup_error(uint32_t key_nr, const char *msg);
 
1307
  void print_keydup_error(uint key_nr, const char *msg);
1277
1308
  virtual void print_error(int error, myf errflag);
1278
1309
  virtual bool get_error_message(int error, String *buf);
1279
 
  uint32_t get_dup_key(int error);
1280
 
  virtual void change_table_ptr(Table *table_arg, TABLE_SHARE *share)
 
1310
  uint get_dup_key(int error);
 
1311
  virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share)
1281
1312
  {
1282
1313
    table= table_arg;
1283
1314
    table_share= share;
1284
1315
  }
1285
1316
  /* Estimates calculation */
1286
1317
  virtual double scan_time(void)
1287
 
  { return uint64_t2double(stats.data_file_length) / IO_SIZE + 2; }
1288
 
  virtual double read_time(uint32_t index __attribute__((unused)),
1289
 
                           uint32_t ranges, ha_rows rows)
 
1318
  { return ulonglong2double(stats.data_file_length) / IO_SIZE + 2; }
 
1319
  virtual double read_time(uint index __attribute__((__unused__)),
 
1320
                           uint ranges, ha_rows rows)
1290
1321
  { return rows2double(ranges+rows); }
1291
1322
 
1292
 
  virtual double index_only_read_time(uint32_t keynr, double records);
 
1323
  virtual double index_only_read_time(uint keynr, double records);
1293
1324
  
1294
 
  virtual ha_rows multi_range_read_info_const(uint32_t keyno, RANGE_SEQ_IF *seq,
 
1325
  virtual ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
1295
1326
                                              void *seq_init_param, 
1296
 
                                              uint32_t n_ranges, uint32_t *bufsz,
1297
 
                                              uint32_t *flags, COST_VECT *cost);
1298
 
  virtual int multi_range_read_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys,
1299
 
                                    uint32_t *bufsz, uint32_t *flags, COST_VECT *cost);
 
1327
                                              uint n_ranges, uint *bufsz,
 
1328
                                              uint *flags, COST_VECT *cost);
 
1329
  virtual int multi_range_read_info(uint keyno, uint n_ranges, uint keys,
 
1330
                                    uint *bufsz, uint *flags, COST_VECT *cost);
1300
1331
  virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
1301
 
                                    uint32_t n_ranges, uint32_t mode,
 
1332
                                    uint n_ranges, uint mode,
1302
1333
                                    HANDLER_BUFFER *buf);
1303
1334
  virtual int multi_range_read_next(char **range_info);
1304
1335
 
1306
1337
  virtual const key_map *keys_to_use_for_scanning() { return &key_map_empty; }
1307
1338
  bool has_transactions()
1308
1339
  { return (ha_table_flags() & HA_NO_TRANSACTIONS) == 0; }
1309
 
  virtual uint32_t extra_rec_buf_length() const { return 0; }
 
1340
  virtual uint extra_rec_buf_length() const { return 0; }
1310
1341
 
1311
1342
  /**
1312
1343
    This method is used to analyse the error to see whether the error
1318
1349
    same thing as HA_ERR_FOUND_DUP_KEY but can in some cases lead to
1319
1350
    a slightly different error message.
1320
1351
  */
1321
 
  virtual bool is_fatal_error(int error, uint32_t flags)
 
1352
  virtual bool is_fatal_error(int error, uint flags)
1322
1353
  {
1323
1354
    if (!error ||
1324
1355
        ((flags & HA_CHECK_DUP_KEY) &&
1348
1379
  */
1349
1380
  virtual enum row_type get_row_type() const { return ROW_TYPE_NOT_USED; }
1350
1381
 
1351
 
  virtual const char *index_type(uint32_t key_number __attribute__((unused)))
 
1382
  virtual const char *index_type(uint key_number __attribute__((__unused__)))
1352
1383
  { assert(0); return "";}
1353
1384
 
1354
1385
 
1360
1391
    as there may be several calls to this routine.
1361
1392
  */
1362
1393
  virtual void column_bitmaps_signal();
1363
 
  uint32_t get_index(void) const { return active_index; }
 
1394
  uint get_index(void) const { return active_index; }
1364
1395
  virtual int close(void)=0;
1365
1396
 
1366
1397
  /**
1384
1415
    @retval  0           Success
1385
1416
    @retval  >0          Error code
1386
1417
  */
1387
 
  virtual int exec_bulk_update(uint32_t *dup_key_found __attribute__((unused)))
 
1418
  virtual int exec_bulk_update(uint *dup_key_found __attribute__((__unused__)))
1388
1419
  {
1389
1420
    assert(false);
1390
1421
    return HA_ERR_WRONG_COMMAND;
1411
1442
     row if available. If the key value is null, begin at the first key of the
1412
1443
     index.
1413
1444
  */
1414
 
  virtual int index_read_map(unsigned char * buf, const unsigned char * key,
 
1445
  virtual int index_read_map(uchar * buf, const uchar * key,
1415
1446
                             key_part_map keypart_map,
1416
1447
                             enum ha_rkey_function find_flag)
1417
1448
  {
1418
 
    uint32_t key_len= calculate_key_len(table, active_index, key, keypart_map);
 
1449
    uint key_len= calculate_key_len(table, active_index, key, keypart_map);
1419
1450
    return  index_read(buf, key, key_len, find_flag);
1420
1451
  }
1421
1452
  /**
1424
1455
     row if available. If the key value is null, begin at the first key of the
1425
1456
     index.
1426
1457
  */
1427
 
  virtual int index_read_idx_map(unsigned char * buf, uint32_t index, const unsigned char * key,
 
1458
  virtual int index_read_idx_map(uchar * buf, uint index, const uchar * key,
1428
1459
                                 key_part_map keypart_map,
1429
1460
                                 enum ha_rkey_function find_flag);
1430
 
  virtual int index_next(unsigned char * buf __attribute__((unused)))
1431
 
   { return  HA_ERR_WRONG_COMMAND; }
1432
 
  virtual int index_prev(unsigned char * buf __attribute__((unused)))
1433
 
   { return  HA_ERR_WRONG_COMMAND; }
1434
 
  virtual int index_first(unsigned char * buf __attribute__((unused)))
1435
 
   { return  HA_ERR_WRONG_COMMAND; }
1436
 
  virtual int index_last(unsigned char * buf __attribute__((unused)))
1437
 
   { return  HA_ERR_WRONG_COMMAND; }
1438
 
  virtual int index_next_same(unsigned char *buf __attribute__((unused)),
1439
 
                              const unsigned char *key __attribute__((unused)),
1440
 
                              uint32_t keylen __attribute__((unused)));
 
1461
  virtual int index_next(uchar * buf __attribute__((__unused__)))
 
1462
   { return  HA_ERR_WRONG_COMMAND; }
 
1463
  virtual int index_prev(uchar * buf __attribute__((__unused__)))
 
1464
   { return  HA_ERR_WRONG_COMMAND; }
 
1465
  virtual int index_first(uchar * buf __attribute__((__unused__)))
 
1466
   { return  HA_ERR_WRONG_COMMAND; }
 
1467
  virtual int index_last(uchar * buf __attribute__((__unused__)))
 
1468
   { return  HA_ERR_WRONG_COMMAND; }
 
1469
  virtual int index_next_same(uchar *buf __attribute__((__unused__)),
 
1470
                              const uchar *key __attribute__((__unused__)),
 
1471
                              uint keylen __attribute__((__unused__)));
1441
1472
  /**
1442
1473
     @brief
1443
1474
     The following functions works like index_read, but it find the last
1444
1475
     row with the current key value or prefix.
1445
1476
  */
1446
 
  virtual int index_read_last_map(unsigned char * buf, const unsigned char * key,
 
1477
  virtual int index_read_last_map(uchar * buf, const uchar * key,
1447
1478
                                  key_part_map keypart_map)
1448
1479
  {
1449
 
    uint32_t key_len= calculate_key_len(table, active_index, key, keypart_map);
 
1480
    uint key_len= calculate_key_len(table, active_index, key, keypart_map);
1450
1481
    return index_read_last(buf, key, key_len);
1451
1482
  }
1452
1483
  virtual int read_range_first(const key_range *start_key,
1455
1486
  virtual int read_range_next();
1456
1487
  int compare_key(key_range *range);
1457
1488
  int compare_key2(key_range *range);
1458
 
  virtual int rnd_next(unsigned char *buf __attribute__((unused)))=0;
1459
 
  virtual int rnd_pos(unsigned char * buf __attribute__((unused)),
1460
 
                      unsigned char *pos __attribute__((unused)))=0;
 
1489
  virtual int rnd_next(uchar *buf __attribute__((__unused__)))=0;
 
1490
  virtual int rnd_pos(uchar * buf __attribute__((__unused__)),
 
1491
                      uchar *pos __attribute__((__unused__)))=0;
1461
1492
  /**
1462
1493
    One has to use this method when to find
1463
1494
    random position by record as the plain
1464
1495
    position() call doesn't work for some
1465
1496
    handlers for random position.
1466
1497
  */
1467
 
  virtual int rnd_pos_by_record(unsigned char *record);
1468
 
  virtual int read_first_row(unsigned char *buf, uint32_t primary_key);
 
1498
  virtual int rnd_pos_by_record(uchar *record);
 
1499
  virtual int read_first_row(uchar *buf, uint primary_key);
1469
1500
  /**
1470
1501
    The following function is only needed for tables that may be temporary
1471
1502
    tables during joins.
1472
1503
  */
1473
 
  virtual int restart_rnd_next(unsigned char *buf __attribute__((unused)),
1474
 
                               unsigned char *pos __attribute__((unused)))
1475
 
    { return HA_ERR_WRONG_COMMAND; }
1476
 
  virtual int rnd_same(unsigned char *buf __attribute__((unused)),
1477
 
                       uint32_t inx __attribute__((unused)))
1478
 
    { return HA_ERR_WRONG_COMMAND; }
1479
 
  virtual ha_rows records_in_range(uint32_t inx __attribute__((unused)),
1480
 
                                   key_range *min_key __attribute__((unused)),
1481
 
                                   key_range *max_key __attribute__((unused)))
 
1504
  virtual int restart_rnd_next(uchar *buf __attribute__((__unused__)),
 
1505
                               uchar *pos __attribute__((__unused__)))
 
1506
    { return HA_ERR_WRONG_COMMAND; }
 
1507
  virtual int rnd_same(uchar *buf __attribute__((__unused__)),
 
1508
                       uint inx __attribute__((__unused__)))
 
1509
    { return HA_ERR_WRONG_COMMAND; }
 
1510
  virtual ha_rows records_in_range(uint inx __attribute__((__unused__)),
 
1511
                                   key_range *min_key __attribute__((__unused__)),
 
1512
                                   key_range *max_key __attribute__((__unused__)))
1482
1513
    { return (ha_rows) 10; }
1483
 
  virtual void position(const unsigned char *record)=0;
 
1514
  virtual void position(const uchar *record)=0;
1484
1515
  virtual int info(uint)=0; // see my_base.h for full description
1485
 
  virtual uint32_t calculate_key_hash_value(Field **field_array __attribute__((unused)))
 
1516
  virtual uint32 calculate_key_hash_value(Field **field_array __attribute__((__unused__)))
1486
1517
  { assert(0); return 0; }
1487
 
  virtual int extra(enum ha_extra_function operation __attribute__((unused)))
 
1518
  virtual int extra(enum ha_extra_function operation __attribute__((__unused__)))
1488
1519
  { return 0; }
1489
1520
  virtual int extra_opt(enum ha_extra_function operation,
1490
 
                        uint32_t cache_size __attribute__((unused)))
 
1521
                        uint32_t cache_size __attribute__((__unused__)))
1491
1522
  { return extra(operation); }
1492
1523
 
1493
1524
  /**
1511
1542
  */
1512
1543
  virtual void try_semi_consistent_read(bool) {}
1513
1544
  virtual void unlock_row(void) {}
1514
 
  virtual int start_stmt(THD *thd __attribute__((unused)),
1515
 
                         thr_lock_type lock_type __attribute__((unused)))
 
1545
  virtual int start_stmt(THD *thd __attribute__((__unused__)),
 
1546
                         thr_lock_type lock_type __attribute__((__unused__)))
1516
1547
  {return 0;}
1517
1548
  virtual void get_auto_increment(uint64_t offset, uint64_t increment,
1518
1549
                                  uint64_t nb_desired_values,
1538
1569
      insert_id_for_cur_row;
1539
1570
  }
1540
1571
 
1541
 
  virtual void update_create_info(HA_CREATE_INFO *create_info __attribute__((unused))) {}
 
1572
  virtual void update_create_info(HA_CREATE_INFO *create_info __attribute__((__unused__))) {}
1542
1573
  int check_old_types(void);
1543
 
  virtual int assign_to_keycache(THD* thd __attribute__((unused)),
1544
 
                                 HA_CHECK_OPT* check_opt __attribute__((unused)))
 
1574
  virtual int assign_to_keycache(THD* thd __attribute__((__unused__)),
 
1575
                                 HA_CHECK_OPT* check_opt __attribute__((__unused__)))
1545
1576
  { return HA_ADMIN_NOT_IMPLEMENTED; }
1546
1577
  /* end of the list of admin commands */
1547
1578
 
1548
1579
  virtual int indexes_are_disabled(void) {return 0;}
1549
1580
  virtual char *update_table_comment(const char * comment)
1550
1581
  { return (char*) comment;}
1551
 
  virtual void append_create_info(String *packet __attribute__((unused)))
 
1582
  virtual void append_create_info(String *packet __attribute__((__unused__)))
1552
1583
  {}
1553
1584
  /**
1554
1585
      If index == MAX_KEY then a check for table is made and if index <
1560
1591
    @retval   true            Foreign key defined on table or index
1561
1592
    @retval   false           No foreign key defined
1562
1593
  */
1563
 
  virtual bool is_fk_defined_on_table_or_index(uint32_t index __attribute__((unused)))
 
1594
  virtual bool is_fk_defined_on_table_or_index(uint index __attribute__((__unused__)))
1564
1595
  { return false; }
1565
1596
  virtual char* get_foreign_key_create_info(void)
1566
1597
  { return(NULL);}  /* gets foreign key create string from InnoDB */
1567
 
  /** used in ALTER Table; 1 if changing storage engine is allowed */
 
1598
  /** used in ALTER TABLE; 1 if changing storage engine is allowed */
1568
1599
  virtual bool can_switch_engines(void) { return 1; }
1569
1600
  /** used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */
1570
 
  virtual int get_foreign_key_list(THD *thd __attribute__((unused)),
1571
 
                                   List<FOREIGN_KEY_INFO> *f_key_list __attribute__((unused)))
 
1601
  virtual int get_foreign_key_list(THD *thd __attribute__((__unused__)),
 
1602
                                   List<FOREIGN_KEY_INFO> *f_key_list __attribute__((__unused__)))
1572
1603
  { return 0; }
1573
 
  virtual uint32_t referenced_by_foreign_key() { return 0;}
 
1604
  virtual uint referenced_by_foreign_key() { return 0;}
1574
1605
  virtual void init_table_handle_for_HANDLER()
1575
1606
  { return; }       /* prepare InnoDB for HANDLER */
1576
 
  virtual void free_foreign_key_create_info(char* str __attribute__((unused))) {}
 
1607
  virtual void free_foreign_key_create_info(char* str __attribute__((__unused__))) {}
1577
1608
  /** The following can be called without an open handler */
1578
1609
  virtual const char *table_type() const =0;
1579
1610
  /**
1585
1616
    and data file), the order of elements is relevant. First element of engine
1586
1617
    file name extentions array should be meta/index file extention. Second
1587
1618
    element - data file extention. This order is assumed by
1588
 
    prepare_for_repair() when REPAIR Table ... USE_FRM is issued.
 
1619
    prepare_for_repair() when REPAIR TABLE ... USE_FRM is issued.
1589
1620
  */
1590
1621
  virtual const char **bas_ext() const =0;
1591
1622
 
1592
 
  virtual int get_default_no_partitions(HA_CREATE_INFO *info __attribute__((unused))) { return 1;}
1593
 
  virtual bool get_no_parts(const char *name __attribute__((unused)),
1594
 
                            uint32_t *no_parts)
 
1623
  virtual int get_default_no_partitions(HA_CREATE_INFO *info __attribute__((__unused__))) { return 1;}
 
1624
  virtual bool get_no_parts(const char *name __attribute__((__unused__)),
 
1625
                            uint *no_parts)
1595
1626
  {
1596
1627
    *no_parts= 0;
1597
1628
    return 0;
1598
1629
  }
1599
1630
 
1600
 
  virtual uint32_t index_flags(uint32_t idx, uint32_t part, bool all_parts) const =0;
1601
 
 
1602
 
  virtual int add_index(Table *table_arg __attribute__((unused)),
1603
 
                        KEY *key_info __attribute__((unused)),
1604
 
                        uint32_t num_of_keys __attribute__((unused)))
1605
 
  { return (HA_ERR_WRONG_COMMAND); }
1606
 
  virtual int prepare_drop_index(Table *table_arg __attribute__((unused)),
1607
 
                                 uint32_t *key_num __attribute__((unused)),
1608
 
                                 uint32_t num_of_keys __attribute__((unused)))
1609
 
  { return (HA_ERR_WRONG_COMMAND); }
1610
 
  virtual int final_drop_index(Table *table_arg __attribute__((unused)))
1611
 
  { return (HA_ERR_WRONG_COMMAND); }
1612
 
 
1613
 
  uint32_t max_record_length() const
1614
 
  { return cmin((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); }
1615
 
  uint32_t max_keys() const
1616
 
  { return cmin((unsigned int)MAX_KEY, max_supported_keys()); }
1617
 
  uint32_t max_key_parts() const
1618
 
  { return cmin((unsigned int)MAX_REF_PARTS, max_supported_key_parts()); }
1619
 
  uint32_t max_key_length() const
1620
 
  { return cmin((unsigned int)MAX_KEY_LENGTH, max_supported_key_length()); }
1621
 
  uint32_t max_key_part_length(void) const
1622
 
  { return cmin((unsigned int)MAX_KEY_LENGTH, max_supported_key_part_length()); }
1623
 
 
1624
 
  virtual uint32_t max_supported_record_length(void) const
 
1631
  virtual uint32_t index_flags(uint idx, uint part, bool all_parts) const =0;
 
1632
 
 
1633
  virtual int add_index(TABLE *table_arg __attribute__((__unused__)),
 
1634
                        KEY *key_info __attribute__((__unused__)),
 
1635
                        uint num_of_keys __attribute__((__unused__)))
 
1636
  { return (HA_ERR_WRONG_COMMAND); }
 
1637
  virtual int prepare_drop_index(TABLE *table_arg __attribute__((__unused__)),
 
1638
                                 uint *key_num __attribute__((__unused__)),
 
1639
                                 uint num_of_keys __attribute__((__unused__)))
 
1640
  { return (HA_ERR_WRONG_COMMAND); }
 
1641
  virtual int final_drop_index(TABLE *table_arg __attribute__((__unused__)))
 
1642
  { return (HA_ERR_WRONG_COMMAND); }
 
1643
 
 
1644
  uint max_record_length() const
 
1645
  { return min(HA_MAX_REC_LENGTH, max_supported_record_length()); }
 
1646
  uint max_keys() const
 
1647
  { return min(MAX_KEY, max_supported_keys()); }
 
1648
  uint max_key_parts() const
 
1649
  { return min(MAX_REF_PARTS, max_supported_key_parts()); }
 
1650
  uint max_key_length() const
 
1651
  { return min(MAX_KEY_LENGTH, max_supported_key_length()); }
 
1652
  uint max_key_part_length(void) const
 
1653
  { return min(MAX_KEY_LENGTH, max_supported_key_part_length()); }
 
1654
 
 
1655
  virtual uint max_supported_record_length(void) const
1625
1656
  { return HA_MAX_REC_LENGTH; }
1626
 
  virtual uint32_t max_supported_keys(void) const { return 0; }
1627
 
  virtual uint32_t max_supported_key_parts(void) const { return MAX_REF_PARTS; }
1628
 
  virtual uint32_t max_supported_key_length(void) const { return MAX_KEY_LENGTH; }
1629
 
  virtual uint32_t max_supported_key_part_length(void) const { return 255; }
1630
 
  virtual uint32_t min_record_length(uint32_t options __attribute__((unused))) const
 
1657
  virtual uint max_supported_keys(void) const { return 0; }
 
1658
  virtual uint max_supported_key_parts(void) const { return MAX_REF_PARTS; }
 
1659
  virtual uint max_supported_key_length(void) const { return MAX_KEY_LENGTH; }
 
1660
  virtual uint max_supported_key_part_length(void) const { return 255; }
 
1661
  virtual uint min_record_length(uint options __attribute__((__unused__))) const
1631
1662
  { return 1; }
1632
1663
 
1633
1664
  virtual bool low_byte_first(void) const { return 1; }
1634
 
  virtual uint32_t checksum(void) const { return 0; }
 
1665
  virtual uint checksum(void) const { return 0; }
1635
1666
  virtual bool is_crashed(void) const  { return 0; }
1636
1667
  virtual bool auto_repair(void) const { return 0; }
1637
1668
 
1644
1675
  /**
1645
1676
    @note lock_count() can return > 1 if the table is MERGE or partitioned.
1646
1677
  */
1647
 
  virtual uint32_t lock_count(void) const { return 1; }
 
1678
  virtual uint lock_count(void) const { return 1; }
1648
1679
  /**
1649
1680
    Is not invoked for non-transactional temporary tables.
1650
1681
 
1663
1694
                                     enum thr_lock_type lock_type)=0;
1664
1695
 
1665
1696
  /** Type of table for caching query */
1666
 
  virtual uint8_t table_cache_type() { return HA_CACHE_TBL_NONTRANSACT; }
 
1697
  virtual uint8 table_cache_type() { return HA_CACHE_TBL_NONTRANSACT; }
1667
1698
 
1668
1699
 
1669
1700
  /**
1696
1727
        cached
1697
1728
  */
1698
1729
 
1699
 
  virtual bool
1700
 
    register_query_cache_table(THD *thd __attribute__((unused)),
1701
 
                               char *table_key __attribute__((unused)),
1702
 
                               uint32_t key_length __attribute__((unused)),
 
1730
  virtual my_bool
 
1731
    register_query_cache_table(THD *thd __attribute__((__unused__)),
 
1732
                               char *table_key __attribute__((__unused__)),
 
1733
                               uint key_length __attribute__((__unused__)),
1703
1734
                               qc_engine_callback *engine_callback,
1704
 
                               uint64_t *engine_data __attribute__((unused)))
 
1735
                               uint64_t *engine_data __attribute__((__unused__)))
1705
1736
  {
1706
1737
    *engine_callback= 0;
1707
1738
    return true;
1714
1745
   @retval false  otherwise
1715
1746
 */
1716
1747
 virtual bool primary_key_is_clustered() { return false; }
1717
 
 virtual int cmp_ref(const unsigned char *ref1, const unsigned char *ref2)
 
1748
 virtual int cmp_ref(const uchar *ref1, const uchar *ref2)
1718
1749
 {
1719
1750
   return memcmp(ref1, ref2, ref_length);
1720
1751
 }
1755
1786
 virtual void cond_pop(void) { return; }
1756
1787
 
1757
1788
 virtual Item
1758
 
   *idx_cond_push(uint32_t keyno __attribute__((unused)),
1759
 
                  Item* idx_cond __attribute__((unused)))
 
1789
   *idx_cond_push(uint keyno __attribute__((__unused__)),
 
1790
                  Item* idx_cond __attribute__((__unused__)))
1760
1791
 { return idx_cond; }
1761
1792
 
1762
1793
 /*
1763
1794
    Part of old fast alter table, to be depricated
1764
1795
  */
1765
1796
 virtual bool
1766
 
   check_if_incompatible_data(HA_CREATE_INFO *create_info __attribute__((unused)),
1767
 
                              uint32_t table_changes __attribute__((unused)))
 
1797
   check_if_incompatible_data(HA_CREATE_INFO *create_info __attribute__((__unused__)),
 
1798
                              uint table_changes __attribute__((__unused__)))
1768
1799
 { return COMPATIBLE_DATA_NO; }
1769
1800
 
1770
 
 /* On-line ALTER Table interface */
 
1801
 /* On-line ALTER TABLE interface */
1771
1802
 
1772
1803
 /**
1773
1804
    Check if a storage engine supports a particular alter table on-line
1793
1824
      implementation.
1794
1825
 */
1795
1826
 virtual int
1796
 
   check_if_supported_alter(Table *altered_table __attribute__((unused)),
 
1827
   check_if_supported_alter(TABLE *altered_table __attribute__((__unused__)),
1797
1828
                            HA_CREATE_INFO *create_info,
1798
 
                            HA_ALTER_FLAGS *alter_flags __attribute__((unused)),
1799
 
                            uint32_t table_changes)
 
1829
                            HA_ALTER_FLAGS *alter_flags __attribute__((__unused__)),
 
1830
                            uint table_changes)
1800
1831
 {
1801
1832
   if (this->check_if_incompatible_data(create_info, table_changes)
1802
1833
       == COMPATIBLE_DATA_NO)
1803
1834
     return(HA_ALTER_NOT_SUPPORTED);
1804
 
   else if ((*alter_flags & HA_ALTER_STORED_VCOL).is_set())
1805
 
     return(HA_ALTER_NOT_SUPPORTED);
1806
1835
   else
1807
1836
     return(HA_ALTER_SUPPORTED_WAIT_LOCK);
1808
1837
 }
1819
1848
   @retval   0      OK
1820
1849
   @retval   error  error code passed from storage engine
1821
1850
 */
1822
 
 virtual int alter_table_phase1(THD *thd __attribute__((unused)),
1823
 
                                Table *altered_table __attribute__((unused)),
1824
 
                                HA_CREATE_INFO *create_info __attribute__((unused)),
1825
 
                                HA_ALTER_INFO *alter_info __attribute__((unused)),
1826
 
                                HA_ALTER_FLAGS *alter_flags  __attribute__((unused)))
 
1851
 virtual int alter_table_phase1(THD *thd __attribute__((__unused__)),
 
1852
                                TABLE *altered_table __attribute__((__unused__)),
 
1853
                                HA_CREATE_INFO *create_info __attribute__((__unused__)),
 
1854
                                HA_ALTER_INFO *alter_info __attribute__((__unused__)),
 
1855
                                HA_ALTER_FLAGS *alter_flags  __attribute__((__unused__)))
1827
1856
 {
1828
1857
   return HA_ERR_UNSUPPORTED;
1829
1858
 }
1845
1874
      this call is to be wrapped with a DDL lock. This is currently NOT
1846
1875
      supported.
1847
1876
 */
1848
 
 virtual int alter_table_phase2(THD *thd  __attribute__((unused)),
1849
 
                                Table *altered_table  __attribute__((unused)),
1850
 
                                HA_CREATE_INFO *create_info __attribute__((unused)),
1851
 
                                HA_ALTER_INFO *alter_info __attribute__((unused)),
1852
 
                                HA_ALTER_FLAGS *alter_flags __attribute__((unused)))
 
1877
 virtual int alter_table_phase2(THD *thd  __attribute__((__unused__)),
 
1878
                                TABLE *altered_table  __attribute__((__unused__)),
 
1879
                                HA_CREATE_INFO *create_info __attribute__((__unused__)),
 
1880
                                HA_ALTER_INFO *alter_info __attribute__((__unused__)),
 
1881
                                HA_ALTER_FLAGS *alter_flags __attribute__((__unused__)))
1853
1882
 {
1854
1883
   return HA_ERR_UNSUPPORTED;
1855
1884
 }
1860
1889
    @param    thd               The thread handle
1861
1890
    @param    table             The altered table, re-opened
1862
1891
 */
1863
 
 virtual int alter_table_phase3(THD *thd __attribute__((unused)),
1864
 
                                Table *table __attribute__((unused)))
 
1892
 virtual int alter_table_phase3(THD *thd __attribute__((__unused__)),
 
1893
                                TABLE *table __attribute__((__unused__)))
1865
1894
 {
1866
1895
   return HA_ERR_UNSUPPORTED;
1867
1896
 }
1903
1932
  {
1904
1933
    return HA_ERR_WRONG_COMMAND;
1905
1934
  }
1906
 
  /*
1907
 
    This procedure defines if the storage engine supports virtual columns.
1908
 
    Default false means "not supported".
1909
 
  */
1910
 
  virtual bool check_if_supported_virtual_columns(void) 
1911
 
  { return false; }
1912
1935
 
1913
1936
protected:
1914
1937
  /* Service methods for use by storage engines. */
1940
1963
    the corresponding 'ha_*' method above.
1941
1964
  */
1942
1965
 
1943
 
  virtual int open(const char *name, int mode, uint32_t test_if_locked)=0;
1944
 
  virtual int index_init(uint32_t idx,
1945
 
                         bool sorted __attribute__((unused)))
 
1966
  virtual int open(const char *name, int mode, uint test_if_locked)=0;
 
1967
  virtual int index_init(uint idx,
 
1968
                         bool sorted __attribute__((__unused__)))
1946
1969
  { active_index= idx; return 0; }
1947
1970
  virtual int index_end() { active_index= MAX_KEY; return 0; }
1948
1971
  /**
1954
1977
  */
1955
1978
  virtual int rnd_init(bool scan)= 0;
1956
1979
  virtual int rnd_end() { return 0; }
1957
 
  virtual int write_row(unsigned char *buf __attribute__((unused)))
1958
 
  {
1959
 
    return HA_ERR_WRONG_COMMAND;
1960
 
  }
1961
 
 
1962
 
  virtual int update_row(const unsigned char *old_data __attribute__((unused)),
1963
 
                         unsigned char *new_data __attribute__((unused)))
1964
 
  {
1965
 
    return HA_ERR_WRONG_COMMAND;
1966
 
  }
1967
 
 
1968
 
  virtual int delete_row(const unsigned char *buf __attribute__((unused)))
 
1980
  virtual int write_row(uchar *buf __attribute__((unused)))
 
1981
  {
 
1982
    return HA_ERR_WRONG_COMMAND;
 
1983
  }
 
1984
 
 
1985
  virtual int update_row(const uchar *old_data __attribute__((unused)),
 
1986
                         uchar *new_data __attribute__((unused)))
 
1987
  {
 
1988
    return HA_ERR_WRONG_COMMAND;
 
1989
  }
 
1990
 
 
1991
  virtual int delete_row(const uchar *buf __attribute__((unused)))
1969
1992
  {
1970
1993
    return HA_ERR_WRONG_COMMAND;
1971
1994
  }
2006
2029
  }
2007
2030
  virtual void release_auto_increment(void) { return; };
2008
2031
  /** admin commands - called from mysql_admin_table */
2009
 
  virtual int check_for_upgrade(HA_CHECK_OPT *check_opt __attribute__((unused)))
 
2032
  virtual int check_for_upgrade(HA_CHECK_OPT *check_opt __attribute__((__unused__)))
2010
2033
  { return 0; }
2011
 
  virtual int check(THD* thd __attribute__((unused)),
2012
 
                    HA_CHECK_OPT* check_opt __attribute__((unused)))
 
2034
  virtual int check(THD* thd __attribute__((__unused__)),
 
2035
                    HA_CHECK_OPT* check_opt __attribute__((__unused__)))
2013
2036
  { return HA_ADMIN_NOT_IMPLEMENTED; }
2014
2037
 
2015
2038
  /**
2017
2040
     to specify CHECK option to use to call check()
2018
2041
     upon the table.
2019
2042
  */
2020
 
  virtual int repair(THD* thd __attribute__((unused)),
2021
 
                     HA_CHECK_OPT* check_opt __attribute__((unused)))
 
2043
  virtual int repair(THD* thd __attribute__((__unused__)),
 
2044
                     HA_CHECK_OPT* check_opt __attribute__((__unused__)))
2022
2045
  { return HA_ADMIN_NOT_IMPLEMENTED; }
2023
 
  virtual void start_bulk_insert(ha_rows rows __attribute__((unused)))
 
2046
  virtual void start_bulk_insert(ha_rows rows __attribute__((__unused__)))
2024
2047
  {}
2025
2048
  virtual int end_bulk_insert(void) { return 0; }
2026
 
  virtual int index_read(unsigned char * buf __attribute__((unused)),
2027
 
                         const unsigned char * key __attribute__((unused)),
2028
 
                         uint32_t key_len __attribute__((unused)),
2029
 
                         enum ha_rkey_function find_flag __attribute__((unused)))
 
2049
  virtual int index_read(uchar * buf __attribute__((__unused__)),
 
2050
                         const uchar * key __attribute__((__unused__)),
 
2051
                         uint key_len __attribute__((__unused__)),
 
2052
                         enum ha_rkey_function find_flag __attribute__((__unused__)))
2030
2053
   { return  HA_ERR_WRONG_COMMAND; }
2031
 
  virtual int index_read_last(unsigned char * buf __attribute__((unused)),
2032
 
                              const unsigned char * key __attribute__((unused)),
2033
 
                              uint32_t key_len __attribute__((unused)))
 
2054
  virtual int index_read_last(uchar * buf __attribute__((__unused__)),
 
2055
                              const uchar * key __attribute__((__unused__)),
 
2056
                              uint key_len __attribute__((__unused__)))
2034
2057
   { return (my_errno= HA_ERR_WRONG_COMMAND); }
2035
2058
  /**
2036
2059
    This method is similar to update_row, however the handler doesn't need
2045
2068
    @retval  0   Bulk delete used by handler
2046
2069
    @retval  1   Bulk delete not used, normal operation used
2047
2070
  */
2048
 
  virtual int bulk_update_row(const unsigned char *old_data __attribute__((unused)),
2049
 
                              unsigned char *new_data __attribute__((unused)),
2050
 
                              uint32_t *dup_key_found __attribute__((unused)))
 
2071
  virtual int bulk_update_row(const uchar *old_data __attribute__((__unused__)),
 
2072
                              uchar *new_data __attribute__((__unused__)),
 
2073
                              uint *dup_key_found __attribute__((__unused__)))
2051
2074
  {
2052
2075
    assert(false);
2053
2076
    return HA_ERR_WRONG_COMMAND;
2066
2089
    is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
2067
2090
    returned by storage engines that don't support this operation.
2068
2091
  */
2069
 
  virtual int reset_auto_increment(uint64_t value __attribute__((unused)))
 
2092
  virtual int reset_auto_increment(uint64_t value __attribute__((__unused__)))
2070
2093
  { return HA_ERR_WRONG_COMMAND; }
2071
 
  virtual int optimize(THD* thd __attribute__((unused)),
2072
 
                       HA_CHECK_OPT* check_opt __attribute__((unused)))
2073
 
  { return HA_ADMIN_NOT_IMPLEMENTED; }
2074
 
  virtual int analyze(THD* thd __attribute__((unused)),
2075
 
                      HA_CHECK_OPT* check_opt __attribute__((unused)))
2076
 
  { return HA_ADMIN_NOT_IMPLEMENTED; }
2077
 
  virtual bool check_and_repair(THD *thd __attribute__((unused)))
 
2094
  virtual int optimize(THD* thd __attribute__((__unused__)),
 
2095
                       HA_CHECK_OPT* check_opt __attribute__((__unused__)))
 
2096
  { return HA_ADMIN_NOT_IMPLEMENTED; }
 
2097
  virtual int analyze(THD* thd __attribute__((__unused__)),
 
2098
                      HA_CHECK_OPT* check_opt __attribute__((__unused__)))
 
2099
  { return HA_ADMIN_NOT_IMPLEMENTED; }
 
2100
  virtual bool check_and_repair(THD *thd __attribute__((__unused__)))
2078
2101
  { return true; }
2079
 
  virtual int disable_indexes(uint32_t mode __attribute__((unused)))
2080
 
  { return HA_ERR_WRONG_COMMAND; }
2081
 
  virtual int enable_indexes(uint32_t mode __attribute__((unused)))
2082
 
  { return HA_ERR_WRONG_COMMAND; }
2083
 
  virtual int discard_or_import_tablespace(bool discard __attribute__((unused)))
 
2102
  virtual int disable_indexes(uint mode __attribute__((__unused__)))
 
2103
  { return HA_ERR_WRONG_COMMAND; }
 
2104
  virtual int enable_indexes(uint mode __attribute__((__unused__)))
 
2105
  { return HA_ERR_WRONG_COMMAND; }
 
2106
  virtual int discard_or_import_tablespace(my_bool discard __attribute__((__unused__)))
2084
2107
  { return (my_errno=HA_ERR_WRONG_COMMAND); }
2085
2108
  virtual void prepare_for_alter(void) { return; }
2086
2109
  virtual void drop_table(const char *name);
2087
 
  virtual int create(const char *name __attribute__((unused)),
2088
 
                     Table *form __attribute__((unused)),
2089
 
                     HA_CREATE_INFO *info __attribute__((unused)))=0;
 
2110
  virtual int create(const char *name __attribute__((__unused__)),
 
2111
                     TABLE *form __attribute__((__unused__)),
 
2112
                     HA_CREATE_INFO *info __attribute__((__unused__)))=0;
2090
2113
 
2091
 
  virtual int create_handler_files(const char *name __attribute__((unused)),
2092
 
                                   const char *old_name __attribute__((unused)),
2093
 
                                   int action_flag __attribute__((unused)),
2094
 
                                   HA_CREATE_INFO *info __attribute__((unused)))
 
2114
  virtual int create_handler_files(const char *name __attribute__((__unused__)),
 
2115
                                   const char *old_name __attribute__((__unused__)),
 
2116
                                   int action_flag __attribute__((__unused__)),
 
2117
                                   HA_CREATE_INFO *info __attribute__((__unused__)))
2095
2118
  { return false; }
2096
2119
};
2097
2120
 
2116
2139
    : h2(NULL) {};
2117
2140
 
2118
2141
  handler *h; /* The "owner" handler object. It is used for scanning the index */
2119
 
  Table *table; /* Always equal to h->table */
 
2142
  TABLE *table; /* Always equal to h->table */
2120
2143
private:
2121
2144
  /*
2122
2145
    Secondary handler object. It is used to retrieve full table rows by
2125
2148
  handler *h2;
2126
2149
 
2127
2150
  /* Buffer to store rowids, or (rowid, range_id) pairs */
2128
 
  unsigned char *rowids_buf;
2129
 
  unsigned char *rowids_buf_cur;   /* Current position when reading/writing */
2130
 
  unsigned char *rowids_buf_last;  /* When reading: end of used buffer space */
2131
 
  unsigned char *rowids_buf_end;   /* End of the buffer */
 
2151
  uchar *rowids_buf;
 
2152
  uchar *rowids_buf_cur;   /* Current position when reading/writing */
 
2153
  uchar *rowids_buf_last;  /* When reading: end of used buffer space */
 
2154
  uchar *rowids_buf_end;   /* End of the buffer */
2132
2155
 
2133
2156
  bool dsmrr_eof; /* true <=> We have reached EOF when reading index tuples */
2134
2157
 
2137
2160
 
2138
2161
  bool use_default_impl; /* true <=> shortcut all calls to default MRR impl */
2139
2162
public:
2140
 
  void init(handler *h_arg, Table *table_arg)
 
2163
  void init(handler *h_arg, TABLE *table_arg)
2141
2164
  {
2142
2165
    h= h_arg; 
2143
2166
    table= table_arg;
2144
2167
  }
2145
2168
  int dsmrr_init(handler *h, KEY *key, RANGE_SEQ_IF *seq_funcs, 
2146
 
                 void *seq_init_param, uint32_t n_ranges, uint32_t mode, 
 
2169
                 void *seq_init_param, uint n_ranges, uint mode, 
2147
2170
                 HANDLER_BUFFER *buf);
2148
2171
  void dsmrr_close();
2149
2172
  int dsmrr_fill_buffer(handler *h);
2150
2173
  int dsmrr_next(handler *h, char **range_info);
2151
2174
 
2152
 
  int dsmrr_info(uint32_t keyno, uint32_t n_ranges, uint32_t keys, uint32_t *bufsz,
2153
 
                 uint32_t *flags, COST_VECT *cost);
 
2175
  int dsmrr_info(uint keyno, uint n_ranges, uint keys, uint *bufsz,
 
2176
                 uint *flags, COST_VECT *cost);
2154
2177
 
2155
 
  ha_rows dsmrr_info_const(uint32_t keyno, RANGE_SEQ_IF *seq, 
2156
 
                            void *seq_init_param, uint32_t n_ranges, uint32_t *bufsz,
2157
 
                            uint32_t *flags, COST_VECT *cost);
 
2178
  ha_rows dsmrr_info_const(uint keyno, RANGE_SEQ_IF *seq, 
 
2179
                            void *seq_init_param, uint n_ranges, uint *bufsz,
 
2180
                            uint *flags, COST_VECT *cost);
2158
2181
private:
2159
 
  bool key_uses_partial_cols(uint32_t keyno);
2160
 
  bool choose_mrr_impl(uint32_t keyno, ha_rows rows, uint32_t *flags, uint32_t *bufsz, 
 
2182
  bool key_uses_partial_cols(uint keyno);
 
2183
  bool choose_mrr_impl(uint keyno, ha_rows rows, uint *flags, uint *bufsz, 
2161
2184
                       COST_VECT *cost);
2162
 
  bool get_disk_sweep_mrr_cost(uint32_t keynr, ha_rows rows, uint32_t flags, 
2163
 
                               uint32_t *buffer_size, COST_VECT *cost);
 
2185
  bool get_disk_sweep_mrr_cost(uint keynr, ha_rows rows, uint flags, 
 
2186
                               uint *buffer_size, COST_VECT *cost);
2164
2187
};
2165
2188
 
2166
2189
extern const char *ha_row_type[];
2195
2218
  return db_type == NULL ? "UNKNOWN" : hton2plugin[db_type->slot]->name.str;
2196
2219
}
2197
2220
 
2198
 
static inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32_t flag)
 
2221
static inline bool ha_check_storage_engine_flag(const handlerton *db_type, uint32 flag)
2199
2222
{
2200
2223
  return db_type == NULL ? false : test(db_type->flags & flag);
2201
2224
}
2214
2237
int ha_finalize_handlerton(st_plugin_int *plugin);
2215
2238
 
2216
2239
TYPELIB *ha_known_exts(void);
 
2240
int ha_panic(enum ha_panic_function flag);
2217
2241
void ha_close_connection(THD* thd);
2218
2242
bool ha_flush_logs(handlerton *db_type);
2219
2243
void ha_drop_database(char* path);
2230
2254
/* discovery */
2231
2255
int ha_create_table_from_engine(THD* thd, const char *db, const char *name);
2232
2256
int ha_discover(THD* thd, const char* dbname, const char* name,
2233
 
                unsigned char** frmblob, size_t* frmlen);
 
2257
                uchar** frmblob, size_t* frmlen);
2234
2258
int ha_find_files(THD *thd,const char *db,const char *path,
2235
2259
                  const char *wild, bool dir, List<LEX_STRING>* files);
2236
2260
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name);
2273
2297
*/
2274
2298
#define trans_need_2pc(thd, all)                   ((total_ha_2pc > 1) && \
2275
2299
        !((all ? &thd->transaction.all : &thd->transaction.stmt)->no_2pc))
 
2300
 
 
2301
#ifdef HAVE_NDB_BINLOG
 
2302
int ha_reset_logs(THD *thd);
 
2303
int ha_binlog_index_purge_file(THD *thd, const char *file);
 
2304
void ha_reset_slave(THD *thd);
 
2305
void ha_binlog_log_query(THD *thd, handlerton *db_type,
 
2306
                         enum_binlog_command binlog_command,
 
2307
                         const char *query, uint query_length,
 
2308
                         const char *db, const char *table_name);
 
2309
void ha_binlog_wait(THD *thd);
 
2310
int ha_binlog_end(THD *thd);
 
2311
#else
 
2312
#define ha_reset_logs(a) do {} while (0)
 
2313
#define ha_binlog_index_purge_file(a,b) do {} while (0)
 
2314
#define ha_reset_slave(a) do {} while (0)
 
2315
#define ha_binlog_log_query(a,b,c,d,e,f,g) do {} while (0)
 
2316
#define ha_binlog_wait(a) do {} while (0)
 
2317
#define ha_binlog_end(a)  do {} while (0)
 
2318
#endif