@@ -225,7 +225,7 @@ func QueryRowsMap(db QueryAble, query string, on_row func(RowMap) error, args ..
225225 }
226226 }()
227227
228- rows , err := db .Query ( query , args ... )
228+ rows , err := db .QueryContext ( context . TODO (), query , args ... )
229229 defer rows .Close ()
230230 if err != nil && err != gosql .ErrNoRows {
231231 return err
@@ -236,23 +236,21 @@ func QueryRowsMap(db QueryAble, query string, on_row func(RowMap) error, args ..
236236
237237// from https://github.com/golang/go/issues/14468
238238type QueryAble interface {
239- Exec (query string , args ... interface {}) (gosql.Result , error )
240- Prepare (query string ) (* gosql.Stmt , error )
241- Query (query string , args ... interface {}) (* gosql.Rows , error )
242- QueryRow (query string , args ... interface {}) * gosql.Row
239+ ExecContext (ctx context.Context , query string , args ... interface {}) (gosql.Result , error )
240+ QueryContext (ctx context.Context , query string , args ... interface {}) (* gosql.Rows , error )
243241 QueryRowContext (ctx context.Context , query string , args ... interface {}) * gosql.Row
244242}
245243
246244func GetServerUUID (db QueryAble ) (result string , err error ) {
247- err = db .QueryRow ( `SELECT @@SERVER_UUID /*dtle*/` ).Scan (& result )
245+ err = db .QueryRowContext ( context . TODO (), `SELECT @@SERVER_UUID /*dtle*/` ).Scan (& result )
248246 if err != nil {
249247 return "" , err
250248 }
251249 return result , nil
252250}
253251
254252func ShowMasterStatus (db QueryAble ) * gosql.Row {
255- return db .QueryRow ( "show master status /*dtle*/" )
253+ return db .QueryRowContext ( context . TODO (), "show master status /*dtle*/" )
256254}
257255
258256// queryResultData returns a raw array of rows for a given query, optionally reading and returning column names
@@ -296,7 +294,7 @@ func ShowDatabases(db QueryAble) ([]string, error) {
296294 dbs := make ([]string , 0 )
297295
298296 // Get table list
299- rows , err := db .Query ( "SHOW DATABASES" )
297+ rows , err := db .QueryContext ( context . TODO (), "SHOW DATABASES" )
300298 if err != nil {
301299 return dbs , err
302300 }
@@ -341,7 +339,7 @@ func ShowTables(db QueryAble, dbName string, showType bool) (tables []*common.Ta
341339 query = fmt .Sprintf ("SHOW TABLES IN %s" , escapedDbName )
342340 }
343341 g .Logger .Debug ("ShowTables" , "query" , query )
344- rows , err := db .Query ( query )
342+ rows , err := db .QueryContext ( context . TODO (), query )
345343 if err != nil {
346344 return tables , err
347345 }
0 commit comments