/* The InnoDB handler: the interface between MySQL and InnoDB. */
/** Prebuilt structures in an InnoDB table handle used within MySQL */ struct row_prebuilt_t;
/** InnoDB transaction */ struct trx_t;
/** Engine specific table options are defined using this struct */ struct ha_table_option_struct
{ bool page_compressed; /*!< Table is using page compression
if this option is true. */
ulonglong page_compression_level; /*!< Table page compression level
0-9. */
uint atomic_writes; /*!< Use atomic writes for this tableifthisoptionsisONor inDEFAULTif innodb_use_atomic_writes. Atomicwritesarenotusedif
value OFF.*/
uint adaptive_hash_index; /*!< DEFAULT, ON, OFF */
uint encryption; /*!< DEFAULT, ON, OFF */
ulonglong encryption_key_id; /*!< encryption key id */
};
struct ha_index_option_struct
{
uint adaptive_hash_index; /*!< DEFAULT, ON, OFF */
ulonglong complete_fields;
ulonglong bytes_from_incomplete_field; /** DEFAULT (0), YES (1), NO (2)
DEFAULT means no fixed recommendation for this AHI parameter. */
uint for_equal_hash_point_to_last_record;
};
/** The class defining a handle to an Innodb table */ class ha_innobase final : public handler
{ public:
ha_innobase(handlerton* hton, TABLE_SHARE* table_arg);
~ha_innobase() override;
/** @return the transaction that last modified the table definition
@see dict_table_t::def_trx_id */
ulonglong table_version() const override;
/** 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 override;
/** Opens dictionary table object using table name. For partition, we need to tryalternativelower/uppercasenamestosupportmovingdatafilesacross platforms. @param[in]table_namenameofthetable/partition @param[in]norm_namenormalizednameofthetable/partition @param[in]is_partitionifthisisapartitionofatable @param[in]ignore_errerrortoignoreforloadingdictionaryobject
@return dictionary table object or NULL if not found */ static dict_table_t* open_dict_table( constchar* table_name, constchar* norm_name, bool is_partition,
dict_err_ignore_t ignore_err);
int open(constchar *name, int mode, uint test_if_locked) override;
int cmp_ref(const uchar* ref1, const uchar* ref2) override;
/** On-line ALTER TABLE interface @see handler0alter.cc @{ */
/** Check if InnoDB supports a particular alter table in-place @paramaltered_tableTABLEobjectfornewversionoftable. @paramha_alter_infoStructuredescribingchangestobedone byALTERTABLEandholdingdatausedduringin-placealter.
/** Alter the table structure in-place with operations specifiedusingHA_ALTER_FLAGSandAlter_inplace_information. Thelevelofconcurrencyallowedduringthisoperationdepends onthereturnvaluefromcheck_if_supported_inplace_alter().
/** Initialize multi range read @see DsMrr_impl::dsmrr_init @paramseq @paramseq_init_param @paramn_ranges @parammode
@param buf */ int multi_range_read_init(
RANGE_SEQ_IF* seq, void* seq_init_param,
uint n_ranges,
uint mode,
HANDLER_BUFFER* buf) override;
/** Process next multi range read @see DsMrr_impl::dsmrr_next
@param range_info */ int multi_range_read_next(range_id_t *range_info) override;
/** Initialize multi range read and get information. @seeha_myisam::multi_range_read_info_const @seeDsMrr_impl::dsmrr_info_const @paramkeyno @paramseq @paramseq_init_param @paramn_ranges @parambufsz @paramflags
@param cost */
ha_rows multi_range_read_info_const(
uint keyno,
RANGE_SEQ_IF* seq, void* seq_init_param,
uint n_ranges,
uint* bufsz,
uint* flags,
ha_rows limit,
Cost_estimate* cost) override;
/** Initialize multi range read and get information. @seeDsMrr_impl::dsmrr_info @paramkeyno @paramseq @paramseq_init_param @paramn_ranges @parambufsz @paramflags
@param cost */
ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys,
uint key_parts, uint* bufsz, uint* flags,
Cost_estimate* cost) override;
int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size) override;
/** Attempt to push down an index condition. @param[in]keynoMySQLkeynumber @param[in]idx_condIndexconditiontobechecked
@return idx_cond if pushed; NULL if not pushed */
Item* idx_cond_push(uint keyno, Item* idx_cond) override; /* @} */
/** Check if InnoDB is not storing virtual column metadata for a table. @paramstabledefinition(basedon.frmfile)
@return whether InnoDB will omit virtual column metadata */ staticbool omits_virtual_cols(const TABLE_SHARE& s)
{ return s.frm_version<FRM_VER_EXPRESSSIONS && s.virtual_fields;
}
/** Push a primary key filter. @param[in]pk_filterfilteragainstwhichprimarykeys aretobechecked
@retval false if pushed (always) */ bool rowid_filter_push(Rowid_filter *rowid_filter) override;
bool can_convert_nocopy(const Field &field, const Column_definition& new_field) const
override;
/** @return whether innodb_strict_mode is active */ staticbool is_innodb_strict_mode(THD* thd);
/** Check the transaction is valid. @paramaltering_to_supportedwhetheranALTERTABLEisbeingrun tosomethingelsethanROW_FORMAT=COMPRESSED @retval0ifthetransactionisvalidforthecurrentoperation @retvalHA_ERR_TABLE_READONLYifthetableisread-only
@retval HA_ERR_ROLLBACK if the transaction has been aborted */ int is_valid_trx(bool altering_to_supported= false) const noexcept;
int general_fetch(uchar* buf, uint direction, uint match_mode); int change_active_index(uint keynr); /* @return true if it's necessary to switch current statement log formatfromSTATEMENTtoROWifbinarylogformatisMIXEDand
autoincrement values are changed in the statement */ bool autoinc_lock_mode_stmt_unsafe() const override;
dict_index_t* innobase_get_index(uint keynr);
#ifdef WITH_WSREP int wsrep_append_keys(
THD *thd,
Wsrep_service_key_type key_type, const uchar* record0, const uchar* record1); #endif /** Builds a 'template' to the prebuilt struct.
Thetemplateisusedinfastretrievalofjustthosecolumn valuesMySQLneedsinitsprocessing. @paramwhole_rowtrueifaccessisneededtoawholerow,
false if accessing individual fields is enough */ void build_template(bool whole_row);
int info_low(uint, bool);
/** The multi range read session object */
DsMrr_impl m_ds_mrr;
/** Save CPU time with prebuilt/cached data structures */
row_prebuilt_t* m_prebuilt;
/** Thread handle of the user currently using the handler;
this is set in external_lock function */
THD* m_user_thd;
/** buffer used in updates */
uchar* m_upd_buf;
/** the size of upd_buf in bytes */
ulint m_upd_buf_size;
/** Flags that specify the handler instance (table) capability. */
Table_flags m_int_table_flags;
/** Index into the server's primary key meta-data table->key_info{} */
uint m_primary_key;
/** this is set to 1 when we are starting a table scan but have
not yet fetched any row, else false */ bool m_start_of_scan;
/*!< match mode of the latest search: ROW_SEL_EXACT,
ROW_SEL_EXACT_PREFIX, or undefined */
uint m_last_match_mode;
/** If mysql has locked with external_lock() */ bool m_mysql_has_locked;
/** If true, disable the Rowid Filter. It is disabled when
the engine is intialized for making rnd_pos() calls */ bool m_disable_rowid_filter;
};
/* Some accessor functions which the InnoDB plugin needs, but which cannotbeaddedtomysql/plugin.haspartofthepublicinterface;
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
/** Get the file name and position of the MySQL binlog corresponding to the *currentcommit.
*/ externvoid mysql_bin_log_commit_pos(THD *thd, ulonglong *out_pos, constchar **out_file);
/*********************************************************************//** This function checks each index name for a table against reserved
system default primary index name 'GEN_CLUST_INDEX'. If a name
matches, this function pushes an warning message to the client, and returns true.
@returntrueif the index name matches the reserved name */ bool
innobase_index_name_is_reserved(
THD* thd, /*!< in/out: MySQL connection */ const KEY* key_info, /*!< in: Indexes to be created */
ulint num_of_keys) /*!< in: Number of indexes to
be created. */
MY_ATTRIBUTE((nonnull(1), warn_unused_result));
/** Parse hint for table and its indexes, and update the information indictionary. @param[in]thdConnectionthread @param[in,out]tableTargettable
@param[in] table_share Table definition */ void
innobase_parse_hint_from_comment(
THD* thd,
dict_table_t* table, const TABLE_SHARE* table_share);
/** Class for handling create table information. */ class create_table_info_t
{ public: /** Constructor. Usedintwoways: -allbutfile_per_tableisused,whencreatingthetable.
- all but name/path is used, when validating options and using flags. */
create_table_info_t(
THD* thd, const TABLE* form,
HA_CREATE_INFO* create_info, bool file_per_table,
trx_t* trx = NULL);
/** Initialize the object. */ int initialize();
/** Set m_tablespace_type. */ void set_tablespace_type(bool table_being_altered_is_file_per_table);
/** Create InnoDB foreign keys from MySQL alter_info. */
dberr_t create_foreign_keys();
/** Create the internal innodb table.
@param create_fk whether to add FOREIGN KEY constraints */ int create_table(bool create_fk = true, bool strict= true);
/** Validates the create options. Checks that the options KEY_BLOCK_SIZE,ROW_FORMAT,DATADIRECTORY,TEMPORARY&TABLESPACE arecompatiblewitheachotherandothersettings. TheseCREATEOPTIONSarenotvalidatedhereunlessinnodb_strict_mode ison.Withstrictmode,thisfunctionwillreporteachproblemit findsusingacustommessagewitherrorcode ER_ILLEGAL_HA_CREATE_OPTION,notitsbuilt-inmessage.
@return NULL if valid, string name of bad option if not. */ constchar* create_options_are_invalid();
bool gcols_in_fulltext_or_spatial();
/** Validates engine specific table options not handled by SQL-parser.
@return NULL if valid, string name of bad option if not. */ constchar* check_table_options();
/** Validate DATA DIRECTORY option. */ bool create_option_data_directory_is_valid();
/** Prepare to create a table. */ int prepare_create_table(constchar* name, bool strict = true);
void allocate_trx();
/** Checks that every index have sane size. Depends on strict mode */ bool row_size_is_acceptable(const dict_table_t& table, bool strict) const; /** Checks that given index have sane size. Depends on strict mode */ bool row_size_is_acceptable(const dict_index_t& index, bool strict) const;
/** Determines InnoDB table flags. Ifstrict_mode=OFF,thiswilladjusttheflagstowhatshouldbeassumed.
@retval true if successful, false if error */ bool innobase_table_flags();
/** Set flags and append '/' to remote path if necessary. */ void set_remote_path_flags();
/** @return the created table */
dict_table_t *table() const { return m_table; }
THD* thd() const { return(m_thd); }
private: /** Parses the table name into normal name and either temp path or
remote path if needed.*/ int
parse_table_name( constchar* name);
/** Create the internal innodb table definition. */ int create_table_def();
/** Connection thread handle. */
THD* m_thd;
/** InnoDB transaction handle. Non-NULL only when createisinvokedfromantruncationoperation. NULLforregularCREATETABLEandALTERTABLE,
which build their own transaction internally. */
trx_t* m_trx;
/** Information on table columns and indexes. */ const TABLE* m_form;
/** Value of innodb_default_row_format */ const ulong m_default_row_format;
/** Remote path (DATA DIRECTORY) or zero length-string */ char m_remote_path[FN_REFLEN]; // Absolute path of the table
/** Local copy of srv_file_per_table. */ bool m_innodb_file_per_table;
/** Allow file_per_table for this table either because: 1)thesettinginnodb_file_per_table=on, 2)itwasexplicitlyrequestedbytablespace=innodb_file_per_table.
3) the table being altered is currently file_per_table */ bool m_allow_file_per_table;
/** After all considerations, this shows whether we will actually
create a table and tablespace using file-per-table. */ bool m_use_file_per_table;
/** Using DATA DIRECTORY */ bool m_use_data_dir;
/** Table flags */
ulint m_flags;
/** Table flags2 */
ulint m_flags2;
/** Whether we are creating a stub table for importing. */ constbool m_creating_stub;
};
/** InitializethetableFTSstopwordlist
@return TRUE if success */
ibool
innobase_fts_load_stopword( /*=======================*/
dict_table_t* table, /*!< in: Table has the FTS */
trx_t* trx, /*!< in: transaction */
THD* thd) /*!< in: current thread */
MY_ATTRIBUTE((warn_unused_result));
/** Some defines for innobase_fts_check_doc_id_index() return value */ enum fts_doc_id_index_enum {
FTS_INCORRECT_DOC_ID_INDEX,
FTS_EXIST_DOC_ID_INDEX,
FTS_NOT_EXIST_DOC_ID_INDEX
};
/** CheckwhetherthetablehasauniqueindexwithnameFTS_DOC_ID_INDEX ontheDocIDcolumn.
@return the status of the FTS_DOC_ID index */
fts_doc_id_index_enum
innobase_fts_check_doc_id_index( const dict_table_t* table, /*!< in: table definition */ const TABLE* altered_table, /*!< in: MySQL table
that is being altered */
ulint* fts_doc_col_no) /*!< out: The column number for
Doc ID */
MY_ATTRIBUTE((warn_unused_result));
/** CheckwhetherthetablehasauniqueindexwithnameFTS_DOC_ID_INDEX ontheDocIDcolumninMySQLcreateindexdefinition. @returnFTS_EXIST_DOC_ID_INDEXifthereexiststheFTS_DOC_IDindex,
FTS_INCORRECT_DOC_ID_INDEX if the FTS_DOC_ID index is of wrong format */
fts_doc_id_index_enum
innobase_fts_check_doc_id_index_in_def(
ulint n_key, /*!< in: Number of keys */ const KEY* key_info) /*!< in: Key definitions */
MY_ATTRIBUTE((warn_unused_result));
/** Set up base columns for virtual column @param[in]tabletheInnoDBtable @param[in]fieldMySQLfield
@param[in,out] v_col virtual column to be set up */ void
innodb_base_col_setup(
dict_table_t* table, const Field* field,
dict_v_col_t* v_col);
/** Set up base columns for stored column @param[in]tableInnoDBtable @param[in]fieldMySQLfield
@param[in,out] s_col stored column */ void
innodb_base_col_setup_for_stored( const dict_table_t* table, const Field* field,
dict_s_col_t* s_col);
/** whether this is a stored generated column */ #define innobase_is_s_fld(field) ((field)->vcol_info && (field)->stored_in_db())
/** Converts a search mode flag understood by MySQL to a flag understood byInnoDB. @param[in]find_flagMySQLsearchmodeflag.
@return InnoDB search mode flag. */
page_cur_mode_t
convert_search_mode_to_innobase( enum ha_rkey_function find_flag);
/** Commits a transaction in an InnoDB database.
@param[in] trx Transaction handle. */ void
innobase_commit_low(
trx_t* trx);
extern my_bool innobase_stats_on_metadata;
/** Calculate Record Per Key value. NeedtoexcludetheNULLvalueifinnodb_stats_methodissetto"nulls_ignored" @param[in]indexInnoDBindex. @param[in]iThecolumnwearecalculatingrecperkey. @param[in]recordsEstimatedtotalrecords.
@return estimated record per key value */ /* JAN: TODO: MySQL 5.7 */ typedeffloat rec_per_key_t;
rec_per_key_t
innodb_rec_per_key(
dict_index_t* index,
ulint i,
ha_rows records);
/** Build template for the virtual columns and their base columns @param[in]tableMySQLTABLE @param[in]ib_tableInnoDBdict_table_t @param[in,out]s_templInnoDBtemplatestructure @param[in]add_vnewvirtualcolumnsaddedalongwith
add index call */ void
innobase_build_v_templ( const TABLE* table, const dict_table_t* ib_table,
dict_vcol_templ_t* s_templ, const dict_add_v_col_t* add_v = nullptr);
/** callback used by MySQL server layer to initialized thetablevirtualcolumns'template @param[in]tableMySQLTABLE
@param[in,out] ib_table InnoDB dict_table_t */ void
innobase_build_v_templ_callback( const TABLE* table, void* ib_table);
/** Callback function definition, used by MySQL server layer to initialized
the table virtual columns' template */ typedefvoid (*my_gcolumn_templatecallback_t)(const TABLE*, void*);
/** Convert MySQL column number to dict_table_t::cols[] offset. @param[in]fieldnon-virtualcolumn
@return column number relative to dict_table_t::cols[] */ unsigned
innodb_col_no(const Field* field)
MY_ATTRIBUTE((nonnull, warn_unused_result));
/** Get the maximum integer value of a numeric column. @paramfieldcolumndefinition
@return maximum allowed integer value */
ulonglong innobase_get_int_col_max_value(const Field *field)
MY_ATTRIBUTE((nonnull, warn_unused_result));
/********************************************************************//**
Helper function to push frm mismatch error to error log and if needed to sql-layer. */ void
ib_push_frm_error(
THD* thd, /*!< in: MySQL thd */
dict_table_t* ib_table, /*!< in: InnoDB table */
TABLE* table, /*!< in: MySQL table */
ulint n_keys, /*!< in: InnoDB #keys */ bool push_warning); /*!< in: print warning ? */
/** Check each index part length whether they not exceed the max limit @param[in]max_field_lenmaximumallowedkeypartlength @param[in]keyMariaDBkeydefinition
@return true if index column length exceeds limit */
MY_ATTRIBUTE((warn_unused_result)) bool too_big_key_part_length(size_t max_field_len, const KEY& key);
/** Adjust the persistent statistics after rebuilding ALTER TABLE. Removestatisticsfordroppedindexes,addstatisticsforcreatedindexes andrenamestatisticsforrenamedindexes. @paramtableInnoDBtablethatwasrebuiltbyALTERTABLE @paramtrxusertransaction
@param copy caller is from COPY algorithm */ void alter_stats_rebuild(dict_table_t *table, trx_t *trx, bool copy=false) noexcept;
/** Find an auto-generated foreign key constraint identifier. @paramtableInnoDBtable
@return the next number to assign to a constraint */
ulint dict_table_get_foreign_id(const dict_table_t &table) noexcept;
/** Generate a foreign key constraint name for an anonymous constraint. @paramid_nrsequencetoallocateidentifiersfrom @paramnametablename
@param foreign foreign key */ void dict_create_add_foreign_id(ulint *id_nr, constchar *name,
dict_foreign_t *foreign) noexcept;
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.29 Sekunden
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.