Drizzled Public API Documentation

ha_innodb.cc File Reference

#include <config.h>
#include <limits.h>
#include <fcntl.h>
#include <drizzled/error.h>
#include <drizzled/errmsg_print.h>
#include <drizzled/charset_info.h>
#include <drizzled/internal/m_string.h>
#include <drizzled/internal/my_sys.h>
#include <drizzled/plugin.h>
#include <drizzled/show.h>
#include <drizzled/data_home.h>
#include <drizzled/field.h>
#include <drizzled/charset.h>
#include <drizzled/session.h>
#include <drizzled/current_session.h>
#include <drizzled/table.h>
#include <drizzled/field/blob.h>
#include <drizzled/field/varstring.h>
#include <drizzled/plugin/xa_storage_engine.h>
#include <drizzled/plugin/daemon.h>
#include <drizzled/memory/multi_malloc.h>
#include <drizzled/pthread_globals.h>
#include <drizzled/named_savepoint.h>
#include <drizzled/transaction_services.h>
#include <drizzled/message/statement_transform.h>
#include <boost/algorithm/string.hpp>
#include <boost/program_options.hpp>
#include <boost/scoped_array.hpp>
#include <boost/filesystem.hpp>
#include <drizzled/module/option_map.h>
#include <iostream>
#include "univ.i"
#include "buf0lru.h"
#include "btr0sea.h"
#include "os0file.h"
#include "os0thread.h"
#include "srv0start.h"
#include "srv0srv.h"
#include "trx0roll.h"
#include "trx0trx.h"
#include "trx0sys.h"
#include "mtr0mtr.h"
#include "row0ins.h"
#include "row0mysql.h"
#include "row0sel.h"
#include "row0upd.h"
#include "log0log.h"
#include "lock0lock.h"
#include "dict0crea.h"
#include "create_replication.h"
#include "btr0cur.h"
#include "btr0btr.h"
#include "fsp0fsp.h"
#include "sync0sync.h"
#include "fil0fil.h"
#include "trx0xa.h"
#include "row0merge.h"
#include "thr0loc.h"
#include "dict0boot.h"
#include "ha_prototypes.h"
#include "ut0mem.h"
#include "ibuf0ibuf.h"
#include "ha_innodb.h"
#include "data_dictionary.h"
#include "replication_dictionary.h"
#include "internal_dictionary.h"
#include "handler0vars.h"
#include <sstream>
#include <string>
#include <plugin/innobase/handler/status_function.h>
#include <plugin/innobase/handler/replication_log.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/text_format.h>
#include <boost/thread/mutex.hpp>

Go to the source code of this file.

Classes

class  InnobaseEngine

Defines

#define INSIDE_HA_INNOBASE_CC
#define EQ_CURRENT_SESSION(session)   ((session) == current_session)
#define INNOBASE_WAKE_INTERVAL   32
#define DEFAULT_FILE_EXTENSION   ".dfe"

Typedefs

typedef constrained_check
< uint32_t, UINT32_MAX, 10 > 
open_files_constraint
typedef constrained_check
< uint32_t, 10, 1 > 
mirrored_log_groups_constraint
typedef constrained_check
< uint32_t, 100, 2 > 
log_files_in_group_constraint
typedef constrained_check
< uint32_t, 6, 0 > 
force_recovery_constraint
typedef constrained_check
< size_t, SIZE_MAX, 256 *1024, 1024 > 
log_buffer_constraint
typedef constrained_check
< size_t, SIZE_MAX, 512 *1024, 1024 > 
additional_mem_pool_constraint
typedef constrained_check
< unsigned int, 1000, 1 > 
autoextend_constraint
typedef constrained_check
< size_t, SIZE_MAX, 5242880, 1048576 > 
buffer_pool_constraint
typedef constrained_check
< uint32_t, MAX_BUFFER_POOLS, 1 > 
buffer_pool_instances_constraint
typedef constrained_check
< uint32_t, UINT32_MAX, 100 > 
io_capacity_constraint
typedef constrained_check
< uint32_t, 5000, 1 > 
purge_batch_constraint
typedef constrained_check
< uint32_t, 1, 0 > 
purge_threads_constraint
typedef constrained_check
< uint32_t, 2, 0 > 
trinary_constraint
typedef constrained_check
< unsigned int, 99, 0 > 
max_dirty_pages_constraint
typedef constrained_check
< uint32_t, 64, 1 > 
io_threads_constraint
typedef constrained_check
< uint32_t, 1000, 0 > 
concurrency_constraint
typedef constrained_check
< int64_t, INT64_MAX, 1024 *1024, 1024 *1024 > 
log_file_constraint
typedef constrained_check
< uint32_t, 95, 5 > 
old_blocks_constraint
typedef constrained_check
< uint32_t, 64, 0 > 
read_ahead_threshold_constraint
typedef constrained_check
< uint32_t, 1024 *1024 *1024, 1 > 
lock_wait_constraint

Functions

static INNOBASE_SHAREget_share (const char *table_name)
static void free_share (INNOBASE_SHARE *share)
static uint innobase_file_format_name_lookup (const char *format_name)
static int innobase_file_format_validate_and_set (const char *format_max)
static void innobase_commit_low (trx_t *trx)
UNIV_INTERN ibool thd_is_replication_slave_thread (drizzled::Session *)
static void innodb_srv_conc_enter_innodb (trx_t *trx)
static void innodb_srv_conc_exit_innodb (trx_t *trx)
static void innobase_release_stat_resources (trx_t *trx)
UNIV_INTERN ibool thd_has_edited_nontrans_tables (drizzled::Session *session)
UNIV_INTERN ibool thd_is_select (const drizzled::Session *session)
UNIV_INTERN ibool thd_supports_xa (drizzled::Session *)
UNIV_INTERN ulong thd_lock_wait_timeout (drizzled::Session *)
UNIV_INTERN void thd_set_lock_wait_time (drizzled::Session *in_session, ulint value)
static trx_t *& session_to_trx (Session *session)
static void innobase_active_small (void)
UNIV_INTERN int convert_error_code_to_mysql (int error, ulint flags, Session *session)
UNIV_INTERN void innobase_mysql_print_thd (FILE *f, drizzled::Session *in_session, uint)
UNIV_INTERN void innobase_get_cset_width (ulint cset, ulint *mbminlen, ulint *mbmaxlen)
UNIV_INTERN void innobase_convert_from_table_id (const void *, char *to, const char *from, ulint len)
UNIV_INTERN void innobase_convert_from_id (const void *, char *to, const char *from, ulint len)
UNIV_INTERN int innobase_strcasecmp (const char *a, const char *b)
UNIV_INTERN void innobase_casedn_str (char *a)
UNIV_INTERN bool innobase_isspace (const void *cs, char char_to_test)
UNIV_INTERN int innobase_mysql_tmpfile (void)
UNIV_INTERN ulint innobase_raw_format (const char *data, ulint data_len, ulint, char *buf, ulint buf_size)
static uint64_t innobase_next_autoinc (uint64_t current, uint64_t increment, uint64_t offset, uint64_t max_value)
static void innobase_trx_init (Session *session, trx_t *trx)
UNIV_INTERN trx_tinnobase_trx_allocate (Session *session)
static trx_tcheck_trx_exists (Session *session)
static char * innobase_convert_identifier (char *buf, ulint buflen, const char *id, ulint idlen, drizzled::Session *session, ibool file_id)
UNIV_INTERN char * innobase_convert_name (char *buf, ulint buflen, const char *id, ulint idlen, drizzled::Session *session, ibool table_id)
UNIV_INTERN ibool trx_is_interrupted (trx_t *trx)
UNIV_INTERN ibool trx_is_strict (trx_t *trx)
static void reset_template (row_prebuilt_t *prebuilt)
template<class T >
void align_value (T &value, size_t align_val=1024)
static void auto_extend_update (Session *, sql_var_t)
static void io_capacity_update (Session *, sql_var_t)
static void purge_batch_update (Session *, sql_var_t)
static void purge_threads_update (Session *, sql_var_t)
static void innodb_adaptive_hash_index_update (Session *, sql_var_t)
static void innodb_old_blocks_pct_update (Session *, sql_var_t)
static void innodb_thread_concurrency_update (Session *, sql_var_t)
static void innodb_sync_spin_loops_update (Session *, sql_var_t)
static void innodb_spin_wait_delay_update (Session *, sql_var_t)
static void innodb_thread_sleep_delay_update (Session *, sql_var_t)
static void innodb_read_ahead_threshold_update (Session *, sql_var_t)
static int innodb_commit_concurrency_validate (Session *session, set_var *var)
static int innodb_file_format_name_validate (Session *, set_var *var)
static int innodb_change_buffering_validate (Session *, set_var *var)
static int innodb_file_format_max_validate (Session *session, set_var *var)
static int innobase_init (module::Context &context)
static int innobase_rollback_trx (trx_t *trx)
static uint64_t innobase_get_int_col_max_value (const Field *field)
static ibool innobase_match_index_columns (const KeyInfo *key_info, const dict_index_t *index_info)
static ibool innobase_build_index_translation (const Table *table, dict_table_t *ib_table, INNOBASE_SHARE *share)
static dict_index_tinnobase_index_lookup (INNOBASE_SHARE *share, uint keynr)
static uint get_field_offset (Table *table, Field *field)
static uint field_in_record_is_null (Table *table, Field *field, char *record)
static void set_field_in_record_to_null (Table *table, Field *field, char *record)
UNIV_INTERN int innobase_mysql_cmp (int mysql_type, uint charset_number, const unsigned char *a, unsigned int a_length, const unsigned char *b, unsigned int b_length)
UNIV_INTERN ulint get_innobase_type_from_mysql_type (ulint *unsigned_flag, const void *f)
static void innobase_write_to_2_little_endian (byte *buf, ulint val)
static uint innobase_read_from_2_little_endian (const unsigned char *buf)
static void build_template (row_prebuilt_t *prebuilt, Session *, Table *table, uint templ_type)
static int calc_row_difference (upd_t *uvect, unsigned char *old_row, unsigned char *new_row, Table *table, unsigned char *upd_buff, ulint buff_len, row_prebuilt_t *prebuilt, Session *)
static ulint convert_search_mode_to_innobase (enum ha_rkey_function find_flag)
static int create_table_def (trx_t *trx, Table *form, const char *table_name, const char *path_of_temp_table, ulint flags)
static int create_index (trx_t *trx, Table *form, ulint flags, const char *table_name, uint key_num)
static int create_clustered_index_when_no_primary (trx_t *trx, ulint flags, const char *table_name)
static int innobase_rename_table (trx_t *trx, const identifier::Table &from, const identifier::Table &to, ibool lock_and_commit)
static unsigned int innobase_get_mysql_key_number_for_index (INNOBASE_SHARE *share, const drizzled::Table *table, dict_table_t *ib_table, const dict_index_t *index)
static ulint innobase_map_isolation_level (enum_tx_isolation iso)
static bool innodb_show_status (plugin::StorageEngine *engine, Session *session, stat_print_fn *stat_print)
static bool innodb_mutex_show_status (plugin::StorageEngine *engine, Session *session, stat_print_fn *stat_print)
ulint innobase_get_at_most_n_mbchars (ulint charset_id, ulint prefix_len, ulint data_len, const char *str)
static void init_options (drizzled::module::option_context &context)
UNIV_INTERN bool innobase_index_name_is_reserved (const trx_t *trx, const KeyInfo *key_info, ulint num_of_keys)

Variables

static boost::mutex innobase_share_mutex
static ulong commit_threads = 0
static boost::condition_variable commit_cond
static boost::mutex commit_cond_m
static bool innodb_inited = 0
static plugin::XaStorageEngine * innodb_engine_ptr = NULL
static open_files_constraint innobase_open_files
static
mirrored_log_groups_constraint 
innobase_mirrored_log_groups
static
log_files_in_group_constraint 
innobase_log_files_in_group
force_recovery_constraint innobase_force_recovery
static log_buffer_constraint innobase_log_buffer_size
static
additional_mem_pool_constraint 
innobase_additional_mem_pool_size
static autoextend_constraint innodb_auto_extend_increment
static buffer_pool_constraint innobase_buffer_pool_size
static
buffer_pool_instances_constraint 
innobase_buffer_pool_instances
static io_capacity_constraint innodb_io_capacity
static purge_batch_constraint innodb_purge_batch_size
static purge_threads_constraint innodb_n_purge_threads
static trinary_constraint innodb_flush_log_at_trx_commit
static max_dirty_pages_constraint innodb_max_dirty_pages_pct
static uint64_constraint innodb_max_purge_lag
static uint64_nonzero_constraint innodb_stats_sample_pages
static io_threads_constraint innobase_read_io_threads
static io_threads_constraint innobase_write_io_threads
static concurrency_constraint innobase_commit_concurrency
static concurrency_constraint innobase_thread_concurrency
static uint32_nonzero_constraint innodb_concurrency_tickets
static log_file_constraint innobase_log_file_size
static uint64_constraint innodb_replication_delay
static old_blocks_constraint innobase_old_blocks_pct
static uint32_constraint innodb_sync_spin_loops
static uint32_constraint innodb_spin_wait_delay
static uint32_constraint innodb_thread_sleep_delay
static
read_ahead_threshold_constraint 
innodb_read_ahead_threshold
std::string innobase_data_home_dir
std::string innobase_data_file_path
std::string innobase_log_group_home_dir
static string innobase_file_format_name
static string innobase_change_buffering
static string innobase_file_format_max
static trinary_constraint innobase_fast_shutdown
static my_bool innobase_file_format_check = TRUE
static my_bool innobase_use_doublewrite = TRUE
static my_bool innobase_use_checksums = TRUE
static my_bool innobase_rollback_on_timeout = FALSE
static my_bool innobase_create_status_file = FALSE
static bool innobase_use_replication_log
static bool support_xa
static bool strict_mode
static lock_wait_constraint lock_wait_timeout
static char * internal_innobase_data_file_path = NULL
static ulong innobase_active_counter = 0
static hash_table_tinnobase_open_tables
static const char * innobase_change_buffering_values [IBUF_USE_COUNT]
static const char innobase_index_reserve_name [] = "GEN_CLUST_INDEX"
static const char * ha_innobase_exts []
static const char innobase_engine_name [] = "InnoDB"
static drizzle_show_var innodb_status_variables []

Detailed Description

Definition in file ha_innodb.cc.


Typedef Documentation

typedef constrained_check<uint32_t, 95, 5> old_blocks_constraint

Percentage of the buffer pool to reserve for 'old' blocks. Connected to buf_LRU_old_ratio.

Definition at line 209 of file ha_innodb.cc.


Function Documentation

static void build_template ( row_prebuilt_t prebuilt,
Session ,
Table table,
uint  templ_type 
) [static]

Builds a 'template' to the prebuilt struct. The template is used in fast retrieval of just those column values MySQL needs in its processing.

Parameters:
prebuiltin/out: prebuilt struct
tablein: MySQL table
templ_typein: ROW_MYSQL_WHOLE_ROW or ROW_DRIZZLE_REC_FIELDS

Definition at line 4051 of file ha_innodb.cc.

References mysql_row_templ_struct::charset, mysql_row_templ_struct::clust_rec_field_no, mysql_row_templ_struct::col_no, dict_table_struct::cols, dict_col_get_clust_pos(), dict_col_get_mbmaxlen(), dict_col_get_mbminlen(), dtype_get_charset_coll(), get_field_offset(), row_prebuilt_struct::hint_need_to_fetch_extra_cols, row_prebuilt_struct::index, mysql_row_templ_struct::is_unsigned, mysql_row_templ_struct::mbmaxlen, mysql_row_templ_struct::mbminlen, dict_col_struct::mtype, mysql_row_templ_struct::mysql_col_len, mysql_row_templ_struct::mysql_col_offset, mysql_row_templ_struct::mysql_length_bytes, mysql_row_templ_struct::mysql_null_bit_mask, mysql_row_templ_struct::mysql_null_byte_offset, row_prebuilt_struct::mysql_prefix_len, row_prebuilt_struct::mysql_template, mysql_row_templ_struct::mysql_type, row_prebuilt_struct::n_template, row_prebuilt_struct::need_to_access_clustered, drizzled::Field::null_bit, row_prebuilt_struct::null_bitmap_len, drizzled::Field::null_ptr, drizzled::Field::pack_length(), dict_col_struct::prtype, row_prebuilt_struct::read_just_key, mysql_row_templ_struct::rec_field_no, row_prebuilt_struct::select_lock_type, dict_index_struct::table, row_prebuilt_struct::table, row_prebuilt_struct::templ_contains_blob, row_prebuilt_struct::template_type, mysql_row_templ_struct::type, and ut_ad.

Referenced by ha_innobase::change_active_index(), ha_innobase::check(), ha_innobase::doInsertRecord(), and ha_innobase::index_read().

static int calc_row_difference ( upd_t uvect,
unsigned char *  old_row,
unsigned char *  new_row,
Table table,
unsigned char *  upd_buff,
ulint  buff_len,
row_prebuilt_t prebuilt,
Session  
) [static]

Checks which fields have changed in a row and stores information of them to an update vector.

Returns:
error number or 0
Parameters:
uvectin/out: update vector
old_rowin: old row in MySQL format
new_rowin: new row in MySQL format
tablein: table in MySQL data dictionary
upd_buffin: buffer to use
buff_lenin: buffer length
prebuiltin: InnoDB prebuilt struct

Definition at line 4555 of file ha_innodb.cc.

References dict_table_struct::cols, dfield_copy_data(), dfield_set_null(), dict_col_copy_type(), dict_col_get_clust_pos(), dict_table_is_comp(), upd_field_struct::exp, field_in_record_is_null(), upd_field_struct::field_no, upd_struct::fields, get_field_offset(), upd_struct::info_bits, dict_col_struct::mtype, upd_struct::n_fields, upd_field_struct::new_val, drizzled::Field::null_ptr, upd_field_struct::orig_len, drizzled::Field::pack_length(), row_mysql_read_blob_ref(), row_mysql_read_true_varchar(), row_mysql_store_col_in_innobase_format(), row_prebuilt_struct::table, dfield_struct::type, and ut_a.

Referenced by ha_innobase::doUpdateRecord().

static trx_t* check_trx_exists ( Session session) [static]
UNIV_INTERN int convert_error_code_to_mysql ( int  error,
ulint  flags,
Session session 
)
static ulint convert_search_mode_to_innobase ( enum ha_rkey_function  find_flag) [inline, static]

Converts a search mode flag understood by MySQL to a flag understood by InnoDB.

Definition at line 4977 of file ha_innodb.cc.

Referenced by ha_innobase::index_read(), and ha_innobase::records_in_range().

static int create_clustered_index_when_no_primary ( trx_t trx,
ulint  flags,
const char *  table_name 
) [static]

Creates an index to an InnoDB table when the user has defined no primary index.

Parameters:
trxin: InnoDB transaction handle
flagsin: InnoDB table flags
table_namein: table name

Definition at line 5962 of file ha_innodb.cc.

References convert_error_code_to_mysql(), DICT_CLUSTERED, and row_create_index_for_mysql().

Referenced by InnobaseEngine::doCreateTable().

static int create_index ( trx_t trx,
Table form,
ulint  flags,
const char *  table_name,
uint  key_num 
) [static]

Creates an index in an InnoDB database.

Parameters:
trxin: InnoDB transaction handle
formin: information on table columns and indexes
flagsin: InnoDB table flags
table_namein: table name
key_numin: index number

Definition at line 5835 of file ha_innodb.cc.

References convert_error_code_to_mysql(), DICT_CLUSTERED, DICT_UNIQUE, drizzled::Field::field_name, get_innobase_type_from_mysql_type(), innobase_strcasecmp(), drizzled::Table::key_info, drizzled::Field::pack_length(), row_create_index_for_mysql(), and ut_a.

Referenced by InnobaseEngine::doCreateTable().

static int create_table_def ( trx_t trx,
Table form,
const char *  table_name,
const char *  path_of_temp_table,
ulint  flags 
) [static]

Creates a table definition to an InnoDB database.

Parameters:
trxin: InnoDB transaction handle
formin: information on table columns and indexes
table_namein: table name
path_of_temp_tablein: if this is a table explicitly created by the user with the TEMPORARY keyword, then this parameter is the dir path where the table should be placed if we create an .ibd file for it (no .ibd extension in the path, though); otherwise this is NULL
flagsin: table flags

Definition at line 5676 of file ha_innodb.cc.

References convert_error_code_to_mysql(), dict_table_struct::dir_path_of_temp_table, drizzled::Field::field_name, get_innobase_type_from_mysql_type(), dict_table_struct::heap, innobase_convert_identifier(), mem_heap_strdup(), trx_struct::mysql_thd, dict_table_struct::name, drizzled::Field::null_ptr, drizzled::Field::pack_length(), row_create_table_for_mysql(), trx_commit_for_mysql(), and ut_a.

Referenced by InnobaseEngine::doCreateTable().

static uint field_in_record_is_null ( Table table,
Field field,
char *  record 
) [inline, static]

Checks if a field in a record is SQL NULL. Uses the record format information in table to track the null bit in record.

Returns:
1 if NULL, 0 otherwise
Parameters:
tablein: MySQL table object
fieldin: MySQL field object
recordin: a row in MySQL format

Definition at line 3569 of file ha_innodb.cc.

References drizzled::Field::null_bit, and drizzled::Field::null_ptr.

Referenced by calc_row_difference().

static uint get_field_offset ( Table table,
Field field 
) [inline, static]

Gets field offset for a field in a table.

Returns:
offset
Parameters:
tablein: MySQL table object
fieldin: MySQL field object

Definition at line 3555 of file ha_innodb.cc.

References drizzled::Field::ptr.

Referenced by build_template(), calc_row_difference(), and ha_innobase::store_key_val_for_row().

UNIV_INTERN ulint get_innobase_type_from_mysql_type ( ulint *  unsigned_flag,
const void *  f 
)

Converts a MySQL type to an InnoDB type. Note that this function returns the 'mtype' of InnoDB. InnoDB differentiates between MySQL's old <= 4.1 VARCHAR and the new true VARCHAR in >= 5.0.3 by the 'prtype'.

Returns:
DATA_BINARY, DATA_VARCHAR, ...
Parameters:
unsigned_flagout: DATA_UNSIGNED if an 'unsigned type'; at least ENUM and SET, and unsigned integer types are 'unsigned types'
fin: MySQL Field

Definition at line 3702 of file ha_innodb.cc.

References ut_error.

Referenced by create_index(), create_table_def(), and innobase_match_index_columns().

static void innobase_active_small ( void  ) [inline, static]

Increments innobase_active_counter and every INNOBASE_WAKE_INTERVALth time calls srv_active_wake_master_thread. This function should be used when a single database operation may introduce a small need for server utility activity, like checkpointing.

Definition at line 1009 of file ha_innodb.cc.

References srv_active_wake_master_thread().

Referenced by ha_innobase::doDeleteRecord(), ha_innobase::doInsertRecord(), and ha_innobase::doUpdateRecord().

static ibool innobase_build_index_translation ( const Table table,
dict_table_t ib_table,
INNOBASE_SHARE share 
) [static]

This function builds a translation table in INNOBASE_SHARE structure for fast index location with mysql array number from its table->key_info structure. This also provides the necessary translation between the key order in mysql key_info and Innodb ib_table->indexes if they are not fully matched with each other. Note we do not have any mutex protecting the translation table building based on the assumption that there is no concurrent index creation/drop and DMLs that requires index lookup. All table handle will be closed before the index creation/drop.

Returns:
TRUE if index translation table built successfully
Parameters:
tablein: table in MySQL data dictionary
ib_tablein: table in Innodb data dictionary
sharein/out: share structure where index translation table will be constructed in.

Definition at line 2996 of file ha_innodb.cc.

References innodb_idx_translate_struct::array_size, st_innobase_share::idx_trans_tbl, innodb_idx_translate_struct::index_count, innodb_idx_translate_struct::index_mapping, dict_table_struct::indexes, innobase_match_index_columns(), drizzled::Table::key_info, dict_sys_struct::mutex, ut_a, and UT_LIST_GET_LEN.

Referenced by ha_innobase::doOpen().

UNIV_INTERN void innobase_casedn_str ( char *  a)

Makes all characters in a NUL-terminated UTF-8 string lower case.

Parameters:
ain/out: string to put in lower case

Definition at line 1263 of file ha_innodb.cc.

Referenced by dict_casedn_str().

static void innobase_commit_low ( trx_t trx) [static]

Commits a transaction in an InnoDB database. in: transaction handle

Commits a transaction in an InnoDB database.

Parameters:
trxin: transaction handle

Definition at line 2445 of file ha_innodb.cc.

References trx_struct::conc_state, and trx_commit_for_mysql().

Referenced by InnobaseEngine::doCommit(), InnobaseEngine::doCreateTable(), InnobaseEngine::doDropSchema(), InnobaseEngine::doDropTable(), InnobaseEngine::doRenameTable(), and InnobaseEngine::doXaCommitXid().

UNIV_INTERN void innobase_convert_from_id ( const void *  ,
char *  to,
const char *  from,
ulint  len 
)

Converts an identifier to UTF-8.

Parameters:
toout: converted identifier
fromin: identifier to convert
lenin: length of 'to', in bytes

Definition at line 1236 of file ha_innodb.cc.

UNIV_INTERN void innobase_convert_from_table_id ( const void *  ,
char *  to,
const char *  from,
ulint  len 
)

Converts an identifier to a table name.

Parameters:
toout: converted identifier
fromin: identifier to convert
lenin: length of 'to', in bytes

Definition at line 1222 of file ha_innodb.cc.

static char* innobase_convert_identifier ( char *  buf,
ulint  buflen,
const char *  id,
ulint  idlen,
drizzled::Session session,
ibool  file_id 
) [static]

Convert an SQL identifier to the MySQL system_charset_info (UTF-8) and quote it if needed.

Returns:
pointer to the end of buf
Parameters:
bufout: buffer for converted identifier
buflenin: length of buf, in bytes
idin: identifier to convert
idlenin: length of id, in bytes
sessionin: MySQL connection thread, or NULL
file_idin: TRUE=id is a table or database name; FALSE=id is an UTF-8 string

Definition at line 1627 of file ha_innodb.cc.

References srv_mysql50_table_name_prefix().

Referenced by create_table_def(), and innobase_convert_name().

UNIV_INTERN char* innobase_convert_name ( char *  buf,
ulint  buflen,
const char *  id,
ulint  idlen,
drizzled::Session session,
ibool  table_id 
)

Convert a table or index name to the MySQL system_charset_info (UTF-8) and quote it if needed.

Returns:
pointer to the end of buf
Parameters:
bufout: buffer for converted identifier
buflenin: length of buf, in bytes
idin: identifier to convert
idlenin: length of id, in bytes
sessionin: MySQL connection thread, or NULL
table_idin: TRUE=id is a table or database name; FALSE=id is an index name

Definition at line 1713 of file ha_innodb.cc.

References innobase_convert_identifier(), and TEMP_INDEX_PREFIX.

Referenced by ut_print_namel().

static uint innobase_file_format_name_lookup ( const char *  format_name) [static]

Validate the file format name and return its corresponding id.

Returns:
valid file format id in: pointer to file format name

Validate the file format name and return its corresponding id.

Returns:
valid file format id
Parameters:
format_namein: pointer to file format name

Definition at line 9054 of file ha_innodb.cc.

References DICT_TF_FORMAT_MAX, innobase_strcasecmp(), trx_sys_file_format_id_to_name(), and ut_a.

Referenced by innobase_file_format_validate_and_set(), innobase_init(), and innodb_file_format_name_validate().

static int innobase_file_format_validate_and_set ( const char *  format_max) [static]

Validate the file format check config parameters, as a side effect it sets the srv_max_file_format_at_startup variable.

Returns:
the format_id if valid config value, otherwise, return -1 in: parameter value

Validate the file format check config parameters, as a side effect it sets the srv_max_file_format_at_startup variable.

Returns:
the format_id if valid config value, otherwise, return -1
Parameters:
format_maxin: parameter value

Definition at line 9098 of file ha_innodb.cc.

References DICT_TF_FORMAT_MAX, innobase_file_format_name_lookup(), and srv_max_file_format_at_startup.

Referenced by innobase_init(), and innodb_file_format_max_validate().

ulint innobase_get_at_most_n_mbchars ( ulint  charset_id,
ulint  prefix_len,
ulint  data_len,
const char *  str 
)

This function is used to find the storage length in bytes of the first n characters for prefix indexes using a multibyte character set. The function finds charset information and returns length of prefix_len characters in the index field in bytes.

Returns:
number of bytes occupied by the first n characters in: character string

< character length in bytes

< number of characters in prefix

< charset used in the field

Parameters:
charset_idin: character set id
prefix_lenin: prefix length in bytes of the index (this has to be divided by mbmaxlen to get the number of CHARACTERS n in the prefix)
data_lenin: length of the string in bytes
strin: character string

Definition at line 8791 of file ha_innodb.cc.

References ut_ad.

Referenced by dtype_get_at_most_n_mbchars().

UNIV_INTERN void innobase_get_cset_width ( ulint  cset,
ulint *  mbminlen,
ulint *  mbmaxlen 
)

Get the variable length bounds of the given character set.

Parameters:
csetin: MySQL charset-collation code
mbminlenout: minimum length of a char (in bytes)
mbmaxlenout: maximum length of a char (in bytes)

Definition at line 1195 of file ha_innodb.cc.

References ut_a, and ut_ad.

static uint64_t innobase_get_int_col_max_value ( const Field field) [static]

Get the upper limit of the MySQL integral and floating-point type.

Returns:
maximum allowed value for the field
Parameters:
fieldin: MySQL field

Definition at line 2883 of file ha_innodb.cc.

References ut_error.

Referenced by ha_innobase::doInsertRecord(), ha_innobase::doUpdateRecord(), ha_innobase::get_auto_increment(), and ha_innobase::innobase_initialize_autoinc().

static unsigned int innobase_get_mysql_key_number_for_index ( INNOBASE_SHARE share,
const drizzled::Table table,
dict_table_t ib_table,
const dict_index_t index 
) [static]

Calculates the key number used inside MySQL for an Innobase index. We will first check the "index translation table" for a match of the index to get the index number. If there does not exist an "index translation table", or not able to find the index in the translation table, then we will fall back to the traditional way of looping through dict_index_t list to find a match. In this case, we have to take into account if we generated a default clustered index for the table

Returns:
the key number used inside MySQL
Parameters:
sharein: share structure for index translation table.
tablein: table in MySQL data dictionary
ib_tablein: table in Innodb data dictionary
indexin: index

Definition at line 6953 of file ha_innodb.cc.

References st_innobase_share::idx_trans_tbl, innodb_idx_translate_struct::index_count, innodb_idx_translate_struct::index_mapping, drizzled::Table::key_info, dict_index_struct::name, row_table_got_default_clust_index(), dict_index_struct::table, ut_a, and ut_ad.

Referenced by ha_innobase::info().

static dict_index_t* innobase_index_lookup ( INNOBASE_SHARE share,
uint  keynr 
) [static]

This function uses index translation table to quickly locate the requested index structure. Note we do not have mutex protection for the index translatoin table access, it is based on the assumption that there is no concurrent translation table rebuild (fter create/drop index) and DMLs that require index lookup.

Returns:
dict_index_t structure for requested index. NULL if fail to locate the index structure.
Parameters:
sharein: share structure for index translation table.
keynrin: index number for the requested index

Definition at line 3113 of file ha_innodb.cc.

References st_innobase_share::idx_trans_tbl, innodb_idx_translate_struct::index_count, and innodb_idx_translate_struct::index_mapping.

Referenced by ha_innobase::innobase_get_index().

static ulint innobase_map_isolation_level ( enum_tx_isolation  iso) [inline, static]

Maps a MySQL trx isolation level code to the InnoDB isolation level code

Returns:
InnoDB isolation level
Parameters:
isoin: MySQL isolation level code

Definition at line 7914 of file ha_innodb.cc.

References ut_a.

Referenced by InnobaseEngine::doStartStatement().

static ibool innobase_match_index_columns ( const KeyInfo key_info,
const dict_index_t index_info 
) [static]

This function checks whether the index column information is consistent between KEY info from mysql and that from innodb index.

Returns:
TRUE if all column types match.
Parameters:
key_infoin: Index info from mysql
index_infoin: Index info from Innodb

Definition at line 2925 of file ha_innodb.cc.

References dict_field_struct::col, dict_index_struct::fields, get_innobase_type_from_mysql_type(), dict_col_struct::mtype, dict_index_struct::n_fields, and dict_index_struct::n_user_defined_cols.

Referenced by innobase_build_index_translation().

int innobase_mysql_cmp ( int  mysql_type,
uint  charset_number,
const unsigned char *  a,
unsigned int  a_length,
const unsigned char *  b,
unsigned int  b_length 
)

InnoDB uses this function to compare two data fields for which the data type is such that we must use MySQL code to compare them. NOTE that the prototype of this function is in rem0cmp.c in InnoDB source code! If you change this function, remember to update the prototype there!

Returns:
1, 0, -1, if a is greater, equal, less than b, respectively
Parameters:
mysql_typein: MySQL type
charset_numberin: number of the charset
ain: data field
a_lengthin: data field length, not UNIV_SQL_NULL
bin: data field

Definition at line 3631 of file ha_innodb.cc.

References ut_a, and ut_error.

UNIV_INTERN void innobase_mysql_print_thd ( FILE *  f,
drizzled::Session in_session,
uint   
)

Prints info of a Session object (== user session thread) to the given file.

Parameters:
fin: output stream
in_sessionin: pointer to a Drizzle Session object

Definition at line 1170 of file ha_innodb.cc.

References drizzled::Session::getQueryId(), and drizzled::Session::getSessionId().

Referenced by trx_print().

UNIV_INTERN int innobase_mysql_tmpfile ( void  )

Creates a temporary file.

Returns:
temporary file descriptor, or < 0 on error

Definition at line 1372 of file ha_innodb.cc.

Referenced by os_file_create_tmpfile().

static uint64_t innobase_next_autoinc ( uint64_t  current,
uint64_t  increment,
uint64_t  offset,
uint64_t  max_value 
) [static]

Compute the next autoinc value.

For MySQL replication the autoincrement values can be partitioned among the nodes. The offset is the start or origin of the autoincrement value for a particular node. For n nodes the increment will be n and the offset will be in the interval [1, n]. The formula tries to allocate the next value for a particular node.

Note: This function is also called with increment set to the number of values we want to reserve for multi-value inserts e.g.,

INSERT INTO T VALUES(), (), ();

innobase_next_autoinc() will be called with increment set to to reserve 3 values for the multi-value INSERT above.

Returns:
the next value
Parameters:
currentin: Current value
incrementin: increment current by
offsetin: AUTOINC offset
max_valuein: max value for type

Definition at line 1443 of file ha_innodb.cc.

References ut_a.

Referenced by ha_innobase::doInsertRecord(), ha_innobase::doUpdateRecord(), ha_innobase::get_auto_increment(), and ha_innobase::innobase_initialize_autoinc().

UNIV_INTERN ulint innobase_raw_format ( const char *  data,
ulint  data_len,
ulint  ,
char *  buf,
ulint  buf_size 
)

Formats the raw data in "data" (in InnoDB on-disk format) that is of type DATA_(CHAR|VARCHAR|DRIZZLE|VARDRIZZLE) using "charset_coll" and writes the result to "buf". The result is converted to "system_charset_info". Not more than "buf_size" bytes are written to "buf". The result is always NUL-terminated (provided buf_size > 0) and the number of bytes that were written to "buf" is returned (including the terminating NUL).

Returns:
number of bytes that were written
Parameters:
datain: raw data
data_lenin: raw data length in bytes
bufout: output buffer
buf_sizein: output buffer size in bytes

Definition at line 1411 of file ha_innodb.cc.

References ut_str_sql_format().

static uint innobase_read_from_2_little_endian ( const unsigned char *  buf) [inline, static]

Reads an unsigned integer value < 64k from 2 bytes, in the little-endian storage format.

Returns:
value
Parameters:
bufin: from where to read

Definition at line 3795 of file ha_innodb.cc.

Referenced by ha_innobase::cmp_ref().

static void innobase_release_stat_resources ( trx_t trx) [inline, static]

Releases possible search latch and InnoDB thread FIFO ticket. These should be released at each SQL statement end, and also when mysqld passes the control to the client. It does no harm to release these also in the middle of an SQL statement.

Parameters:
trxin: transaction object

Definition at line 850 of file ha_innodb.cc.

References srv_conc_force_exit_innodb(), and trx_search_latch_release_if_reserved().

Referenced by InnobaseEngine::doReleaseTemporaryLatches(), InnobaseEngine::doRollback(), InnobaseEngine::doRollbackToSavepoint(), InnobaseEngine::doSetSavepoint(), InnobaseEngine::doStartTransaction(), InnobaseEngine::doXaPrepare(), innobase_rollback_trx(), and innodb_show_status().

static int innobase_rename_table ( trx_t trx,
const identifier::Table from,
const identifier::Table to,
ibool  lock_and_commit 
) [static]

Renames an InnoDB table.

Returns:
0 or error code
Parameters:
trxin: transaction
lock_and_commitin: TRUE=lock data dictionary and commit

Definition at line 6607 of file ha_innodb.cc.

References log_buffer_flush_to_disk(), row_mysql_unlock_data_dictionary(), row_rename_table_for_mysql(), and ut_print_name().

Referenced by InnobaseEngine::doRenameTable().

static int innobase_rollback_trx ( trx_t trx) [static]

Rolls back a transaction

Returns:
0 or error number
Parameters:
trxin: transaction

Definition at line 2661 of file ha_innodb.cc.

References convert_error_code_to_mysql(), innobase_release_stat_resources(), row_unlock_table_autoinc_for_mysql(), and trx_rollback_for_mysql().

Referenced by InnobaseEngine::close_connection(), and InnobaseEngine::doXaRollbackXid().

UNIV_INTERN int innobase_strcasecmp ( const char *  a,
const char *  b 
)

Compares NUL-terminated UTF-8 strings case insensitively.

Returns:
0 if a=b, <0 if a<b, >1 if a>b
Parameters:
ain: first string to compare
bin: second string to compare

Definition at line 1251 of file ha_innodb.cc.

Referenced by create_index(), dict_col_name_is_reserved(), dict_table_get_index_by_max_id(), innobase_file_format_name_lookup(), innobase_init(), and innodb_change_buffering_validate().

UNIV_INTERN trx_t* innobase_trx_allocate ( Session session)

Allocates an InnoDB transaction for a MySQL Cursor object.

Returns:
InnoDB transaction handle
Parameters:
sessionin: user thread handle

Definition at line 1531 of file ha_innodb.cc.

References innobase_trx_init(), trx_struct::mysql_thd, and trx_allocate_for_mysql().

Referenced by check_trx_exists(), InnobaseEngine::doCreateTable(), InnobaseEngine::doDropSchema(), InnobaseEngine::doDropTable(), and InnobaseEngine::doRenameTable().

static void innobase_trx_init ( Session session,
trx_t trx 
) [static]

Initializes some fields in an InnoDB transaction object.

Parameters:
sessionin: user thread handle
trxin/out: InnoDB transaction handle

Definition at line 1510 of file ha_innodb.cc.

References trx_struct::mysql_thd.

Referenced by check_trx_exists(), and innobase_trx_allocate().

static void innobase_write_to_2_little_endian ( byte *  buf,
ulint  val 
) [inline, static]

Writes an unsigned integer value < 64k to 2 bytes, in the little-endian storage format.

Parameters:
bufin: where to store
valin: value to write, must be < 64k

Definition at line 3778 of file ha_innodb.cc.

References ut_a.

Referenced by ha_innobase::store_key_val_for_row().

static int innodb_change_buffering_validate ( Session ,
set_var var 
) [static]

Check if it is a valid value of innodb_change_buffering. This function is registered as a callback with MySQL.

Returns:
0 for valid innodb_change_buffering

Definition at line 1924 of file ha_innodb.cc.

References innobase_change_buffering_values, innobase_strcasecmp(), and drizzled::Item::str_value.

Referenced by innobase_init().

static int innodb_file_format_max_validate ( Session session,
set_var var 
) [static]

Check if valid argument to innodb_file_format_max. This function is registered as a callback with MySQL.

Returns:
0 for valid file format
Parameters:
sessionin: thread handle

Definition at line 1957 of file ha_innodb.cc.

References DICT_TF_FORMAT_MAX, innobase_file_format_validate_and_set(), drizzled::Item::str_value, trx_sys_file_format_id_to_name(), and trx_sys_file_format_max_set().

Referenced by innobase_init().

static int innodb_file_format_name_validate ( Session ,
set_var var 
) [static]

Check if it is a valid file format. This function is registered as a callback with MySQL.

Returns:
0 for valid file format

Definition at line 1892 of file ha_innodb.cc.

References DICT_TF_FORMAT_MAX, innobase_file_format_name_lookup(), drizzled::Item::str_value, and trx_sys_file_format_id_to_name().

Referenced by innobase_init().

static bool innodb_mutex_show_status ( plugin::StorageEngine *  engine,
Session session,
stat_print_fn *  stat_print 
) [static]

Implements the SHOW MUTEX STATUS command.

Returns:
true on failure false on success
Parameters:
enginein: the innodb StorageEngine
sessionin: the MySQL query thread of the caller
stat_printin: function for printing statistics

Definition at line 8094 of file ha_innodb.cc.

References buf_pool_is_block_lock, buf_pool_is_block_mutex, rw_lock_struct::cfile_name, mutex_struct::cfile_name, rw_lock_struct::cline, mutex_struct::cline, rw_lock_struct::count_os_wait, mutex_struct::count_os_wait, mutex_list, mutex_list_mutex, UT_LIST_GET_FIRST, and UT_LIST_GET_NEXT.

static bool innodb_show_status ( plugin::StorageEngine *  engine,
Session session,
stat_print_fn *  stat_print 
) [static]

Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB Monitor to the client.

Parameters:
enginein: the innodb StorageEngine
sessionin: the MySQL query thread of the caller

Definition at line 8008 of file ha_innodb.cc.

References check_trx_exists(), innobase_release_stat_resources(), os_file_set_eof(), and srv_printf_innodb_monitor().

static void innodb_srv_conc_enter_innodb ( trx_t trx) [inline, static]

Save some CPU by testing the value of srv_thread_concurrency in inline functions.

Parameters:
trxin: transaction handle

Definition at line 814 of file ha_innodb.cc.

References srv_conc_enter_innodb().

Referenced by ha_innobase::doDeleteRecord(), ha_innobase::doInsertRecord(), ha_innobase::doUpdateRecord(), ha_innobase::general_fetch(), and ha_innobase::index_read().

static void innodb_srv_conc_exit_innodb ( trx_t trx) [inline, static]

Save some CPU by testing the value of srv_thread_concurrency in inline functions.

Parameters:
trxin: transaction handle

Definition at line 831 of file ha_innodb.cc.

References srv_conc_exit_innodb().

Referenced by ha_innobase::doDeleteRecord(), ha_innobase::doInsertRecord(), ha_innobase::doUpdateRecord(), ha_innobase::general_fetch(), and ha_innobase::index_read().

static void reset_template ( row_prebuilt_t prebuilt) [static]

Resets some fields of a prebuilt struct. The template is used in fast retrieval of just those column values MySQL needs in its processing.

Parameters:
prebuiltin/out: prebuilt struct

Definition at line 1794 of file ha_innodb.cc.

References row_prebuilt_struct::keep_other_fields_on_keyread, and row_prebuilt_struct::read_just_key.

Referenced by ha_innobase::external_lock(), ha_innobase::extra(), and ha_innobase::reset().

static void set_field_in_record_to_null ( Table table,
Field field,
char *  record 
) [inline, static]

Sets a field in a record to SQL NULL. Uses the record format information in table to track the null bit in record.

Parameters:
tablein: MySQL table object
fieldin: MySQL field object
recordin: a row in MySQL format

Definition at line 3598 of file ha_innodb.cc.

References drizzled::Field::null_bit, and drizzled::Field::null_ptr.

UNIV_INTERN ibool thd_has_edited_nontrans_tables ( drizzled::Session session)

Returns true if the transaction this thread is processing has edited non-transactional tables. Used by the deadlock detector when deciding which transaction to rollback in case of a deadlock - we try to avoid rolling back transactions that have edited non-transactional tables.

DRIZZLE: Note, we didn't change this name to avoid more ifdef forking in non-Cursor code.

Returns:
true if non-transactional tables have been edited
Parameters:
sessionin: thread handle (Session*)

Definition at line 876 of file ha_innodb.cc.

References drizzled::session::Transactions::all, and drizzled::TransactionContext::hasModifiedNonTransData().

Referenced by trx_weight_ge().

UNIV_INTERN ibool thd_is_replication_slave_thread ( drizzled::Session )

Returns true if the thread is the replication thread on the slave server. Used in srv_conc_enter_innodb() to determine if the thread should be allowed to enter InnoDB - the replication thread is treated differently than other threads. Also used in srv_conc_force_exit_innodb().

DRIZZLE: Note, we didn't change this name to avoid more ifdef forking in non-Cursor code.

Returns:
true if session is the replication thread

Definition at line 802 of file ha_innodb.cc.

Referenced by srv_conc_enter_innodb(), and srv_conc_force_exit_innodb().

UNIV_INTERN ibool thd_is_select ( const drizzled::Session session)

Returns true if the thread is executing a SELECT statement.

Returns:
true if session is executing SELECT
Parameters:
sessionin: thread handle (Session*)

Definition at line 888 of file ha_innodb.cc.

Referenced by row_search_for_mysql().

UNIV_INTERN ulong thd_lock_wait_timeout ( drizzled::Session )

Returns the lock wait timeout for the current connection.

Returns:
the lock wait timeout, in seconds

Definition at line 915 of file ha_innodb.cc.

Referenced by srv_lock_timeout_thread(), and srv_suspend_mysql_thread().

UNIV_INTERN void thd_set_lock_wait_time ( drizzled::Session in_session,
ulint  value 
)

Set the time waited for the lock for the current query.

Parameters:
in_sessionin: thread handle (THD*)
valuein: time waited for the lock

Definition at line 930 of file ha_innodb.cc.

Referenced by srv_suspend_mysql_thread().

UNIV_INTERN ibool thd_supports_xa ( drizzled::Session )

Returns true if the thread supports XA, global value of innodb_supports_xa if session is NULL.

Returns:
true if session has XA support

Definition at line 901 of file ha_innodb.cc.

Referenced by trx_start().

UNIV_INTERN ibool trx_is_interrupted ( trx_t trx)

Determines if the currently running transaction has been interrupted.

Returns:
TRUE if interrupted
Parameters:
trxin: transaction

Definition at line 1769 of file ha_innodb.cc.

References trx_struct::mysql_thd.

Referenced by btr_validate_index(), row_check_index_for_mysql(), srv_lock_timeout_thread(), and srv_suspend_mysql_thread().

UNIV_INTERN ibool trx_is_strict ( trx_t trx)

Determines if the currently running transaction is in strict mode.

Returns:
TRUE if strict
Parameters:
trxin: transaction

Definition at line 1781 of file ha_innodb.cc.

References trx_struct::mysql_thd.

Referenced by dict_create_index_step().


Variable Documentation

ulong commit_threads = 0 [static]

to force correct commit order in binlog

Definition at line 144 of file ha_innodb.cc.

Referenced by InnobaseEngine::doCommit().

const char* ha_innobase_exts[] [static]
Initial value:
 {
  ".ibd",
  NULL
}

Definition at line 294 of file ha_innodb.cc.

const char* innobase_change_buffering_values[IBUF_USE_COUNT] [static]
Initial value:
 {
  "none",   
  "inserts",  
  "deletes",  
  "changes",  
  "purges", 
  "all"   
}

Allowed values of innodb_change_buffering

Definition at line 279 of file ha_innodb.cc.

Referenced by innobase_init(), and innodb_change_buffering_validate().

boost::mutex innobase_share_mutex [static]

to protect innobase_open_files

Definition at line 141 of file ha_innodb.cc.

Referenced by get_share().