Commit b9ebc675 authored by Russ Cox's avatar Russ Cox

database/sql/driver: document that Execer, Queryer need not be implemented

CL 21663 allowed drivers to implement ExecerContext without
also implementing Execer, and similarly QueryerContext without
Queryer, but it did not make that clear in the documentation.

This CL updates the documentation.

Change-Id: I9a4accaac32edfe255fe7c0b0907d4c1014322b4
Reviewed-on: https://go-review.googlesource.com/78129Reviewed-by: default avatarDaniel Theophanes <kardianos@gmail.com>
parent d0ce197c
...@@ -109,22 +109,23 @@ type Pinger interface { ...@@ -109,22 +109,23 @@ type Pinger interface {
// Execer is an optional interface that may be implemented by a Conn. // Execer is an optional interface that may be implemented by a Conn.
// //
// If a Conn does not implement Execer, the sql package's DB.Exec will // If a Conn implements neither ExecerContext nor Execer Execer,
// first prepare a query, execute the statement, and then close the // the sql package's DB.Exec will first prepare a query, execute the statement,
// statement. // and then close the statement.
// //
// Exec may return ErrSkip. // Exec may return ErrSkip.
// //
// Deprecated: Drivers should implement ExecerContext instead (or additionally). // Deprecated: Drivers should implement ExecerContext instead.
type Execer interface { type Execer interface {
Exec(query string, args []Value) (Result, error) Exec(query string, args []Value) (Result, error)
} }
// ExecerContext is an optional interface that may be implemented by a Conn. // ExecerContext is an optional interface that may be implemented by a Conn.
// //
// If a Conn does not implement ExecerContext, the sql package's DB.Exec will // If a Conn does not implement ExecerContext, the sql package's DB.Exec
// first prepare a query, execute the statement, and then close the // will fall back to Execer; if the Conn does not implement Execer either,
// statement. // DB.Exec will first prepare a query, execute the statement, and then
// close the statement.
// //
// ExecerContext may return ErrSkip. // ExecerContext may return ErrSkip.
// //
...@@ -135,22 +136,23 @@ type ExecerContext interface { ...@@ -135,22 +136,23 @@ type ExecerContext interface {
// Queryer is an optional interface that may be implemented by a Conn. // Queryer is an optional interface that may be implemented by a Conn.
// //
// If a Conn does not implement Queryer, the sql package's DB.Query will // If a Conn implements neither QueryerContext nor Queryer,
// first prepare a query, execute the statement, and then close the // the sql package's DB.Query will first prepare a query, execute the statement,
// statement. // and then close the statement.
// //
// Query may return ErrSkip. // Query may return ErrSkip.
// //
// Deprecated: Drivers should implement QueryerContext instead (or additionally). // Deprecated: Drivers should implement QueryerContext instead.
type Queryer interface { type Queryer interface {
Query(query string, args []Value) (Rows, error) Query(query string, args []Value) (Rows, error)
} }
// QueryerContext is an optional interface that may be implemented by a Conn. // QueryerContext is an optional interface that may be implemented by a Conn.
// //
// If a Conn does not implement QueryerContext, the sql package's DB.Query will // If a Conn does not implement QueryerContext, the sql package's DB.Query
// first prepare a query, execute the statement, and then close the // will fall back to Queryer; if the Conn does not implement Queryer either,
// statement. // DB.Query will first prepare a query, execute the statement, and then
// close the statement.
// //
// QueryerContext may return ErrSkip. // QueryerContext may return ErrSkip.
// //
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment