243
235
Discrete_interval auto_inc_interval_for_cur_row;
245
Cursor(plugin::StorageEngine &engine_arg, TableShare &share_arg);
246
virtual ~Cursor(void);
247
virtual Cursor *clone(memory::Root *mem_root);
237
handler(StorageEngine *engine_arg, TableShare *share_arg)
238
:table_share(share_arg), table(0),
239
estimation_rows_to_insert(0), engine(engine_arg),
240
ref(0), in_range_check_pushed_down(false),
241
key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
242
ref_length(sizeof(my_off_t)),
244
locked(false), implicit_emptied(0),
245
next_insert_id(0), insert_id_for_cur_row(0)
247
virtual ~handler(void);
248
virtual handler *clone(MEM_ROOT *mem_root);
249
/** This is called after create to allow us to set up cached variables */
252
cached_table_flags= table_flags();
249
255
/* ha_ methods: pubilc wrappers for private virtual API */
276
283
void ha_start_bulk_insert(ha_rows rows);
277
284
int ha_end_bulk_insert();
285
int ha_bulk_update_row(const unsigned char *old_data, unsigned char *new_data,
286
uint32_t *dup_key_found);
278
287
int ha_delete_all_rows();
279
288
int ha_reset_auto_increment(uint64_t value);
289
int ha_optimize(Session* session, HA_CHECK_OPT* check_opt);
280
290
int ha_analyze(Session* session, HA_CHECK_OPT* check_opt);
282
292
int ha_disable_indexes(uint32_t mode);
283
293
int ha_enable_indexes(uint32_t mode);
284
294
int ha_discard_or_import_tablespace(bool discard);
285
void closeMarkForDelete(const char *name);
295
void ha_prepare_for_alter();
296
void ha_drop_table(const char *name);
287
298
void adjust_next_insert_id_after_explicit_value(uint64_t nr);
288
299
int update_auto_increment();
300
void print_keydup_error(uint32_t key_nr, const char *msg);
301
virtual void print_error(int error, myf errflag);
302
virtual bool get_error_message(int error, String *buf);
303
uint32_t get_dup_key(int error);
289
304
virtual void change_table_ptr(Table *table_arg, TableShare *share);
291
306
/* Estimates calculation */
353
366
virtual int close(void)=0;
369
@retval 0 Bulk update used by handler
370
@retval 1 Bulk update not used, normal operation used
372
virtual bool start_bulk_update() { return 1; }
374
@retval 0 Bulk delete used by handler
375
@retval 1 Bulk delete not used, normal operation used
377
virtual bool start_bulk_delete() { return 1; }
379
After this call all outstanding updates must be performed. The number
380
of duplicate key errors are reported in the duplicate key parameter.
381
It is allowed to continue to the batched update after this call, the
382
handler has to wait until end_bulk_update with changing state.
384
@param dup_key_found Number of duplicate keys found
387
@retval >0 Error code
389
virtual int exec_bulk_update(uint32_t *)
392
return HA_ERR_WRONG_COMMAND;
395
Perform any needed clean-up, no outstanding updates are there at the
398
virtual void end_bulk_update() { return; }
400
Execute all outstanding deletes and close down the bulk delete.
403
@retval >0 Error code
405
virtual int end_bulk_delete()
408
return HA_ERR_WRONG_COMMAND;
357
412
Positions an index cursor to the index specified in the handle. Fetches the
358
413
row if available. If the key value is null, begin at the first key of the
513
579
virtual int final_drop_index(Table *)
514
580
{ return (HA_ERR_WRONG_COMMAND); }
582
uint32_t max_record_length() const
583
{ return std::min((unsigned int)HA_MAX_REC_LENGTH, max_supported_record_length()); }
584
uint32_t max_keys() const
585
{ return std::min((unsigned int)MAX_KEY, max_supported_keys()); }
586
uint32_t max_key_parts() const
587
{ return std::min((unsigned int)MAX_REF_PARTS, max_supported_key_parts()); }
588
uint32_t max_key_length() const
589
{ return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_length()); }
590
uint32_t max_key_part_length(void) const
591
{ return std::min((unsigned int)MAX_KEY_LENGTH, max_supported_key_part_length()); }
593
virtual uint32_t max_supported_record_length(void) const
594
{ return HA_MAX_REC_LENGTH; }
595
virtual uint32_t max_supported_keys(void) const { return 0; }
596
virtual uint32_t max_supported_key_parts(void) const { return MAX_REF_PARTS; }
597
virtual uint32_t max_supported_key_length(void) const { return MAX_KEY_LENGTH; }
598
virtual uint32_t max_supported_key_part_length(void) const { return 255; }
600
virtual bool low_byte_first(void) const { return 1; }
516
601
virtual uint32_t checksum(void) const { return 0; }
602
virtual bool is_crashed(void) const { return 0; }
603
virtual bool auto_repair(void) const { return 0; }
519
606
Is not invoked for non-transactional temporary tables.
548
630
return memcmp(ref1, ref2, ref_length);
551
virtual bool isOrdered(void)
636
@param session Thread handle
637
@param lock_type HA_LOCK_IN_SHARE_MODE (F_RDLCK)
638
HA_LOCK_IN_EXCLUSIVE_MODE (F_WRLCK)
639
@param lock_timeout -1 default timeout
641
>0 wait timeout in milliseconds.
644
lock_timeout >0 is not used by MySQL currently. If the storage
645
engine does not support NOWAIT (lock_timeout == 0) it should
646
return an error. But if it does not support WAIT X (lock_timeout
647
>0) it should treat it as lock_timeout == -1 and wait a default
648
(or even hard-coded) timeout.
650
@retval HA_ERR_WRONG_COMMAND Storage engine does not support
652
@retval HA_ERR_UNSUPPORTED Storage engine does not support NOWAIT
653
@retval HA_ERR_LOCK_WAIT_TIMEOUT Lock request timed out or
654
lock conflict with NOWAIT option
655
@retval HA_ERR_LOCK_DEADLOCK Deadlock detected
657
virtual int lock_table(Session *, int, int)
659
return HA_ERR_WRONG_COMMAND;
558
663
/* Service methods for use by storage engines. */
559
void ha_statistic_increment(ulong system_status_var::*offset) const;
664
void ha_statistic_increment(ulong SSV::*offset) const;
560
665
void **ha_data(Session *) const;
561
666
Session *ha_session(void) const;
564
669
/* Private helpers */
565
inline void setTransactionReadWrite();
670
inline void mark_trx_read_write();
568
673
Low-level primitives for storage engines. These should be
642
750
uint32_t, enum ha_rkey_function)
643
751
{ return HA_ERR_WRONG_COMMAND; }
644
752
virtual int index_read_last(unsigned char *, const unsigned char *, uint32_t)
645
{ return (errno= HA_ERR_WRONG_COMMAND); }
753
{ return (my_errno= HA_ERR_WRONG_COMMAND); }
755
This method is similar to update_row, however the handler doesn't need
756
to execute the updates at this point in time. The handler can be certain
757
that another call to bulk_update_row will occur OR a call to
758
exec_bulk_update before the set of updates in this query is concluded.
760
@param old_data Old record
761
@param new_data New record
762
@param dup_key_found Number of duplicate keys found
764
@retval 0 Bulk delete used by handler
765
@retval 1 Bulk delete not used, normal operation used
767
virtual int bulk_update_row(const unsigned char *, unsigned char *, uint32_t *)
770
return HA_ERR_WRONG_COMMAND;
647
773
This is called to delete all rows in a table
648
If the Cursor don't support this, then this function will
774
If the handler don't support this, then this function will
649
775
return HA_ERR_WRONG_COMMAND and MySQL will delete the rows one
652
778
virtual int delete_all_rows(void)
653
{ return (errno=HA_ERR_WRONG_COMMAND); }
779
{ return (my_errno=HA_ERR_WRONG_COMMAND); }
655
781
Reset the auto-increment counter to the given value, i.e. the next row
656
782
inserted will get the given value. This is called e.g. after TRUNCATE
660
786
virtual int reset_auto_increment(uint64_t)
661
787
{ return HA_ERR_WRONG_COMMAND; }
663
virtual int analyze(Session *)
788
virtual int optimize(Session *, HA_CHECK_OPT *)
789
{ return HA_ADMIN_NOT_IMPLEMENTED; }
790
virtual int analyze(Session *, HA_CHECK_OPT *)
664
791
{ return HA_ADMIN_NOT_IMPLEMENTED; }
666
793
virtual int disable_indexes(uint32_t)
667
794
{ return HA_ERR_WRONG_COMMAND; }
669
795
virtual int enable_indexes(uint32_t)
670
796
{ return HA_ERR_WRONG_COMMAND; }
672
797
virtual int discard_or_import_tablespace(bool)
673
{ return (errno=HA_ERR_WRONG_COMMAND); }
676
@todo this is just for the HEAP engine, it should
677
be removed at some point in the future (and
678
no new engine should ever use it). Right
679
now HEAP does rely on it, so we cannot remove it.
798
{ return (my_errno=HA_ERR_WRONG_COMMAND); }
799
virtual void prepare_for_alter(void) { return; }
681
800
virtual void drop_table(const char *name);
684
803
extern const char *ha_row_type[];
804
extern const char *tx_isolation_names[];
805
extern const char *binlog_format_names[];
806
extern TYPELIB tx_isolation_typelib;
807
extern TYPELIB myisam_stats_method_typelib;
808
extern uint32_t total_ha, total_ha_2pc;
810
/* Wrapper functions */
811
#define ha_commit(session) (ha_commit_trans((session), true))
812
#define ha_rollback(session) (ha_rollback_trans((session), true))
686
814
/* basic stuff */
687
void ha_init_errors(void);
815
int ha_init_errors(void);
819
void add_storage_engine(StorageEngine *engine);
820
void remove_storage_engine(StorageEngine *engine);
822
void ha_close_connection(Session* session);
823
bool ha_flush_logs(StorageEngine *db_type);
824
void ha_drop_database(char* path);
825
int ha_create_table(Session *session, const char *path,
826
const char *db, const char *table_name,
827
HA_CREATE_INFO *create_info,
828
bool update_create_info,
829
drizzled::message::Table *table_proto);
830
int ha_delete_table(Session *session, const char *path,
831
const char *db, const char *alias, bool generate_warning);
833
/* statistics and info */
834
bool ha_show_status(Session *session, StorageEngine *db_type, enum ha_stat_type stat);
836
int ha_find_files(Session *session,const char *db,const char *path,
837
const char *wild, bool dir, List<LEX_STRING>* files);
839
/* report to InnoDB that control passes to the client */
840
int ha_release_temporary_latches(Session *session);
842
/* transactions: interface to StorageEngine functions */
843
int ha_start_consistent_snapshot(Session *session);
844
int ha_commit_or_rollback_by_xid(XID *xid, bool commit);
845
int ha_commit_one_phase(Session *session, bool all);
846
int ha_rollback_trans(Session *session, bool all);
847
int ha_recover(HASH *commit_list);
849
/* transactions: these functions never call StorageEngine functions directly */
850
int ha_commit_trans(Session *session, bool all);
851
int ha_autocommit_or_rollback(Session *session, int error);
852
int ha_enable_transaction(Session *session, bool on);
855
int ha_rollback_to_savepoint(Session *session, SAVEPOINT *sv);
856
int ha_savepoint(Session *session, SAVEPOINT *sv);
857
int ha_release_savepoint(Session *session, SAVEPOINT *sv);
859
/* these are called by storage engines */
860
void trans_register_ha(Session *session, bool all, StorageEngine *engine);
862
uint32_t filename_to_tablename(const char *from, char *to, uint32_t to_length);
863
bool tablename_to_filename(const char *from, char *to, size_t to_length);
866
bool mysql_ha_open(Session *session, TableList *tables, bool reopen);
867
bool mysql_ha_close(Session *session, TableList *tables);
868
bool mysql_ha_read(Session *, TableList *,enum enum_ha_read_modes,char *,
869
List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
870
void mysql_ha_flush(Session *session);
871
void mysql_ha_rm_tables(Session *session, TableList *tables, bool is_locked);
872
void mysql_ha_cleanup(Session *session);
875
Storage engine has to assume the transaction will end up with 2pc if
876
- there is more than one 2pc-capable storage engine available
877
- in the current transaction 2pc was not disabled yet
879
#define trans_need_2pc(session, all) ((total_ha_2pc > 1) && \
880
!((all ? &session->transaction.all : &session->transaction.stmt)->no_2pc))
883
bool mysql_xa_recover(Session *session);
689
885
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
690
886
SORT_FIELD *sortorder);
699
895
bool handle_select(Session *session, LEX *lex, select_result *result,
700
896
uint64_t setup_tables_done_option);
897
bool mysql_select(Session *session, Item ***rref_pointer_array,
898
TableList *tables, uint32_t wild_num, List<Item> &list,
899
COND *conds, uint32_t og_num, order_st *order, order_st *group,
900
Item *having, uint64_t select_type,
901
select_result *result, Select_Lex_Unit *unit,
902
Select_Lex *select_lex);
701
903
void free_underlaid_joins(Session *session, Select_Lex *select);
904
bool mysql_explain_union(Session *session, Select_Lex_Unit *unit,
905
select_result *result);
906
int mysql_explain_select(Session *session, Select_Lex *sl, char const *type,
907
select_result *result);
703
909
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
705
911
TableList *table));
706
912
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t);
707
913
bool mysql_derived_filling(Session *session, LEX *lex, TableList *t);
914
void sp_prepare_create_field(Session *session, CreateField *sql_field);
708
915
int prepare_create_field(CreateField *sql_field,
709
916
uint32_t *blob_columns,
710
int *timestamps, int *timestamps_with_niladic);
712
bool mysql_create_table(Session *session,
713
TableIdentifier &identifier,
917
int *timestamps, int *timestamps_with_niladic,
918
int64_t table_flags);
919
bool mysql_create_table(Session *session,const char *db, const char *table_name,
714
920
HA_CREATE_INFO *create_info,
715
message::Table &table_proto,
716
AlterInfo *alter_info,
717
bool tmp_table, uint32_t select_field_count,
718
bool is_if_not_exists);
720
bool mysql_create_table_no_lock(Session *session,
721
TableIdentifier &identifier,
921
drizzled::message::Table *table_proto,
922
Alter_info *alter_info,
923
bool tmp_table, uint32_t select_field_count);
924
bool mysql_create_table_no_lock(Session *session, const char *db,
925
const char *table_name,
722
926
HA_CREATE_INFO *create_info,
723
message::Table &table_proto,
724
AlterInfo *alter_info,
725
bool tmp_table, uint32_t select_field_count,
726
bool is_if_not_exists);
728
bool mysql_create_like_table(Session* session,
729
TableIdentifier &destination_identifier,
730
TableList* table, TableList* src_table,
731
message::Table &create_table_proto,
732
bool is_if_not_exists,
735
bool mysql_rename_table(plugin::StorageEngine *base,
736
TableIdentifier &old_identifier,
737
TableIdentifier &new_identifier,
927
drizzled::message::Table *table_proto,
928
Alter_info *alter_info,
929
bool tmp_table, uint32_t select_field_count);
931
bool mysql_alter_table(Session *session, char *new_db, char *new_name,
932
HA_CREATE_INFO *create_info,
933
TableList *table_list,
934
Alter_info *alter_info,
935
uint32_t order_num, order_st *order, bool ignore);
936
bool mysql_recreate_table(Session *session, TableList *table_list);
937
bool mysql_create_like_table(Session *session, TableList *table,
938
TableList *src_table,
939
HA_CREATE_INFO *create_info);
940
bool mysql_rename_table(StorageEngine *base, const char *old_db,
941
const char * old_name, const char *new_db,
942
const char * new_name, uint32_t flags);
740
943
bool mysql_prepare_update(Session *session, TableList *table_list,
741
944
Item **conds, uint32_t order_num, order_st *order);
742
945
int mysql_update(Session *session,TableList *tables,List<Item> &fields,