pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://tidbcloud.com/free-trial
https://pingcap.com
Apache License 2.0
36.27k stars 5.72k forks source link

Support for collation with ID>255 #52996

Open dveeden opened 2 weeks ago

dveeden commented 2 weeks ago

Bug Report

Many places use a int or uint8 for the Collation ID. This breaks collations with an ID above 255.

$ git grep -iE 'collation *(uint8|int)(,|$|\ )'
pkg/server/conn.go:     collation     uint8                 // collation used by client, may be different from the collation used by database.
pkg/server/driver.go:   OpenCtx(connID uint64, capability uint32, collation uint8, dbname string, tlsState *tls.ConnectionState, extensions *extension.SessionExtensions) (*TiDBContext, error)
pkg/server/driver_tidb.go:func (qd *TiDBDriver) OpenCtx(connID uint64, capability uint32, collation uint8, _ string,
pkg/server/internal/handshake/handshake.go:     Collation  uint8

https://github.com/pingcap/tidb/blob/c60f97d16c6ff981b16279254ddee0f6b0e8ef19/pkg/parser/charset/charset.go#L47

Also there is quite a bit of duplication between these: