Skip to content

Commit ea12e61

Browse files
committed
remove support for older versions of ClickHouse
1 parent b388b59 commit ea12e61

6 files changed

+31
-43
lines changed

clickhouse_progress.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package clickhouse
22

3-
import "github.com/kshvakov/clickhouse/lib/protocol"
4-
53
type progress struct {
64
rows uint64
75
bytes uint64
@@ -19,10 +17,10 @@ func (ch *clickhouse) progress() (*progress, error) {
1917
if p.bytes, err = ch.decoder.Uvarint(); err != nil {
2018
return nil, err
2119
}
22-
if ch.ServerInfo.Revision >= protocol.DBMS_MIN_REVISION_WITH_TOTAL_ROWS_IN_PROGRESS {
23-
if p.totalRows, err = ch.decoder.Uvarint(); err != nil {
24-
return nil, err
25-
}
20+
21+
if p.totalRows, err = ch.decoder.Uvarint(); err != nil {
22+
return nil, err
2623
}
24+
2725
return &p, nil
2826
}

clickhouse_read_block.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@ import (
44
"time"
55

66
"github.com/kshvakov/clickhouse/lib/data"
7-
"github.com/kshvakov/clickhouse/lib/protocol"
87
)
98

109
func (ch *clickhouse) readBlock() (*data.Block, error) {
1110
{
1211
ch.conn.SetReadDeadline(time.Now().Add(ch.readTimeout))
1312
ch.conn.SetWriteDeadline(time.Now().Add(ch.writeTimeout))
1413
}
15-
if ch.ServerInfo.Revision >= protocol.DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES {
16-
if _, err := ch.decoder.String(); err != nil {
17-
return nil, err
18-
}
14+
15+
if _, err := ch.decoder.String(); err != nil { // temporary table
16+
return nil, err
1917
}
18+
2019
if ch.compress {
2120

2221
}

clickhouse_send_query.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ func (ch *clickhouse) sendQuery(query string) error {
1919
if err := ch.encoder.String(""); err != nil {
2020
return err
2121
}
22-
if ch.ServerInfo.Revision >= protocol.DBMS_MIN_REVISION_WITH_CLIENT_INFO {
23-
ch.encoder.Uvarint(1)
22+
23+
ch.encoder.Uvarint(1)
24+
ch.encoder.String("")
25+
ch.encoder.String("") //initial_query_id
26+
ch.encoder.String("[::ffff:127.0.0.1]:0")
27+
ch.encoder.Uvarint(1) // iface type TCP
28+
ch.encoder.String(hostname)
29+
ch.encoder.String(hostname)
30+
if err := ch.ClientInfo.Write(ch.encoder); err != nil {
31+
return err
32+
}
33+
if ch.ServerInfo.Revision >= protocol.DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO {
2434
ch.encoder.String("")
25-
ch.encoder.String("") //initial_query_id
26-
ch.encoder.String("[::ffff:127.0.0.1]:0")
27-
ch.encoder.Uvarint(1) // iface type TCP
28-
ch.encoder.String(hostname)
29-
ch.encoder.String(hostname)
30-
if err := ch.ClientInfo.Write(ch.encoder); err != nil {
31-
return err
32-
}
33-
if ch.ServerInfo.Revision >= protocol.DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO {
34-
ch.encoder.String("")
35-
}
3635
}
36+
3737
if err := ch.encoder.String(""); err != nil { // settings
3838
return err
3939
}

clickhouse_write_block.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ func (ch *clickhouse) writeBlock(block *data.Block) error {
1717
if err := ch.encoder.Uvarint(protocol.ClientData); err != nil {
1818
return err
1919
}
20-
if ch.ServerInfo.Revision >= protocol.DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES {
21-
if err := ch.encoder.String(""); err != nil {
22-
return err
23-
}
20+
21+
if err := ch.encoder.String(""); err != nil { // temporary table
22+
return err
2423
}
24+
2525
// @todo: implement CityHash v 1.0.2 and add LZ4 compression
2626
if ch.compress {
2727
/*

lib/data/block.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/kshvakov/clickhouse/lib/binary"
1010
"github.com/kshvakov/clickhouse/lib/column"
11-
"github.com/kshvakov/clickhouse/lib/protocol"
1211
wb "github.com/kshvakov/clickhouse/lib/writebuffer"
1312
)
1413

@@ -39,11 +38,10 @@ func (block *Block) ColumnNames() []string {
3938
}
4039

4140
func (block *Block) Read(serverInfo *ServerInfo, decoder *binary.Decoder) (err error) {
42-
if serverInfo.Revision >= protocol.DBMS_MIN_REVISION_WITH_BLOCK_INFO {
43-
if err = block.info.read(decoder); err != nil {
44-
return err
45-
}
41+
if err = block.info.read(decoder); err != nil {
42+
return err
4643
}
44+
4745
if block.NumColumns, err = decoder.Uvarint(); err != nil {
4846
return err
4947
}
@@ -163,11 +161,10 @@ func (block *Block) Reset() {
163161
}
164162

165163
func (block *Block) Write(serverInfo *ServerInfo, encoder *binary.Encoder) error {
166-
if serverInfo.Revision >= protocol.DBMS_MIN_REVISION_WITH_BLOCK_INFO {
167-
if err := block.info.write(encoder); err != nil {
168-
return err
169-
}
164+
if err := block.info.write(encoder); err != nil {
165+
return err
170166
}
167+
171168
encoder.Uvarint(block.NumColumns)
172169
encoder.Uvarint(block.NumRows)
173170
block.NumRows = 0

lib/protocol/protocol.go

-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
package protocol
22

33
const (
4-
DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES = 50264
5-
DBMS_MIN_REVISION_WITH_TOTAL_ROWS_IN_PROGRESS = 51554
6-
DBMS_MIN_REVISION_WITH_BLOCK_INFO = 51903
7-
DBMS_MIN_REVISION_WITH_CLIENT_INFO = 54032
84
DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE = 54058
95
DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO = 54060
106
)
@@ -17,8 +13,6 @@ const (
1713
ClientPing = 4
1814
)
1915

20-
const Query = 1
21-
2216
const (
2317
CompressEnable uint64 = 1
2418
CompressDisable uint64 = 0

0 commit comments

Comments
 (0)