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) #23599

Merged
merged 6 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8916,3 +8916,15 @@ func (s *testIntegrationSuite) TestClusteredIndexCorCol(c *C) {
tk.MustExec("insert into t2 select * from t1 ;")
tk.MustQuery("select (select t2.c_str from t2 where t2.c_str = t1.c_str and t2.c_int = 10 order by t2.c_str limit 1) x from t1;").Check(testkit.Rows("<nil>", "goofy mestorf"))
}

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