OLD | NEW |
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 driver defines interfaces to be implemented by database | 5 // Package driver defines interfaces to be implemented by database |
6 // drivers as used by package sql. | 6 // drivers as used by package sql. |
7 // | 7 // |
8 // Most code should use package sql. | 8 // Most code should use package sql. |
9 package driver | 9 package driver |
10 | 10 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // size as the Columns() are wide. | 166 // size as the Columns() are wide. |
167 // | 167 // |
168 // The dest slice may be populated only with | 168 // The dest slice may be populated only with |
169 // a driver Value type, but excluding string. | 169 // a driver Value type, but excluding string. |
170 // All string values must be converted to []byte. | 170 // All string values must be converted to []byte. |
171 // | 171 // |
172 // Next should return io.EOF when there are no more rows. | 172 // Next should return io.EOF when there are no more rows. |
173 Next(dest []Value) error | 173 Next(dest []Value) error |
174 } | 174 } |
175 | 175 |
| 176 // ColumnsCounter may be optionally implemented by Rows if the number |
| 177 // of columns is known without building a slice of all column names. |
| 178 // If implemented, the number of columns of the result is inferred |
| 179 // from ColumnsCount instead of the length of the slice returned by |
| 180 // Columns. |
| 181 type ColumnsCounter interface { |
| 182 ColumnsCount() int |
| 183 } |
| 184 |
176 // Tx is a transaction. | 185 // Tx is a transaction. |
177 type Tx interface { | 186 type Tx interface { |
178 Commit() error | 187 Commit() error |
179 Rollback() error | 188 Rollback() error |
180 } | 189 } |
181 | 190 |
182 // RowsAffected implements Result for an INSERT or UPDATE operation | 191 // RowsAffected implements Result for an INSERT or UPDATE operation |
183 // which mutates a number of rows. | 192 // which mutates a number of rows. |
184 type RowsAffected int64 | 193 type RowsAffected int64 |
185 | 194 |
(...skipping 16 matching lines...) Expand all Loading... |
202 | 211 |
203 var _ Result = noRows{} | 212 var _ Result = noRows{} |
204 | 213 |
205 func (noRows) LastInsertId() (int64, error) { | 214 func (noRows) LastInsertId() (int64, error) { |
206 return 0, errors.New("no LastInsertId available after DDL statement") | 215 return 0, errors.New("no LastInsertId available after DDL statement") |
207 } | 216 } |
208 | 217 |
209 func (noRows) RowsAffected() (int64, error) { | 218 func (noRows) RowsAffected() (int64, error) { |
210 return 0, errors.New("no RowsAffected available after DDL statement") | 219 return 0, errors.New("no RowsAffected available after DDL statement") |
211 } | 220 } |
OLD | NEW |