Skip to content

Commit 3e6afcc

Browse files
authored
Merge branch 'main' into angela/union
2 parents 28f683a + 8f7bd00 commit 3e6afcc

17 files changed

+998
-265
lines changed

enginetest/queries/charset_collation_engine.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,10 @@ var CharsetCollationEngineTests = []CharsetCollationEngineTest{
605605
{int64(2), uint16(2)},
606606
},
607607
},
608+
{
609+
Query: "create table t (e enum('abc', 'ABC') collate utf8mb4_0900_ai_ci))",
610+
Error: true,
611+
},
608612
},
609613
},
610614
{

enginetest/queries/index_queries.go

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4065,6 +4065,121 @@ var IndexPrefixQueries = []ScriptTest{
40654065
},
40664066
},
40674067
},
4068+
{
4069+
Name: "multiple nullable index prefixes",
4070+
SetUpScript: []string{
4071+
"create table test(pk int primary key, shared1 int, shared2 int, a3 int, a4 int, b3 int, b4 int, unique key a_idx(shared1, shared2, a3, a4), unique key b_idx(shared1, shared2, b3, b4))",
4072+
},
4073+
Assertions: []ScriptTestAssertion{
4074+
{
4075+
Query: "select * from test where shared1 = 1 and shared2 = 2 and a3 = 3;",
4076+
Expected: []sql.Row{},
4077+
ExpectedIndexes: []string{"a_idx"},
4078+
},
4079+
{
4080+
Query: "select * from test where shared1 = 1 and shared2 = 2 and b3 = 3;",
4081+
Expected: []sql.Row{},
4082+
ExpectedIndexes: []string{"b_idx"},
4083+
},
4084+
},
4085+
},
4086+
{
4087+
Name: "multiple non-unique index prefixes",
4088+
SetUpScript: []string{
4089+
"create table test(pk int primary key, shared1 int not null, shared2 int not null, a3 int not null, a4 int not null, b3 int not null, b4 int not null, key a_idx(shared1, shared2, a3, a4), key b_idx(shared1, shared2, b3, b4))",
4090+
},
4091+
Assertions: []ScriptTestAssertion{
4092+
{
4093+
Query: "select * from test where shared1 = 1 and shared2 = 2 and a3 = 3;",
4094+
Expected: []sql.Row{},
4095+
ExpectedIndexes: []string{"a_idx"},
4096+
},
4097+
{
4098+
Query: "select * from test where shared1 = 1 and shared2 = 2 and a3 > 3 and a3 < 5;",
4099+
Expected: []sql.Row{},
4100+
ExpectedIndexes: []string{"a_idx"},
4101+
},
4102+
{
4103+
Query: "select * from test where shared1 = 1 and shared2 = 2 and b3 = 3;",
4104+
Expected: []sql.Row{},
4105+
ExpectedIndexes: []string{"b_idx"},
4106+
},
4107+
{
4108+
Query: "select * from test where shared1 = 1 and shared2 = 2 and b3 > 3 and b3 < 5;",
4109+
Expected: []sql.Row{},
4110+
ExpectedIndexes: []string{"b_idx"},
4111+
},
4112+
},
4113+
},
4114+
{
4115+
Name: "multiple non-unique nullable index prefixes",
4116+
SetUpScript: []string{
4117+
"create table test(pk int primary key, shared1 int, shared2 int, a3 int, a4 int, b3 int, b4 int, key a_idx(shared1, shared2, a3, a4), key b_idx(shared1, shared2, b3, b4))",
4118+
},
4119+
Assertions: []ScriptTestAssertion{
4120+
{
4121+
Query: "select * from test where shared1 = 1 and shared2 = 2 and a3 = 3;",
4122+
Expected: []sql.Row{},
4123+
ExpectedIndexes: []string{"a_idx"},
4124+
},
4125+
{
4126+
Query: "select * from test where shared1 = 1 and shared2 = 2 and a3 > 3 and a3 < 5;",
4127+
Expected: []sql.Row{},
4128+
ExpectedIndexes: []string{"a_idx"},
4129+
},
4130+
{
4131+
Query: "select * from test where shared1 = 1 and shared2 = 2 and b3 = 3;",
4132+
Expected: []sql.Row{},
4133+
ExpectedIndexes: []string{"b_idx"},
4134+
},
4135+
{
4136+
Query: "select * from test where shared1 = 1 and shared2 = 2 and b3 > 3 and b3 < 5;",
4137+
Expected: []sql.Row{},
4138+
ExpectedIndexes: []string{"b_idx"},
4139+
},
4140+
},
4141+
},
4142+
{
4143+
Name: "unique and non-unique nullable index prefixes",
4144+
SetUpScript: []string{
4145+
"create table test(pk int primary key, shared1 int, shared2 int, a3 int, a4 int, b3 int, b4 int, unique key a_idx(shared1, shared2, a3, a4), key b_idx(shared1, shared2, b3, b4))",
4146+
},
4147+
Assertions: []ScriptTestAssertion{
4148+
{
4149+
Query: "select * from test where shared1 = 1 and shared2 = 2 and a3 = 3;",
4150+
Expected: []sql.Row{},
4151+
ExpectedIndexes: []string{"a_idx"},
4152+
},
4153+
{
4154+
Query: "select * from test where shared1 = 1 and shared2 = 2 and a3 > 3 and a3 < 5;",
4155+
Expected: []sql.Row{},
4156+
ExpectedIndexes: []string{"a_idx"},
4157+
},
4158+
{
4159+
Query: "select * from test where shared1 = 1 and shared2 = 2 and b3 = 3;",
4160+
Expected: []sql.Row{},
4161+
ExpectedIndexes: []string{"b_idx"},
4162+
},
4163+
{
4164+
Query: "select * from test where shared1 = 1 and shared2 = 2 and b3 > 3 and b3 < 5;",
4165+
Expected: []sql.Row{},
4166+
ExpectedIndexes: []string{"b_idx"},
4167+
},
4168+
},
4169+
},
4170+
{
4171+
Name: "avoid picking an index simply because it matches more filters if those filters are not in the prefix.",
4172+
SetUpScript: []string{
4173+
"create table test(pk int primary key, shared1 int, shared2 int, a3 int, a4 int, b3 int, b4 int, unique key a_idx(shared1, a3, a4, shared2), key b_idx(shared1, shared2, b3, b4))",
4174+
},
4175+
Assertions: []ScriptTestAssertion{
4176+
{
4177+
Query: "select * from test where shared1 = 1 and shared2 = 2 and a4 = 3;",
4178+
Expected: []sql.Row{},
4179+
ExpectedIndexes: []string{"b_idx"},
4180+
},
4181+
},
4182+
},
40684183
}
40694184

40704185
var IndexQueries = []ScriptTest{

enginetest/queries/queries.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4830,6 +4830,47 @@ SELECT * FROM cte WHERE d = 2;`,
48304830
Query: "SELECT subdate(da, f32/10) from typestable;",
48314831
Expected: []sql.Row{{time.Date(2019, time.December, 30, 0, 0, 0, 0, time.UTC)}},
48324832
},
4833+
{
4834+
Query: "SELECT date_add('4444-01-01', INTERVAL 5400000 DAY);",
4835+
Expected: []sql.Row{{nil}},
4836+
},
4837+
{
4838+
Query: "SELECT date_add('4444-01-01', INTERVAL -5300000 DAY);",
4839+
Expected: []sql.Row{{nil}},
4840+
},
4841+
{
4842+
Query: "SELECT subdate('2008-01-02', 12e10);",
4843+
Expected: []sql.Row{{nil}},
4844+
},
4845+
{
4846+
Query: "SELECT date_add('2008-01-02', INTERVAL 1000000 day);",
4847+
Expected: []sql.Row{{"4745-11-29"}},
4848+
},
4849+
{
4850+
Query: "SELECT subdate('2008-01-02', INTERVAL 700000 day);",
4851+
Expected: []sql.Row{{"0091-06-20"}},
4852+
},
4853+
{
4854+
Query: "SELECT date_add('0000-01-01:01:00:00', INTERVAL 0 day);",
4855+
// MYSQL uses a proleptic gregorian, however, Go's time package does normal gregorian.
4856+
Expected: []sql.Row{{"0000-01-01 01:00:00"}},
4857+
},
4858+
{
4859+
Query: "SELECT date_add('9999-12-31:23:59:59.9999994', INTERVAL 0 day);",
4860+
Expected: []sql.Row{{"9999-12-31 23:59:59.999999"}},
4861+
},
4862+
{
4863+
Query: "SELECT date_add('9999-12-31:23:59:59.9999995', INTERVAL 0 day);",
4864+
Expected: []sql.Row{{nil}},
4865+
},
4866+
{
4867+
Query: "SELECT date_add('9999-12-31:23:59:59.99999945', INTERVAL 0 day);",
4868+
Expected: []sql.Row{{"9999-12-31 23:59:59.999999"}},
4869+
},
4870+
{
4871+
Query: "SELECT date_add('9999-12-31:23:59:59.99999944444444444-', INTERVAL 0 day);",
4872+
Expected: []sql.Row{{nil}},
4873+
},
48334874
{
48344875
Query: `SELECT * FROM (SELECT * FROM (SELECT * FROM (SELECT * FROM othertable) othertable_one) othertable_two) othertable_three WHERE s2 = 'first'`,
48354876
Expected: []sql.Row{

enginetest/queries/query_plans.go

Lines changed: 39 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)