summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2021-02-02 00:05:41 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2021-02-02 00:19:52 +0100
commitb5dab19efaf9dfcc61ef91db19f38e9f8c8d8382 (patch)
tree174cc73f042b3dfa4bb9bab0fa457910244e1425
parente2c571ad842b7ac699b2a6f3f95a4012bb7089f7 (diff)
downloadmariadb-git-b5dab19efaf9dfcc61ef91db19f38e9f8c8d8382.tar.gz
MDEV-24757 : fix potential null pointer dereference in I_S.thread_pool_queues
With the fix, new connection without THDs will now show NULL in thread_pool_queues.CONNECTION_ID.
-rw-r--r--mysql-test/main/thread_pool_info.result2
-rw-r--r--sql/thread_pool_info.cc5
2 files changed, 4 insertions, 3 deletions
diff --git a/mysql-test/main/thread_pool_info.result b/mysql-test/main/thread_pool_info.result
index 5eeb0ca1d6a..27717aa298a 100644
--- a/mysql-test/main/thread_pool_info.result
+++ b/mysql-test/main/thread_pool_info.result
@@ -31,7 +31,7 @@ Field Type Null Key Default Extra
GROUP_ID int(6) NO 0
POSITION int(6) NO 0
PRIORITY int(1) NO 0
-CONNECTION_ID bigint(19) unsigned NO 0
+CONNECTION_ID bigint(19) unsigned YES NULL
QUEUEING_TIME_MICROSECONDS bigint(19) NO 0
DESC INFORMATION_SCHEMA.THREAD_POOL_STATS;
Field Type Null Key Default Extra
diff --git a/sql/thread_pool_info.cc b/sql/thread_pool_info.cc
index cf9ffe94f94..f003581a5b0 100644
--- a/sql/thread_pool_info.cc
+++ b/sql/thread_pool_info.cc
@@ -92,7 +92,7 @@ static ST_FIELD_INFO queues_field_info[] =
Column("GROUP_ID", SLong(6), NOT_NULL),
Column("POSITION", SLong(6), NOT_NULL),
Column("PRIORITY", SLong(1), NOT_NULL),
- Column("CONNECTION_ID", ULonglong(19), NOT_NULL),
+ Column("CONNECTION_ID", ULonglong(19), NULLABLE),
Column("QUEUEING_TIME_MICROSECONDS", SLonglong(19), NOT_NULL),
CEnd()
};
@@ -130,7 +130,8 @@ static int queues_fill_table(THD* thd, TABLE_LIST* tables, COND*)
/* PRIORITY */
table->field[2]->store(prio, true);
/* CONNECTION_ID */
- table->field[3]->store(c->thd->thread_id, true);
+ if (c->thd)
+ table->field[3]->store(c->thd->thread_id, true);
/* QUEUEING_TIME */
table->field[4]->store(now - c->enqueue_time, true);