MySQL 8.0.39
Source Code Documentation
row0mysql.h File Reference

Interface between Innobase row operations and MySQL. More...

#include "ha_prototypes.h"
#include <stddef.h>
#include <sys/types.h>
#include <algorithm>
#include "btr0pcur.h"
#include "data0data.h"
#include "data0type.h"
#include "db0err.h"
#include "dict0types.h"
#include "fts0fts.h"
#include "gis0type.h"
#include "lob0undo.h"
#include "lock0types.h"
#include "mem0mem.h"
#include "my_compiler.h"
#include "my_inttypes.h"
#include "que0types.h"
#include "rem0types.h"
#include "row0types.h"
#include "sess0sess.h"
#include "sql_cmd.h"
#include "trx0types.h"
#include "univ.i"
#include "ut0bool_scope_guard.h"

Go to the source code of this file.

Classes

struct  mysql_row_templ_t
 
struct  row_prebuilt_t
 A struct for (sometimes lazily) prebuilt structures in an Innobase table handle used within MySQL; these are used to save CPU time. More...
 
class  row_prebuilt_t::row_is_reading_range_guard_t
 
struct  SysIndexCallback
 Callback for row_mysql_sys_index_iterate() More...
 

Namespaces

namespace  dd
 The version of the current data dictionary table definitions.
 

Functions

void row_mysql_prebuilt_free_blob_heap (row_prebuilt_t *prebuilt)
 Frees the blob heap in prebuilt when no longer needed. More...
 
byterow_mysql_store_true_var_len (byte *dest, ulint len, ulint lenlen)
 Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row format. More...
 
const byterow_mysql_read_true_varchar (ulint *len, const byte *field, ulint lenlen)
 Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and returns a pointer to the data. More...
 
void row_mysql_store_blob_ref (byte *dest, ulint col_len, const void *data, ulint len)
 Stores a reference to a BLOB in the MySQL format. More...
 
const byterow_mysql_read_blob_ref (ulint *len, const byte *ref, ulint col_len)
 Reads a reference to a BLOB in the MySQL format. More...
 
void row_mysql_store_geometry (byte *dest, ulint dest_len, const byte *src, ulint src_len)
 Converts InnoDB geometry data format to MySQL data format. More...
 
void row_mysql_pad_col (ulint mbminlen, byte *pad, ulint len)
 Pad a column with spaces. More...
 
byterow_mysql_store_col_in_innobase_format (dfield_t *dfield, byte *buf, bool row_format_col, const byte *mysql_data, ulint col_len, ulint comp)
 Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format. More...
 
bool row_mysql_handle_errors (dberr_t *new_err, trx_t *trx, que_thr_t *thr, trx_savept_t *savept)
 Handles user errors and lock waits detected by the database engine. More...
 
row_prebuilt_trow_create_prebuilt (dict_table_t *table, ulint mysql_row_len)
 Create a prebuilt struct for a MySQL table handle. More...
 
void row_prebuilt_free (row_prebuilt_t *prebuilt, bool dict_locked)
 Free a prebuilt struct for a MySQL table handle. More...
 
void row_update_prebuilt_trx (row_prebuilt_t *prebuilt, trx_t *trx)
 Updates the transaction pointers in query graphs stored in the prebuilt struct. More...
 
dberr_t row_lock_table_autoinc_for_mysql (row_prebuilt_t *prebuilt)
 Sets an AUTO_INC type lock on the table mentioned in prebuilt. More...
 
dberr_t row_lock_table (row_prebuilt_t *prebuilt)
 Sets a table lock on the table mentioned in prebuilt. More...
 
dberr_t row_insert_for_mysql (const byte *mysql_rec, row_prebuilt_t *prebuilt)
 Does an insert for MySQL. More...
 
void row_prebuild_sel_graph (row_prebuilt_t *prebuilt)
 Builds a dummy query graph used in selects. More...
 
upd_trow_get_prebuilt_update_vector (row_prebuilt_t *prebuilt)
 Gets pointer to a prebuilt update vector used in updates. More...
 
bool row_table_got_default_clust_index (const dict_table_t *table)
 Checks if a table is such that we automatically created a clustered index on it (on row id). More...
 
dberr_t row_update_for_mysql (const byte *mysql_rec, row_prebuilt_t *prebuilt)
 Does an update or delete of a row for MySQL. More...
 
void row_delete_all_rows (dict_table_t *table)
 Delete all rows for the given table by freeing/truncating indexes. More...
 
bool row_is_mysql_tmp_table_name (const char *name)
 Checks if a table name contains the string "/#sql" which denotes temporary tables in MySQL. More...
 
upd_node_trow_create_update_node_for_mysql (dict_table_t *table, mem_heap_t *heap)
 Creates an query graph node of 'update' type to be used in the MySQL interface. More...
 
dberr_t row_update_cascade_for_mysql (que_thr_t *thr, upd_node_t *node, dict_table_t *table)
 Does a cascaded delete or set null in a foreign key operation. More...
 
void row_mysql_lock_data_dictionary (trx_t *trx, ut::Location location)
 Locks the data dictionary exclusively for performing a table create or other data dictionary modification operation. More...
 
void row_mysql_unlock_data_dictionary (trx_t *trx)
 Unlocks the data dictionary exclusive lock. More...
 
void row_mysql_freeze_data_dictionary (trx_t *trx, ut::Location location)
 Locks the data dictionary in shared mode from modifications, for performing foreign key check, rollback, or other operation invisible to MySQL. More...
 
void row_mysql_unfreeze_data_dictionary (trx_t *trx)
 Unlocks the data dictionary shared lock. More...
 
dberr_t row_create_table_for_mysql (dict_table_t *&table, const char *compression, const HA_CREATE_INFO *create_info, trx_t *trx, mem_heap_t *heap)
 Creates a table for MySQL. More...
 
dberr_t row_create_index_for_mysql (dict_index_t *index, trx_t *trx, const ulint *field_lengths, dict_table_t *handler)
 Does an index creation operation for MySQL. More...
 
dberr_t row_table_load_foreign_constraints (trx_t *trx, const char *name, const dd::Table *dd_table)
 Loads foreign key constraints for the table being created. More...
 
ulint row_drop_tables_for_mysql_in_background (void)
 The master thread in srv0srv.cc calls this regularly to drop tables which we must drop in background after queries to them have ended. More...
 
dberr_t row_mysql_lock_table (trx_t *trx, dict_table_t *table, enum lock_mode mode, const char *op_info)
 Sets an exclusive lock on a table. More...
 
dberr_t row_drop_tablespace (space_id_t space_id, const char *filepath)
 Drop a tablespace as part of dropping or renaming a table. More...
 
dberr_t row_drop_table_for_mysql (const char *name, trx_t *trx, bool nonatomic, dict_table_t *handler=nullptr)
 Drop a table for MySQL. More...
 
dberr_t row_drop_table_for_mysql (const char *name, trx_t *trx)
 Drop a table for MySQL. More...
 
dberr_t row_discard_tablespace_for_mysql (const char *name, trx_t *trx)
 Discards the tablespace of a table which stored in an .ibd file. More...
 
dberr_t row_drop_database_for_mysql (const char *name, trx_t *trx, ulint *found)
 Drop a database for MySQL. More...
 
dberr_t row_rename_table_for_mysql (const char *old_name, const char *new_name, const dd::Table *dd_table, trx_t *trx, bool replay)
 Renames a table for MySQL. More...
 
dberr_t row_mysql_parallel_select_count_star (trx_t *trx, std::vector< dict_index_t * > &indexes, size_t max_threads, ulint *n_rows)
 Read the total number of records in a consistent view. More...
 
dberr_t row_scan_index_for_mysql (row_prebuilt_t *prebuilt, dict_index_t *index, size_t n_threads, bool check_keys, ulint *n_rows)
 Scans an index for either COUNT(*) or CHECK TABLE. More...
 
void row_mysql_init (void)
 Initialize this module. More...
 
void row_mysql_close (void)
 Close this module. More...
 
dfield_tinnobase_get_field_from_update_vector (dict_foreign_t *foreign, upd_t *update, uint32_t col_no)
 Get the updated parent field value from the update vector for the given col_no. More...
 
dfield_tinnobase_get_computed_value (const dtuple_t *row, const dict_v_col_t *col, const dict_index_t *index, mem_heap_t **local_heap, mem_heap_t *heap, const dict_field_t *ifield, THD *thd, TABLE *mysql_table, const dict_table_t *old_table, upd_t *parent_update, dict_foreign_t *foreign)
 Get the computed value by supplying the base column values. More...
 
void innobase_get_multi_value (const TABLE *mysql_table, ulint f_idx, dfield_t *dfield, multi_value_data *value, uint old_val, ulint comp, mem_heap_t *heap)
 Parse out multi-values from a MySQL record. More...
 
void innobase_init_vc_templ (dict_table_t *table)
 Get the computed value by supplying the base column values. More...
 
void innobase_rename_vc_templ (dict_table_t *table)
 Change dbname and table name in table->vc_templ. More...
 
void row_wait_for_background_drop_list_empty ()
 Wait for the background drop list to become empty. More...
 

Variables

bool row_rollback_on_timeout
 Provide optional 4.x backwards compatibility for 5.0 and above. More...
 
constexpr uint32_t MYSQL_FETCH_CACHE_SIZE = 8
 
constexpr uint32_t MYSQL_FETCH_CACHE_THRESHOLD = 4
 
constexpr uint32_t ROW_PREBUILT_ALLOCATED = 78540783
 
constexpr uint32_t ROW_PREBUILT_FREED = 26423527
 
constexpr uint32_t ROW_PREBUILT_FETCH_MAGIC_N = 465765687
 
constexpr uint32_t ROW_MYSQL_WHOLE_ROW = 0
 
constexpr uint32_t ROW_MYSQL_REC_FIELDS = 1
 
constexpr uint32_t ROW_MYSQL_NO_TEMPLATE = 2
 
constexpr uint32_t ROW_MYSQL_DUMMY_TEMPLATE = 3
 dummy template used in row_scan_and_check_index More...
 
constexpr uint32_t ROW_RETRIEVE_PRIMARY_KEY = 1
 
constexpr uint32_t ROW_RETRIEVE_ALL_COLS = 2
 
constexpr uint32_t ROW_READ_WITH_LOCKS = 0
 
constexpr uint32_t ROW_READ_TRY_SEMI_CONSISTENT = 1
 
constexpr uint32_t ROW_READ_DID_SEMI_CONSISTENT = 2
 

Detailed Description

Interface between Innobase row operations and MySQL.

Contains also create table and other data dictionary operations.

Created 9/17/2000 Heikki Tuuri

Function Documentation

◆ innobase_get_computed_value()

dfield_t * innobase_get_computed_value ( const dtuple_t row,
const dict_v_col_t col,
const dict_index_t index,
mem_heap_t **  local_heap,
mem_heap_t heap,
const dict_field_t ifield,
THD thd,
TABLE mysql_table,
const dict_table_t old_table,
upd_t parent_update,
dict_foreign_t foreign 
)

Get the computed value by supplying the base column values.

Parameters
[in,out]rowthe data row
[in]colvirtual column
[in]indexindex on the virtual column
[in,out]local_heapheap memory for processing large data etc.
[in,out]heapmemory heap that copies the actual index row
[in]ifieldindex field
[in]thdMySQL thread handle
[in,out]mysql_tablemysql table object
[in]old_tableduring ALTER TABLE, this is the old table or NULL.
[in]parent_updateupdate vector for the parent row
[in]foreignforeign key information
Returns
the field filled with computed value, or NULL if just want to store the value in passed in "my_rec"

◆ innobase_get_field_from_update_vector()

dfield_t * innobase_get_field_from_update_vector ( dict_foreign_t foreign,
upd_t update,
uint32_t  col_no 
)

Get the updated parent field value from the update vector for the given col_no.

Parameters
[in]foreignforeign key information
[in]updateupdated parent vector.
[in]col_nobase column position of the child table to check
Returns
updated field from the parent update vector, else NULL

◆ innobase_get_multi_value()

void innobase_get_multi_value ( const TABLE mysql_table,
ulint  f_idx,
dfield_t dfield,
multi_value_data value,
uint  old_val,
ulint  comp,
mem_heap_t heap 
)

Parse out multi-values from a MySQL record.

Parameters
[in]mysql_tableMySQL table structure
[in]f_idxfield index of the multi-value column
[in,out]dfieldfield structure to store parsed multi-value
[in,out]valuenullptr or the multi-value structure to store the parsed values
[in]old_valold value if exists
[in]comptrue if InnoDB table uses compact row format
[in,out]heapmemory heap

◆ innobase_init_vc_templ()

void innobase_init_vc_templ ( dict_table_t table)

Get the computed value by supplying the base column values.

Parameters
[in,out]tablethe table whose virtual column template to be built

◆ innobase_rename_vc_templ()

void innobase_rename_vc_templ ( dict_table_t table)

Change dbname and table name in table->vc_templ.

Parameters
[in,out]tablethe table whose virtual column template dbname and tbname to be renamed.

◆ row_create_index_for_mysql()

dberr_t row_create_index_for_mysql ( dict_index_t index,
trx_t trx,
const ulint field_lengths,
dict_table_t handler 
)

Does an index creation operation for MySQL.

TODO: currently failure to create an index results in dropping the whole table! This is no problem currently as all indexes must be created at the same time as the table.

Returns
error number or DB_SUCCESS
Parameters
indexin, own: index definition (will be freed)
trxin: transaction handle
field_lengthsin: if not NULL, must contain dict_index_get_n_fields(index) actual field lengths for the index columns, which are then checked for not being too large.
handlerin/out: table handler.

◆ row_create_prebuilt()

row_prebuilt_t * row_create_prebuilt ( dict_table_t table,
ulint  mysql_row_len 
)

Create a prebuilt struct for a MySQL table handle.

Returns
own: a prebuilt struct in: length in bytes of a row in the MySQL format
own: a prebuilt struct
Parameters
tablein: Innobase table handle
mysql_row_lenin: length in bytes of a row in the MySQL format

◆ row_create_table_for_mysql()

dberr_t row_create_table_for_mysql ( dict_table_t *&  table,
const char *  compression,
const HA_CREATE_INFO create_info,
trx_t trx,
mem_heap_t heap 
)

Creates a table for MySQL.

On success the in-memory table could be kept in non-LRU list while on failure the 'table' object will be freed.

Parameters
[in,out]tabletable definition(will be freed, or on DB_SUCCESS added to the data dictionary cache)
[in]compressioncompression algorithm to use, can be nullptr
[in]create_infoHA_CREATE_INFO object
[in,out]trxtransaction
[in]heaptemp memory heap or nullptr
Returns
error code or DB_SUCCESS

◆ row_create_update_node_for_mysql()

upd_node_t * row_create_update_node_for_mysql ( dict_table_t table,
mem_heap_t heap 
)

Creates an query graph node of 'update' type to be used in the MySQL interface.

Returns
own: update node in: mem heap from which allocated
own: update node
Parameters
tablein: table to update
heapin: mem heap from which allocated

◆ row_delete_all_rows()

void row_delete_all_rows ( dict_table_t table)

Delete all rows for the given table by freeing/truncating indexes.

Parameters
[in,out]tabletable handler

◆ row_discard_tablespace_for_mysql()

dberr_t row_discard_tablespace_for_mysql ( const char *  name,
trx_t trx 
)

Discards the tablespace of a table which stored in an .ibd file.

Discarding means that this function deletes the .ibd file and assigns a new table id for the table. Also the flag table->ibd_file_missing is set true.

Returns
error code or DB_SUCCESS in: transaction handle

Discarding means that this function renames the .ibd file and assigns a new table id for the table. Also the flag table->ibd_file_missing is set to true.

Returns
error code or DB_SUCCESS
Parameters
namein: table name
trxin: transaction handle

◆ row_drop_database_for_mysql()

dberr_t row_drop_database_for_mysql ( const char *  name,
trx_t trx,
ulint found 
)

Drop a database for MySQL.

Parameters
[in]namedatabase name which ends at '/'
[in]trxtransaction handle
[out]foundnumber of dropped tables
Returns
error code or DB_SUCCESS

◆ row_drop_table_for_mysql() [1/2]

dberr_t row_drop_table_for_mysql ( const char *  name,
trx_t trx 
)
inline

Drop a table for MySQL.

If the data dictionary was not already locked by the transaction, the transaction will be committed. Otherwise, the data dictionary will remain locked.

Parameters
[in]nametable name
[in,out]trxdata dictionary transaction
Returns
error code or DB_SUCCESS

◆ row_drop_table_for_mysql() [2/2]

dberr_t row_drop_table_for_mysql ( const char *  name,
trx_t trx,
bool  nonatomic,
dict_table_t handler 
)

Drop a table for MySQL.

If the data dictionary was not already locked by the transaction, the transaction will be committed. Otherwise, the data dictionary will remain locked.

Parameters
[in]nameTable name
[in]trxTransaction handle
[in]nonatomicWhether it is permitted to release and reacquire dict_operation_lock
[in,out]handlerTable handler or NULL
Returns
error code or DB_SUCCESS

◆ row_drop_tables_for_mysql_in_background()

ulint row_drop_tables_for_mysql_in_background ( void  )

The master thread in srv0srv.cc calls this regularly to drop tables which we must drop in background after queries to them have ended.

Such lazy dropping of tables is needed in ALTER TABLE on Unix.

Returns
how many tables dropped + remaining tables in list

The master thread in srv0srv.cc calls this regularly to drop tables which we must drop in background after queries to them have ended.

Such lazy dropping of tables is needed in ALTER TABLE on Unix.

Returns
how many tables dropped + remaining tables in list

◆ row_drop_tablespace()

dberr_t row_drop_tablespace ( space_id_t  space_id,
const char *  filepath 
)

Drop a tablespace as part of dropping or renaming a table.

This deletes the fil_space_t if found and the file on disk.

Parameters
[in]space_idTablespace ID
[in]filepathFile path of tablespace to delete
Returns
error code or DB_SUCCESS

◆ row_get_prebuilt_update_vector()

upd_t * row_get_prebuilt_update_vector ( row_prebuilt_t prebuilt)

Gets pointer to a prebuilt update vector used in updates.

If the update graph has not yet been built in the prebuilt struct, then this function first builds it.

Returns
prebuilt update vector in: prebuilt struct in MySQL handle

If the update graph has not yet been built in the prebuilt struct, then this function first builds it.

Returns
prebuilt update vector
Parameters
prebuiltin: prebuilt struct in MySQL handle

◆ row_insert_for_mysql()

dberr_t row_insert_for_mysql ( const byte mysql_rec,
row_prebuilt_t prebuilt 
)

Does an insert for MySQL.

Parameters
[in]mysql_recrow in the MySQL format
[in,out]prebuiltprebuilt struct in MySQL handle
Returns
error code or DB_SUCCESS

◆ row_is_mysql_tmp_table_name()

bool row_is_mysql_tmp_table_name ( const char *  name)

Checks if a table name contains the string "/#sql" which denotes temporary tables in MySQL.

Returns
true if temporary table in: table name in the form 'database/tablename'

◆ row_lock_table()

dberr_t row_lock_table ( row_prebuilt_t prebuilt)

Sets a table lock on the table mentioned in prebuilt.

Parameters
[in,out]prebuilttable handle
Returns
error code or DB_SUCCESS

◆ row_lock_table_autoinc_for_mysql()

dberr_t row_lock_table_autoinc_for_mysql ( row_prebuilt_t prebuilt)

Sets an AUTO_INC type lock on the table mentioned in prebuilt.

The AUTO_INC lock gives exclusive access to the auto-inc counter of the table. The lock is reserved only for the duration of an SQL statement. It is not compatible with another AUTO_INC or exclusive lock on the table.

Returns
error code or DB_SUCCESS in: prebuilt struct in the MySQL table handle

The AUTO_INC lock gives exclusive access to the auto-inc counter of the table. The lock is reserved only for the duration of an SQL statement. It is not compatible with another AUTO_INC or exclusive lock on the table.

Returns
error code or DB_SUCCESS
Parameters
prebuiltin: prebuilt struct in the MySQL table handle

◆ row_mysql_close()

void row_mysql_close ( void  )

Close this module.

◆ row_mysql_freeze_data_dictionary()

void row_mysql_freeze_data_dictionary ( trx_t trx,
ut::Location  location 
)

Locks the data dictionary in shared mode from modifications, for performing foreign key check, rollback, or other operation invisible to MySQL.

Parameters
[in,out]trxTransaction
[in]locationLocation

◆ row_mysql_handle_errors()

bool row_mysql_handle_errors ( dberr_t new_err,
trx_t trx,
que_thr_t thr,
trx_savept_t savept 
)

Handles user errors and lock waits detected by the database engine.

Returns
true if it was a lock wait and we should continue running the query thread in: savepoint, or NULL
true if it was a lock wait and we should continue running the query thread and in that case the thr is ALREADY in the running state.
Parameters
new_errout: possible new error encountered in lock wait, or if no new error, the value of trx->error_state at the entry of this function
trxin: transaction
thrin: query thread, or NULL
saveptin: savepoint, or NULL

◆ row_mysql_init()

void row_mysql_init ( void  )

Initialize this module.

◆ row_mysql_lock_data_dictionary()

void row_mysql_lock_data_dictionary ( trx_t trx,
ut::Location  location 
)

Locks the data dictionary exclusively for performing a table create or other data dictionary modification operation.

Parameters
[in,out]trxTransaction
[in]locationLocation

◆ row_mysql_lock_table()

dberr_t row_mysql_lock_table ( trx_t trx,
dict_table_t table,
enum lock_mode  mode,
const char *  op_info 
)

Sets an exclusive lock on a table.

Returns
error code or DB_SUCCESS in: string for trx->op_info
error code or DB_SUCCESS
Parameters
trxin/out: transaction
tablein: table to lock
modein: LOCK_X or LOCK_S
op_infoin: string for trx->op_info

◆ row_mysql_pad_col()

void row_mysql_pad_col ( ulint  mbminlen,
byte pad,
ulint  len 
)

Pad a column with spaces.

Parameters
[in]mbminlenMinimum size of a character, in bytes
[out]padPadded buffer
[in]lenNumber of bytes to pad

◆ row_mysql_parallel_select_count_star()

dberr_t row_mysql_parallel_select_count_star ( trx_t trx,
std::vector< dict_index_t * > &  indexes,
size_t  max_threads,
ulint n_rows 
)

Read the total number of records in a consistent view.

Parameters
[in,out]trxCovering transaction.
[in]indexesIndexes to scan.
[in]max_threadsMaximum number of threads to use.
[out]n_rowsNumber of rows seen.
Returns
DB_SUCCESS or error code.

◆ row_mysql_prebuilt_free_blob_heap()

void row_mysql_prebuilt_free_blob_heap ( row_prebuilt_t prebuilt)

Frees the blob heap in prebuilt when no longer needed.

in: prebuilt struct of a ha_innobase:: table handle

◆ row_mysql_read_blob_ref()

const byte * row_mysql_read_blob_ref ( ulint len,
const byte ref,
ulint  col_len 
)

Reads a reference to a BLOB in the MySQL format.

Parameters
[out]lenBLOB length.
[in]refBLOB reference in the MySQL format.
[in]col_lenBLOB reference length (not BLOB length).
Returns
pointer to BLOB data

◆ row_mysql_read_true_varchar()

const byte * row_mysql_read_true_varchar ( ulint len,
const byte field,
ulint  lenlen 
)

Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and returns a pointer to the data.

Returns
pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len in: storage length of len: either 1 or 2 bytes
pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len
Parameters
lenout: variable-length field length
fieldin: field in the MySQL format
lenlenin: storage length of len: either 1 or 2 bytes

◆ row_mysql_store_blob_ref()

void row_mysql_store_blob_ref ( byte dest,
ulint  col_len,
const void *  data,
ulint  len 
)

Stores a reference to a BLOB in the MySQL format.

Parameters
[in]destWhere to store
[in,out]col_lenDest buffer size: determines into how many bytes the blob length is stored, the space for the length may vary from 1 to 4 bytes
[in]dataBlob data; if the value to store is sql null this should be null pointer
[in]lenBlob length; if the value to store is sql null this should be 0; remember also to set the null bit in the mysql record header!

◆ row_mysql_store_col_in_innobase_format()

byte * row_mysql_store_col_in_innobase_format ( dfield_t dfield,
byte buf,
bool  row_format_col,
const byte mysql_data,
ulint  col_len,
ulint  comp 
)

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() in row0sel.cc.

Returns
up to which byte we used buf in the conversion in: nonzero=compact format

The counterpart of this function is row_sel_field_store_in_mysql_format() in row0sel.cc.

Returns
up to which byte we used buf in the conversion
Parameters
dfieldin/out: dfield where dtype information must be already set when this function is called!
bufin/out: buffer for a converted integer value; this must be at least col_len long then! NOTE that dfield may also get a pointer to 'buf', therefore do not discard this as long as dfield is used!
row_format_coltrue 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!
mysql_datain: 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!
col_lenin: 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
compin: nonzero=compact format

◆ row_mysql_store_geometry()

void row_mysql_store_geometry ( byte dest,
ulint  dest_len,
const byte src,
ulint  src_len 
)

Converts InnoDB geometry data format to MySQL data format.

in: geometry length; if the value to store is SQL NULL this should be 0; remember also to set the NULL bit in the MySQL record header!

Converts InnoDB geometry data format to MySQL data format.

Show the meaning of geometry data.

Parameters
destin/out: where to store
dest_lenin: dest buffer size: determines into how many bytes the GEOMETRY length is stored, the space for the length may vary from 1 to 4 bytes
srcin: GEOMETRY data; if the value to store is SQL NULL this should be NULL pointer
src_lenin: GEOMETRY length; if the value to store is SQL NULL this should be 0; remember also to set the NULL bit in the MySQL record header!

◆ row_mysql_store_true_var_len()

byte * row_mysql_store_true_var_len ( byte dest,
ulint  len,
ulint  lenlen 
)

Stores a >= 5.0.3 format true VARCHAR length to dest, in the MySQL row format.

Returns
pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len in: storage length of len: either 1 or 2 bytes
pointer to the data, we skip the 1 or 2 bytes at the start that are used to store the len
Parameters
destin: where to store
lenin: length, must fit in two bytes
lenlenin: storage length of len: either 1 or 2 bytes

◆ row_mysql_unfreeze_data_dictionary()

void row_mysql_unfreeze_data_dictionary ( trx_t trx)

Unlocks the data dictionary shared lock.

in/out: transaction

Parameters
trxin/out: transaction

◆ row_mysql_unlock_data_dictionary()

void row_mysql_unlock_data_dictionary ( trx_t trx)

Unlocks the data dictionary exclusive lock.

in/out: transaction

Parameters
trxin/out: transaction

◆ row_prebuild_sel_graph()

void row_prebuild_sel_graph ( row_prebuilt_t prebuilt)

Builds a dummy query graph used in selects.

in: prebuilt struct in MySQL handle

◆ row_prebuilt_free()

void row_prebuilt_free ( row_prebuilt_t prebuilt,
bool  dict_locked 
)

Free a prebuilt struct for a MySQL table handle.

Parameters
[in,out]prebuiltPrebuilt struct
[in]dict_lockedTrue=data dictionary locked

◆ row_rename_table_for_mysql()

dberr_t row_rename_table_for_mysql ( const char *  old_name,
const char *  new_name,
const dd::Table dd_table,
trx_t trx,
bool  replay 
)

Renames a table for MySQL.

Parameters
[in]old_nameold table name
[in]new_namenew table name
[in]dd_tabledd::Table for new table
[in,out]trxtransaction
[in]replaywhether in replay stage
Returns
error code or DB_SUCCESS

◆ row_scan_index_for_mysql()

dberr_t row_scan_index_for_mysql ( row_prebuilt_t prebuilt,
dict_index_t index,
size_t  n_threads,
bool  check_keys,
ulint n_rows 
)

Scans an index for either COUNT(*) or CHECK TABLE.

If CHECK TABLE; Checks that the index contains entries in an ascending order, unique constraint is not broken, and calculates the number of index entries in the read view of the current transaction.

Parameters
[in,out]prebuiltPrebuilt struct in MySQL handle.
[in,out]indexIndex to scan.
[in]n_threadsNumber of threads to use for the scan
[in]check_keysTrue if called form check table.
[out]n_rowsNumber of entries seen in the consistent read.
Returns
DB_SUCCESS or other error

◆ row_table_got_default_clust_index()

bool row_table_got_default_clust_index ( const dict_table_t table)

Checks if a table is such that we automatically created a clustered index on it (on row id).

Returns
true if the clustered index was generated automatically in: table
true if the clustered index was generated automatically
Parameters
tablein: table

◆ row_table_load_foreign_constraints()

dberr_t row_table_load_foreign_constraints ( trx_t trx,
const char *  name,
const dd::Table dd_table 
)

Loads foreign key constraints for the table being created.

This function should be called after the indexes for a table have been created. Each foreign key constraint must be accompanied with indexes in both participating tables. The indexes are allowed to contain more fields than mentioned in the constraint.

Parameters
[in]trxtransaction
[in]nametable full name in normalized form
[in]dd_tableMySQL dd::Table for the table
Returns
error code or DB_SUCCESS

◆ row_update_cascade_for_mysql()

dberr_t row_update_cascade_for_mysql ( que_thr_t thr,
upd_node_t node,
dict_table_t table 
)

Does a cascaded delete or set null in a foreign key operation.

Returns
error code or DB_SUCCESS
Parameters
thrin: query thread
nodein: update node used in the cascade or set null operation
tablein: table where we do the operation

◆ row_update_for_mysql()

dberr_t row_update_for_mysql ( const byte mysql_rec,
row_prebuilt_t prebuilt 
)

Does an update or delete of a row for MySQL.

Parameters
[in]mysql_recrow in the MySQL format
[in,out]prebuiltprebuilt struct in MySQL handle
Returns
error code or DB_SUCCESS

◆ row_update_prebuilt_trx()

void row_update_prebuilt_trx ( row_prebuilt_t prebuilt,
trx_t trx 
)

Updates the transaction pointers in query graphs stored in the prebuilt struct.

Parameters
[in,out]prebuiltPrebuilt struct in MySQL handle.
[in,out]trxTransaction handle.

◆ row_wait_for_background_drop_list_empty()

void row_wait_for_background_drop_list_empty ( )

Wait for the background drop list to become empty.

Variable Documentation

◆ MYSQL_FETCH_CACHE_SIZE

constexpr uint32_t MYSQL_FETCH_CACHE_SIZE = 8
constexpr

◆ MYSQL_FETCH_CACHE_THRESHOLD

constexpr uint32_t MYSQL_FETCH_CACHE_THRESHOLD = 4
constexpr

◆ ROW_MYSQL_DUMMY_TEMPLATE

constexpr uint32_t ROW_MYSQL_DUMMY_TEMPLATE = 3
constexpr

dummy template used in row_scan_and_check_index

◆ ROW_MYSQL_NO_TEMPLATE

constexpr uint32_t ROW_MYSQL_NO_TEMPLATE = 2
constexpr

◆ ROW_MYSQL_REC_FIELDS

constexpr uint32_t ROW_MYSQL_REC_FIELDS = 1
constexpr

◆ ROW_MYSQL_WHOLE_ROW

constexpr uint32_t ROW_MYSQL_WHOLE_ROW = 0
constexpr

◆ ROW_PREBUILT_ALLOCATED

constexpr uint32_t ROW_PREBUILT_ALLOCATED = 78540783
constexpr

◆ ROW_PREBUILT_FETCH_MAGIC_N

constexpr uint32_t ROW_PREBUILT_FETCH_MAGIC_N = 465765687
constexpr

◆ ROW_PREBUILT_FREED

constexpr uint32_t ROW_PREBUILT_FREED = 26423527
constexpr

◆ ROW_READ_DID_SEMI_CONSISTENT

constexpr uint32_t ROW_READ_DID_SEMI_CONSISTENT = 2
constexpr

◆ ROW_READ_TRY_SEMI_CONSISTENT

constexpr uint32_t ROW_READ_TRY_SEMI_CONSISTENT = 1
constexpr

◆ ROW_READ_WITH_LOCKS

constexpr uint32_t ROW_READ_WITH_LOCKS = 0
constexpr

◆ ROW_RETRIEVE_ALL_COLS

constexpr uint32_t ROW_RETRIEVE_ALL_COLS = 2
constexpr

◆ ROW_RETRIEVE_PRIMARY_KEY

constexpr uint32_t ROW_RETRIEVE_PRIMARY_KEY = 1
constexpr

◆ row_rollback_on_timeout

bool row_rollback_on_timeout
extern

Provide optional 4.x backwards compatibility for 5.0 and above.