Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: Port missing in processlist #30183

Merged
merged 5 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ func (cc *clientConn) checkAuthPlugin(ctx context.Context, resp *handshakeRespon

func (cc *clientConn) PeerHost(hasPassword string) (host, port string, err error) {
if len(cc.peerHost) > 0 {
return cc.peerHost, "", nil
return cc.peerHost, cc.peerPort, nil
}
host = variable.DefHostname
if cc.isUnixSocket {
Expand Down
6 changes: 5 additions & 1 deletion server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ func (cli *testServerClient) runTestLoadDataForListColumnPartition2(t *testing.T
})
}

func (cli *testServerClient) checkRows(t *testing.T, rows *sql.Rows, expectedRows ...string) {
func (cli *testServerClient) Rows(t *testing.T, rows *sql.Rows) []string {
buf := bytes.NewBuffer(nil)
result := make([]string, 0, 2)
for rows.Next() {
Expand All @@ -806,7 +806,11 @@ func (cli *testServerClient) checkRows(t *testing.T, rows *sql.Rows, expectedRow
}
result = append(result, buf.String())
}
return result
}

func (cli *testServerClient) checkRows(t *testing.T, rows *sql.Rows, expectedRows ...string) {
result := cli.Rows(t, rows)
require.Equal(t, strings.Join(expectedRows, "\n"), strings.Join(result, "\n"))
}

Expand Down
3 changes: 3 additions & 0 deletions server/tidb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ func TestSocketAndIp(t *testing.T) {
cli.checkRows(t, rows, "[email protected]")
rows = dbt.MustQuery("show grants")
cli.checkRows(t, rows, "GRANT USAGE ON *.* TO 'user1'@'%'\nGRANT SELECT ON test.* TO 'user1'@'%'")
rows = dbt.MustQuery("select host from information_schema.processlist where user = 'user1'")
records := cli.Rows(t, rows)
require.Contains(t, records[0], ":", "Missing :<port> in is.processlist")
})
// Test with unix domain socket file connection with all hosts
cli.runTests(t, func(config *mysql.Config) {
Expand Down