1/* -*- c-basic-offset: 2; indent-tabs-mode: nil -*- */
2/*
3 Copyright(C) 2010 Tetsuro IKEDA
4 Copyright(C) 2010-2013 Kentoku SHIBA
5 Copyright(C) 2011-2013 Kouhei Sutou <kou@clear-code.com>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
22#ifndef HA_MROONGA_HPP_
23#define HA_MROONGA_HPP_
24
25#ifdef USE_PRAGMA_INTERFACE
26#pragma interface
27#endif
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <groonga.h>
34#include "mrn_mysql_compat.h"
35#include <mrn_operations.hpp>
36#include <mrn_database.hpp>
37
38#if __cplusplus >= 201402
39# define mrn_override override
40#else
41# define mrn_override
42#endif
43
44#if (MYSQL_VERSION_ID >= 50514 && MYSQL_VERSION_ID < 50600)
45# define MRN_HANDLER_HAVE_FINAL_ADD_INDEX 1
46#endif
47
48#if (MYSQL_VERSION_ID >= 50603) || defined(MRN_MARIADB_P)
49# define MRN_HANDLER_HAVE_HA_RND_NEXT 1
50# define MRN_HANDLER_HAVE_HA_RND_POS 1
51# define MRN_HANDLER_HAVE_HA_INDEX_READ_MAP 1
52# define MRN_HANDLER_HAVE_HA_INDEX_READ_IDX_MAP 1
53# define MRN_HANDLER_HAVE_HA_INDEX_NEXT 1
54# define MRN_HANDLER_HAVE_HA_INDEX_PREV 1
55# define MRN_HANDLER_HAVE_HA_INDEX_FIRST 1
56# define MRN_HANDLER_HAVE_HA_INDEX_LAST 1
57# define MRN_HANDLER_HAVE_HA_INDEX_NEXT_SAME 1
58#endif
59
60#if (MYSQL_VERSION_ID >= 50604) || defined(MRN_MARIADB_P)
61# define MRN_HANDLER_HAVE_HA_CLOSE 1
62# define MRN_HANDLER_HAVE_MULTI_RANGE_READ 1
63#endif
64
65#if (MYSQL_VERSION_ID >= 50607)
66# define MRN_HANDLER_HAVE_CHECK_IF_SUPPORTED_INPLACE_ALTER 1
67# define MRN_HANDLER_HAVE_HA_PREPARE_INPLACE_ALTER_TABLE 1
68# define MRN_HANDLER_HAVE_HA_INPLACE_ALTER_TABLE 1
69# define MRN_HANDLER_HAVE_HA_COMMIT_INPLACE_ALTER_TABLE 1
70# define MRN_SUPPORT_FOREIGN_KEYS 1
71#endif
72
73#ifndef MRN_MARIADB_P
74# define MRN_HANDLER_HAVE_INDEX_READ_LAST_MAP
75# if MYSQL_VERSION_ID >= 50611
76# define MRN_HANDLER_HAVE_HA_INDEX_READ_LAST_MAP
77# endif
78#endif
79
80#ifdef MRN_MARIADB_P
81# define MRN_HANDLER_HAVE_MULTI_RANGE_READ_INFO_KEY_PARTS
82#endif
83
84#if MYSQL_VERSION_ID < 50600
85# define MRN_HANDLER_HAVE_GET_TABLESPACE_NAME
86#endif
87
88#if MYSQL_VERSION_ID >= 50607
89# define MRN_HANDLER_HAVE_SET_HA_SHARE_REF
90#endif
91
92#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
93# define MRN_BIG_TABLES
94#elif defined(BIG_TABLES)
95# define MRN_BIG_TABLES
96#endif
97
98#ifdef MRN_BIG_TABLES
99# define MRN_HA_ROWS_FORMAT "llu"
100#else
101# define MRN_HA_ROWS_FORMAT "lu"
102#endif
103
104#ifdef MRN_MARIADB_P
105# define MRN_NEED_FREE_STRING_MEMALLOC_PLUGIN_VAR
106#endif
107
108#ifdef MRN_MARIADB_P
109# define MRN_HAVE_HA_EXTRA_DETACH_CHILD
110# define MRN_HAVE_HA_EXTRA_PREPARE_FOR_FORCED_CLOSE
111#endif
112
113#if (!defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 80002)
114#define MRN_HAVE_HA_EXTRA_SKIP_SERIALIZABLE_DD_VIEW
115#define MRN_HAVE_HA_EXTRA_BEGIN_ALTER_COPY
116#define MRN_HAVE_HA_EXTRA_END_ALTER_COPY
117#define MRN_HAVE_HA_EXTRA_NO_AUTOINC_LOCKING
118#endif
119
120#if MYSQL_VERSION_ID >= 50607 && \
121 (!defined(MRN_MARIADB_P) || MYSQL_VERSION_ID < 100008)
122# define MRN_HAVE_HA_EXTRA_EXPORT
123#endif
124
125#if MYSQL_VERSION_ID >= 50617 && !defined(MRN_MARIADB_P)
126# define MRN_HAVE_HA_EXTRA_SECONDARY_SORT_ROWID
127#endif
128
129#if MYSQL_VERSION_ID >= 50604 && !defined(MRN_MARIADB_P)
130# define MRN_TIMESTAMP_USE_TIMEVAL
131#elif defined(MRN_MARIADB_P)
132# define MRN_TIMESTAMP_USE_MY_TIME_T
133#else
134# define MRN_TIMESTAMP_USE_LONG
135#endif
136
137#if MYSQL_VERSION_ID < 50600 && !defined(MRN_MARIADB_P)
138# define MRN_FIELD_STORE_TIME_NEED_TYPE
139#endif
140
141#if MYSQL_VERSION_ID < 50706 || defined(MRN_MARIADB_P)
142# define MRN_HAVE_TL_WRITE_DELAYED
143#endif
144
145#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
146# define MRN_HAVE_TL_WRITE_CONCURRENT_DEFAULT
147#endif
148
149#ifdef MRN_MARIADB_P
150# define MRN_HANDLER_AUTO_REPAIR_HAVE_ERROR
151#endif
152
153#if MYSQL_VERSION_ID >= 50604
154# define MRN_JOIN_TAB_HAVE_CONDITION
155#endif
156
157#if MYSQL_VERSION_ID < 50600
158# define MRN_RBR_UPDATE_NEED_ALL_COLUMNS
159#endif
160
161#if MYSQL_VERSION_ID >= 50500
162# define MRN_ROW_BASED_CHECK_IS_METHOD
163#endif
164
165#if MYSQL_VERSION_ID >= 50600
166# define MRN_HAVE_HA_REBIND_PSI
167#endif
168
169#if MYSQL_VERSION_ID >= 50612 && !defined(MRN_MARIADB_P)
170# define MRN_HAVE_POINT_XY
171#endif
172
173#if (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100000)
174# define MRN_HANDLER_START_BULK_INSERT_HAS_FLAGS
175#endif
176
177#if (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100010)
178# define MRN_HAVE_TDC_LOCK_TABLE_SHARE
179# if MYSQL_VERSION_ID >= 100100
180# define MRN_TABLE_SHARE_TDC_IS_POINTER
181# endif
182#endif
183
184#ifdef MRN_MARIADB_P
185# if MYSQL_VERSION_ID >= 50542 && MYSQL_VERSION_ID < 100000
186# define MRN_SUPPORT_THDVAR_SET
187# elif MYSQL_VERSION_ID >= 100017
188# define MRN_SUPPORT_THDVAR_SET
189# endif
190#else
191# define MRN_SUPPORT_THDVAR_SET
192#endif
193
194#ifdef MRN_MARIADB_P
195# if MYSQL_VERSION_ID < 100000
196# define MRN_SUPPORT_PARTITION
197# endif
198#else
199# define MRN_SUPPORT_PARTITION
200#endif
201
202#if MYSQL_VERSION_ID >= 50706 && !defined(MRN_MARIADB_P)
203# define MRN_FLUSH_LOGS_HAVE_BINLOG_GROUP_FLUSH
204#endif
205
206#if MYSQL_VERSION_ID < 50706 || defined(MRN_MARIADB_P)
207# define MRN_HAVE_HTON_ALTER_TABLE_FLAGS
208#endif
209
210#if MYSQL_VERSION_ID >= 50706
211# define MRN_FOREIGN_KEY_USE_CONST_STRING
212#endif
213
214#if MYSQL_VERSION_ID >= 100203 && defined(MRN_MARIADB_P)
215# define MRN_FOREIGN_KEY_USE_METHOD_ENUM
216#endif
217
218#if MYSQL_VERSION_ID < 50706 || defined(MRN_MARIADB_P)
219# define MRN_HANDLER_IS_FATAL_ERROR_HAVE_FLAGS
220#endif
221
222#if MYSQL_VERSION_ID < 50706 || defined(MRN_MARIADB_P)
223# define MRN_HANDLER_HAVE_RESET_AUTO_INCREMENT
224#endif
225
226#if (!defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 50709) || \
227 (defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 100203)
228# define MRN_ALTER_INPLACE_INFO_ALTER_STORED_COLUMN_TYPE \
229 ALTER_STORED_COLUMN_TYPE
230# define MRN_ALTER_INPLACE_INFO_ALTER_STORED_COLUMN_ORDER \
231 ALTER_STORED_COLUMN_ORDER
232#else
233# define MRN_ALTER_INPLACE_INFO_ALTER_STORED_COLUMN_TYPE \
234 Alter_inplace_info::ALTER_COLUMN_TYPE
235# define MRN_ALTER_INPLACE_INFO_ALTER_STORED_COLUMN_ORDER \
236 Alter_inplace_info::ALTER_COLUMN_ORDER
237#endif
238
239#if MYSQL_VERSION_ID >= 50700 && !defined(MRN_MARIADB_P)
240# define MRN_HANDLER_RECORDS_RETURN_ERROR
241#endif
242
243#if MYSQL_VERSION_ID < 80002 || defined(MRN_MARIADB_P)
244# define MRN_HANDLER_HAVE_KEYS_TO_USE_FOR_SCANNING
245#endif
246
247#if (!defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 80002)
248# define MRN_ST_MYSQL_PLUGIN_HAVE_CHECK_UNINSTALL
249#endif
250
251#if (!defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 80002)
252# define MRN_HANDLER_OPEN_HAVE_TABLE_DEFINITION
253# define MRN_HANDLER_CREATE_HAVE_TABLE_DEFINITION
254#endif
255
256#if (!defined(MRN_MARIADB_P) && MYSQL_VERSION_ID >= 80002)
257# define MRN_HANDLERTON_CREATE_HAVE_PARTITIONED
258#endif
259
260#if defined(HAVE_PSI_INTERFACE) && \
261 (MYSQL_VERSION_ID < 80002 || defined(MRN_MARIADB_P))
262# define MRN_HAVE_PSI_SERVER
263#endif
264
265class ha_mroonga;
266
267/* structs */
268struct st_mrn_ft_info
269{
270 struct _ft_vft *please;
271#ifdef HA_CAN_FULLTEXT_EXT
272 struct _ft_vft_ext *could_you;
273#endif
274 grn_ctx *ctx;
275 grn_encoding encoding;
276 grn_obj *table;
277 grn_obj *result;
278 grn_obj *score_column;
279 grn_obj key;
280 grn_obj score;
281 uint active_index;
282 KEY *key_info;
283 KEY *primary_key_info;
284 grn_obj *cursor;
285 grn_obj *id_accessor;
286 grn_obj *key_accessor;
287 ha_mroonga *mroonga;
288};
289
290#ifdef MRN_SUPPORT_CUSTOM_OPTIONS
291struct ha_field_option_struct
292{
293 const char *groonga_type;
294 const char *flags;
295};
296
297struct ha_index_option_struct
298{
299 const char *tokenizer;
300 const char *normalizer;
301 const char *token_filters;
302 const char *flags;
303};
304#endif
305
306/* handler class */
307class ha_mroonga: public handler
308{
309public:
310 handler *wrap_handler;
311 bool is_clone;
312 ha_mroonga *parent_for_clone;
313 MEM_ROOT *mem_root_for_clone;
314 grn_obj key_buffer;
315 grn_id record_id;
316 grn_id *key_id;
317 grn_id *del_key_id;
318 MY_BITMAP multiple_column_key_bitmap;
319
320private:
321 THR_LOCK_DATA thr_lock_data;
322
323 // for wrapper mode (TODO: need to be confirmed)
324 uint wrap_ft_init_count;
325 MRN_SHARE *share;
326 KEY *wrap_key_info;
327 KEY *base_key_info;
328 key_part_map pk_keypart_map;
329 MEM_ROOT mem_root;
330 /// for create table and alter table
331 mutable bool analyzed_for_create;
332 mutable TABLE table_for_create;
333 mutable MRN_SHARE share_for_create;
334 mutable TABLE_SHARE table_share_for_create;
335 mutable MEM_ROOT mem_root_for_create;
336 mutable handler *wrap_handler_for_create;
337#ifdef MRN_HANDLER_HAVE_FINAL_ADD_INDEX
338 handler_add_index *hnd_add_index;
339#endif
340#ifdef MRN_HANDLER_HAVE_CHECK_IF_SUPPORTED_INPLACE_ALTER
341 alter_table_operations alter_handler_flags;
342 KEY *alter_key_info_buffer;
343 uint alter_key_count;
344 uint alter_index_drop_count;
345 KEY *alter_index_drop_buffer;
346 uint alter_index_add_count;
347 uint *alter_index_add_buffer;
348 TABLE *wrap_altered_table;
349 KEY *wrap_altered_table_key_info;
350 TABLE_SHARE *wrap_altered_table_share;
351 KEY *wrap_altered_table_share_key_info;
352#else
353 KEY *wrap_alter_key_info;
354#endif
355 int mrn_lock_type;
356
357 // for groonga objects
358 grn_ctx ctx_entity_;
359 grn_ctx *ctx;
360 grn_obj *grn_table;
361 grn_obj **grn_columns;
362 grn_obj **grn_column_ranges;
363 grn_obj **grn_index_tables;
364 grn_obj **grn_index_columns;
365
366 // buffers
367 grn_obj encoded_key_buffer;
368 grn_obj old_value_buffer;
369 grn_obj new_value_buffer;
370 grn_obj top_left_point;
371 grn_obj bottom_right_point;
372 grn_obj source_point;
373 double top_left_longitude_in_degree;
374 double bottom_right_longitude_in_degree;
375 double bottom_right_latitude_in_degree;
376 double top_left_latitude_in_degree;
377
378 // for search
379 grn_obj *grn_source_column_geo;
380 grn_obj *cursor_geo;
381 grn_table_cursor *cursor;
382 grn_table_cursor *index_table_cursor;
383 grn_obj *empty_value_records;
384 grn_table_cursor *empty_value_records_cursor;
385 grn_obj *sorted_result;
386 grn_obj *matched_record_keys;
387 String *blob_buffers;
388
389 // for error report
390 uint dup_key;
391
392 // for optimization
393 bool count_skip;
394 bool fast_order_limit;
395 bool fast_order_limit_with_index;
396
397 // for context
398 bool ignoring_duplicated_key;
399 bool inserting_with_update;
400 bool fulltext_searching;
401 bool ignoring_no_key_columns;
402 bool replacing_;
403 uint written_by_row_based_binlog;
404
405 // for ft in where clause test
406 Item_func_match *current_ft_item;
407
408 mrn::Operations *operations_;
409
410public:
411 ha_mroonga(handlerton *hton, TABLE_SHARE *share_arg);
412 ~ha_mroonga();
413 const char *table_type() const; // required
414 const char *index_type(uint inx);
415 const char **bas_ext() const; // required
416
417 ulonglong table_flags() const; // required
418 ulong index_flags(uint idx, uint part, bool all_parts) const; // required
419
420 // required
421 int create(const char *name, TABLE *form, HA_CREATE_INFO *info
422#ifdef MRN_HANDLER_CREATE_HAVE_TABLE_DEFINITION
423 ,
424 dd::Table *table_def
425#endif
426 ) mrn_override;
427 // required
428 int open(const char *name, int mode, uint open_options
429#ifdef MRN_HANDLER_OPEN_HAVE_TABLE_DEFINITION
430 ,
431 const dd::Table *table_def
432#endif
433 ) mrn_override;
434#ifndef MRN_HANDLER_HAVE_HA_CLOSE
435 int close(); // required
436#endif
437 int info(uint flag); // required
438
439 uint lock_count() const;
440 THR_LOCK_DATA **store_lock(THD *thd, // required
441 THR_LOCK_DATA **to,
442 enum thr_lock_type lock_type);
443 int external_lock(THD *thd, int lock_type);
444
445 int rnd_init(bool scan); // required
446 int rnd_end();
447#ifndef MRN_HANDLER_HAVE_HA_RND_NEXT
448 int rnd_next(uchar *buf); // required
449#endif
450#ifndef MRN_HANDLER_HAVE_HA_RND_POS
451 int rnd_pos(uchar *buf, uchar *pos); // required
452#endif
453 void position(const uchar *record); // required
454 int extra(enum ha_extra_function operation);
455 int extra_opt(enum ha_extra_function operation, ulong cache_size);
456
457 int delete_table(const char *name);
458 int write_row(uchar *buf);
459 int update_row(const uchar *old_data, const uchar *new_data);
460 int delete_row(const uchar *buf);
461
462 uint max_supported_record_length() const;
463 uint max_supported_keys() const;
464 uint max_supported_key_parts() const;
465 uint max_supported_key_length() const;
466 uint max_supported_key_part_length() const;
467
468 ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key);
469 int index_init(uint idx, bool sorted);
470 int index_end();
471#ifndef MRN_HANDLER_HAVE_HA_INDEX_READ_MAP
472 int index_read_map(uchar * buf, const uchar * key,
473 key_part_map keypart_map,
474 enum ha_rkey_function find_flag);
475#endif
476#ifdef MRN_HANDLER_HAVE_INDEX_READ_LAST_MAP
477 int index_read_last_map(uchar *buf, const uchar *key,
478 key_part_map keypart_map);
479#endif
480#ifndef MRN_HANDLER_HAVE_HA_INDEX_NEXT
481 int index_next(uchar *buf);
482#endif
483#ifndef MRN_HANDLER_HAVE_HA_INDEX_PREV
484 int index_prev(uchar *buf);
485#endif
486#ifndef MRN_HANDLER_HAVE_HA_INDEX_FIRST
487 int index_first(uchar *buf);
488#endif
489#ifndef MRN_HANDLER_HAVE_HA_INDEX_LAST
490 int index_last(uchar *buf);
491#endif
492 int index_next_same(uchar *buf, const uchar *key, uint keylen);
493
494 int ft_init();
495 FT_INFO *ft_init_ext(uint flags, uint inx, String *key);
496 int ft_read(uchar *buf);
497
498 const Item *cond_push(const Item *cond);
499 void cond_pop();
500
501 bool get_error_message(int error, String *buf);
502
503 int reset();
504
505 handler *clone(const char *name, MEM_ROOT *mem_root);
506 uint8 table_cache_type();
507#ifdef MRN_HANDLER_HAVE_MULTI_RANGE_READ
508 ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
509 void *seq_init_param,
510 uint n_ranges, uint *bufsz,
511 uint *flags, Cost_estimate *cost);
512 ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
513#ifdef MRN_HANDLER_HAVE_MULTI_RANGE_READ_INFO_KEY_PARTS
514 uint key_parts,
515#endif
516 uint *bufsz, uint *flags, Cost_estimate *cost);
517 int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
518 uint n_ranges, uint mode,
519 HANDLER_BUFFER *buf);
520 int multi_range_read_next(range_id_t *range_info);
521#else // MRN_HANDLER_HAVE_MULTI_RANGE_READ
522 int read_multi_range_first(KEY_MULTI_RANGE **found_range_p,
523 KEY_MULTI_RANGE *ranges,
524 uint range_count,
525 bool sorted,
526 HANDLER_BUFFER *buffer);
527 int read_multi_range_next(KEY_MULTI_RANGE **found_range_p);
528#endif // MRN_HANDLER_HAVE_MULTI_RANGE_READ
529#ifdef MRN_HANDLER_START_BULK_INSERT_HAS_FLAGS
530 void start_bulk_insert(ha_rows rows, uint flags);
531#else
532 void start_bulk_insert(ha_rows rows);
533#endif
534 int end_bulk_insert();
535 int delete_all_rows();
536 int truncate();
537 double scan_time();
538 double read_time(uint index, uint ranges, ha_rows rows);
539#ifdef MRN_HANDLER_HAVE_KEYS_TO_USE_FOR_SCANNING
540 const key_map *keys_to_use_for_scanning();
541#endif
542 ha_rows estimate_rows_upper_bound();
543 void update_create_info(HA_CREATE_INFO* create_info);
544 int rename_table(const char *from, const char *to);
545 bool is_crashed() const;
546 bool auto_repair(int error) const;
547 bool auto_repair() const;
548 int disable_indexes(uint mode);
549 int enable_indexes(uint mode);
550 int check(THD* thd, HA_CHECK_OPT* check_opt);
551 int repair(THD* thd, HA_CHECK_OPT* check_opt);
552 bool check_and_repair(THD *thd);
553 int analyze(THD* thd, HA_CHECK_OPT* check_opt);
554 int optimize(THD* thd, HA_CHECK_OPT* check_opt);
555 bool is_fatal_error(int error_num, uint flags=0);
556 bool check_if_incompatible_data(HA_CREATE_INFO *create_info,
557 uint table_changes);
558#ifdef MRN_HANDLER_HAVE_CHECK_IF_SUPPORTED_INPLACE_ALTER
559 enum_alter_inplace_result
560 check_if_supported_inplace_alter(TABLE *altered_table,
561 Alter_inplace_info *ha_alter_info);
562#else
563 alter_table_operations alter_table_flags(alter_table_operations flags);
564# ifdef MRN_HANDLER_HAVE_FINAL_ADD_INDEX
565 int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys,
566 handler_add_index **add);
567 int final_add_index(handler_add_index *add, bool commit);
568# else
569 int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys);
570# endif
571 int prepare_drop_index(TABLE *table_arg, uint *key_num, uint num_of_keys);
572 int final_drop_index(TABLE *table_arg);
573#endif
574 int update_auto_increment();
575 void set_next_insert_id(ulonglong id);
576 void get_auto_increment(ulonglong offset, ulonglong increment, ulonglong nb_desired_values,
577 ulonglong *first_value, ulonglong *nb_reserved_values);
578 void restore_auto_increment(ulonglong prev_insert_id);
579 void release_auto_increment();
580 int check_for_upgrade(HA_CHECK_OPT *check_opt);
581#ifdef MRN_HANDLER_HAVE_RESET_AUTO_INCREMENT
582 int reset_auto_increment(ulonglong value);
583#endif
584 bool was_semi_consistent_read();
585 void try_semi_consistent_read(bool yes);
586 void unlock_row();
587 int start_stmt(THD *thd, thr_lock_type lock_type);
588
589protected:
590#ifdef MRN_HANDLER_RECORDS_RETURN_ERROR
591 int records(ha_rows *num_rows);
592#else
593 ha_rows records();
594#endif
595#ifdef MRN_HANDLER_HAVE_HA_RND_NEXT
596 int rnd_next(uchar *buf);
597#endif
598#ifdef MRN_HANDLER_HAVE_HA_RND_POS
599 int rnd_pos(uchar *buf, uchar *pos);
600#endif
601#ifdef MRN_HANDLER_HAVE_HA_INDEX_READ_MAP
602 int index_read_map(uchar *buf, const uchar *key,
603 key_part_map keypart_map,
604 enum ha_rkey_function find_flag);
605#endif
606#ifdef MRN_HANDLER_HAVE_HA_INDEX_NEXT
607 int index_next(uchar *buf);
608#endif
609#ifdef MRN_HANDLER_HAVE_HA_INDEX_PREV
610 int index_prev(uchar *buf);
611#endif
612#ifdef MRN_HANDLER_HAVE_HA_INDEX_FIRST
613 int index_first(uchar *buf);
614#endif
615#ifdef MRN_HANDLER_HAVE_HA_INDEX_LAST
616 int index_last(uchar *buf);
617#endif
618 void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share_arg);
619 bool primary_key_is_clustered();
620 bool is_fk_defined_on_table_or_index(uint index);
621 char *get_foreign_key_create_info();
622#ifdef MRN_HANDLER_HAVE_GET_TABLESPACE_NAME
623 char *get_tablespace_name(THD *thd, char *name, uint name_len);
624#endif
625 bool can_switch_engines();
626 int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
627 int get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
628 uint referenced_by_foreign_key();
629 void init_table_handle_for_HANDLER();
630 void free_foreign_key_create_info(char* str);
631#ifdef MRN_HAVE_HA_REBIND_PSI
632 void unbind_psi();
633 void rebind_psi();
634#endif
635 my_bool register_query_cache_table(THD *thd,
636 const char *table_key,
637 uint key_length,
638 qc_engine_callback *engine_callback,
639 ulonglong *engine_data);
640#ifdef MRN_HANDLER_HAVE_CHECK_IF_SUPPORTED_INPLACE_ALTER
641 bool prepare_inplace_alter_table(TABLE *altered_table,
642 Alter_inplace_info *ha_alter_info);
643 bool inplace_alter_table(TABLE *altered_table,
644 Alter_inplace_info *ha_alter_info);
645 bool commit_inplace_alter_table(TABLE *altered_table,
646 Alter_inplace_info *ha_alter_info,
647 bool commit);
648 void notify_table_changed();
649#endif
650
651private:
652 void mkdir_p(const char *directory);
653 ulonglong file_size(const char *path);
654
655 bool have_unique_index();
656
657 bool is_foreign_key_field(const char *table_name,
658 const char *field_name);
659
660 void push_warning_unsupported_spatial_index_search(enum ha_rkey_function flag);
661 void clear_cursor();
662 void clear_cursor_geo();
663 void clear_empty_value_records();
664 void clear_search_result();
665 void clear_search_result_geo();
666 void clear_indexes();
667 int add_wrap_hton(const char *path, handlerton *wrap_handlerton);
668 void remove_related_files(const char *base_path);
669 void remove_grn_obj_force(const char *name);
670 int drop_index(MRN_SHARE *target_share, uint key_index);
671 int drop_indexes_normal(const char *table_name, grn_obj *table);
672 int drop_indexes_multiple(const char *table_name, grn_obj *table,
673 const char *index_table_name_separator);
674 int drop_indexes(const char *table_name);
675 bool find_column_flags(Field *field, MRN_SHARE *mrn_share, int i,
676 grn_obj_flags *column_flags);
677 grn_obj *find_column_type(Field *field, MRN_SHARE *mrn_share, int i,
678 int error_code);
679 grn_obj *find_tokenizer(KEY *key, MRN_SHARE *mrn_share, int i);
680 grn_obj *find_tokenizer(const char *name, int name_length);
681 bool have_custom_normalizer(KEY *key) const;
682 grn_obj *find_normalizer(KEY *key);
683 grn_obj *find_normalizer(KEY *key, const char *name);
684 bool find_index_column_flags(KEY *key, grn_column_flags *index_column_flags);
685 bool find_token_filters(KEY *key, grn_obj *token_filters);
686 bool find_token_filters_put(grn_obj *token_filters,
687 const char *token_filter_name,
688 int token_filter_name_length);
689 bool find_token_filters_fill(grn_obj *token_filters,
690 const char *token_filter_names,
691 int token_filter_name_length);
692 int wrapper_get_record(uchar *buf, const uchar *key);
693 int wrapper_get_next_geo_record(uchar *buf);
694 int storage_get_next_record(uchar *buf);
695 void geo_store_rectangle(const uchar *rectangle);
696 int generic_geo_open_cursor(const uchar *key, enum ha_rkey_function find_flag);
697
698#ifdef MRN_HANDLER_HAVE_HA_CLOSE
699 int close();
700#endif
701 bool is_dry_write();
702 bool is_enable_optimization();
703 bool should_normalize(Field *field) const;
704 void check_count_skip(key_part_map target_key_part_map);
705 bool is_grn_zero_column_value(grn_obj *column, grn_obj *value);
706 bool is_primary_key_field(Field *field) const;
707 void check_fast_order_limit(grn_table_sort_key **sort_keys, int *n_sort_keys,
708 longlong *limit);
709
710 long long int get_grn_time_from_timestamp_field(Field_timestamp *field);
711
712 int generic_store_bulk_fixed_size_string(Field *field, grn_obj *buf);
713 int generic_store_bulk_variable_size_string(Field *field, grn_obj *buf);
714 int generic_store_bulk_integer(Field *field, grn_obj *buf);
715 int generic_store_bulk_unsigned_integer(Field *field, grn_obj *buf);
716 int generic_store_bulk_float(Field *field, grn_obj *buf);
717 int generic_store_bulk_timestamp(Field *field, grn_obj *buf);
718 int generic_store_bulk_date(Field *field, grn_obj *buf);
719 int generic_store_bulk_time(Field *field, grn_obj *buf);
720 int generic_store_bulk_datetime(Field *field, grn_obj *buf);
721 int generic_store_bulk_year(Field *field, grn_obj *buf);
722 int generic_store_bulk_new_date(Field *field, grn_obj *buf);
723#ifdef MRN_HAVE_MYSQL_TYPE_DATETIME2
724 int generic_store_bulk_datetime2(Field *field, grn_obj *buf);
725#endif
726#ifdef MRN_HAVE_MYSQL_TYPE_TIME2
727 int generic_store_bulk_time2(Field *field, grn_obj *buf);
728#endif
729 int generic_store_bulk_new_decimal(Field *field, grn_obj *buf);
730 int generic_store_bulk_blob(Field *field, grn_obj *buf);
731 int generic_store_bulk_geometry(Field *field, grn_obj *buf);
732#ifdef MRN_HAVE_MYSQL_TYPE_JSON
733 int generic_store_bulk_json(Field *field, grn_obj *buf);
734#endif
735 int generic_store_bulk(Field *field, grn_obj *buf);
736
737 void storage_store_field_string(Field *field,
738 const char *value, uint value_length);
739 void storage_store_field_integer(Field *field,
740 const char *value, uint value_length);
741 void storage_store_field_unsigned_integer(Field *field,
742 const char *value,
743 uint value_length);
744 void storage_store_field_float(Field *field,
745 const char *value, uint value_length);
746 void storage_store_field_timestamp(Field *field,
747 const char *value, uint value_length);
748 void storage_store_field_date(Field *field,
749 const char *value, uint value_length);
750 void storage_store_field_time(Field *field,
751 const char *value, uint value_length);
752 void storage_store_field_datetime(Field *field,
753 const char *value, uint value_length);
754 void storage_store_field_year(Field *field,
755 const char *value, uint value_length);
756 void storage_store_field_new_date(Field *field,
757 const char *value, uint value_length);
758#ifdef MRN_HAVE_MYSQL_TYPE_DATETIME2
759 void storage_store_field_datetime2(Field *field,
760 const char *value, uint value_length);
761#endif
762#ifdef MRN_HAVE_MYSQL_TYPE_TIME2
763 void storage_store_field_time2(Field *field,
764 const char *value, uint value_length);
765#endif
766 void storage_store_field_blob(Field *field,
767 const char *value, uint value_length);
768 void storage_store_field_geometry(Field *field,
769 const char *value, uint value_length);
770#ifdef MRN_HAVE_MYSQL_TYPE_JSON
771 void storage_store_field_json(Field *field,
772 const char *value, uint value_length);
773#endif
774 void storage_store_field(Field *field, const char *value, uint value_length);
775 void storage_store_field_column(Field *field, bool is_primary_key,
776 int nth_column, grn_id record_id);
777 void storage_store_fields(uchar *buf, grn_id record_id);
778 void storage_store_fields_for_prep_update(const uchar *old_data,
779 const uchar *new_data,
780 grn_id record_id);
781 void storage_store_fields_by_index(uchar *buf);
782
783 int storage_encode_key_normalize_min_sort_chars(Field *field,
784 uchar *buf,
785 uint size);
786 int storage_encode_key_fixed_size_string(Field *field, const uchar *key,
787 uchar *buf, uint *size);
788 int storage_encode_key_variable_size_string(Field *field, const uchar *key,
789 uchar *buf, uint *size);
790 int storage_encode_key_timestamp(Field *field, const uchar *key,
791 uchar *buf, uint *size);
792 int storage_encode_key_time(Field *field, const uchar *key,
793 uchar *buf, uint *size);
794 int storage_encode_key_year(Field *field, const uchar *key,
795 uchar *buf, uint *size);
796 int storage_encode_key_datetime(Field *field, const uchar *key,
797 uchar *buf, uint *size);
798#ifdef MRN_HAVE_MYSQL_TYPE_TIMESTAMP2
799 int storage_encode_key_timestamp2(Field *field, const uchar *key,
800 uchar *buf, uint *size);
801#endif
802#ifdef MRN_HAVE_MYSQL_TYPE_DATETIME2
803 int storage_encode_key_datetime2(Field *field, const uchar *key,
804 uchar *buf, uint *size);
805#endif
806#ifdef MRN_HAVE_MYSQL_TYPE_TIME2
807 int storage_encode_key_time2(Field *field, const uchar *key,
808 uchar *buf, uint *size);
809#endif
810 int storage_encode_key_enum(Field *field, const uchar *key,
811 uchar *buf, uint *size);
812 int storage_encode_key_set(Field *field, const uchar *key,
813 uchar *buf, uint *size);
814 int storage_encode_key(Field *field, const uchar *key, uchar *buf, uint *size);
815 int storage_encode_multiple_column_key(KEY *key_info,
816 const uchar *key, uint key_length,
817 uchar *buffer, uint *encoded_length);
818 int storage_encode_multiple_column_key_range(KEY *key_info,
819 const uchar *start,
820 uint start_size,
821 const uchar *end,
822 uint end_size,
823 uchar *min_buffer,
824 uint *min_encoded_size,
825 uchar *max_buffer,
826 uint *max_encoded_size);
827 int storage_encode_multiple_column_key_range(KEY *key_info,
828 const key_range *start,
829 const key_range *end,
830 uchar *min_buffer,
831 uint *min_encoded_size,
832 uchar *max_buffer,
833 uint *max_encoded_size);
834
835 void set_pk_bitmap();
836 int create_share_for_create() const;
837 int wrapper_create(const char *name, TABLE *table,
838 HA_CREATE_INFO *info, MRN_SHARE *tmp_share);
839 int storage_create(const char *name, TABLE *table,
840 HA_CREATE_INFO *info, MRN_SHARE *tmp_share);
841 int wrapper_create_index_fulltext_validate(KEY *key_info);
842 int wrapper_create_index_fulltext(const char *grn_table_name,
843 int i,
844 KEY *key_info,
845 grn_obj **index_tables,
846 grn_obj **index_columns,
847 MRN_SHARE *tmp_share);
848 int wrapper_create_index_geo(const char *grn_table_name,
849 int i,
850 KEY *key_info,
851 grn_obj **index_tables,
852 grn_obj **index_columns,
853 MRN_SHARE *tmp_share);
854 int wrapper_create_index(const char *name, TABLE *table, MRN_SHARE *tmp_share);
855 int storage_create_validate_pseudo_column(TABLE *table);
856#ifdef MRN_SUPPORT_FOREIGN_KEYS
857 bool storage_create_foreign_key(TABLE *table, const char *grn_table_name,
858 Field *field, grn_obj *table_obj, int &error);
859#endif
860 int storage_create_validate_index(TABLE *table);
861 int storage_create_index_table(TABLE *table, const char *grn_table_name,
862 grn_obj *grn_table, MRN_SHARE *tmp_share,
863 KEY *key_info, grn_obj **index_tables,
864 uint i);
865 int storage_create_index(TABLE *table, const char *grn_table_name,
866 grn_obj *grn_table, MRN_SHARE *tmp_share,
867 KEY *key_info, grn_obj **index_tables,
868 grn_obj **index_columns, uint i);
869 int storage_create_indexes(TABLE *table, const char *grn_table_name,
870 grn_obj *grn_table, MRN_SHARE *tmp_share);
871 int close_databases();
872 int ensure_database_open(const char *name, mrn::Database **db=NULL);
873 int ensure_database_remove(const char *name);
874 int wrapper_delete_table(const char *name, handlerton *wrap_handlerton,
875 const char *table_name);
876 int generic_delete_table(const char *name, const char *table_name);
877 int wrapper_open(const char *name, int mode, uint open_options);
878 int wrapper_open_indexes(const char *name);
879 int storage_reindex();
880 int storage_open(const char *name, int mode, uint open_options);
881 int open_table(const char *name);
882 int storage_open_columns(void);
883 void storage_close_columns(void);
884 int storage_open_indexes(const char *name);
885 void wrapper_overwrite_index_bits();
886 int wrapper_close();
887 int storage_close();
888 int generic_extra(enum ha_extra_function operation);
889 int wrapper_extra(enum ha_extra_function operation);
890 int storage_extra(enum ha_extra_function operation);
891 int wrapper_extra_opt(enum ha_extra_function operation, ulong cache_size);
892 int storage_extra_opt(enum ha_extra_function operation, ulong cache_size);
893 int generic_reset();
894 int wrapper_reset();
895 int storage_reset();
896 uint wrapper_lock_count() const;
897 uint storage_lock_count() const;
898 THR_LOCK_DATA **wrapper_store_lock(THD *thd, THR_LOCK_DATA **to,
899 enum thr_lock_type lock_type);
900 THR_LOCK_DATA **storage_store_lock(THD *thd, THR_LOCK_DATA **to,
901 enum thr_lock_type lock_type);
902 int wrapper_external_lock(THD *thd, int lock_type);
903 int storage_external_lock(THD *thd, int lock_type);
904#ifdef MRN_HANDLER_START_BULK_INSERT_HAS_FLAGS
905 void wrapper_start_bulk_insert(ha_rows rows, uint flags);
906 void storage_start_bulk_insert(ha_rows rows, uint flags);
907#else
908 void wrapper_start_bulk_insert(ha_rows rows);
909 void storage_start_bulk_insert(ha_rows rows);
910#endif
911 int wrapper_end_bulk_insert();
912 int storage_end_bulk_insert();
913 bool wrapper_is_target_index(KEY *key_info);
914 bool wrapper_have_target_index();
915 int wrapper_write_row(uchar *buf);
916 int wrapper_write_row_index(uchar *buf);
917 int storage_write_row(uchar *buf);
918 int storage_write_row_multiple_column_index(uchar *buf,
919 grn_id record_id,
920 KEY *key_info,
921 grn_obj *index_column);
922 int storage_write_row_multiple_column_indexes(uchar *buf, grn_id record_id);
923 int storage_write_row_unique_index(const uchar *buf,
924 KEY *key_info,
925 grn_obj *index_table,
926 grn_obj *index_column,
927 grn_id *key_id);
928 int storage_write_row_unique_indexes(uchar *buf);
929 int wrapper_get_record_id(uchar *data, grn_id *record_id,
930 const char *context);
931 int wrapper_update_row(const uchar *old_data, const uchar *new_data);
932 int wrapper_update_row_index(const uchar *old_data,
933 const uchar *new_data);
934 int storage_update_row(const uchar *old_data, const uchar *new_data);
935 int storage_update_row_index(const uchar *old_data,
936 const uchar *new_data);
937 int storage_update_row_unique_indexes(const uchar *new_data);
938 int wrapper_delete_row(const uchar *buf);
939 int wrapper_delete_row_index(const uchar *buf);
940 int storage_delete_row(const uchar *buf);
941 int storage_delete_row_index(const uchar *buf);
942 int storage_delete_row_unique_index(grn_obj *index_table, grn_id del_key_id);
943 int storage_delete_row_unique_indexes();
944 int storage_prepare_delete_row_unique_index(const uchar *buf,
945 grn_id record_id,
946 KEY *key_info,
947 grn_obj *index_table,
948 grn_obj *index_column,
949 grn_id *del_key_id);
950 int storage_prepare_delete_row_unique_indexes(const uchar *buf,
951 grn_id record_id);
952 uint wrapper_max_supported_record_length() const;
953 uint storage_max_supported_record_length() const;
954 uint wrapper_max_supported_keys() const;
955 uint storage_max_supported_keys() const;
956 uint wrapper_max_supported_key_parts() const;
957 uint storage_max_supported_key_parts() const;
958 uint wrapper_max_supported_key_length() const;
959 uint storage_max_supported_key_length() const;
960 uint wrapper_max_supported_key_part_length() const;
961 uint storage_max_supported_key_part_length() const;
962 ulonglong wrapper_table_flags() const;
963 ulonglong storage_table_flags() const;
964 ulong wrapper_index_flags(uint idx, uint part, bool all_parts) const;
965 ulong storage_index_flags(uint idx, uint part, bool all_parts) const;
966 int wrapper_info(uint flag);
967 int storage_info(uint flag);
968 void storage_info_variable();
969 void storage_info_variable_records();
970 void storage_info_variable_data_file_length();
971#ifdef MRN_HANDLER_RECORDS_RETURN_ERROR
972 int wrapper_records(ha_rows *num_rows);
973 int storage_records(ha_rows *num_rows);
974#else
975 ha_rows wrapper_records();
976 ha_rows storage_records();
977#endif
978 int wrapper_rnd_init(bool scan);
979 int storage_rnd_init(bool scan);
980 int wrapper_rnd_end();
981 int storage_rnd_end();
982 int wrapper_rnd_next(uchar *buf);
983 int storage_rnd_next(uchar *buf);
984 int wrapper_rnd_pos(uchar *buf, uchar *pos);
985 int storage_rnd_pos(uchar *buf, uchar *pos);
986 void wrapper_position(const uchar *record);
987 void storage_position(const uchar *record);
988 ha_rows wrapper_records_in_range(uint key_nr, key_range *range_min,
989 key_range *range_max);
990 ha_rows storage_records_in_range(uint key_nr, key_range *range_min,
991 key_range *range_max);
992 ha_rows generic_records_in_range_geo(uint key_nr, key_range *range_min,
993 key_range *range_max);
994 int wrapper_index_init(uint idx, bool sorted);
995 int storage_index_init(uint idx, bool sorted);
996 int wrapper_index_end();
997 int storage_index_end();
998 int wrapper_index_read_map(uchar *buf, const uchar *key,
999 key_part_map keypart_map,
1000 enum ha_rkey_function find_flag);
1001 int storage_index_read_map(uchar *buf, const uchar *key,
1002 key_part_map keypart_map,
1003 enum ha_rkey_function find_flag);
1004#ifdef MRN_HANDLER_HAVE_INDEX_READ_LAST_MAP
1005 int wrapper_index_read_last_map(uchar *buf, const uchar *key,
1006 key_part_map keypart_map);
1007 int storage_index_read_last_map(uchar *buf, const uchar *key,
1008 key_part_map keypart_map);
1009#endif
1010 int wrapper_index_next(uchar *buf);
1011 int storage_index_next(uchar *buf);
1012 int wrapper_index_prev(uchar *buf);
1013 int storage_index_prev(uchar *buf);
1014 int wrapper_index_first(uchar *buf);
1015 int storage_index_first(uchar *buf);
1016 int wrapper_index_last(uchar *buf);
1017 int storage_index_last(uchar *buf);
1018 int wrapper_index_next_same(uchar *buf, const uchar *key, uint keylen);
1019 int storage_index_next_same(uchar *buf, const uchar *key, uint keylen);
1020 int generic_ft_init();
1021 int wrapper_ft_init();
1022 int storage_ft_init();
1023 FT_INFO *wrapper_ft_init_ext(uint flags, uint key_nr, String *key);
1024 FT_INFO *storage_ft_init_ext(uint flags, uint key_nr, String *key);
1025 void generic_ft_init_ext_add_conditions_fast_order_limit(
1026 struct st_mrn_ft_info *info, grn_obj *expression);
1027 grn_rc generic_ft_init_ext_prepare_expression_in_boolean_mode(
1028 struct st_mrn_ft_info *info,
1029 String *key,
1030 grn_obj *index_column,
1031 grn_obj *match_columns,
1032 grn_obj *expression);
1033 grn_rc generic_ft_init_ext_prepare_expression_in_normal_mode(
1034 struct st_mrn_ft_info *info,
1035 String *key,
1036 grn_obj *index_column,
1037 grn_obj *match_columns,
1038 grn_obj *expression);
1039 struct st_mrn_ft_info *generic_ft_init_ext_select(uint flags,
1040 uint key_nr,
1041 String *key);
1042 FT_INFO *generic_ft_init_ext(uint flags, uint key_nr, String *key);
1043 int wrapper_ft_read(uchar *buf);
1044 int storage_ft_read(uchar *buf);
1045 const Item *wrapper_cond_push(const Item *cond);
1046 const Item *storage_cond_push(const Item *cond);
1047 void wrapper_cond_pop();
1048 void storage_cond_pop();
1049 bool wrapper_get_error_message(int error, String *buf);
1050 bool storage_get_error_message(int error, String *buf);
1051 handler *wrapper_clone(const char *name, MEM_ROOT *mem_root);
1052 handler *storage_clone(const char *name, MEM_ROOT *mem_root);
1053 uint8 wrapper_table_cache_type();
1054 uint8 storage_table_cache_type();
1055#ifdef MRN_HANDLER_HAVE_MULTI_RANGE_READ
1056 ha_rows wrapper_multi_range_read_info_const(uint keyno,
1057 RANGE_SEQ_IF *seq,
1058 void *seq_init_param,
1059 uint n_ranges,
1060 uint *bufsz,
1061 uint *flags,
1062 Cost_estimate *cost);
1063 ha_rows storage_multi_range_read_info_const(uint keyno,
1064 RANGE_SEQ_IF *seq,
1065 void *seq_init_param,
1066 uint n_ranges,
1067 uint *bufsz,
1068 uint *flags,
1069 Cost_estimate *cost);
1070 ha_rows wrapper_multi_range_read_info(uint keyno, uint n_ranges, uint keys,
1071#ifdef MRN_HANDLER_HAVE_MULTI_RANGE_READ_INFO_KEY_PARTS
1072 uint key_parts,
1073#endif
1074 uint *bufsz, uint *flags,
1075 Cost_estimate *cost);
1076 ha_rows storage_multi_range_read_info(uint keyno, uint n_ranges, uint keys,
1077#ifdef MRN_HANDLER_HAVE_MULTI_RANGE_READ_INFO_KEY_PARTS
1078 uint key_parts,
1079#endif
1080 uint *bufsz, uint *flags,
1081 Cost_estimate *cost);
1082 int wrapper_multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
1083 uint n_ranges, uint mode,
1084 HANDLER_BUFFER *buf);
1085 int storage_multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
1086 uint n_ranges, uint mode,
1087 HANDLER_BUFFER *buf);
1088 int wrapper_multi_range_read_next(range_id_t *range_info);
1089 int storage_multi_range_read_next(range_id_t *range_info);
1090#else // MRN_HANDLER_HAVE_MULTI_RANGE_READ
1091 int wrapper_read_multi_range_first(KEY_MULTI_RANGE **found_range_p,
1092 KEY_MULTI_RANGE *ranges,
1093 uint range_count,
1094 bool sorted,
1095 HANDLER_BUFFER *buffer);
1096 int storage_read_multi_range_first(KEY_MULTI_RANGE **found_range_p,
1097 KEY_MULTI_RANGE *ranges,
1098 uint range_count,
1099 bool sorted,
1100 HANDLER_BUFFER *buffer);
1101 int wrapper_read_multi_range_next(KEY_MULTI_RANGE **found_range_p);
1102 int storage_read_multi_range_next(KEY_MULTI_RANGE **found_range_p);
1103#endif // MRN_HANDLER_HAVE_MULTI_RANGE_READ
1104 int generic_delete_all_rows(grn_obj *target_grn_table,
1105 const char *function_name);
1106 int wrapper_delete_all_rows();
1107 int storage_delete_all_rows();
1108 int wrapper_truncate();
1109 int wrapper_truncate_index();
1110 int storage_truncate();
1111 int storage_truncate_index();
1112 double wrapper_scan_time();
1113 double storage_scan_time();
1114 double wrapper_read_time(uint index, uint ranges, ha_rows rows);
1115 double storage_read_time(uint index, uint ranges, ha_rows rows);
1116#ifdef MRN_HANDLER_HAVE_KEYS_TO_USE_FOR_SCANNING
1117 const key_map *wrapper_keys_to_use_for_scanning();
1118 const key_map *storage_keys_to_use_for_scanning();
1119#endif
1120 ha_rows wrapper_estimate_rows_upper_bound();
1121 ha_rows storage_estimate_rows_upper_bound();
1122 void wrapper_update_create_info(HA_CREATE_INFO* create_info);
1123 void storage_update_create_info(HA_CREATE_INFO* create_info);
1124 int wrapper_rename_table(const char *from, const char *to,
1125 MRN_SHARE *tmp_share,
1126 const char *from_table_name,
1127 const char *to_table_name);
1128 int wrapper_rename_index(const char *from, const char *to,
1129 MRN_SHARE *tmp_share,
1130 const char *from_table_name,
1131 const char *to_table_name);
1132 int storage_rename_table(const char *from, const char *to,
1133 MRN_SHARE *tmp_share,
1134 const char *from_table_name,
1135 const char *to_table_name);
1136#ifdef MRN_SUPPORT_FOREIGN_KEYS
1137 int storage_rename_foreign_key(MRN_SHARE *tmp_share,
1138 const char *from_table_name,
1139 const char *to_table_name);
1140#endif
1141 bool wrapper_is_crashed() const;
1142 bool storage_is_crashed() const;
1143 bool wrapper_auto_repair(int error) const;
1144 bool storage_auto_repair(int error) const;
1145 int generic_disable_index(int i, KEY *key_info);
1146 int wrapper_disable_indexes_mroonga(uint mode);
1147 int wrapper_disable_indexes(uint mode);
1148 int storage_disable_indexes(uint mode);
1149 int wrapper_enable_indexes_mroonga(uint mode);
1150 int wrapper_enable_indexes(uint mode);
1151 int storage_enable_indexes(uint mode);
1152 int wrapper_check(THD* thd, HA_CHECK_OPT* check_opt);
1153 int storage_check(THD* thd, HA_CHECK_OPT* check_opt);
1154 int wrapper_fill_indexes(THD *thd, KEY *key_info,
1155 grn_obj **index_columns, uint n_keys);
1156 int wrapper_recreate_indexes(THD *thd);
1157 int storage_recreate_indexes(THD *thd);
1158 int wrapper_repair(THD* thd, HA_CHECK_OPT* check_opt);
1159 int storage_repair(THD* thd, HA_CHECK_OPT* check_opt);
1160 bool wrapper_check_and_repair(THD *thd);
1161 bool storage_check_and_repair(THD *thd);
1162 int wrapper_analyze(THD* thd, HA_CHECK_OPT* check_opt);
1163 int storage_analyze(THD* thd, HA_CHECK_OPT* check_opt);
1164 int wrapper_optimize(THD* thd, HA_CHECK_OPT* check_opt);
1165 int storage_optimize(THD* thd, HA_CHECK_OPT* check_opt);
1166 bool wrapper_is_fatal_error(int error_num, uint flags);
1167 bool storage_is_fatal_error(int error_num, uint flags);
1168 bool wrapper_is_comment_changed(TABLE *table1, TABLE *table2);
1169 bool wrapper_check_if_incompatible_data(HA_CREATE_INFO *create_info,
1170 uint table_changes);
1171 bool storage_check_if_incompatible_data(HA_CREATE_INFO *create_info,
1172 uint table_changes);
1173 int storage_add_index_multiple_columns(KEY *key_info, uint num_of_keys,
1174 grn_obj **index_tables,
1175 grn_obj **index_columns,
1176 bool skip_unique_key);
1177#ifdef MRN_HANDLER_HAVE_CHECK_IF_SUPPORTED_INPLACE_ALTER
1178 enum_alter_inplace_result
1179 wrapper_check_if_supported_inplace_alter(TABLE *altered_table,
1180 Alter_inplace_info *ha_alter_info);
1181 enum_alter_inplace_result
1182 storage_check_if_supported_inplace_alter(TABLE *altered_table,
1183 Alter_inplace_info *ha_alter_info);
1184 bool wrapper_prepare_inplace_alter_table(TABLE *altered_table,
1185 Alter_inplace_info *ha_alter_info);
1186 bool storage_prepare_inplace_alter_table(TABLE *altered_table,
1187 Alter_inplace_info *ha_alter_info);
1188 bool wrapper_inplace_alter_table(TABLE *altered_table,
1189 Alter_inplace_info *ha_alter_info);
1190 bool storage_inplace_alter_table_add_index(TABLE *altered_table,
1191 Alter_inplace_info *ha_alter_info);
1192 bool storage_inplace_alter_table_drop_index(TABLE *altered_table,
1193 Alter_inplace_info *ha_alter_info);
1194 bool storage_inplace_alter_table_add_column(TABLE *altered_table,
1195 Alter_inplace_info *ha_alter_info);
1196 bool storage_inplace_alter_table_drop_column(TABLE *altered_table,
1197 Alter_inplace_info *ha_alter_info);
1198 bool storage_inplace_alter_table_rename_column(TABLE *altered_table,
1199 Alter_inplace_info *ha_alter_info);
1200 bool storage_inplace_alter_table(TABLE *altered_table,
1201 Alter_inplace_info *ha_alter_info);
1202 bool wrapper_commit_inplace_alter_table(TABLE *altered_table,
1203 Alter_inplace_info *ha_alter_info,
1204 bool commit);
1205 bool storage_commit_inplace_alter_table(TABLE *altered_table,
1206 Alter_inplace_info *ha_alter_info,
1207 bool commit);
1208 void wrapper_notify_table_changed();
1209 void storage_notify_table_changed();
1210#else
1211 alter_table_operations wrapper_alter_table_flags(alter_table_operations flags);
1212 alter_table_operations storage_alter_table_flags(alter_table_operations flags);
1213# ifdef MRN_HANDLER_HAVE_FINAL_ADD_INDEX
1214 int wrapper_add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys,
1215 handler_add_index **add);
1216 int storage_add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys,
1217 handler_add_index **add);
1218# else
1219 int wrapper_add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys);
1220 int storage_add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys);
1221# endif
1222# ifdef MRN_HANDLER_HAVE_FINAL_ADD_INDEX
1223 int wrapper_final_add_index(handler_add_index *add, bool commit);
1224 int storage_final_add_index(handler_add_index *add, bool commit);
1225# endif
1226 int wrapper_prepare_drop_index(TABLE *table_arg, uint *key_num,
1227 uint num_of_keys);
1228 int storage_prepare_drop_index(TABLE *table_arg, uint *key_num,
1229 uint num_of_keys);
1230 int wrapper_final_drop_index(TABLE *table_arg);
1231 int storage_final_drop_index(TABLE *table_arg);
1232#endif
1233 int wrapper_update_auto_increment();
1234 int storage_update_auto_increment();
1235 void wrapper_set_next_insert_id(ulonglong id);
1236 void storage_set_next_insert_id(ulonglong id);
1237 void wrapper_get_auto_increment(ulonglong offset, ulonglong increment,
1238 ulonglong nb_desired_values,
1239 ulonglong *first_value,
1240 ulonglong *nb_reserved_values);
1241 void storage_get_auto_increment(ulonglong offset, ulonglong increment,
1242 ulonglong nb_desired_values,
1243 ulonglong *first_value,
1244 ulonglong *nb_reserved_values);
1245 void wrapper_restore_auto_increment(ulonglong prev_insert_id);
1246 void storage_restore_auto_increment(ulonglong prev_insert_id);
1247 void wrapper_release_auto_increment();
1248 void storage_release_auto_increment();
1249 int wrapper_check_for_upgrade(HA_CHECK_OPT *check_opt);
1250 int storage_check_for_upgrade(HA_CHECK_OPT *check_opt);
1251#ifdef MRN_HANDLER_HAVE_RESET_AUTO_INCREMENT
1252 int wrapper_reset_auto_increment(ulonglong value);
1253 int storage_reset_auto_increment(ulonglong value);
1254#endif
1255 bool wrapper_was_semi_consistent_read();
1256 bool storage_was_semi_consistent_read();
1257 void wrapper_try_semi_consistent_read(bool yes);
1258 void storage_try_semi_consistent_read(bool yes);
1259 void wrapper_unlock_row();
1260 void storage_unlock_row();
1261 int wrapper_start_stmt(THD *thd, thr_lock_type lock_type);
1262 int storage_start_stmt(THD *thd, thr_lock_type lock_type);
1263 void wrapper_change_table_ptr(TABLE *table_arg, TABLE_SHARE *share_arg);
1264 void storage_change_table_ptr(TABLE *table_arg, TABLE_SHARE *share_arg);
1265 bool wrapper_primary_key_is_clustered();
1266 bool storage_primary_key_is_clustered();
1267 bool wrapper_is_fk_defined_on_table_or_index(uint index);
1268 bool storage_is_fk_defined_on_table_or_index(uint index);
1269 char *wrapper_get_foreign_key_create_info();
1270 char *storage_get_foreign_key_create_info();
1271#ifdef MRN_HANDLER_HAVE_GET_TABLESPACE_NAME
1272 char *wrapper_get_tablespace_name(THD *thd, char *name, uint name_len);
1273 char *storage_get_tablespace_name(THD *thd, char *name, uint name_len);
1274#endif
1275 bool wrapper_can_switch_engines();
1276 bool storage_can_switch_engines();
1277 int wrapper_get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
1278 int storage_get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
1279 int wrapper_get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
1280 int storage_get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
1281 uint wrapper_referenced_by_foreign_key();
1282 uint storage_referenced_by_foreign_key();
1283 void wrapper_init_table_handle_for_HANDLER();
1284 void storage_init_table_handle_for_HANDLER();
1285 void wrapper_free_foreign_key_create_info(char* str);
1286 void storage_free_foreign_key_create_info(char* str);
1287 void wrapper_set_keys_in_use();
1288 void storage_set_keys_in_use();
1289#ifdef MRN_RBR_UPDATE_NEED_ALL_COLUMNS
1290 bool check_written_by_row_based_binlog();
1291#endif
1292#ifdef MRN_HAVE_HA_REBIND_PSI
1293 void wrapper_unbind_psi();
1294 void storage_unbind_psi();
1295 void wrapper_rebind_psi();
1296 void storage_rebind_psi();
1297#endif
1298 my_bool wrapper_register_query_cache_table(THD *thd,
1299 const char *table_key,
1300 uint key_length,
1301 qc_engine_callback
1302 *engine_callback,
1303 ulonglong *engine_data);
1304 my_bool storage_register_query_cache_table(THD *thd,
1305 const char *table_key,
1306 uint key_length,
1307 qc_engine_callback
1308 *engine_callback,
1309 ulonglong *engine_data);
1310};
1311
1312#ifdef __cplusplus
1313}
1314#endif
1315
1316#endif /* HA_MROONGA_HPP_ */
1317