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

planner: fix wrong ranges for binary literal + in #31292

Merged
merged 7 commits into from
Jan 5, 2022
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
19 changes: 19 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,25 @@ func (s *testIntegrationSuite) TestIssue15813(c *C) {
tk.MustQuery("select /*+ MERGE_JOIN(t0, t1) */ * from t0, t1 where t0.c0 = t1.c0").Check(testkit.Rows())
}

func (s *testIntegrationSuite) TestIssue31261(c *C) {
tk := testkit.NewTestKit(c, s.store)

tk.MustExec(`use test`)
tk.MustExec(`drop table if exists PK_MULTI_COL_5177`)
tk.MustExec(` CREATE TABLE PK_MULTI_COL_5177 (
COL1 binary(10) NOT NULL,
COL2 varbinary(10) NOT NULL,
COL3 smallint(45) NOT NULL,
PRIMARY KEY (COL1(5),COL2,COL3),
UNIQUE KEY UIDXM (COL1(5),COL2),
UNIQUE KEY UIDX (COL2),
KEY IDX3 (COL3),
KEY IDXM (COL3,COL2))`)
tk.MustExec(`insert into PK_MULTI_COL_5177(col1, col2, col3) values(0x00000000000000000000, 0x002B200DF5BA03E59F82, 1)`)
c.Assert(len(tk.MustQuery(`select col1, col2 from PK_MULTI_COL_5177 where col1 = 0x00000000000000000000 and col2 in (0x002B200DF5BA03E59F82, 0x002B200DF5BA03E59F82, 0x002B200DF5BA03E59F82)`).Rows()), Equals, 1)
c.Assert(len(tk.MustQuery(`select col1, col2 from PK_MULTI_COL_5177 where col1 = 0x00000000000000000000 and col2 = 0x002B200DF5BA03E59F82`).Rows()), Equals, 1)
}

func (s *testIntegrationSuite) TestFullGroupByOrderBy(c *C) {
tk := testkit.NewTestKit(c, s.store)

Expand Down
3 changes: 3 additions & 0 deletions util/ranger/points.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,9 @@ func (r *builder) buildFromIn(expr *expression.ScalarFunction) ([]*point, bool)
continue
}
}
if expr.GetArgs()[0].GetType().EvalType() == types.ETString && (dt.Kind() == types.KindString || dt.Kind() == types.KindBinaryLiteral) {
dt.SetString(dt.GetString(), expr.GetArgs()[0].GetType().Collate) // refine the string like what we did in builder.buildFromBinOp
}
var startValue, endValue types.Datum
dt.Copy(&startValue)
dt.Copy(&endValue)
Expand Down