1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

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.

include/thr_lock.h:
  Add warning.
sql/sql_test.cc:
  Update lock descriptions.
This commit is contained in:
Davi Arnaut
2009-04-14 14:05:32 +02:00
parent f739349994
commit b27261a6f7
2 changed files with 20 additions and 12 deletions

View File

@ -27,6 +27,10 @@ extern "C" {
struct st_thr_lock; struct st_thr_lock;
extern ulong locks_immediate,locks_waited ; extern ulong locks_immediate,locks_waited ;
/*
Important: if a new lock type is added, a matching lock description
must be added to sql_test.cc's lock_descriptions array.
*/
enum thr_lock_type { TL_IGNORE=-1, enum thr_lock_type { TL_IGNORE=-1,
TL_UNLOCK, /* UNLOCK ANY LOCK */ TL_UNLOCK, /* UNLOCK ANY LOCK */
/* /*

View File

@ -33,18 +33,20 @@
static const char *lock_descriptions[] = static const char *lock_descriptions[] =
{ {
"No lock", /* TL_UNLOCK */ "No lock",
"Low priority read lock", /* TL_READ_DEFAULT */ NULL,
"Shared Read lock", /* TL_READ */ "Low priority read lock",
"High priority read lock", /* TL_READ_WITH_SHARED_LOCKS */ "Shared read lock",
"Read lock without concurrent inserts", /* TL_READ_HIGH_PRIORITY */ "High priority read lock",
"Write lock that allows other writers", /* TL_READ_NO_INSERT */ "Read lock without concurrent inserts",
"Write lock, but allow reading", /* TL_WRITE_ALLOW_WRITE */ "Write lock that allows other writers",
"Concurrent insert lock", /* TL_WRITE_ALLOW_READ */ "Write lock, but allow reading",
"Lock Used by delayed insert", /* TL_WRITE_CONCURRENT_INSERT */ "Concurrent insert lock",
"Low priority write lock", /* TL_WRITE_DELAYED */ "Lock used by delayed insert",
"High priority write lock", /* TL_WRITE_DEFAULT */ NULL,
"Highest priority write lock" /* TL_WRITE_LOW_PRIORITY */ "Low priority write lock",
/* TL_WRITE */ "High priority write lock",
/* TL_WRITE_ONLY */ "Highest priority write lock"
}; };
@ -75,6 +77,8 @@ void print_cached_tables(void)
uint idx,count,unused; uint idx,count,unused;
TABLE *start_link,*lnk; TABLE *start_link,*lnk;
compile_time_assert(TL_WRITE_ONLY+1 == array_elements(lock_descriptions));
/* purecov: begin tested */ /* purecov: begin tested */
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
puts("DB Table Version Thread Open Lock"); puts("DB Table Version Thread Open Lock");