MCPcopy Create free account
hub / github.com/actiontech/dtle / GetSetWaitTimeout

Function GetSetWaitTimeout

driver/mysql/sql/sqlutils.go:415–428  ·  view source on GitHub ↗

GetSetWaitTimeout sets session wait_timeout to `WaitTimeout` unless it is larger.

(db QueryAble)

Source from the content-addressed store, hash-verified

413
414// GetSetWaitTimeout sets session wait_timeout to `WaitTimeout` unless it is larger.
415func GetSetWaitTimeout(db QueryAble) (originVal int, err error) {
416 row := db.QueryRowContext(context.TODO(), "select @@wait_timeout")
417 err = row.Scan(&originVal)
418 if err != nil {
419 return originVal, err
420 }
421 if originVal < WaitTimeout {
422 _, err = db.ExecContext(context.TODO(), fmt.Sprintf("set wait_timeout = %v", WaitTimeout))
423 if err != nil {
424 return originVal, err
425 }
426 }
427 return originVal, nil
428}
429
430func ShowCreateTable(ctx context.Context, db QueryAble, dbName, tbName string) (r string, err error) {
431 query := fmt.Sprintf("SHOW CREATE TABLE %s.%s", mysqlconfig.EscapeName(dbName), mysqlconfig.EscapeName(tbName))

Callers 2

mysqlDumpMethod · 0.92
CreateConnsFunction · 0.85

Calls 3

QueryRowContextMethod · 0.80
ScanMethod · 0.80
ExecContextMethod · 0.80

Tested by

no test coverage detected