aboutsummaryrefslogtreecommitdiff
path: root/src/database
diff options
context:
space:
mode:
authorDaniel Theophanes <kardianos@gmail.com>2020-04-27 09:48:42 -0700
committerDaniel Theophanes <kardianos@gmail.com>2020-04-27 17:36:02 +0000
commit1518123114d12d852d92793bd986e8856ac13e25 (patch)
tree46901dfea7b4b3df189b6feda214fe131eb86252 /src/database
parenta3374fa0f8ffe27d3a1e118b75b484ce56c7af2e (diff)
downloadgo-1518123114d12d852d92793bd986e8856ac13e25.tar.gz
go-1518123114d12d852d92793bd986e8856ac13e25.zip
database/sql/driver: enhance driver package documentation
Change-Id: I455acdb71354f14e0bc4104cbd7abd5c89958dd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/230214 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/database')
-rw-r--r--src/database/sql/driver/driver.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/database/sql/driver/driver.go b/src/database/sql/driver/driver.go
index 76f1bd3aa1..928b308d19 100644
--- a/src/database/sql/driver/driver.go
+++ b/src/database/sql/driver/driver.go
@@ -6,6 +6,35 @@
// drivers as used by package sql.
//
// Most code should use package sql.
+//
+// The driver interface has evolved over time. Drivers should implement
+// Connector and DriverContext interfaces.
+// The Connector.Connect and Driver.Open methods should never return ErrBadConn.
+// ErrBadConn should only be returned from Validator, SessionResetter, or
+// a query method if the connection is already in an invalid (e.g. closed) state.
+//
+// All Conn implementations should implement the following interfaces:
+// Pinger, SessionResetter, and Validator.
+//
+// If named parameters or context are supported, the driver's Conn should implement:
+// ExecerContext, QueryerContext, ConnPrepareContext, and ConnBeginTx.
+//
+// To support custom data types, implement NamedValueChecker. NamedValueChecker
+// also allows queries to accept per-query options as a parameter by returning
+// ErrRemoveArgument from CheckNamedValue.
+//
+// If multiple result sets are supported, Rows should implement RowsNextResultSet.
+// If the driver knows how to describe the types present in the returned result
+// it should implement the following interfaces: RowsColumnTypeScanType,
+// RowsColumnTypeDatabaseTypeName, RowsColumnTypeLength, RowsColumnTypeNullable,
+// and RowsColumnTypePrecisionScale. A given row value may also return a Rows
+// type, which may represent a database cursor value.
+//
+// Before a connection is returned to the connection pool after use, IsValid is
+// called if implemented. Before a connection is reused for another query,
+// ResetSession is called if implemented. If a connection is never returned to the
+// connection pool but immediately reused, then ResetSession is called prior to
+// reuse but IsValid is not called.
package driver
import (