Skip to content

Commit

Permalink
tests workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Jul 17, 2024
1 parent bccd231 commit f1776d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
2 changes: 1 addition & 1 deletion bulkerlib/implementations/sql/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (ch *ClickHouse) OpenTx(ctx context.Context) (*TxSQLAdapter, error) {
if err != nil {
return nil, fmt.Errorf("failed to open connection: %v", err)
}
db = NewConWithDB(sessionDb, c, sessionId)
db = NewConWithDB(sessionDb, c)
time.Sleep(1 * time.Second)
} else {
var err error
Expand Down
36 changes: 11 additions & 25 deletions bulkerlib/implementations/sql/tx_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,42 +179,28 @@ func (t *TxWrapper) Rollback() error {
}

type ConWithDB struct {
db *sql.DB
con *sql.Conn
sessionId string
db *sql.DB
con *sql.Conn
}

func NewConWithDB(db *sql.DB, con *sql.Conn, sessionId string) *ConWithDB {
fmt.Println("OPEN", sessionId)
return &ConWithDB{db: db, con: con, sessionId: sessionId}
func NewConWithDB(db *sql.DB, con *sql.Conn) *ConWithDB {
return &ConWithDB{db: db, con: con}
}

func (c *ConWithDB) ExecContext(ctx context.Context, query string, args ...any) (res sql.Result, err error) {
fmt.Println("START", c.sessionId, query)
res, err = c.con.ExecContext(ctx, query, args...)
fmt.Println("END", c.sessionId, query)
return
func (c *ConWithDB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) {
return c.con.ExecContext(ctx, query, args...)
}

func (c *ConWithDB) QueryContext(ctx context.Context, query string, args ...any) (res *sql.Rows, err error) {
fmt.Println("START", c.sessionId, query)
res, err = c.con.QueryContext(ctx, query, args...)
fmt.Println("END", c.sessionId, query)
return
func (c *ConWithDB) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) {
return c.con.QueryContext(ctx, query, args...)
}

func (c *ConWithDB) QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row {
fmt.Println("START", c.sessionId, query)
row := c.con.QueryRowContext(ctx, query, args...)
fmt.Println("END", c.sessionId, query)
return row
return c.con.QueryRowContext(ctx, query, args...)
}

func (c *ConWithDB) PrepareContext(ctx context.Context, query string) (res *sql.Stmt, err error) {
fmt.Println("START", c.sessionId, query)
res, err = c.con.PrepareContext(ctx, query)
fmt.Println("END", c.sessionId, query)
return
func (c *ConWithDB) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) {
return c.con.PrepareContext(ctx, query)
}

func (c *ConWithDB) Close() error {
Expand Down

0 comments on commit f1776d4

Please sign in to comment.