Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 98b725a

Browse files
author
Alan Braithwaite
committed
clickhouse: fix protocol error for alter table
This fix works because Clickhouse has already closed the stream, so there's nothing more to be read. We return an empty driver.Rows so that it doesn't break the caller's expectations and panic trying to dereference it's contents.
1 parent adf448e commit 98b725a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

clickhouse_read_meta.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ func (ch *clickhouse) readMeta() (*data.Block, error) {
4242
ch.logf("[read meta] <- data: packet=%d, columns=%d, rows=%d", packet, block.NumColumns, block.NumRows)
4343
return block, nil
4444
case protocol.ServerEndOfStream:
45-
_, err := ch.readBlock()
4645
ch.logf("[process] <- end of stream")
47-
return nil, err
46+
return nil, nil
4847
default:
4948
ch.conn.Close()
5049
return nil, fmt.Errorf("[read meta] unexpected packet [%d] from server", packet)

stmt.go

+9
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ func (stmt *stmt) queryContext(ctx context.Context, args []driver.NamedValue) (d
8686
finish()
8787
return nil, err
8888
}
89+
if meta == nil {
90+
sc := make(chan *data.Block)
91+
defer close(sc)
92+
return &rows{
93+
ch: stmt.ch,
94+
finish: finish,
95+
stream: sc,
96+
}, nil
97+
}
8998
rows := rows{
9099
ch: stmt.ch,
91100
finish: finish,

0 commit comments

Comments
 (0)