LEFT | RIGHT |
(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 // | 10 // |
(...skipping 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 | 1497 |
1498 // Next prepares the next result row for reading with the Scan method. | 1498 // Next prepares the next result row for reading with the Scan method. |
1499 // It returns true on success, false if there is no next result row. | 1499 // It returns true on success, false if there is no next result row. |
1500 // Every call to Scan, even the first one, must be preceded by a call | 1500 // Every call to Scan, even the first one, must be preceded by a call |
1501 // to Next. | 1501 // to Next. |
1502 func (rs *Rows) Next() bool { | 1502 func (rs *Rows) Next() bool { |
1503 if rs.closed { | 1503 if rs.closed { |
1504 return false | 1504 return false |
1505 } | 1505 } |
1506 if rs.lastcols == nil { | 1506 if rs.lastcols == nil { |
1507 » » rs.lastcols = make([]driver.Value, len(rs.rowsi.Columns())) | 1507 » » if cc, ok := rs.rowsi.(driver.ColumnsCounter); ok { |
| 1508 » » » rs.lastcols = make([]driver.Value, cc.ColumnsCount()) |
| 1509 » » } else { |
| 1510 » » » rs.lastcols = make([]driver.Value, len(rs.rowsi.Columns(
))) |
| 1511 » » } |
1508 } | 1512 } |
1509 rs.lasterr = rs.rowsi.Next(rs.lastcols) | 1513 rs.lasterr = rs.rowsi.Next(rs.lastcols) |
1510 if rs.lasterr != nil { | 1514 if rs.lasterr != nil { |
1511 rs.Close() | 1515 rs.Close() |
1512 return false | 1516 return false |
1513 } | 1517 } |
1514 return true | 1518 return true |
1515 } | 1519 } |
1516 | 1520 |
1517 // Err returns the error, if any, that was encountered during iteration. | 1521 // Err returns the error, if any, that was encountered during iteration. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 var buf [2 << 10]byte | 1666 var buf [2 << 10]byte |
1663 return string(buf[:runtime.Stack(buf[:], false)]) | 1667 return string(buf[:runtime.Stack(buf[:], false)]) |
1664 } | 1668 } |
1665 | 1669 |
1666 // withLock runs while holding lk. | 1670 // withLock runs while holding lk. |
1667 func withLock(lk sync.Locker, fn func()) { | 1671 func withLock(lk sync.Locker, fn func()) { |
1668 lk.Lock() | 1672 lk.Lock() |
1669 fn() | 1673 fn() |
1670 lk.Unlock() | 1674 lk.Unlock() |
1671 } | 1675 } |
LEFT | RIGHT |