24
24
#include <mysys/my_pthread.h>
25
25
#include <mysys/my_list.h>
26
#include <mysys/definitions.h>
28
27
struct st_thr_lock;
29
28
extern uint32_t locks_immediate,locks_waited ;
30
29
extern pthread_mutex_t THR_LOCK_lock;
31
enum thr_lock_type { TL_IGNORE=-1,
32
TL_UNLOCK, /* UNLOCK ANY LOCK */
33
TL_READ, /* Read lock */
34
TL_READ_WITH_SHARED_LOCKS,
35
/* High prior. than TL_WRITE. Allow concurrent insert */
36
TL_READ_HIGH_PRIORITY,
37
/* READ, Don't allow concurrent insert */
40
Write lock, but allow other threads to read / write.
41
Used by BDB tables in MySQL to mark that someone is
42
reading/writing to the table.
46
Write lock, but allow other threads to read.
47
Used by ALTER TABLE in MySQL to allow readers
48
to use the table until ALTER TABLE is finished.
52
WRITE lock used by concurrent insert. Will allow
53
READ, if one could use concurrent insert on table.
55
TL_WRITE_CONCURRENT_INSERT,
56
/* Write used by INSERT DELAYED. Allows READ locks */
59
parser only! Late bound low_priority flag.
60
At open_tables() becomes thd->update_lock_default.
63
/* WRITE lock that has lower priority than TL_READ */
64
TL_WRITE_LOW_PRIORITY,
65
/* Normal WRITE lock */
67
/* Abort new lock request with an error */
70
enum enum_thr_lock_result { THR_LOCK_SUCCESS= 0, THR_LOCK_ABORTED= 1,
71
THR_LOCK_WAIT_TIMEOUT= 2, THR_LOCK_DEADLOCK= 3 };
33
74
extern ulong max_write_lock_count;
34
75
extern ulong table_lock_wait_timeout;
81
122
struct st_lock_list write;
82
123
/* write_lock_count is incremented for write locks and reset on read locks */
83
124
uint32_t write_lock_count;
84
uint32_t read_no_write_count;
125
uint read_no_write_count;
85
126
void (*get_status)(void*, int); /* When one gets a lock */
86
127
void (*copy_status)(void*,void*);
87
128
void (*update_status)(void*); /* Before release of write */
104
145
enum thr_lock_type lock_type);
105
146
void thr_unlock(THR_LOCK_DATA *data);
106
147
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data,
107
uint32_t count, THR_LOCK_OWNER *owner);
108
void thr_multi_unlock(THR_LOCK_DATA **data,uint32_t count);
148
uint count, THR_LOCK_OWNER *owner);
149
void thr_multi_unlock(THR_LOCK_DATA **data,uint count);
109
150
void thr_abort_locks(THR_LOCK *lock, bool upgrade_lock);
110
151
bool thr_abort_locks_for_thread(THR_LOCK *lock, my_thread_id thread);
111
152
bool thr_upgrade_write_delay_lock(THR_LOCK_DATA *data);