MySQL 9.1.0
Source Code Documentation
Table Access services
Collaboration diagram for Table Access services:

Classes

struct  TA_table_field_def
 Expected field definition. More...
 
struct  TA_index_field_def
 Expected index definition. More...
 
struct  s_mysql_table_access_factory_v1
 Table access service, factory. More...
 
struct  s_mysql_table_access_v1
 Table access service, table access. More...
 
struct  s_mysql_table_access_index_v1
 Table access service, index scan. More...
 
struct  s_mysql_table_access_scan_v1
 Table access service, table scan. More...
 
struct  s_mysql_table_access_update_v1
 Table access service, update. More...
 
struct  s_mysql_table_access_binlog
 Table access service, control binlogging. More...
 
struct  s_mysql_field_access_nullability_v1
 Table access service, all columns. More...
 
struct  s_mysql_field_integer_access_v1
 Table access service, integer columns. More...
 
struct  s_mysql_field_varchar_access_v1
 Table access service, varchar columns. More...
 
struct  s_mysql_field_any_access_v1
 Table access service, any columns. More...
 

Macros

#define TA_ERROR_GRL   1
 
#define TA_ERROR_READONLY   2
 
#define TA_ERROR_OPEN   3
 

Typedefs

typedef struct Table_access_imp * Table_access
 Table_access. More...
 
typedef struct TA_table_imp * TA_table
 An opened table. More...
 
typedef struct TA_key_imp * TA_key
 An index key. More...
 
typedef Table_access(* create_table_access_v1_t) (MYSQL_THD thd, size_t count)
 Create a table access object. More...
 
typedef void(* destroy_table_access_v1_t) (Table_access ta)
 Destroy a table access object. More...
 
typedef size_t(* add_table_v1_t) (Table_access ta, const char *schema_name, size_t schema_name_length, const char *table_name, size_t table_name_length, TA_lock_type lock_type_arg)
 Add a table to a table access session. More...
 
typedef int(* begin_v1_t) (Table_access ta)
 Start a table access transaction. More...
 
typedef int(* commit_v1_t) (Table_access ta)
 Commit changes. More...
 
typedef int(* rollback_v1_t) (Table_access ta)
 Rollback changes. More...
 
typedef TA_table(* get_table_v1_t) (Table_access ta, size_t ticket)
 Get an opened table. More...
 
typedef int(* check_table_fields_v1_t) (Table_access ta, TA_table table, const TA_table_field_def *fields, size_t fields_count)
 Check the actual table fields against expected fields. More...
 
typedef int(* index_init_v1_t) (Table_access ta, TA_table table, const char *index_name, size_t index_name_length, const TA_index_field_def *fields, size_t fields_count, TA_key *key)
 Open a table index. More...
 
typedef int(* index_read_map_v1_t) (Table_access ta, TA_table table, size_t num_parts, TA_key key)
 Position a table index at a search key. More...
 
typedef int(* index_first_v1_t) (Table_access ta, TA_table table, TA_key key)
 Position on index at the beginning. More...
 
typedef int(* index_next_v1_t) (Table_access ta, TA_table table, TA_key key)
 Advance to the next record in the index. More...
 
typedef int(* index_next_same_v1_t) (Table_access ta, TA_table table, TA_key key)
 Advance to the next record that matches the current search key. More...
 
typedef int(* index_end_v1_t) (Table_access ta, TA_table table, TA_key key)
 Close an index. More...
 
typedef int(* rnd_init_v1_t) (Table_access ta, TA_table table)
 Start a full table scan. More...
 
typedef int(* rnd_next_v1_t) (Table_access ta, TA_table table)
 Advance to the next record in a table scan. More...
 
typedef int(* rnd_end_v1_t) (Table_access ta, TA_table table)
 End a full table scan. More...
 
typedef int(* write_row_v1_t) (Table_access ta, TA_table table)
 Insert a new row in the table. More...
 
typedef int(* update_row_v1_t) (Table_access ta, TA_table table)
 Update the current row. More...
 
typedef int(* delete_row_v1_t) (Table_access ta, TA_table table)
 Delete the current row. More...
 
typedef void(* set_field_null_v1_t) (Table_access ta, TA_table table, size_t index)
 Set a column to NULL. More...
 
typedef bool(* is_field_null_v1_t) (Table_access ta, TA_table table, size_t index)
 Is a column NULL. More...
 
typedef bool(* maybe_field_null_v1_t) (Table_access ta, TA_table table, size_t index)
 Can a column be NULL. More...
 
typedef int(* set_field_integer_value_v1_t) (Table_access ta, TA_table table, size_t index, long long v)
 Write an INTEGER column value. More...
 
typedef int(* get_field_integer_value_v1_t) (Table_access ta, TA_table table, size_t index, long long *v)
 Read an INTEGER column value. More...
 
typedef int(* set_field_varchar_value_v1_t) (Table_access ta, TA_table table, size_t index, my_h_string v)
 Write a VARCHAR column value. More...
 
typedef int(* get_field_varchar_value_v1_t) (Table_access ta, TA_table table, size_t index, my_h_string v)
 Read a VARCHAR column value. More...
 
typedef int(* set_field_any_value_v1_t) (Table_access ta, TA_table table, size_t index, my_h_string v)
 Write any column value. More...
 
typedef int(* get_field_any_value_v1_t) (Table_access ta, TA_table table, size_t index, my_h_string v)
 Read any column value. More...
 
typedef void(* table_access_binlog_set_t) (Table_access ta, bool is_binlogging)
 Turns on or off the binlogging flag for the current thread. More...
 
typedef bool(* table_access_binlog_get_t) (Table_access ta)
 Gets the binlogging flag for the current thread. More...
 
typedef struct s_mysql_table_access_factory_v1 mysql_service_table_access_factory_v1_t
 Table access service, factory. More...
 
typedef struct s_mysql_table_access_v1 mysql_service_table_access_v1_t
 Table access service, table access. More...
 
typedef struct s_mysql_table_access_index_v1 mysql_service_table_access_index_v1_t
 Table access service, index scan. More...
 
typedef struct s_mysql_table_access_scan_v1 mysql_service_table_access_scan_v1_t
 Table access service, table scan. More...
 
typedef struct s_mysql_table_access_update_v1 mysql_service_table_access_update_v1_t
 Table access service, update. More...
 
typedef struct s_mysql_table_access_binlog mysql_service_table_access_binlog_t
 Table access service, control binlogging. More...
 
typedef struct s_mysql_field_access_nullability_v1 mysql_service_field_access_nullability_v1_t
 Table access service, all columns. More...
 
typedef struct s_mysql_field_integer_access_v1 mysql_service_field_integer_access_v1_t
 Table access service, integer columns. More...
 
typedef struct s_mysql_field_varchar_access_v1 mysql_service_field_varchar_access_v1_t
 Table access service, varchar columns. More...
 
typedef struct s_mysql_field_any_access_v1 mysql_service_field_any_access_v1_t
 Table access service, any columns. More...
 

Enumerations

enum  TA_lock_type { TA_READ , TA_WRITE }
 Table lock type. More...
 
enum  TA_field_type {
  TA_TYPE_UNKNOWN = 0 , TA_TYPE_INTEGER = 1 , TA_TYPE_VARCHAR = 2 , TA_TYPE_JSON = 3 ,
  TA_TYPE_ENUM = 4
}
 Types of columns supported by the table access service. More...
 

Detailed Description

Macro Definition Documentation

◆ TA_ERROR_GRL

#define TA_ERROR_GRL   1

◆ TA_ERROR_OPEN

#define TA_ERROR_OPEN   3

◆ TA_ERROR_READONLY

#define TA_ERROR_READONLY   2

Typedef Documentation

◆ add_table_v1_t

typedef size_t(* add_table_v1_t) (Table_access ta, const char *schema_name, size_t schema_name_length, const char *table_name, size_t table_name_length, TA_lock_type lock_type_arg)

Add a table to a table access session.

This method adds a table to a table access session. It returns a ticket, to use with get_table_v1_t.

Parameters
taTable access session
schema_nameSchema name raw buffer, in UTF8MB4.
schema_name_lengthLength, in bytes, of schema_name
table_nameTable name raw buffer, in UTF8MB4.
table_name_lengthLength, in bytes, of table_name
lock_type_argLock type to use (read or write)
Returns
ticket number for the table added

◆ begin_v1_t

typedef int(* begin_v1_t) (Table_access ta)

Start a table access transaction.

Open all tables from the table access session, and lock them.

Locking all the tables at once is necessary to prevent deadlocks on table metadata between different sessions. The caller should not own the global read lock when opening tables, as this would also create deadlocks.

Returns
An error status
Return values
0success
TA_ERROR_GRLGlobal read lock held by the caller
TA_ERROR_OPENFailed to open and lock tables.

◆ check_table_fields_v1_t

typedef int(* check_table_fields_v1_t) (Table_access ta, TA_table table, const TA_table_field_def *fields, size_t fields_count)

Check the actual table fields against expected fields.

Return values
0success

◆ commit_v1_t

typedef int(* commit_v1_t) (Table_access ta)

Commit changes.

◆ create_table_access_v1_t

typedef Table_access(* create_table_access_v1_t) (MYSQL_THD thd, size_t count)

Create a table access object.

See also
destroy_table_access_v1_t
Parameters
thdThe current session. Pass a null ptr if running from a non-MySQLd thread
countThe maximum number of tables to access.
Note
The table access service will create a child session to perform table read and writes. The following properties from the current session are used to initialize the child session:
  • log_bin
  • transaction_isolation
  • skip_readonly_check
Warning
The table access service will set the current THD thread attribute to the temporary child THD it creates. The current THD will be reset back by destroy_table_access_v1_t. This means that the whole table access routine should happen as fast as possible and without thread switching until its completion and disposal of the thread access attribute. The Table_access handle should not be cached and reused.

◆ delete_row_v1_t

typedef int(* delete_row_v1_t) (Table_access ta, TA_table table)

Delete the current row.

◆ destroy_table_access_v1_t

typedef void(* destroy_table_access_v1_t) (Table_access ta)

Destroy a table access object.

See also
create_table_access_v1_t

◆ get_field_any_value_v1_t

typedef int(* get_field_any_value_v1_t) (Table_access ta, TA_table table, size_t index, my_h_string v)

Read any column value.

This is a generic interface. The column value is converted to a string, expressed in UTF8MB4_bin.

◆ get_field_integer_value_v1_t

typedef int(* get_field_integer_value_v1_t) (Table_access ta, TA_table table, size_t index, long long *v)

Read an INTEGER column value.

◆ get_field_varchar_value_v1_t

typedef int(* get_field_varchar_value_v1_t) (Table_access ta, TA_table table, size_t index, my_h_string v)

Read a VARCHAR column value.

◆ get_table_v1_t

typedef TA_table(* get_table_v1_t) (Table_access ta, size_t ticket)

Get an opened table.

Once tables are opened and locked, this method returns the opened table that correspond to the ticket returned by add tables.

Returns
An opened table.

◆ index_end_v1_t

typedef int(* index_end_v1_t) (Table_access ta, TA_table table, TA_key key)

Close an index.

◆ index_first_v1_t

typedef int(* index_first_v1_t) (Table_access ta, TA_table table, TA_key key)

Position on index at the beginning.

◆ index_init_v1_t

typedef int(* index_init_v1_t) (Table_access ta, TA_table table, const char *index_name, size_t index_name_length, const TA_index_field_def *fields, size_t fields_count, TA_key *key)

Open a table index.

An index is identified by name. The caller lists the columns expected in the index. If the index DDL matches the expected columns and count, the index is opened. Otherwise, an error is returned, and the index is not opened.

Note
The list of columns must contain the ACTUAL columns in the index rather than USER defined (used on SQL level). The actual list depends on engine and current implementation. E.g. InnoDB may add columns to the user defined set.
Parameters
taTable access
tableOpened table
index_nameIndex name, in UTF8MB4, must match the table DDL.
index_name_lengthLength of index_name, in bytes.
fieldsExpected fields for the index
fields_countExpected number of fields for the index
[out]keyOpened index.
Return values
0Success
See also
index_end_v1_t

◆ index_next_same_v1_t

typedef int(* index_next_same_v1_t) (Table_access ta, TA_table table, TA_key key)

Advance to the next record that matches the current search key.

◆ index_next_v1_t

typedef int(* index_next_v1_t) (Table_access ta, TA_table table, TA_key key)

Advance to the next record in the index.

◆ index_read_map_v1_t

typedef int(* index_read_map_v1_t) (Table_access ta, TA_table table, size_t num_parts, TA_key key)

Position a table index at a search key.

The search key is not passed explicitly in this call. The search key is set by populating columns in the table current record, before invoking this method.

Parameters
taTable access
tableOpened table
num_partsNumber of key parts populated in the current record.
keyOpened index

◆ is_field_null_v1_t

typedef bool(* is_field_null_v1_t) (Table_access ta, TA_table table, size_t index)

Is a column NULL.

◆ maybe_field_null_v1_t

typedef bool(* maybe_field_null_v1_t) (Table_access ta, TA_table table, size_t index)

Can a column be NULL.

◆ mysql_service_field_access_nullability_v1_t

Table access service, all columns.

Version 1. Status: active

◆ mysql_service_field_any_access_v1_t

Table access service, any columns.

Version 1. Status: active

◆ mysql_service_field_integer_access_v1_t

Table access service, integer columns.

Version 1. Status: active

◆ mysql_service_field_varchar_access_v1_t

Table access service, varchar columns.

Version 1. Status: active

◆ mysql_service_table_access_binlog_t

Table access service, control binlogging.

◆ mysql_service_table_access_factory_v1_t

Table access service, factory.

Version 1. Status: active

◆ mysql_service_table_access_index_v1_t

Table access service, index scan.

Version 1. Status: active

◆ mysql_service_table_access_scan_v1_t

Table access service, table scan.

Version 1. Status: active

◆ mysql_service_table_access_update_v1_t

Table access service, update.

Version 1. Status: active

◆ mysql_service_table_access_v1_t

Table access service, table access.

Version 1. Status: active

◆ rnd_end_v1_t

typedef int(* rnd_end_v1_t) (Table_access ta, TA_table table)

End a full table scan.

◆ rnd_init_v1_t

typedef int(* rnd_init_v1_t) (Table_access ta, TA_table table)

Start a full table scan.

◆ rnd_next_v1_t

typedef int(* rnd_next_v1_t) (Table_access ta, TA_table table)

Advance to the next record in a table scan.

◆ rollback_v1_t

typedef int(* rollback_v1_t) (Table_access ta)

Rollback changes.

◆ set_field_any_value_v1_t

typedef int(* set_field_any_value_v1_t) (Table_access ta, TA_table table, size_t index, my_h_string v)

Write any column value.

This is a generic interface. The column value must be expressed in UTF8MB4_bin, and is converted to the column type.

◆ set_field_integer_value_v1_t

typedef int(* set_field_integer_value_v1_t) (Table_access ta, TA_table table, size_t index, long long v)

Write an INTEGER column value.

◆ set_field_null_v1_t

typedef void(* set_field_null_v1_t) (Table_access ta, TA_table table, size_t index)

Set a column to NULL.

◆ set_field_varchar_value_v1_t

typedef int(* set_field_varchar_value_v1_t) (Table_access ta, TA_table table, size_t index, my_h_string v)

Write a VARCHAR column value.

◆ TA_key

typedef struct TA_key_imp* TA_key

An index key.

◆ TA_table

typedef struct TA_table_imp* TA_table

An opened table.

◆ Table_access

typedef struct Table_access_imp* Table_access

Table_access.

A table access session.

◆ table_access_binlog_get_t

typedef bool(* table_access_binlog_get_t) (Table_access ta)

Gets the binlogging flag for the current thread.

◆ table_access_binlog_set_t

typedef void(* table_access_binlog_set_t) (Table_access ta, bool is_binlogging)

Turns on or off the binlogging flag for the current thread.

◆ update_row_v1_t

typedef int(* update_row_v1_t) (Table_access ta, TA_table table)

Update the current row.

◆ write_row_v1_t

typedef int(* write_row_v1_t) (Table_access ta, TA_table table)

Insert a new row in the table.

Enumeration Type Documentation

◆ TA_field_type

Types of columns supported by the table access service.

Enumerator
TA_TYPE_UNKNOWN 
TA_TYPE_INTEGER 
TA_TYPE_VARCHAR 
TA_TYPE_JSON 
TA_TYPE_ENUM 

◆ TA_lock_type

Table lock type.

Enumerator
TA_READ 

Table is opened for read.

TA_WRITE 

Table is opened for write.