Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: fix collation for binary literal (#23591) #23598

Merged
merged 7 commits into from
May 10, 2021
12 changes: 12 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8080,3 +8080,15 @@ func (s *testIntegrationSerialSuite) TestIssue19116(c *C) {
tk.MustQuery("select coercibility(1);").Check(testkit.Rows("5"))
tk.MustQuery("select coercibility(1=1);").Check(testkit.Rows("5"))
}

func (s *testIntegrationSerialSuite) TestCollationForBinaryLiteral(c *C) {
tk := testkit.NewTestKit(c, s.store)
collate.SetNewCollationEnabledForTest(true)
defer collate.SetNewCollationEnabledForTest(false)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("CREATE TABLE t (`COL1` tinyblob NOT NULL, `COL2` binary(1) NOT NULL, `COL3` bigint(11) NOT NULL, PRIMARY KEY (`COL1`(5),`COL2`,`COL3`) /*T![clustered_index] CLUSTERED */)")
tk.MustExec("insert into t values(0x1E,0xEC,6966939640596047133);")
tk.MustQuery("select * from t where col1 not in (0x1B,0x20) order by col1").Check(testkit.Rows("\x1e \xec 6966939640596047133"))
tk.MustExec("drop table t")
}
1 change: 1 addition & 0 deletions types/datum.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func (d *Datum) GetMysqlBit() BinaryLiteral {
func (d *Datum) SetBinaryLiteral(b BinaryLiteral) {
d.k = KindBinaryLiteral
d.b = b
d.collation = charset.CollationBin
}

// SetMysqlBit sets MysqlBit value
Expand Down