@@ -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
33473373func 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
33563380func 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`.
61306172func ExecuteNode (ctx * sql.Context , engine QueryEngine , node sql.Node ) error {
0 commit comments