From 1b48aa072d1210c2ba315aeea18b57fddb634875 Mon Sep 17 00:00:00 2001 From: "hjwblog.com" Date: Thu, 28 Mar 2024 16:47:39 +0800 Subject: [PATCH] feat: prepare_stmt support ping (#6924) * feat: prepare_stmt support ping * feat: prepare_stmt tx support ping --- prepare_stmt.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/prepare_stmt.go b/prepare_stmt.go index c60b5db7..4d533885 100644 --- a/prepare_stmt.go +++ b/prepare_stmt.go @@ -182,6 +182,14 @@ func (db *PreparedStmtDB) QueryRowContext(ctx context.Context, query string, arg return &sql.Row{} } +func (db *PreparedStmtDB) Ping() error { + conn, err := db.GetDBConn() + if err != nil { + return err + } + return conn.Ping() +} + type PreparedStmtTX struct { Tx PreparedStmtDB *PreparedStmtDB @@ -242,3 +250,11 @@ func (tx *PreparedStmtTX) QueryRowContext(ctx context.Context, query string, arg } return &sql.Row{} } + +func (tx *PreparedStmtTX) Ping() error { + conn, err := tx.GetDBConn() + if err != nil { + return err + } + return conn.Ping() +}