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

executor: fix point_get result on clustered index when new-row-format disabled but new-collation enabled #24544

Merged
merged 6 commits into from
May 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions executor/point_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ func tryDecodeFromHandle(tblInfo *model.TableInfo, schemaColIdx int, col *expres
chk.AppendInt64(schemaColIdx, handle.IntValue())
return true, nil
}
if types.NeedRestoredData(col.RetType) {
return false, nil
}
// Try to decode common handle.
if mysql.HasPriKeyFlag(col.RetType.Flag) {
for i, hid := range pkCols {
Expand Down
15 changes: 15 additions & 0 deletions session/clustered_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,3 +616,18 @@ func (s *testClusteredSerialSuite) TestPrefixedClusteredIndexUniqueKeyWithNewCol
tk.MustExec("admin check table t;")
tk.MustExec("drop table t;")
}

func (s *testClusteredSerialSuite) TestClusteredIndexNewCollationWithOldRowFormat(c *C) {
// This case maybe not useful, because newCollation isn't convenience to run on TiKV(it's required serialSuit)
// but unistore doesn't support old row format.
defer collate.SetNewCollationEnabledForTest(false)
collate.SetNewCollationEnabledForTest(true)
tk := testkit.NewTestKitWithInit(c, s.store)
tk.MustExec("use test;")
tk.Se.GetSessionVars().EnableClusteredIndex = variable.ClusteredIndexDefModeOn
tk.Se.GetSessionVars().RowEncoder.Enable = false
tk.MustExec("drop table if exists t2")
tk.MustExec("create table t2(col_1 varchar(132) CHARACTER SET utf8 COLLATE utf8_unicode_ci, primary key(col_1) clustered)")
tk.MustExec("insert into t2 select 'aBc'")
tk.MustQuery("select col_1 from t2 where col_1 = 'aBc'").Check(testkit.Rows("aBc"))
}