Skip to content

Commit b49ea60

Browse files
committed
Merge remote-tracking branch 'origin/main' into nicktobey/wrapper
2 parents 2ce4c01 + df44c73 commit b49ea60

27 files changed

+22982
-23956
lines changed

enginetest/join_planning_tests.go

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ type JoinPlanTest struct {
4343
skipOld bool
4444
}
4545

46-
var JoinPlanningTests = []struct {
46+
type joinPlanScript struct {
4747
name string
4848
setup []string
4949
tests []JoinPlanTest
50-
}{
50+
}
51+
52+
var JoinPlanningTests = []joinPlanScript{
5153
{
5254
name: "filter pushdown through join uppercase name",
5355
setup: []string{
@@ -78,6 +80,43 @@ var JoinPlanningTests = []struct {
7880
},
7981
},
8082
},
83+
{
84+
name: "block merge join",
85+
setup: []string{
86+
"CREATE table xy (x int primary key, y int, unique index y_idx(y));",
87+
"CREATE table ab (a int primary key, b int);",
88+
"insert into xy values (1,0), (2,1), (0,2), (3,3);",
89+
"insert into ab values (0,2), (1,2), (2,2), (3,1);",
90+
`analyze table xy update histogram on x using data '{"row_count":1000000}'`,
91+
`analyze table ab update histogram on a using data '{"row_count":1000000}'`,
92+
},
93+
tests: []JoinPlanTest{
94+
{
95+
q: "select /*+ JOIN_ORDER(ab, xy) MERGE_JOIN(ab, xy)*/ * from ab join xy on y = a order by 1, 3",
96+
types: []plan.JoinType{plan.JoinTypeMerge},
97+
exp: []sql.Row{{0, 2, 1, 0}, {1, 2, 2, 1}, {2, 2, 0, 2}, {3, 1, 3, 3}},
98+
},
99+
{
100+
q: "select * from ab join xy on x = a and y = a order by 1, 3",
101+
types: []plan.JoinType{plan.JoinTypeMerge},
102+
exp: []sql.Row{{3, 1, 3, 3}},
103+
},
104+
{
105+
q: "set @@SESSION.disable_merge_join = 1",
106+
exp: []sql.Row{{}},
107+
},
108+
{
109+
q: "select /*+ JOIN_ORDER(ab, xy) MERGE_JOIN(ab, xy)*/ * from ab join xy on y = a order by 1, 3",
110+
types: []plan.JoinType{plan.JoinTypeLookup},
111+
exp: []sql.Row{{0, 2, 1, 0}, {1, 2, 2, 1}, {2, 2, 0, 2}, {3, 1, 3, 3}},
112+
},
113+
{
114+
q: "select * from ab join xy on x = a and y = a order by 1, 3",
115+
types: []plan.JoinType{plan.JoinTypeLookup},
116+
exp: []sql.Row{{3, 1, 3, 3}},
117+
},
118+
},
119+
},
81120
{
82121
name: "merge join unary index",
83122
setup: []string{
@@ -1725,8 +1764,17 @@ join uv d on d.u = c.x`,
17251764
}
17261765

17271766
func TestJoinPlanning(t *testing.T, harness Harness) {
1728-
for _, tt := range JoinPlanningTests {
1767+
runJoinPlanningTests(t, harness, JoinPlanningTests)
1768+
}
1769+
1770+
func runJoinPlanningTests(t *testing.T, harness Harness, tests []joinPlanScript) {
1771+
for _, tt := range tests {
17291772
t.Run(tt.name, func(t *testing.T) {
1773+
if sh, ok := harness.(SkippingHarness); ok {
1774+
if sh.SkipQueryTest(tt.name) {
1775+
t.Skip(tt.name)
1776+
}
1777+
}
17301778
harness.Setup([]setup.SetupScript{setup.MydbData[0], tt.setup})
17311779
e := mustNewEngine(t, harness)
17321780
defer e.Close()
@@ -1750,7 +1798,6 @@ func TestJoinPlanning(t *testing.T, harness Harness) {
17501798
})
17511799
}
17521800
}
1753-
17541801
func evalJoinTypeTest(t *testing.T, harness Harness, e QueryEngine, query string, types []plan.JoinType, skipOld bool) {
17551802
t.Run(query+" join types", func(t *testing.T) {
17561803
if skipOld {

enginetest/join_stats_tests.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,8 @@ var JoinStatTests = []struct {
135135
{
136136
// b is smallest table, bxc is smallest b-connected join
137137
// due to b < 0 filter and positive c skew
138-
q: "select /*+ LEFT_DEEP */ count(*) from u0 b join `u-15` a on a.b = b.b join `u+15` c on a.b = c.b where b.b < -2",
139-
order: [][]string{{"b", "c", "a"}},
140-
},
141-
{
142138
q: "select /*+ LEFT_DEEP */ count(*) from u0 b join `u-15` a on a.b = b.b join `u+15` c on a.b = c.b where b.b < -2",
143-
order: [][]string{{"b", "c", "a"}},
139+
order: [][]string{{"b", "c", "a"}, {"a", "c", "b"}},
144140
},
145141
{
146142
// b is smallest table, bxa is smallest b-connected join

enginetest/memory_engine_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ func TestLateralJoin(t *testing.T) {
111111

112112
// TestJoinPlanning runs join-specific tests for merge
113113
func TestJoinPlanning(t *testing.T) {
114-
enginetest.TestJoinPlanning(t, enginetest.NewDefaultMemoryHarness())
114+
harness := enginetest.NewDefaultMemoryHarness()
115+
if harness.IsUsingServer() {
116+
harness.QueriesToSkip("block merge join")
117+
}
118+
enginetest.TestJoinPlanning(t, harness)
115119
}
116120

117121
// TestJoinOps runs join-specific tests for merge

enginetest/queries/alter_table_queries.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,22 @@ var AlterTableScripts = []ScriptTest{
513513
},
514514
},
515515
},
516+
{
517+
Name: "add column with inline check constraint definition",
518+
SetUpScript: []string{
519+
"create table t (pk int primary key);",
520+
},
521+
Assertions: []ScriptTestAssertion{
522+
{
523+
Query: "alter table t add column c int CONSTRAINT chk_c check(c > 10);",
524+
Expected: []sql.Row{{types.NewOkResult(0)}},
525+
},
526+
{
527+
Query: "insert into t values (1, 9);",
528+
ExpectedErrStr: `Check constraint "chk_c" violated`,
529+
},
530+
},
531+
},
516532
{
517533
Name: "multi-alter ddl column errors",
518534
SetUpScript: []string{

0 commit comments

Comments
 (0)