Skip to content

Commit 09d4c1d

Browse files
Davi ArnautDavi Arnaut
Davi Arnaut
authored and
Davi Arnaut
committed
Bug#44164: TL_WRITE has no description in lock_descriptions[]
The problem was that new lock types were being added without a corresponding description. Since the lock types (enum values) are used as indices to the description array, the descriptions could be shifted depending on the lock type. The solution is to ensure that every lock type has a correspondent description.
1 parent c0db307 commit 09d4c1d

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

include/thr_lock.h

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ extern "C" {
2727
struct st_thr_lock;
2828
extern ulong locks_immediate,locks_waited ;
2929

30+
/*
31+
Important: if a new lock type is added, a matching lock description
32+
must be added to sql_test.cc's lock_descriptions array.
33+
*/
3034
enum thr_lock_type { TL_IGNORE=-1,
3135
TL_UNLOCK, /* UNLOCK ANY LOCK */
3236
/*

sql/sql_test.cc

+16-12
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,20 @@
3333

3434
static const char *lock_descriptions[] =
3535
{
36-
"No lock",
37-
"Low priority read lock",
38-
"Shared Read lock",
39-
"High priority read lock",
40-
"Read lock without concurrent inserts",
41-
"Write lock that allows other writers",
42-
"Write lock, but allow reading",
43-
"Concurrent insert lock",
44-
"Lock Used by delayed insert",
45-
"Low priority write lock",
46-
"High priority write lock",
47-
"Highest priority write lock"
36+
/* TL_UNLOCK */ "No lock",
37+
/* TL_READ_DEFAULT */ NULL,
38+
/* TL_READ */ "Low priority read lock",
39+
/* TL_READ_WITH_SHARED_LOCKS */ "Shared read lock",
40+
/* TL_READ_HIGH_PRIORITY */ "High priority read lock",
41+
/* TL_READ_NO_INSERT */ "Read lock without concurrent inserts",
42+
/* TL_WRITE_ALLOW_WRITE */ "Write lock that allows other writers",
43+
/* TL_WRITE_ALLOW_READ */ "Write lock, but allow reading",
44+
/* TL_WRITE_CONCURRENT_INSERT */ "Concurrent insert lock",
45+
/* TL_WRITE_DELAYED */ "Lock used by delayed insert",
46+
/* TL_WRITE_DEFAULT */ NULL,
47+
/* TL_WRITE_LOW_PRIORITY */ "Low priority write lock",
48+
/* TL_WRITE */ "High priority write lock",
49+
/* TL_WRITE_ONLY */ "Highest priority write lock"
4850
};
4951

5052

@@ -75,6 +77,8 @@ void print_cached_tables(void)
7577
uint idx,count,unused;
7678
TABLE *start_link,*lnk;
7779

80+
compile_time_assert(TL_WRITE_ONLY+1 == array_elements(lock_descriptions));
81+
7882
/* purecov: begin tested */
7983
VOID(pthread_mutex_lock(&LOCK_open));
8084
puts("DB Table Version Thread Open Lock");

0 commit comments

Comments
 (0)