GetSetWaitTimeout sets session wait_timeout to `WaitTimeout` unless it is larger.
(db QueryAble)
| 413 | |
| 414 | // GetSetWaitTimeout sets session wait_timeout to `WaitTimeout` unless it is larger. |
| 415 | func 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 | |
| 430 | func 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)) |
no test coverage detected