Created
September 26, 2023 18:15
-
-
Save grantstephens/610e6951751a5498c0337624158cf617 to your computer and use it in GitHub Desktop.
Clickhouse IPv6 Address Bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"net" | |
"github.com/ClickHouse/clickhouse-go/v2" | |
) | |
func main() { | |
conn, err := clickhouse.Open(&clickhouse.Options{ | |
Addr: []string{":9000"}, | |
Auth: clickhouse.Auth{}, | |
}) | |
if err != nil { | |
panic(err) | |
} | |
ctx := context.Background() | |
defer func() { | |
conn.Exec(ctx, "DROP TABLE example") | |
}() | |
conn.Exec(context.Background(), "DROP TABLE IF EXISTS example") | |
err = conn.Exec(ctx, ` | |
CREATE TABLE IF NOT EXISTS example ( | |
Col1 UInt8 | |
, Col2 IPv6 | |
) Engine = Memory | |
`) | |
if err != nil { | |
panic(err) | |
} | |
batch, err := conn.PrepareBatch(ctx, "INSERT INTO example") | |
if err != nil { | |
panic(err) | |
} | |
for i := 0; i < 1000; i++ { | |
err := batch.Append( | |
uint8(42), | |
net.IP{}, | |
) | |
if err != nil { | |
panic(err) | |
} | |
} | |
if err := batch.Send(); err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment