MySQL 8.4.3
Source Code Documentation
thr_lock.h File Reference
#include <sys/types.h>
#include "my_inttypes.h"
#include "my_list.h"
#include "my_thread_local.h"
#include "mysql/psi/mysql_cond.h"
#include "mysql/psi/mysql_mutex.h"

Go to the source code of this file.

Classes

struct  Lock_descriptor
 
struct  THR_LOCK_INFO
 
struct  THR_LOCK_DATA
 
struct  st_lock_list
 
struct  THR_LOCK
 

Enumerations

enum  thr_lock_type {
  TL_IGNORE = -1 , TL_UNLOCK , TL_READ_DEFAULT , TL_READ ,
  TL_READ_WITH_SHARED_LOCKS , TL_READ_HIGH_PRIORITY , TL_READ_NO_INSERT , TL_WRITE_ALLOW_WRITE ,
  TL_WRITE_CONCURRENT_DEFAULT , TL_WRITE_CONCURRENT_INSERT , TL_WRITE_DEFAULT , TL_WRITE_LOW_PRIORITY ,
  TL_WRITE , TL_WRITE_ONLY , TL_IGNORE = -1 , TL_UNLOCK ,
  TL_READ_DEFAULT , TL_READ , TL_READ_WITH_SHARED_LOCKS , TL_READ_HIGH_PRIORITY ,
  TL_READ_NO_INSERT , TL_WRITE_ALLOW_WRITE , TL_WRITE_CONCURRENT_DEFAULT , TL_WRITE_CONCURRENT_INSERT ,
  TL_WRITE_DEFAULT , TL_WRITE_LOW_PRIORITY , TL_WRITE , TL_WRITE_ONLY
}
 
enum  thr_locked_row_action { THR_DEFAULT , THR_WAIT , THR_NOWAIT , THR_SKIP }
 
enum  enum_thr_lock_result { THR_LOCK_SUCCESS = 0 , THR_LOCK_ABORTED = 1 , THR_LOCK_WAIT_TIMEOUT = 2 , THR_LOCK_DEADLOCK = 3 }
 

Functions

void thr_lock_info_init (THR_LOCK_INFO *info, my_thread_id thread_id, mysql_cond_t *suspend)
 
void thr_lock_init (THR_LOCK *lock)
 
void thr_lock_delete (THR_LOCK *lock)
 
void thr_lock_data_init (THR_LOCK *lock, THR_LOCK_DATA *data, void *status_param)
 
enum enum_thr_lock_result thr_lock (THR_LOCK_DATA *data, THR_LOCK_INFO *owner, enum thr_lock_type lock_type, ulong lock_wait_timeout)
 
void thr_unlock (THR_LOCK_DATA *data)
 
enum enum_thr_lock_result thr_multi_lock (THR_LOCK_DATA **data, uint count, THR_LOCK_INFO *owner, ulong lock_wait_timeout)
 
void thr_multi_unlock (THR_LOCK_DATA **data, uint count)
 
void thr_lock_merge_status (THR_LOCK_DATA **data, uint count)
 Ensure that all locks for a given table have the same status_param. More...
 
void thr_abort_locks_for_thread (THR_LOCK *lock, my_thread_id thread)
 
void thr_print_locks (void)
 
void thr_set_lock_wait_callback (void(*before_wait)(void), void(*after_wait)(void))
 

Variables

mysql_mutex_t THR_LOCK_lock
 
ulong locks_immediate
 
ulong locks_waited
 
ulong max_write_lock_count
 
enum thr_lock_type thr_upgraded_concurrent_insert_lock
 
LISTthr_lock_thread_list
 

Enumeration Type Documentation

◆ enum_thr_lock_result

Enumerator
THR_LOCK_SUCCESS 
THR_LOCK_ABORTED 
THR_LOCK_WAIT_TIMEOUT 
THR_LOCK_DEADLOCK 

◆ thr_lock_type

Enumerator
TL_IGNORE 
TL_UNLOCK 
TL_READ_DEFAULT 
TL_READ 
TL_READ_WITH_SHARED_LOCKS 
TL_READ_HIGH_PRIORITY 
TL_READ_NO_INSERT 
TL_WRITE_ALLOW_WRITE 
TL_WRITE_CONCURRENT_DEFAULT 
TL_WRITE_CONCURRENT_INSERT 
TL_WRITE_DEFAULT 
TL_WRITE_LOW_PRIORITY 
TL_WRITE 
TL_WRITE_ONLY 
TL_IGNORE 
TL_UNLOCK 
TL_READ_DEFAULT 
TL_READ 
TL_READ_WITH_SHARED_LOCKS 
TL_READ_HIGH_PRIORITY 
TL_READ_NO_INSERT 
TL_WRITE_ALLOW_WRITE 
TL_WRITE_CONCURRENT_DEFAULT 
TL_WRITE_CONCURRENT_INSERT 
TL_WRITE_DEFAULT 
TL_WRITE_LOW_PRIORITY 
TL_WRITE 
TL_WRITE_ONLY 

◆ thr_locked_row_action

Enumerator
THR_DEFAULT 
THR_WAIT 
THR_NOWAIT 
THR_SKIP 

Function Documentation

◆ thr_abort_locks_for_thread()

void thr_abort_locks_for_thread ( THR_LOCK lock,
my_thread_id  thread 
)

◆ thr_lock()

enum enum_thr_lock_result thr_lock ( THR_LOCK_DATA data,
THR_LOCK_INFO owner,
enum thr_lock_type  lock_type,
ulong  lock_wait_timeout 
)

◆ thr_lock_data_init()

void thr_lock_data_init ( THR_LOCK lock,
THR_LOCK_DATA data,
void *  status_param 
)

◆ thr_lock_delete()

void thr_lock_delete ( THR_LOCK lock)

◆ thr_lock_info_init()

void thr_lock_info_init ( THR_LOCK_INFO info,
my_thread_id  thread_id,
mysql_cond_t suspend 
)

◆ thr_lock_init()

void thr_lock_init ( THR_LOCK lock)

◆ thr_lock_merge_status()

void thr_lock_merge_status ( THR_LOCK_DATA **  data,
uint  count 
)

Ensure that all locks for a given table have the same status_param.

This is a MyISAM and possibly Maria specific crutch. MyISAM engine stores data file length, record count and other table properties in status_param member of handler. When a table is locked, connection-local copy is made from a global copy (myisam_share) by mi_get_status(). When a table is unlocked, the changed status is transferred back to the global share by mi_update_status().

One thing MyISAM doesn't do is to ensure that when the same table is opened twice in a connection all instances share the same status_param. This is necessary, however: for one, to keep all instances of a connection "on the same page" with regard to the current state of the table. For other, unless this is done, myisam_share will always get updated from the last unlocked instance (in mi_update_status()), and when this instance was not the one that was used to update data, records may be lost.

For each table, this function looks up the last lock_data in the list of acquired locks, and makes sure that all other instances share status_param with it.

◆ thr_multi_lock()

enum enum_thr_lock_result thr_multi_lock ( THR_LOCK_DATA **  data,
uint  count,
THR_LOCK_INFO owner,
ulong  lock_wait_timeout 
)

◆ thr_multi_unlock()

void thr_multi_unlock ( THR_LOCK_DATA **  data,
uint  count 
)

◆ thr_print_locks()

void thr_print_locks ( void  )

◆ thr_set_lock_wait_callback()

void thr_set_lock_wait_callback ( void(*)(void)  before_wait,
void(*)(void)  after_wait 
)

◆ thr_unlock()

void thr_unlock ( THR_LOCK_DATA data)

Variable Documentation

◆ locks_immediate

ulong locks_immediate
extern

◆ locks_waited

ulong locks_waited

◆ max_write_lock_count

ulong max_write_lock_count
extern

◆ THR_LOCK_lock

mysql_mutex_t THR_LOCK_lock
extern

◆ thr_lock_thread_list

LIST* thr_lock_thread_list
extern

◆ thr_upgraded_concurrent_insert_lock

enum thr_lock_type thr_upgraded_concurrent_insert_lock
extern