Skip to content

Commit b3a51de

Browse files
authored
Remove incompatible server version direct stdout (#1032)
1 parent d04681d commit b3a51de

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

conn.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ func dial(ctx context.Context, addr string, num int, opt *Options) (*connect, er
102102

103103
// warn only on the first connection in the pool
104104
if num == 1 && !resources.ClientMeta.IsSupportedClickHouseVersion(connect.server.Version) {
105-
// send to debugger and console
106-
fmt.Printf("WARNING: version %v of ClickHouse is not supported by this client\n", connect.server.Version)
107105
debugf("[handshake] WARNING: version %v of ClickHouse is not supported by this client - client supports %v", connect.server.Version, resources.ClientMeta.SupportedVersions())
108106
}
109107
return connect, nil

conn_http.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ import (
2727
"fmt"
2828
"io"
2929
"io/ioutil"
30+
"log"
3031
"mime/multipart"
3132
"net"
3233
"net/http"
3334
"net/url"
35+
"os"
3436
"strings"
3537
"sync"
3638
"time"
@@ -136,6 +138,15 @@ func (rw *HTTPReaderWriter) reset(pw *io.PipeWriter) io.WriteCloser {
136138
}
137139

138140
func dialHttp(ctx context.Context, addr string, num int, opt *Options) (*httpConnect, error) {
141+
var debugf = func(format string, v ...any) {}
142+
if opt.Debug {
143+
if opt.Debugf != nil {
144+
debugf = opt.Debugf
145+
} else {
146+
debugf = log.New(os.Stdout, fmt.Sprintf("[clickhouse][conn=%d][%s]", num, addr), 0).Printf
147+
}
148+
}
149+
139150
if opt.scheme == "" {
140151
switch opt.Protocol {
141152
case HTTP:
@@ -239,7 +250,7 @@ func dialHttp(ctx context.Context, addr string, num int, opt *Options) (*httpCon
239250
return nil, err
240251
}
241252
if !resources.ClientMeta.IsSupportedClickHouseVersion(version) {
242-
fmt.Printf("WARNING: version %v of ClickHouse is not supported by this client\n", version)
253+
debugf("WARNING: version %v of ClickHouse is not supported by this client\n", version)
243254
}
244255
}
245256

0 commit comments

Comments
 (0)