Fix activity list
This commit is contained in:
parent
77770112bd
commit
56f3b45a4e
@ -154,7 +154,7 @@ func (client *Client) setServerVersion() {
|
|||||||
// Detect cockroachdb
|
// Detect cockroachdb
|
||||||
matches = cockroachSignature.FindAllStringSubmatch(version, 1)
|
matches = cockroachSignature.FindAllStringSubmatch(version, 1)
|
||||||
if len(matches) > 0 {
|
if len(matches) > 0 {
|
||||||
client.serverType = postgresType
|
client.serverType = cockroachType
|
||||||
client.serverVersion = matches[0][1]
|
client.serverVersion = matches[0][1]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -255,9 +255,11 @@ func (client *Client) TableConstraints(table string) (*Result, error) {
|
|||||||
|
|
||||||
// Returns all active queriers on the server
|
// Returns all active queriers on the server
|
||||||
func (client *Client) Activity() (*Result, error) {
|
func (client *Client) Activity() (*Result, error) {
|
||||||
chunks := strings.Split(client.serverVersion, ".")
|
if client.serverType == cockroachType {
|
||||||
version := strings.Join(chunks[0:2], ".")
|
return client.query("SHOW QUERIES")
|
||||||
|
}
|
||||||
|
|
||||||
|
version := getMajorMinorVersion(client.serverVersion)
|
||||||
query := statements.Activity[version]
|
query := statements.Activity[version]
|
||||||
if query == "" {
|
if query == "" {
|
||||||
query = statements.Activity["default"]
|
query = statements.Activity["default"]
|
||||||
|
15
pkg/client/util.go
Normal file
15
pkg/client/util.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get short version from the string
|
||||||
|
// Example: 10.2.3.1 -> 10.2
|
||||||
|
func getMajorMinorVersion(str string) string {
|
||||||
|
chunks := strings.Split(str, ".")
|
||||||
|
if len(chunks) == 0 {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
return strings.Join(chunks[0:2], ".")
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user