You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stmt="SELECT Id, User, Host, `Db` AS `db`, Command, Time_ms as Time, State, SUBSTRING(COALESCE(INFO_BINARY,''),1,1000) as Info, CASE WHEN Max_Stage < 2 THEN Progress ELSE (Stage-1)/Max_Stage*100+Progress/Max_Stage END AS Progress FROM INFORMATION_SCHEMA.PROCESSLIST WHERE User='+ user +'"
443
+
} elseifversion.IsMySQLOrPercona() {
444
+
//MySQL
445
+
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 User='+ user +'"
446
+
ifversion.GreaterEqual("8.0") {
447
+
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 User='+ user +'"
448
+
}
449
+
} elseifversion.IsPPostgreSQL() {
450
+
// WHERE state <> 'idle' AND pid<>pg_backend_pid()
451
+
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`
419
452
}
420
-
stmt:="ANALYZE FORMAT=JSON "+query
421
-
rows, err:=db.Query(stmt)
453
+
err=db.Select(&pl, stmt)
422
454
iferr!=nil {
423
-
return"", stmt, err
424
-
}
425
-
deferrows.Close()
426
-
427
-
ifrows.Next() {
428
-
iferr:=rows.Scan(&res); err!=nil {
429
-
returnres, stmt, err
430
-
}
455
+
returnnil, stmt, fmt.Errorf("ERROR: Could not get processlist: %s", err)
0 commit comments