Skip to content

Commit 176b7f2

Browse files
committed
Merge branch 'main' of https://github.com/dolthub/go-mysql-server into angela/binding
2 parents 7ea932a + 11ef8b7 commit 176b7f2

File tree

143 files changed

+6832
-2766
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+6832
-2766
lines changed

enginetest/enginetests.go

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ func TestQueries(t *testing.T, harness Harness) {
7474
})
7575
}
7676

77+
for _, tt := range queries.FunctionQueryTests {
78+
t.Run(tt.Query, func(t *testing.T) {
79+
if sh, ok := harness.(SkippingHarness); ok {
80+
if sh.SkipQueryTest(tt.Query) {
81+
t.Skipf("Skipping query plan for %s", tt.Query)
82+
}
83+
}
84+
if IsServerEngine(e) && tt.SkipServerEngine {
85+
t.Skip("skipping for server engine")
86+
}
87+
TestQueryWithContext(t, ctx, e, harness, tt.Query, tt.Expected, tt.ExpectedColumns, nil, nil)
88+
})
89+
}
90+
7791
// TODO: move this into its own test method
7892
if keyless, ok := harness.(KeylessTableHarness); ok && keyless.SupportsKeylessTables() {
7993
for _, tt := range queries.KeylessQueries {
@@ -218,6 +232,17 @@ func TestQueriesPrepared(t *testing.T, harness Harness) {
218232
}
219233
})
220234

235+
t.Run("function query prepared tests", func(t *testing.T) {
236+
for _, tt := range queries.FunctionQueryTests {
237+
if tt.SkipPrepared {
238+
continue
239+
}
240+
t.Run(tt.Query, func(t *testing.T) {
241+
TestPreparedQueryWithEngine(t, harness, e, tt)
242+
})
243+
}
244+
})
245+
221246
t.Run("keyless prepared tests", func(t *testing.T) {
222247
harness.Setup(setup.MydbData, setup.KeylessData, setup.Keyless_idxData, setup.MytableData)
223248
for _, tt := range queries.KeylessQueries {
@@ -487,6 +512,7 @@ func TestReadOnlyDatabases(t *testing.T, harness ReadOnlyDatabaseHarness) {
487512

488513
for _, querySet := range [][]queries.QueryTest{
489514
queries.QueryTests,
515+
queries.FunctionQueryTests,
490516
queries.KeylessQueries,
491517
} {
492518
for _, tt := range querySet {
@@ -3346,19 +3372,15 @@ func TestDropDatabase(t *testing.T, harness Harness) {
33463372

33473373
func TestCreateForeignKeys(t *testing.T, harness Harness) {
33483374
harness.Setup(setup.MydbData, setup.MytableData)
3349-
e := mustNewEngine(t, harness)
3350-
defer e.Close()
33513375
for _, tt := range queries.CreateForeignKeyTests {
3352-
TestScriptWithEngine(t, e, harness, tt)
3376+
TestScript(t, harness, tt)
33533377
}
33543378
}
33553379

33563380
func TestDropForeignKeys(t *testing.T, harness Harness) {
33573381
harness.Setup(setup.MydbData, setup.MytableData)
3358-
e := mustNewEngine(t, harness)
3359-
defer e.Close()
33603382
for _, tt := range queries.DropForeignKeyTests {
3361-
TestScriptWithEngine(t, e, harness, tt)
3383+
TestScript(t, harness, tt)
33623384
}
33633385
}
33643386

@@ -4501,14 +4523,14 @@ func TestPreparedInsert(t *testing.T, harness Harness) {
45014523
Bindings: map[string]sqlparser.Expr{
45024524
"v1": mustBuildBindVariable([]byte{0x99, 0x98, 0x97}),
45034525
},
4504-
ExpectedErrStr: "invalid string for charset utf8mb4: '[153 152 151]'",
4526+
ExpectedErrStr: "Incorrect string value: '\\x99\\x98\\x97' for column 'v1' at row 1",
45054527
},
45064528
{
45074529
Query: "INSERT INTO test VALUES (?);",
45084530
Bindings: map[string]sqlparser.Expr{
45094531
"v1": mustBuildBindVariable(string([]byte{0x99, 0x98, 0x97})),
45104532
},
4511-
ExpectedErrStr: "invalid string for charset utf8mb4: '[153 152 151]'",
4533+
ExpectedErrStr: "Incorrect string value: '\\x99\\x98\\x97' for column 'v1' at row 1",
45124534
},
45134535
{
45144536
Query: "INSERT INTO test2 VALUES (?);",
@@ -6125,6 +6147,26 @@ func TestSQLLogicTests(t *testing.T, harness Harness) {
61256147
}
61266148
}
61276149

6150+
func TestTimeQueries(t *testing.T, harness Harness) {
6151+
// "America/Phoenix" is a non-UTC time zone that does not observe daylight savings time
6152+
phoenixTimeZone, _ := time.LoadLocation("America/Phoenix")
6153+
mockNow := time.Date(2025, time.July, 23, 9, 43, 21, 0, phoenixTimeZone)
6154+
for _, script := range queries.TimeQueryTests {
6155+
if sh, ok := harness.(SkippingHarness); ok {
6156+
if sh.SkipQueryTest(script.Name) {
6157+
t.Run(script.Name, func(t *testing.T) {
6158+
t.Skip(script.Name)
6159+
})
6160+
continue
6161+
}
6162+
}
6163+
sql.RunWithNowFunc(func() time.Time { return mockNow }, func() error {
6164+
TestScript(t, harness, script)
6165+
return nil
6166+
})
6167+
}
6168+
}
6169+
61286170
// ExecuteNode builds an iterator and then drains it.
61296171
// This is useful for populating actual row counts for `DESCRIBE ANALYZE`.
61306172
func ExecuteNode(ctx *sql.Context, engine QueryEngine, node sql.Node) error {

enginetest/evaluation.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ func WidenRow(t *testing.T, sch sql.Schema, row sql.Row) sql.Row {
852852
widened := make(sql.Row, len(row))
853853
for i, v := range row {
854854
if i < len(sch) && types.IsJSON(sch[i].Type) {
855-
widened[i] = widenJSONValues(v)
855+
widened[i] = widenJSONValues(t.Context(), v)
856856
continue
857857
}
858858

@@ -893,7 +893,7 @@ func widenValue(t *testing.T, v interface{}) (vw interface{}) {
893893
return vw
894894
}
895895

896-
func widenJSONValues(val interface{}) sql.JSONWrapper {
896+
func widenJSONValues(ctx context.Context, val interface{}) sql.JSONWrapper {
897897
if val == nil {
898898
return nil
899899
}
@@ -907,7 +907,7 @@ func widenJSONValues(val interface{}) sql.JSONWrapper {
907907
js = types.MustJSON(str)
908908
}
909909

910-
doc, err := js.ToInterface()
910+
doc, err := js.ToInterface(ctx)
911911
if err != nil {
912912
panic(err)
913913
}

enginetest/memory_engine_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ func TestSingleQuery(t *testing.T) {
156156
Expected: []sql.Row{{-1}},
157157
}
158158

159-
fmt.Sprintf("%v", test)
160159
harness := enginetest.NewMemoryHarness("", 1, testNumPartitions, true, nil)
161160
// harness.UseServer()
162161
harness.Setup(setup.MydbData, setup.NiltableData)
@@ -186,7 +185,6 @@ func TestSingleQueryPrepared(t *testing.T) {
186185
},
187186
}
188187

189-
fmt.Sprintf("%v", test)
190188
harness := enginetest.NewMemoryHarness("", 1, testNumPartitions, false, nil)
191189
harness.Setup(setup.KeylessSetup...)
192190
engine, err := harness.NewEngine(t)
@@ -1099,3 +1097,7 @@ func TestSQLLogicTestFiles(t *testing.T) {
10991097
}
11001098
logictest.RunTestFiles(h, paths...)
11011099
}
1100+
1101+
func TestTimeQueries(t *testing.T) {
1102+
enginetest.TestTimeQueries(t, enginetest.NewDefaultMemoryHarness())
1103+
}

0 commit comments

Comments
 (0)