Skip to content

Commit

Permalink
types: fix collation for binary literal (#23591)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhuang2016 authored Mar 26, 2021
1 parent 6cdfaab commit c9e041e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8926,3 +8926,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

0 comments on commit c9e041e

Please sign in to comment.