Skip to content

Commit 6e1d4bd

Browse files
committed
Can not fetch processlist MySQL 8.x #542
1 parent ead9acf commit 6e1d4bd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

utils/dbhelper/dbhelper.go

+3
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ func GetProcesslistTable(db *sqlx.DB, version *MySQLVersion) ([]Processlist, str
398398
} else if version.IsMySQLOrPercona() {
399399
//MySQL
400400
stmt = "SELECT Id, User, Host, `Db` AS `db`, Command, Time as Time, State, SUBSTRING(COALESCE(INFO,''),1,1000) as Info ,0 as Progress FROM INFORMATION_SCHEMA.PROCESSLIST WHERE command='query' ORDER BY TIME DESC LIMIT 50"
401+
if version.GreaterEqual("8.0") {
402+
stmt = "SELECT Id, User, Host, `Db` AS `db`, Command, Time_ms as Time, State, SUBSTRING(COALESCE(INFO,''),1,1000) as Info ,0 as Progress FROM INFORMATION_SCHEMA.PROCESSLIST WHERE command='query' ORDER BY TIME DESC LIMIT 50"
403+
}
401404
} else if version.IsPPostgreSQL() {
402405
// WHERE state <> 'idle' AND pid<>pg_backend_pid()
403406
stmt = `SELECT pid as "Id", coalesce(usename,'') as "User",coalesce(client_hostname || client_port,'') as "Host" , coalesce(datname,'') as db , coalesce(query,'') as "Command", extract(epoch from NOW()) - extract(epoch from query_start) as "Time", coalesce(state,'') as "State",COALESCE(application_name,'') as "Info" ,0 as "Progress" FROM pg_stat_activity`

0 commit comments

Comments
 (0)