mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Revert "database/sql: add driver.ResetSessioner and add pool support"
This reverts commit 2620ac3aea.
Reason for revert: broke all the builds.
Change-Id: I26fc09a13f5f80fa708de66c843442ff9d934694
Reviewed-on: https://go-review.googlesource.com/73050
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
parent
8c58900aeb
commit
3b9d947b2f
4 changed files with 25 additions and 214 deletions
|
|
@ -55,22 +55,6 @@ type fakeDriver struct {
|
|||
dbs map[string]*fakeDB
|
||||
}
|
||||
|
||||
type fakeConnector struct {
|
||||
name string
|
||||
|
||||
waiter func(context.Context)
|
||||
}
|
||||
|
||||
func (c *fakeConnector) Connect(context.Context) (driver.Conn, error) {
|
||||
conn, err := fdriver.Open(c.name)
|
||||
conn.(*fakeConn).waiter = c.waiter
|
||||
return conn, err
|
||||
}
|
||||
|
||||
func (c *fakeConnector) Driver() driver.Driver {
|
||||
return fdriver
|
||||
}
|
||||
|
||||
type fakeDB struct {
|
||||
name string
|
||||
|
||||
|
|
@ -123,16 +107,6 @@ type fakeConn struct {
|
|||
// bad connection tests; see isBad()
|
||||
bad bool
|
||||
stickyBad bool
|
||||
|
||||
skipDirtySession bool // tests that use Conn should set this to true.
|
||||
|
||||
// dirtySession tests ResetSession, true if a query has executed
|
||||
// until ResetSession is called.
|
||||
dirtySession bool
|
||||
|
||||
// The waiter is called before each query. May be used in place of the "WAIT"
|
||||
// directive.
|
||||
waiter func(context.Context)
|
||||
}
|
||||
|
||||
func (c *fakeConn) touchMem() {
|
||||
|
|
@ -324,9 +298,6 @@ func (c *fakeConn) isBad() bool {
|
|||
if c.stickyBad {
|
||||
return true
|
||||
} else if c.bad {
|
||||
if c.db == nil {
|
||||
return false
|
||||
}
|
||||
// alternate between bad conn and not bad conn
|
||||
c.db.badConn = !c.db.badConn
|
||||
return c.db.badConn
|
||||
|
|
@ -335,21 +306,6 @@ func (c *fakeConn) isBad() bool {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *fakeConn) isDirtyAndMark() bool {
|
||||
if c.skipDirtySession {
|
||||
return false
|
||||
}
|
||||
if c.currTx != nil {
|
||||
c.dirtySession = true
|
||||
return false
|
||||
}
|
||||
if c.dirtySession {
|
||||
return true
|
||||
}
|
||||
c.dirtySession = true
|
||||
return false
|
||||
}
|
||||
|
||||
func (c *fakeConn) Begin() (driver.Tx, error) {
|
||||
if c.isBad() {
|
||||
return nil, driver.ErrBadConn
|
||||
|
|
@ -381,14 +337,6 @@ func setStrictFakeConnClose(t *testing.T) {
|
|||
testStrictClose = t
|
||||
}
|
||||
|
||||
func (c *fakeConn) ResetSession(ctx context.Context) error {
|
||||
c.dirtySession = false
|
||||
if c.isBad() {
|
||||
return driver.ErrBadConn
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *fakeConn) Close() (err error) {
|
||||
drv := fdriver.(*fakeDriver)
|
||||
defer func() {
|
||||
|
|
@ -624,10 +572,6 @@ func (c *fakeConn) PrepareContext(ctx context.Context, query string) (driver.Stm
|
|||
stmt.cmd = cmd
|
||||
parts = parts[1:]
|
||||
|
||||
if c.waiter != nil {
|
||||
c.waiter(ctx)
|
||||
}
|
||||
|
||||
if stmt.wait > 0 {
|
||||
wait := time.NewTimer(stmt.wait)
|
||||
select {
|
||||
|
|
@ -718,9 +662,6 @@ func (s *fakeStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (d
|
|||
if s.c.stickyBad || (hookExecBadConn != nil && hookExecBadConn()) {
|
||||
return nil, driver.ErrBadConn
|
||||
}
|
||||
if s.c.isDirtyAndMark() {
|
||||
return nil, errors.New("session is dirty")
|
||||
}
|
||||
|
||||
err := checkSubsetTypes(s.c.db.allowAny, args)
|
||||
if err != nil {
|
||||
|
|
@ -833,9 +774,6 @@ func (s *fakeStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (
|
|||
if s.c.stickyBad || (hookQueryBadConn != nil && hookQueryBadConn()) {
|
||||
return nil, driver.ErrBadConn
|
||||
}
|
||||
if s.c.isDirtyAndMark() {
|
||||
return nil, errors.New("session is dirty")
|
||||
}
|
||||
|
||||
err := checkSubsetTypes(s.c.db.allowAny, args)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue