Skip to content

Commit 936af39

Browse files
authored
fix: when using queryContext, it will cause the transaction to fail (#810)
remmove queryContxt
1 parent ff0f0a7 commit 936af39

File tree

1 file changed

+0
-40
lines changed

1 file changed

+0
-40
lines changed

pkg/datasource/sql/conn_at.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -43,46 +43,6 @@ func (c *ATConn) PrepareContext(ctx context.Context, query string) (driver.Stmt,
4343
return c.Conn.PrepareContext(ctx, query)
4444
}
4545

46-
// QueryContext
47-
func (c *ATConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
48-
if c.createOnceTxContext(ctx) {
49-
defer func() {
50-
c.txCtx = types.NewTxCtx()
51-
}()
52-
}
53-
54-
ret, err := c.createNewTxOnExecIfNeed(ctx, func() (types.ExecResult, error) {
55-
executor, err := exec.BuildExecutor(c.res.dbType, c.txCtx.TransactionMode, query)
56-
if err != nil {
57-
return nil, err
58-
}
59-
60-
execCtx := &types.ExecContext{
61-
TxCtx: c.txCtx,
62-
Query: query,
63-
NamedValues: args,
64-
Conn: c.targetConn,
65-
DBName: c.dbName,
66-
DbVersion: c.GetDbVersion(),
67-
IsSupportsSavepoints: true,
68-
IsAutoCommit: c.GetAutoCommit(),
69-
}
70-
71-
return executor.ExecWithNamedValue(ctx, execCtx,
72-
func(ctx context.Context, query string, args []driver.NamedValue) (types.ExecResult, error) {
73-
ret, err := c.Conn.QueryContext(ctx, query, args)
74-
if err != nil {
75-
return nil, err
76-
}
77-
return types.NewResult(types.WithRows(ret)), nil
78-
})
79-
})
80-
if err != nil {
81-
return nil, err
82-
}
83-
return ret.GetRows(), nil
84-
}
85-
8646
// ExecContext
8747
func (c *ATConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
8848
if c.createOnceTxContext(ctx) {

0 commit comments

Comments
 (0)