Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(659)

Delta Between Two Patch Sets: src/pkg/database/sql/sql.go

Issue 11620046: code review 11620046: database/sql: close statement before connection (Closed)
Left Patch Set: Created 10 years, 8 months ago
Right Patch Set: diff -r 977306015f5d https://go.googlecode.com/hg/ Created 10 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/database/sql/sql_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package sql provides a generic interface around SQL (or SQL-like) 5 // Package sql provides a generic interface around SQL (or SQL-like)
6 // databases. 6 // databases.
7 // 7 //
8 // The sql package must be used in conjunction with a database driver. 8 // The sql package must be used in conjunction with a database driver.
9 // See http://golang.org/s/sqldrivers for a list of drivers. 9 // See http://golang.org/s/sqldrivers for a list of drivers.
10 package sql 10 package sql
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 si, err := dc.ci.Prepare(query) 752 si, err := dc.ci.Prepare(query)
753 dc.Unlock() 753 dc.Unlock()
754 if err != nil { 754 if err != nil {
755 releaseConn(err) 755 releaseConn(err)
756 return nil, err 756 return nil, err
757 } 757 }
758 758
759 ds := driverStmt{dc, si} 759 ds := driverStmt{dc, si}
760 rowsi, err := rowsiFromStatement(ds, args...) 760 rowsi, err := rowsiFromStatement(ds, args...)
761 if err != nil { 761 if err != nil {
762 releaseConn(err)
763 dc.Lock() 762 dc.Lock()
764 si.Close() 763 si.Close()
765 dc.Unlock() 764 dc.Unlock()
765 releaseConn(err)
766 return nil, err 766 return nil, err
767 } 767 }
768 768
769 // Note: ownership of ci passes to the *Rows, to be freed 769 // Note: ownership of ci passes to the *Rows, to be freed
770 // with releaseConn. 770 // with releaseConn.
771 rows := &Rows{ 771 rows := &Rows{
772 dc: dc, 772 dc: dc,
773 releaseConn: releaseConn, 773 releaseConn: releaseConn,
774 rowsi: rowsi, 774 rowsi: rowsi,
775 closeStmt: si, 775 closeStmt: si,
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 var buf [2 << 10]byte 1462 var buf [2 << 10]byte
1463 return string(buf[:runtime.Stack(buf[:], false)]) 1463 return string(buf[:runtime.Stack(buf[:], false)])
1464 } 1464 }
1465 1465
1466 // withLock runs while holding lk. 1466 // withLock runs while holding lk.
1467 func withLock(lk sync.Locker, fn func()) { 1467 func withLock(lk sync.Locker, fn func()) {
1468 lk.Lock() 1468 lk.Lock()
1469 fn() 1469 fn()
1470 lk.Unlock() 1470 lk.Unlock()
1471 } 1471 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b