@@ -412,7 +412,7 @@ func testQueryWithContext(
412412 require .NoError (err , "Unexpected error for query %s: %s" , q , err )
413413
414414 if expected != nil {
415- checkResults (t , harness , expected , expectedCols , sch , rows , q , e , wrapBehavior )
415+ checkResults (t , ctx , harness , expected , expectedCols , sch , rows , q , e , wrapBehavior )
416416 }
417417
418418 require .Equal (
@@ -455,7 +455,7 @@ func TestQueryWithIndexCheck(t *testing.T, ctx *sql.Context, e QueryEngine, harn
455455 require .NoError (err , "Unexpected error for query %s: %s" , q , err )
456456
457457 if expected != nil {
458- CheckResults (t , harness , expected , expectedCols , sch , rows , q , e )
458+ CheckResults (ctx , t , harness , expected , expectedCols , sch , rows , q , e )
459459 }
460460
461461 require .Equal (
@@ -514,41 +514,22 @@ func TestPreparedQueryWithContext(t *testing.T, ctx *sql.Context, e QueryEngine,
514514
515515 if expected != nil {
516516 // TODO fix expected cols for prepared?
517- CheckResults (t , h , expected , expectedCols , sch , rows , q , e )
517+ CheckResults (ctx , t , h , expected , expectedCols , sch , rows , q , e )
518518 }
519519
520520 require .Equal (0 , ctx .Memory .NumCaches ())
521521 validateEngine (t , ctx , h , e )
522522}
523523
524- func CheckResults (
525- t * testing.T ,
526- h Harness ,
527- expected []sql.Row ,
528- expectedCols []* sql.Column ,
529- sch sql.Schema ,
530- rows []sql.Row ,
531- q string ,
532- e QueryEngine ,
533- ) {
534- checkResults (t , h , expected , expectedCols , sch , rows , q , e , queries .WrapBehavior_Unwrap )
524+ func CheckResults (ctx * sql.Context , t * testing.T , h Harness , expected []sql.Row , expectedCols []* sql.Column , sch sql.Schema , rows []sql.Row , q string , e QueryEngine ) {
525+ checkResults (t , ctx , h , expected , expectedCols , sch , rows , q , e , queries .WrapBehavior_Unwrap )
535526}
536527
537- func checkResults (
538- t * testing.T ,
539- h Harness ,
540- expected []sql.Row ,
541- expectedCols []* sql.Column ,
542- sch sql.Schema ,
543- rows []sql.Row ,
544- q string ,
545- e QueryEngine ,
546- wrapBehavior queries.WrapBehavior ,
547- ) {
528+ func checkResults (t * testing.T , ctx * sql.Context , h Harness , expected []sql.Row , expectedCols []* sql.Column , sch sql.Schema , rows []sql.Row , q string , e QueryEngine , wrapBehavior queries.WrapBehavior ) {
548529 if reh , ok := h .(ResultEvaluationHarness ); ok {
549530 reh .EvaluateQueryResults (t , expected , expectedCols , sch , rows , q , wrapBehavior )
550531 } else {
551- checkResultsDefault (t , expected , expectedCols , sch , rows , q , e , wrapBehavior )
532+ checkResultsDefault (t , ctx , expected , expectedCols , sch , rows , q , e , wrapBehavior )
552533 }
553534}
554535
@@ -688,7 +669,7 @@ type CustomValueValidator interface {
688669// toSQL converts the given expected value into appropriate type of given column.
689670// |isZeroTime| is true if the query is any `SHOW` statement, except for `SHOW EVENTS`.
690671// This is set earlier in `checkResult()` method.
691- func toSQL (c * sql.Column , expected any , isZeroTime bool ) (any , error ) {
672+ func toSQL (ctx * sql. Context , c * sql.Column , expected any , isZeroTime bool ) (any , error ) {
692673 _ , isTime := expected .(time.Time )
693674 _ , isStr := expected .(string )
694675 // cases where we don't want the result value to be converted
@@ -705,16 +686,7 @@ func toSQL(c *sql.Column, expected any, isZeroTime bool) (any, error) {
705686// don't implement ResultEvaluationHarness. All numerical values are widened to their widest type before comparison.
706687// Based on the value of |unwrapValues|, this either normalized wrapped values by unwrapping them, or replaces them
707688// with their hash so the test caller can assert that the values are wrapped and have a certain hash.
708- func checkResultsDefault (
709- t * testing.T ,
710- expected []sql.Row ,
711- expectedCols []* sql.Column ,
712- sch sql.Schema ,
713- rows []sql.Row ,
714- q string ,
715- e QueryEngine ,
716- wrapBehavior queries.WrapBehavior ,
717- ) {
689+ func checkResultsDefault (t * testing.T , ctx * sql.Context , expected []sql.Row , expectedCols []* sql.Column , sch sql.Schema , rows []sql.Row , q string , e QueryEngine , wrapBehavior queries.WrapBehavior ) {
718690 widenedRows := WidenRows (t , sch , rows )
719691 widenedExpected := WidenRows (t , sch , expected )
720692
@@ -804,7 +776,7 @@ func checkResultsDefault(
804776 } else {
805777 // this attempts to do what `rowToSQL()` method in `handler.go` on expected row
806778 // because over the wire values gets converted to SQL values depending on the column types.
807- convertedExpected , err := toSQL (sch [j ], widenedExpected [i ][j ], setZeroTime )
779+ convertedExpected , err := toSQL (ctx , sch [j ], widenedExpected [i ][j ], setZeroTime )
808780 require .NoError (t , err )
809781 widenedExpected [i ][j ] = convertedExpected
810782 }
@@ -1120,7 +1092,7 @@ func AssertWarningAndTestQuery(
11201092 }
11211093
11221094 if ! skipResultsCheck {
1123- CheckResults (t , harness , expected , expectedCols , sch , rows , query , e )
1095+ CheckResults (ctx , t , harness , expected , expectedCols , sch , rows , query , e )
11241096 }
11251097 validateEngine (t , ctx , harness , e )
11261098}
0 commit comments