diff options
Diffstat (limited to 'sql/handler.h')
-rw-r--r-- | sql/handler.h | 136 |
1 files changed, 90 insertions, 46 deletions
diff --git a/sql/handler.h b/sql/handler.h index 052c245b801..e80b62c1250 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -117,6 +117,18 @@ #define HA_HAS_RECORDS (LL(1) << 32) /* records() gives exact count*/ /* Has it's own method of binlog logging */ #define HA_HAS_OWN_BINLOGGING (LL(1) << 33) +/* + Engine is capable of row-format and statement-format logging, + respectively +*/ +#define HA_BINLOG_ROW_CAPABLE (LL(1) << 34) +#define HA_BINLOG_STMT_CAPABLE (LL(1) << 35) + +/* + Set of all binlog flags. Currently only contain the capabilities + flags. + */ +#define HA_BINLOG_FLAGS (HA_BINLOG_ROW_CAPABLE | HA_BINLOG_STMT_CAPABLE) /* bits in index_flags(index_number) for what you can do with index */ #define HA_READ_NEXT 1 /* TODO really use this flag */ @@ -223,6 +235,7 @@ #define HA_LEX_CREATE_TMP_TABLE 1 #define HA_LEX_CREATE_IF_NOT_EXISTS 2 +#define HA_LEX_CREATE_TABLE_LIKE 4 #define HA_OPTION_NO_CHECKSUM (1L << 17) #define HA_OPTION_NO_DELAY_KEY_WRITE (1L << 18) #define HA_MAX_REC_LENGTH 65535 @@ -378,9 +391,9 @@ struct xid_t { return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+ gtrid_length+bqual_length; } - byte *key() + uchar *key() { - return (byte *)>rid_length; + return (uchar *)>rid_length; } uint key_length() { @@ -674,8 +687,8 @@ struct handlerton struct handler_iterator *fill_this_in); int (*discover)(handlerton *hton, THD* thd, const char *db, const char *name, - const void** frmblob, - uint* frmlen); + uchar **frmblob, + size_t *frmlen); int (*find_files)(handlerton *hton, THD *thd, const char *db, const char *path, @@ -687,7 +700,7 @@ struct handlerton }; -/* Possible flags of a handlerton */ +/* Possible flags of a handlerton (there can be 32 of them) */ #define HTON_NO_FLAGS 0 #define HTON_CLOSE_CURSORS_AT_COMMIT (1 << 0) #define HTON_ALTER_NOT_SUPPORTED (1 << 1) //Engine does not support alter @@ -792,19 +805,37 @@ typedef struct st_key_create_information class TABLEOP_HOOKS { public: + TABLEOP_HOOKS() {} + virtual ~TABLEOP_HOOKS() {} + inline void prelock(TABLE **tables, uint count) { do_prelock(tables, count); } - virtual ~TABLEOP_HOOKS() {} - TABLEOP_HOOKS() {} + inline int postlock(TABLE **tables, uint count) + { + return do_postlock(tables, count); + } private: /* Function primitive that is called prior to locking tables */ virtual void do_prelock(TABLE **tables, uint count) { /* Default is to do nothing */ } + + /** + Primitive called after tables are locked. + + If an error is returned, the tables will be unlocked and error + handling start. + + @return Error code or zero. + */ + virtual int do_postlock(TABLE **tables, uint count) + { + return 0; /* Default is to do nothing */ + } }; typedef struct st_savepoint SAVEPOINT; @@ -835,9 +866,9 @@ typedef struct st_ha_check_opt typedef struct st_handler_buffer { - const byte *buffer; /* Buffer one can start using */ - const byte *buffer_end; /* End of buffer */ - byte *end_of_used_area; /* End of area that was used by handler */ + const uchar *buffer; /* Buffer one can start using */ + const uchar *buffer_end; /* End of buffer */ + uchar *end_of_used_area; /* End of area that was used by handler */ } HANDLER_BUFFER; typedef struct system_status_var SSV; @@ -851,7 +882,15 @@ public: ulonglong max_index_file_length; ulonglong delete_length; /* Free bytes */ ulonglong auto_increment_value; - ha_rows records; /* Estimated records in table */ + /* + The number of records in the table. + 0 - means the table has exactly 0 rows + other - if (table_flags() & HA_STATS_RECORDS_IS_EXACT) + the value is the exact number of records in the table + else + it is an estimate + */ + ha_rows records; ha_rows deleted; /* Deleted records */ ulong mean_rec_length; /* physical reclength */ time_t create_time; /* When table was created */ @@ -867,7 +906,7 @@ public: {} }; -uint calculate_key_len(TABLE *, uint, const byte *, key_part_map); +uint calculate_key_len(TABLE *, uint, const uchar *, key_part_map); /* bitmap with first N+1 bits set (keypart_map for a key prefix of [0..N] keyparts) @@ -891,10 +930,13 @@ class handler :public Sql_alloc friend int ha_delete_table(THD*,handlerton*,const char*,const char*, const char*,bool); +public: + typedef ulonglong Table_flags; + protected: struct st_table_share *table_share; /* The table definition */ struct st_table *table; /* The current open table */ - ulonglong cached_table_flags; /* Set on init() and open() */ + Table_flags cached_table_flags; /* Set on init() and open() */ virtual int index_init(uint idx, bool sorted) { active_index=idx; return 0; } virtual int index_end() { active_index=MAX_KEY; return 0; } @@ -907,7 +949,7 @@ class handler :public Sql_alloc */ virtual int rnd_init(bool scan) =0; virtual int rnd_end() { return 0; } - virtual ulonglong table_flags(void) const =0; + virtual Table_flags table_flags(void) const =0; void ha_statistic_increment(ulong SSV::*offset) const; void **ha_data(THD *) const; @@ -918,8 +960,8 @@ class handler :public Sql_alloc virtual int end_bulk_insert() {return 0; } public: handlerton *ht; /* storage engine of this handler */ - byte *ref; /* Pointer to current row */ - byte *dup_ref; /* Pointer to duplicate row */ + uchar *ref; /* Pointer to current row */ + uchar *dup_ref; /* Pointer to duplicate row */ ha_statistics stats; @@ -1121,7 +1163,7 @@ public: { return inited == INDEX ? ha_index_end() : inited == RND ? ha_rnd_end() : 0; } - longlong ha_table_flags() { return cached_table_flags; } + Table_flags ha_table_flags() const { return cached_table_flags; } /* Signal that the table->read_set and table->write_set table maps changed @@ -1142,9 +1184,9 @@ public: and delete_row() below. */ int ha_external_lock(THD *thd, int lock_type); - int ha_write_row(byte * buf); - int ha_update_row(const byte * old_data, byte * new_data); - int ha_delete_row(const byte * buf); + int ha_write_row(uchar * buf); + int ha_update_row(const uchar * old_data, uchar * new_data); + int ha_delete_row(const uchar * buf); /* SYNOPSIS @@ -1177,7 +1219,7 @@ public: 0 Bulk delete used by handler 1 Bulk delete not used, normal operation used */ - virtual int bulk_update_row(const byte *old_data, byte *new_data, + virtual int bulk_update_row(const uchar *old_data, uchar *new_data, uint *dup_key_found) { DBUG_ASSERT(FALSE); @@ -1226,7 +1268,7 @@ public: return HA_ERR_WRONG_COMMAND; } private: - virtual int index_read(byte * buf, const byte * key, uint key_len, + virtual int index_read(uchar * buf, const uchar * key, uint key_len, enum ha_rkey_function find_flag) { return HA_ERR_WRONG_COMMAND; } public: @@ -1236,7 +1278,7 @@ public: row if available. If the key value is null, begin at the first key of the index. */ - virtual int index_read(byte * buf, const byte * key, key_part_map keypart_map, + virtual int index_read(uchar * buf, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { uint key_len= calculate_key_len(table, active_index, key, keypart_map); @@ -1248,20 +1290,20 @@ public: row if available. If the key value is null, begin at the first key of the index. */ - virtual int index_read_idx(byte * buf, uint index, const byte * key, + virtual int index_read_idx(uchar * buf, uint index, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag); - virtual int index_next(byte * buf) + virtual int index_next(uchar * buf) { return HA_ERR_WRONG_COMMAND; } - virtual int index_prev(byte * buf) + virtual int index_prev(uchar * buf) { return HA_ERR_WRONG_COMMAND; } - virtual int index_first(byte * buf) + virtual int index_first(uchar * buf) { return HA_ERR_WRONG_COMMAND; } - virtual int index_last(byte * buf) + virtual int index_last(uchar * buf) { return HA_ERR_WRONG_COMMAND; } - virtual int index_next_same(byte *buf, const byte *key, uint keylen); + virtual int index_next_same(uchar *buf, const uchar *key, uint keylen); private: - virtual int index_read_last(byte * buf, const byte * key, uint key_len) + virtual int index_read_last(uchar * buf, const uchar * key, uint key_len) { return (my_errno=HA_ERR_WRONG_COMMAND); } public: /** @@ -1269,7 +1311,7 @@ public: The following functions works like index_read, but it find the last row with the current key value or prefix. */ - virtual int index_read_last(byte * buf, const byte * key, + virtual int index_read_last(uchar * buf, const uchar * key, key_part_map keypart_map) { uint key_len= calculate_key_len(table, active_index, key, keypart_map); @@ -1288,21 +1330,21 @@ public: void ft_end() { ft_handler=NULL; } virtual FT_INFO *ft_init_ext(uint flags, uint inx,String *key) { return NULL; } - virtual int ft_read(byte *buf) { return HA_ERR_WRONG_COMMAND; } - virtual int rnd_next(byte *buf)=0; - virtual int rnd_pos(byte * buf, byte *pos)=0; - virtual int read_first_row(byte *buf, uint primary_key); + virtual int ft_read(uchar *buf) { return HA_ERR_WRONG_COMMAND; } + virtual int rnd_next(uchar *buf)=0; + virtual int rnd_pos(uchar * buf, uchar *pos)=0; + virtual int read_first_row(uchar *buf, uint primary_key); /* The following function is only needed for tables that may be temporary tables during joins */ - virtual int restart_rnd_next(byte *buf, byte *pos) + virtual int restart_rnd_next(uchar *buf, uchar *pos) { return HA_ERR_WRONG_COMMAND; } - virtual int rnd_same(byte *buf, uint inx) + virtual int rnd_same(uchar *buf, uint inx) { return HA_ERR_WRONG_COMMAND; } virtual ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key) { return (ha_rows) 10; } - virtual void position(const byte *record)=0; + virtual void position(const uchar *record)=0; virtual int info(uint)=0; // see my_base.h for full description virtual void get_dynamic_partition_info(PARTITION_INFO *stat_info, uint part_id); @@ -1558,8 +1600,8 @@ public: const char *path, ulonglong *copied, ulonglong *deleted, - const void *pack_frm_data, - uint pack_frm_len) + const uchar *pack_frm_data, + size_t pack_frm_len) { return HA_ERR_WRONG_COMMAND; } virtual int drop_partitions(const char *path) { return HA_ERR_WRONG_COMMAND; } @@ -1602,7 +1644,7 @@ public: false otherwise */ virtual bool primary_key_is_clustered() { return FALSE; } - virtual int cmp_ref(const byte *ref1, const byte *ref2) + virtual int cmp_ref(const uchar *ref1, const uchar *ref2) { return memcmp(ref1, ref2, ref_length); } @@ -1647,18 +1689,18 @@ public: { return COMPATIBLE_DATA_NO; } /* These are only called from sql_select for internal temporary tables */ - virtual int write_row(byte *buf __attribute__((unused))) + virtual int write_row(uchar *buf __attribute__((unused))) { return HA_ERR_WRONG_COMMAND; } - virtual int update_row(const byte *old_data __attribute__((unused)), - byte *new_data __attribute__((unused))) + virtual int update_row(const uchar *old_data __attribute__((unused)), + uchar *new_data __attribute__((unused))) { return HA_ERR_WRONG_COMMAND; } - virtual int delete_row(const byte *buf __attribute__((unused))) + virtual int delete_row(const uchar *buf __attribute__((unused))) { return HA_ERR_WRONG_COMMAND; } @@ -1685,6 +1727,8 @@ private: /* Some extern variables used with handlers */ extern const char *ha_row_type[]; +extern const char *tx_isolation_names[]; +extern const char *binlog_format_names[]; extern TYPELIB tx_isolation_typelib; extern TYPELIB myisam_stats_method_typelib; extern ulong total_ha, total_ha_2pc; @@ -1751,7 +1795,7 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat); /* discovery */ int ha_create_table_from_engine(THD* thd, const char *db, const char *name); int ha_discover(THD* thd, const char* dbname, const char* name, - const void** frmblob, uint* frmlen); + uchar** frmblob, size_t* frmlen); int ha_find_files(THD *thd,const char *db,const char *path, const char *wild, bool dir,List<char>* files); int ha_table_exists_in_engine(THD* thd, const char* db, const char* name); |