Skip to content

Commit d7918e3

Browse files
authored
Merge pull request #918 from lib/revert-768-master
Revert "implement additional context specific sql interfaces"
2 parents a2bfbdf + 2e055ea commit d7918e3

File tree

3 files changed

+0
-70
lines changed

3 files changed

+0
-70
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
*.test
33
*~
44
*.swp
5-
.idea

conn.go

-4
Original file line numberDiff line numberDiff line change
@@ -1245,10 +1245,6 @@ func (st *stmt) Close() (err error) {
12451245
}
12461246

12471247
func (st *stmt) Query(v []driver.Value) (r driver.Rows, err error) {
1248-
return st.query(v)
1249-
}
1250-
1251-
func (st *stmt) query(v []driver.Value) (r *rows, err error) {
12521248
if st.cn.bad {
12531249
return nil, driver.ErrBadConn
12541250
}

conn_go18.go

-65
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ func (cn *conn) ExecContext(ctx context.Context, query string, args []driver.Nam
4242
return cn.Exec(query, list)
4343
}
4444

45-
// Implement the "ConnPrepareContext" interface
46-
func (cn *conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
47-
if finish := cn.watchCancel(ctx); finish != nil {
48-
defer finish()
49-
}
50-
return cn.Prepare(query)
51-
}
52-
5345
// Implement the "ConnBeginTx" interface
5446
func (cn *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
5547
var mode string
@@ -155,60 +147,3 @@ func (cn *conn) cancel(ctx context.Context) error {
155147
return err
156148
}
157149
}
158-
159-
// Implement the "StmtQueryContext" interface
160-
func (st *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
161-
list := make([]driver.Value, len(args))
162-
for i, nv := range args {
163-
list[i] = nv.Value
164-
}
165-
finish := st.watchCancel(ctx)
166-
r, err := st.query(list)
167-
if err != nil {
168-
if finish != nil {
169-
finish()
170-
}
171-
return nil, err
172-
}
173-
r.finish = finish
174-
return r, nil
175-
}
176-
177-
// Implement the "StmtExecContext" interface
178-
func (st *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
179-
list := make([]driver.Value, len(args))
180-
for i, nv := range args {
181-
list[i] = nv.Value
182-
}
183-
184-
if finish := st.watchCancel(ctx); finish != nil {
185-
defer finish()
186-
}
187-
188-
return st.Exec(list)
189-
}
190-
191-
func (st *stmt) watchCancel(ctx context.Context) func() {
192-
if done := ctx.Done(); done != nil {
193-
finished := make(chan struct{})
194-
go func() {
195-
select {
196-
case <-done:
197-
_ = st.cancel()
198-
finished <- struct{}{}
199-
case <-finished:
200-
}
201-
}()
202-
return func() {
203-
select {
204-
case <-finished:
205-
case finished <- struct{}{}:
206-
}
207-
}
208-
}
209-
return nil
210-
}
211-
212-
func (st *stmt) cancel() error {
213-
return st.cn.cancel()
214-
}

0 commit comments

Comments
 (0)