1SET GLOBAL event_scheduler = OFF;
2SELECT name, type, processlist_user, processlist_host, processlist_db,
3processlist_command, processlist_info,
4IF(parent_thread_id IS NULL, parent_thread_id, 'unified parent_thread_id')
5AS unified_parent_thread_id,
6role, instrumented
7FROM performance_schema.threads
8WHERE name LIKE 'thread/sql%'
9ORDER BY name;
10name	thread/sql/compress_gtid_table
11type	FOREGROUND
12processlist_user	NULL
13processlist_host	NULL
14processlist_db	NULL
15processlist_command	Daemon
16processlist_info	NULL
17unified_parent_thread_id	unified parent_thread_id
18role	NULL
19instrumented	YES
20name	thread/sql/main
21type	BACKGROUND
22processlist_user	NULL
23processlist_host	NULL
24processlist_db	NULL
25processlist_command	NULL
26processlist_info	NULL
27unified_parent_thread_id	NULL
28role	NULL
29instrumented	YES
30name	thread/sql/one_connection
31type	FOREGROUND
32processlist_user	root
33processlist_host	localhost
34processlist_db	test
35processlist_command	Query
36processlist_info	SELECT name, type, processlist_user, processlist_host, processlist_db,
37processlist_command, processlist_info,
38IF(parent_thread_id IS NULL, parent_thread_id, 'unified parent_thread_id')
39AS unified_parent_thread_id,
40role, instrumented
41FROM performance_schema.threads
42WHERE name LIKE 'thread/sql%'
43ORDER BY name
44unified_parent_thread_id	unified parent_thread_id
45role	NULL
46instrumented	YES
47name	thread/sql/signal_handler
48type	BACKGROUND
49processlist_user	NULL
50processlist_host	NULL
51processlist_db	NULL
52processlist_command	NULL
53processlist_info	NULL
54unified_parent_thread_id	unified parent_thread_id
55role	NULL
56instrumented	YES
57name	thread/sql/thread_timer_notifier
58type	BACKGROUND
59processlist_user	NULL
60processlist_host	NULL
61processlist_db	NULL
62processlist_command	NULL
63processlist_info	NULL
64unified_parent_thread_id	unified parent_thread_id
65role	NULL
66instrumented	YES
67CREATE TEMPORARY TABLE t1 AS
68SELECT thread_id FROM performance_schema.threads
69WHERE name LIKE 'thread/sql%';
70SET GLOBAL event_scheduler = ON;
71SELECT name, type, processlist_user, processlist_host, processlist_db,
72processlist_command, processlist_info,
73IF(parent_thread_id IS NULL, parent_thread_id, 'unified parent_thread_id')
74AS unified_parent_thread_id,
75role, instrumented
76FROM performance_schema.threads
77WHERE name LIKE 'thread/sql%'
78  AND thread_id NOT IN (SELECT thread_id FROM t1)
79ORDER BY name;
80name	thread/sql/event_scheduler
81type	FOREGROUND
82processlist_user	root
83processlist_host	localhost
84processlist_db	NULL
85processlist_command	Sleep
86processlist_info	NULL
87unified_parent_thread_id	unified parent_thread_id
88role	NULL
89instrumented	YES
90TRUNCATE t1;
91INSERT INTO t1
92SELECT thread_id FROM performance_schema.threads
93WHERE name LIKE 'thread/sql%';
94SELECT COUNT(*) INTO @aux FROM t1;
95DROP EVENT IF EXISTS t_ps_event;
96CREATE EVENT t_ps_event
97ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND
98DO SELECT SLEEP(3);
99SELECT name, type, processlist_user, processlist_host, processlist_db,
100processlist_command, processlist_info,
101IF(parent_thread_id IS NULL, parent_thread_id, 'unified parent_thread_id')
102AS unified_parent_thread_id,
103role, instrumented
104FROM performance_schema.threads
105WHERE name LIKE 'thread/sql%'
106  AND thread_id NOT IN (SELECT thread_id FROM t1)
107ORDER BY name;
108name	thread/sql/event_worker
109type	FOREGROUND
110processlist_user	root
111processlist_host	localhost
112processlist_db	NULL
113processlist_command	Sleep
114processlist_info	SELECT SLEEP(3)
115unified_parent_thread_id	unified parent_thread_id
116role	NULL
117instrumented	YES
118SELECT t2.name AS parent_thread_name, t1.name AS child_thread_name
119FROM performance_schema.threads t1 INNER JOIN performance_schema.threads t2
120ON t1.parent_thread_id = t2.thread_id
121WHERE t1.name LIKE 'thread/sql%'
122  AND t1.parent_thread_id IS NOT NULL
123ORDER BY parent_thread_name, child_thread_name;
124parent_thread_name	child_thread_name
125thread/sql/event_scheduler	thread/sql/event_worker
126thread/sql/main	thread/sql/compress_gtid_table
127thread/sql/main	thread/sql/one_connection
128thread/sql/main	thread/sql/signal_handler
129thread/sql/main	thread/sql/thread_timer_notifier
130thread/sql/one_connection	thread/sql/event_scheduler
131