mariadb/handler/ha_innodb.h
marko 1865d59b7a branches/innodb+: Merge revisions 4528:4657 from branches/zip:
------------------------------------------------------------------------
  r4530 | marko | 2009-03-24 14:02:29 +0200 (Tue, 24 Mar 2009) | 3 lines

  branches/zip: Remove references to UNIV_HOTBACKUP from files that are
  not used when building InnoDB Hot Backup.  Declare
  innobase_invalidate_query_cache() in ha_prototypes.h.
  ------------------------------------------------------------------------
  r4531 | marko | 2009-03-24 15:46:12 +0200 (Tue, 24 Mar 2009) | 7 lines

  branches/zip: Note that buf_page_t::list and buf_page_t::in_flush_list
  are only protected by buf_pool_mutex, not by the block mutex.

  buf_page_release(): Remove the assertion on in_flush_list.
  The function is only holding block->mutex, not buf_pool_mutex.
  This was reported by Sunny.  This was the only piece of code
  that accessed in_flush_list while not holding buf_pool_mutex.
  ------------------------------------------------------------------------
  r4532 | calvin | 2009-03-24 17:59:45 +0200 (Tue, 24 Mar 2009) | 13 lines

  branches/zip: Mantis issue #201 - remove innodb_plugin_init() due to
  new option --ignore_builtin_innodb

  Starting 5.1.33, MySQL has a new option --ignore_builtin_innodb
  for using the dynamic plugin. It is required to remove
  innodb_plugin_init() in the plugin.

  This patch removes innodb_plugin_init() as well as functions,
  variables used by innodb_plugin_init().

  rb://98

  Approved by: Marko
  ------------------------------------------------------------------------
  r4543 | inaam | 2009-03-25 19:18:33 +0200 (Wed, 25 Mar 2009) | 17 lines

  branches/zip

  SHOW ENGINE INNODB MUTEX shows all mutexes and rw_locks. This can
  be overwhelming particularly when the buffer pool is very large
  (note that each block in buffer pool has at least one mutex, one
  rw_lock and an additional mutex if rw_lock does not use atomics).
  With this patch status of following mutexes and rw-locks is not shown:

  1) block->mutex
  2) block->lock
  3) block->lock->mutex (if applicable)
  4) All other mutexes and rw-locks for which number of os-waits are zero

  Addresses issue# 179 rb://99

  Approved by: Marko
  ------------------------------------------------------------------------
  r4579 | marko | 2009-03-31 10:40:58 +0300 (Tue, 31 Mar 2009) | 3 lines

  branches/zip: struct read_view_struct: Add clarifying comments about
  low_limit_id and up_limit_id.
  ------------------------------------------------------------------------
  r4630 | calvin | 2009-04-02 15:46:47 +0300 (Thu, 02 Apr 2009) | 6 lines

  branches/zip: Mantis issue #197 - Make srv_spin_wait_delay configurable

  New parameter innodb_spin_wait_delay to set the maximum delay between
  polling for a spin lock. 5 is the default.

  Approved by: Marko (on IM)
  ------------------------------------------------------------------------
  r4631 | marko | 2009-04-02 16:23:12 +0300 (Thu, 02 Apr 2009) | 24 lines

  branches/zip: Refuse to use newly created indexes that may lack
  history.  This addresses Mantis issue #116.

  dict_index_t: Enable the storage of trx_id.

  row_prebuilt_t: Make many fields bit-fields to reduce the memory
  footprint. Add index_usable.

  ha_innobase::change_active_index(): Check if the index is usable and
  set prebuilt->index_usable accordingly. Unfortunately, the return
  status of this function is ignored by MySQL, and the actual refusal to
  use the index must be made in row_search_for_mysql().

  row_search_for_mysql(): Return DB_MISSING_HISTORY if
  !prebuilt->index_usable.

  convert_error_code_to_mysql(): Map DB_MISSING_HISTORY to
  HA_ERR_TABLE_DEF_CHANGED.

  innodb-index.test: Add a test case where access to a newly created
  secondary index must be blocked for old transactions.

  rb://100 approved by Heikki Tuuri
  ------------------------------------------------------------------------
  r4647 | vasil | 2009-04-06 10:05:25 +0300 (Mon, 06 Apr 2009) | 4 lines

  branches/zip:

  Add changelog entry for c4630.
  ------------------------------------------------------------------------
  r4648 | vasil | 2009-04-06 10:07:26 +0300 (Mon, 06 Apr 2009) | 4 lines

  branches/zip:

  Fix formatting in ChangeLog to be consistent.
  ------------------------------------------------------------------------
  r4657 | marko | 2009-04-06 15:13:45 +0300 (Mon, 06 Apr 2009) | 1 line

  branches/zip: Remove the bogus failure reported in Issue #219.
  ------------------------------------------------------------------------
2009-04-06 11:18:22 +00:00

275 lines
9.6 KiB
C++

/*****************************************************************************
Copyright (c) 2000, 2009, MySQL AB & Innobase Oy. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
*****************************************************************************/
/*
This file is based on ha_berkeley.h of MySQL distribution
This file defines the Innodb handler: the interface between MySQL and
Innodb
*/
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */
#endif
typedef struct st_innobase_share {
THR_LOCK lock;
pthread_mutex_t mutex;
const char* table_name;
uint use_count;
void* table_name_hash;
} INNOBASE_SHARE;
struct dict_index_struct;
struct row_prebuilt_struct;
typedef struct dict_index_struct dict_index_t;
typedef struct row_prebuilt_struct row_prebuilt_t;
/* The class defining a handle to an Innodb table */
class ha_innobase: public handler
{
row_prebuilt_t* prebuilt; /* prebuilt struct in InnoDB, used
to save CPU time with prebuilt data
structures*/
THD* user_thd; /* the thread handle of the user
currently using the handle; this is
set in external_lock function */
THR_LOCK_DATA lock;
INNOBASE_SHARE *share;
uchar* upd_buff; /* buffer used in updates */
uchar* key_val_buff; /* buffer used in converting
search key values from MySQL format
to Innodb format */
ulong upd_and_key_val_buff_len;
/* the length of each of the previous
two buffers */
Table_flags int_table_flags;
uint primary_key;
ulong start_of_scan; /* this is set to 1 when we are
starting a table scan but have not
yet fetched any row, else 0 */
uint last_match_mode;/* match mode of the latest search:
ROW_SEL_EXACT, ROW_SEL_EXACT_PREFIX,
or undefined */
uint num_write_row; /* number of write_row() calls */
uint store_key_val_for_row(uint keynr, char* buff, uint buff_len,
const uchar* record);
inline void update_thd(THD* thd);
void update_thd();
int change_active_index(uint keynr);
int general_fetch(uchar* buf, uint direction, uint match_mode);
ulint innobase_lock_autoinc();
ulonglong innobase_peek_autoinc();
ulint innobase_set_max_autoinc(ulonglong auto_inc);
ulint innobase_reset_autoinc(ulonglong auto_inc);
ulint innobase_get_autoinc(ulonglong* value);
ulint innobase_update_autoinc(ulonglong auto_inc);
ulint innobase_initialize_autoinc();
dict_index_t* innobase_get_index(uint keynr);
ulonglong innobase_get_int_col_max_value(const Field* field);
/* Init values for the class: */
public:
ha_innobase(handlerton *hton, TABLE_SHARE *table_arg);
~ha_innobase();
/*
Get the row type from the storage engine. If this method returns
ROW_TYPE_NOT_USED, the information in HA_CREATE_INFO should be used.
*/
enum row_type get_row_type() const;
const char* table_type() const;
const char* index_type(uint key_number);
const char** bas_ext() const;
Table_flags table_flags() const;
ulong index_flags(uint idx, uint part, bool all_parts) const;
uint max_supported_keys() const;
uint max_supported_key_length() const;
uint max_supported_key_part_length() const;
const key_map* keys_to_use_for_scanning();
int open(const char *name, int mode, uint test_if_locked);
int close(void);
double scan_time();
double read_time(uint index, uint ranges, ha_rows rows);
int write_row(uchar * buf);
int update_row(const uchar * old_data, uchar * new_data);
int delete_row(const uchar * buf);
bool was_semi_consistent_read();
void try_semi_consistent_read(bool yes);
void unlock_row();
int index_init(uint index, bool sorted);
int index_end();
int index_read(uchar * buf, const uchar * key,
uint key_len, enum ha_rkey_function find_flag);
int index_read_idx(uchar * buf, uint index, const uchar * key,
uint key_len, enum ha_rkey_function find_flag);
int index_read_last(uchar * buf, const uchar * key, uint key_len);
int index_next(uchar * buf);
int index_next_same(uchar * buf, const uchar *key, uint keylen);
int index_prev(uchar * buf);
int index_first(uchar * buf);
int index_last(uchar * buf);
int rnd_init(bool scan);
int rnd_end();
int rnd_next(uchar *buf);
int rnd_pos(uchar * buf, uchar *pos);
void position(const uchar *record);
int info(uint);
int analyze(THD* thd,HA_CHECK_OPT* check_opt);
int optimize(THD* thd,HA_CHECK_OPT* check_opt);
int discard_or_import_tablespace(my_bool discard);
int extra(enum ha_extra_function operation);
int reset();
int external_lock(THD *thd, int lock_type);
int transactional_table_lock(THD *thd, int lock_type);
int start_stmt(THD *thd, thr_lock_type lock_type);
void position(uchar *record);
ha_rows records_in_range(uint inx, key_range *min_key, key_range
*max_key);
ha_rows estimate_rows_upper_bound();
void update_create_info(HA_CREATE_INFO* create_info);
int create(const char *name, register TABLE *form,
HA_CREATE_INFO *create_info);
int delete_all_rows();
int delete_table(const char *name);
int rename_table(const char* from, const char* to);
int check(THD* thd, HA_CHECK_OPT* check_opt);
char* update_table_comment(const char* comment);
char* get_foreign_key_create_info();
int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
bool can_switch_engines();
uint referenced_by_foreign_key();
void free_foreign_key_create_info(char* str);
THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to,
enum thr_lock_type lock_type);
void init_table_handle_for_HANDLER();
virtual void get_auto_increment(ulonglong offset, ulonglong increment,
ulonglong nb_desired_values,
ulonglong *first_value,
ulonglong *nb_reserved_values);
int reset_auto_increment(ulonglong value);
virtual bool get_error_message(int error, String *buf);
uint8 table_cache_type();
/*
ask handler about permission to cache table during query registration
*/
my_bool register_query_cache_table(THD *thd, char *table_key,
uint key_length,
qc_engine_callback *call_back,
ulonglong *engine_data);
static char *get_mysql_bin_log_name();
static ulonglong get_mysql_bin_log_pos();
bool primary_key_is_clustered();
int cmp_ref(const uchar *ref1, const uchar *ref2);
/** Fast index creation (smart ALTER TABLE) @see handler0alter.cc @{ */
int add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys);
int prepare_drop_index(TABLE *table_arg, uint *key_num,
uint num_of_keys);
int final_drop_index(TABLE *table_arg);
/** @} */
bool check_if_incompatible_data(HA_CREATE_INFO *info,
uint table_changes);
};
/* Some accessor functions which the InnoDB plugin needs, but which
can not be added to mysql/plugin.h as part of the public interface;
the definitions are bracketed with #ifdef INNODB_COMPATIBILITY_HOOKS */
#ifndef INNODB_COMPATIBILITY_HOOKS
#error InnoDB needs MySQL to be built with #define INNODB_COMPATIBILITY_HOOKS
#endif
extern "C" {
struct charset_info_st *thd_charset(MYSQL_THD thd);
char **thd_query(MYSQL_THD thd);
/** Get the file name of the MySQL binlog.
* @return the name of the binlog file
*/
const char* mysql_bin_log_file_name(void);
/** Get the current position of the MySQL binlog.
* @return byte offset from the beginning of the binlog
*/
ulonglong mysql_bin_log_file_pos(void);
/**
Check if a user thread is a replication slave thread
@param thd user thread
@retval 0 the user thread is not a replication slave thread
@retval 1 the user thread is a replication slave thread
*/
int thd_slave_thread(const MYSQL_THD thd);
/**
Check if a user thread is running a non-transactional update
@param thd user thread
@retval 0 the user thread is not running a non-transactional update
@retval 1 the user thread is running a non-transactional update
*/
int thd_non_transactional_update(const MYSQL_THD thd);
/**
Get the user thread's binary logging format
@param thd user thread
@return Value to be used as index into the binlog_format_names array
*/
int thd_binlog_format(const MYSQL_THD thd);
/**
Mark transaction to rollback and mark error as fatal to a sub-statement.
@param thd Thread handle
@param all TRUE <=> rollback main transaction.
*/
void thd_mark_transaction_to_rollback(MYSQL_THD thd, bool all);
}
typedef struct trx_struct trx_t;
/************************************************************************
Converts an InnoDB error code to a MySQL error code and also tells to MySQL
about a possible transaction rollback inside InnoDB caused by a lock wait
timeout or a deadlock. */
extern "C"
int
convert_error_code_to_mysql(
/*========================*/
/* out: MySQL error code */
int error, /* in: InnoDB error code */
ulint flags, /* in: InnoDB table flags, or 0 */
MYSQL_THD thd); /* in: user thread handle or NULL */
/*************************************************************************
Allocates an InnoDB transaction for a MySQL handler object. */
extern "C"
trx_t*
innobase_trx_allocate(
/*==================*/
/* out: InnoDB transaction handle */
MYSQL_THD thd); /* in: user thread handle */