📄 row0mysql.h
字号:
/******************************************************Interface between Innobase row operations and MySQL.Contains also create table and other data dictionary operations.(c) 2000 Innobase OyCreated 9/17/2000 Heikki Tuuri*******************************************************/#ifndef row0mysql_h#define row0mysql_h#include "univ.i"#include "data0data.h"#include "que0types.h"#include "dict0types.h"#include "trx0types.h"#include "row0types.h"#include "btr0pcur.h"#include "trx0types.h"typedef struct row_prebuilt_struct row_prebuilt_t;/***********************************************************************Frees the blob heap in prebuilt when no longer needed. */voidrow_mysql_prebuilt_free_blob_heap(/*==============================*/ row_prebuilt_t* prebuilt); /* in: prebuilt struct of a ha_innobase:: table handle *//***********************************************************************Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL rowformat. */byte*row_mysql_store_true_var_len(/*=========================*/ /* out: pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len */ byte* dest, /* in: where to store */ ulint len, /* in: length, must fit in two bytes */ ulint lenlen);/* in: storage length of len: either 1 or 2 bytes *//***********************************************************************Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, andreturns a pointer to the data. */byte*row_mysql_read_true_varchar(/*========================*/ /* out: pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len */ ulint* len, /* out: variable-length field length */ byte* field, /* in: field in the MySQL format */ ulint lenlen);/* in: storage length of len: either 1 or 2 bytes *//***********************************************************************Stores a reference to a BLOB in the MySQL format. */voidrow_mysql_store_blob_ref(/*=====================*/ byte* dest, /* in: where to store */ ulint col_len, /* in: dest buffer size: determines into how many bytes the BLOB length is stored, this may vary from 1 to 4 bytes */ byte* data, /* in: BLOB data */ ulint len); /* in: BLOB length *//***********************************************************************Reads a reference to a BLOB in the MySQL format. */byte*row_mysql_read_blob_ref(/*====================*/ /* out: pointer to BLOB data */ ulint* len, /* out: BLOB length */ byte* ref, /* in: BLOB reference in the MySQL format */ ulint col_len); /* in: BLOB reference length (not BLOB length) *//******************************************************************Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format.The counterpart of this function is row_sel_field_store_in_mysql_format() inrow0sel.c. */byte*row_mysql_store_col_in_innobase_format(/*===================================*/ /* out: up to which byte we used buf in the conversion */ dfield_t* dfield, /* in/out: dfield where dtype information must be already set when this function is called! */ byte* buf, /* in/out: buffer for a converted integer value; this must be at least col_len long then! */ ibool row_format_col, /* TRUE if the mysql_data is from a MySQL row, FALSE if from a MySQL key value; in MySQL, a true VARCHAR storage format differs in a row and in a key value: in a key value the length is always stored in 2 bytes! */ byte* mysql_data, /* in: MySQL column value, not SQL NULL; NOTE that dfield may also get a pointer to mysql_data, therefore do not discard this as long as dfield is used! */ ulint col_len, /* in: MySQL column length; NOTE that this is the storage length of the column in the MySQL format row, not necessarily the length of the actual payload data; if the column is a true VARCHAR then this is irrelevant */ ulint comp); /* in: nonzero=compact format *//********************************************************************Handles user errors and lock waits detected by the database engine. */iboolrow_mysql_handle_errors(/*====================*/ /* out: TRUE if it was a lock wait and we should continue running the query thread */ ulint* new_err,/* out: possible new error encountered in rollback, or the old error which was during the function entry */ trx_t* trx, /* in: transaction */ que_thr_t* thr, /* in: query thread */ trx_savept_t* savept);/* in: savepoint *//************************************************************************Create a prebuilt struct for a MySQL table handle. */row_prebuilt_t*row_create_prebuilt(/*================*/ /* out, own: a prebuilt struct */ dict_table_t* table); /* in: Innobase table handle *//************************************************************************Free a prebuilt struct for a MySQL table handle. */voidrow_prebuilt_free(/*==============*/ row_prebuilt_t* prebuilt); /* in, own: prebuilt struct *//*************************************************************************Updates the transaction pointers in query graphs stored in the prebuiltstruct. */voidrow_update_prebuilt_trx(/*====================*/ /* out: prebuilt dtuple */ row_prebuilt_t* prebuilt, /* in: prebuilt struct in MySQL handle */ trx_t* trx); /* in: transaction handle *//*************************************************************************Unlocks an AUTO_INC type lock possibly reserved by trx. */void row_unlock_table_autoinc_for_mysql(/*===============================*/ trx_t* trx); /* in: transaction *//*************************************************************************Sets an AUTO_INC type lock on the table mentioned in prebuilt. TheAUTO_INC lock gives exclusive access to the auto-inc counter of thetable. The lock is reserved only for the duration of an SQL statement.It is not compatible with another AUTO_INC or exclusive lock on thetable. */introw_lock_table_autoinc_for_mysql(/*=============================*/ /* out: error code or DB_SUCCESS */ row_prebuilt_t* prebuilt); /* in: prebuilt struct in the MySQL table handle *//*************************************************************************Sets a table lock on the table mentioned in prebuilt. */introw_lock_table_for_mysql(/*=====================*/ /* out: error code or DB_SUCCESS */ row_prebuilt_t* prebuilt, /* in: prebuilt struct in the MySQL table handle */ dict_table_t* table, /* in: table to lock, or NULL if prebuilt->table should be locked as prebuilt->select_lock_type */ ulint mode); /* in: lock mode of table (ignored if table==NULL) */ /*************************************************************************Does an insert for MySQL. */introw_insert_for_mysql(/*=================*/ /* out: error code or DB_SUCCESS */ byte* mysql_rec, /* in: row in the MySQL format */ row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL handle *//*************************************************************************Builds a dummy query graph used in selects. */voidrow_prebuild_sel_graph(/*===================*/ row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL handle *//*************************************************************************Gets pointer to a prebuilt update vector used in updates. If the updategraph has not yet been built in the prebuilt struct, then this functionfirst builds it. */upd_t*row_get_prebuilt_update_vector(/*===========================*/ /* out: prebuilt update vector */ row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL handle *//*************************************************************************Checks if a table is such that we automatically created a clusteredindex on it (on row id). */iboolrow_table_got_default_clust_index(/*==============================*/ dict_table_t* table);/*************************************************************************Calculates the key number used inside MySQL for an Innobase index. We haveto take into account if we generated a default clustered index for the table */ulintrow_get_mysql_key_number_for_index(/*===============================*/ dict_index_t* index);/*************************************************************************Does an update or delete of a row for MySQL. */introw_update_for_mysql(/*=================*/ /* out: error code or DB_SUCCESS */ byte* mysql_rec, /* in: the row to be updated, in the MySQL format */ row_prebuilt_t* prebuilt); /* in: prebuilt struct in MySQL handle *//*************************************************************************This can only be used when srv_locks_unsafe_for_binlog is TRUE. Beforecalling this function we must use trx_reset_new_rec_lock_info() andtrx_register_new_rec_lock() to store the information which new record locksreally were set. This function removes a newly set lock under prebuilt->pcur,and also under prebuilt->clust_pcur. Currently, this is only used and testedin the case of an UPDATE or a DELETE statement, where the row lock is of theLOCK_X or LOCK_S type. Thus, this implements a 'mini-rollback' that releases the latest record locks we set. */introw_unlock_for_mysql(/*=================*/ /* out: error code or DB_SUCCESS */ row_prebuilt_t* prebuilt, /* in: prebuilt struct in MySQL handle */ ibool has_latches_on_recs);/* TRUE if called so that we have the latches on the records under pcur and clust_pcur, and we do not need to reposition the cursors. *//*************************************************************************Creates an query graph node of 'update' type to be used in the MySQLinterface. */upd_node_t*row_create_update_node_for_mysql(/*=============================*/ /* out, own: update node */ dict_table_t* table, /* in: table to update */ mem_heap_t* heap); /* in: mem heap from which allocated *//**************************************************************************Does a cascaded delete or set null in a foreign key operation. */ulintrow_update_cascade_for_mysql(/*=========================*/ /* out: error code or DB_SUCCESS */ que_thr_t* thr, /* in: query thread */ upd_node_t* node, /* in: update node used in the cascade or set null operation */ dict_table_t* table); /* in: table where we do the operation *//*************************************************************************Locks the data dictionary exclusively for performing a table create or otherdata dictionary modification operation. */voidrow_mysql_lock_data_dictionary(/*===========================*/ trx_t* trx); /* in: transaction *//*************************************************************************Unlocks the data dictionary exclusive lock. */voidrow_mysql_unlock_data_dictionary(/*=============================*/ trx_t* trx); /* in: transaction *//*************************************************************************Locks the data dictionary in shared mode from modifications, for performingforeign key check, rollback, or other operation invisible to MySQL. */voidrow_mysql_freeze_data_dictionary(/*=============================*/ trx_t* trx); /* in: transaction *//*************************************************************************Unlocks the data dictionary shared lock. */voidrow_mysql_unfreeze_data_dictionary(/*===============================*/ trx_t* trx); /* in: transaction *//*************************************************************************Does a table creation operation for MySQL. If the name of the createdtable ends to characters INNODB_MONITOR, then this also startsprinting of monitor output by the master thread. */introw_create_table_for_mysql(/*=======================*/ /* out: error code or DB_SUCCESS */ dict_table_t* table, /* in: table definition */ trx_t* trx); /* in: transaction handle *//*************************************************************************Does an index creation operation for MySQL. TODO: currently failureto create an index results in dropping the whole table! This is no problemcurrently as all indexes must be created at the same time as the table. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -