API
#database/sql/driver
Xu 0.8.8 API
import: #database/sql/driver
counts: 7 fns, 0 methods, 6 types, 0 consts, 5 ifaces
Driver snapshot RowsResult plus Conn/Stmt/Tx/Driver.
struct NamedValue
pub struct NamedValue {
pub name string
pub ordinal int
pub value temp
}
Purpose
`database/sql/driver`. Value is Xu `temp` ( `driver.Value` = empty interface). Conn / Driver / Connector / Stmt / Tx are struct@ ( interfaces). Connector.Connect is `connect(&context.Context)` (borrowed context). reset_session / is_valid are SessionResetter / Validator (closed-world Conn has no optional interfaces). has no iface defer (Driver would name Connector and vice versa). Same concrete type implements Driver and Connector; call open_db. Exec/Query take `[]NamedValue` like QueryerContext/ExecerContext (closed-world struct@ has no optional Queryer). Boxed methods cannot `>>` (dynamic dispatch is not may_throw), so outcomes carry `err`. v1 query path is a concrete snapshot `RowsResult` (columns + flat cells + ncols + err), not streaming `driver.Rows`. sql.Rows iterates the snapshot; ColumnType* defaults live in the sql layer. itables were the C8 known-fail.) Declare result structs and Stmt/Tx before Conn/Driver so method
Parameters
name string- name
ordinal int- field (int)
value temp- field (temp)
struct ExecResult
pub struct ExecResult {
pub last_insert_id int
pub rows_affected int
pub err string
}
Purpose
Public struct `ExecResult`.
Parameters
last_insert_id int- field (int)
rows_affected int- field (int)
err string- error
struct RowsResult
pub struct RowsResult {
pub columns []string
pub cells []string
pub ncols int
pub err string
}
Purpose
Public struct `RowsResult`.
Parameters
columns []string- field ([]string)
cells []string- field ([]string)
ncols int- field (int)
err string- error
struct Number
pub struct Number {
pub n int
pub ok bool
}
Purpose
Public struct `Number`.
Parameters
n int- count, length, or limit
ok bool- field (bool)
struct NullInfo
pub struct NullInfo {
pub nullable bool
pub ok bool
}
Purpose
Public struct `NullInfo`.
Parameters
nullable bool- field (bool)
ok bool- field (bool)
struct DecimalSize
pub struct DecimalSize {
pub precision int
pub scale int
pub ok bool
}
Purpose
Public struct `DecimalSize`.
Parameters
precision int- field (int)
scale int- field (int)
ok bool- field (bool)
struct@ Stmt
struct@ Stmt {
fn num_input() int
fn exec([]NamedValue) ExecResult
fn query([]NamedValue) RowsResult
fn close() string
}
Purpose
Method-set constraint `Stmt`. Implementing types must provide the methods below. Not an interface value.
Parameters
num_input fn num_input() int- Method on `Stmt`: num input.
exec fn exec([]NamedValue) ExecResult- Call `exec` on `Stmt`.
query fn query([]NamedValue) RowsResult- Call `query` on `Stmt`.
close fn close() string- Method on `Stmt`: close the resource.
(Stmt) num_input
Purpose
Method on `Stmt`: num input.
Parameters
self Self- receiver Self (value receiver)
Returns
int — a value of this type
(Stmt) exec
fn exec([]NamedValue) ExecResult
Purpose
Call `exec` on `Stmt`.
Parameters
self Self- receiver Self (value receiver)
namedValue []NamedValue- namedValue ([]NamedValue)
Returns
ExecResult — a value of this type
(Stmt) query
fn query([]NamedValue) RowsResult
Purpose
Call `query` on `Stmt`.
Parameters
self Self- receiver Self (value receiver)
namedValue []NamedValue- namedValue ([]NamedValue)
Returns
RowsResult — a value of this type
(Stmt) close
Purpose
Method on `Stmt`: close the resource.
Parameters
self Self- receiver Self (value receiver)
Returns
string — result string
struct@ Tx
struct@ Tx {
fn commit() string
fn rollback() string
}
Purpose
Method-set constraint `Tx`. Implementing types must provide the methods below. Not an interface value.
Parameters
commit fn commit() string- Call `commit` on `Tx`.
rollback fn rollback() string- Call `rollback` on `Tx`.
(Tx) commit
Purpose
Call `commit` on `Tx`.
Parameters
self Self- receiver Self (value receiver)
Returns
string — result string
(Tx) rollback
Purpose
Call `rollback` on `Tx`.
Parameters
self Self- receiver Self (value receiver)
Returns
string — result string
struct@ Conn
struct@ Conn {
fn ping() string
fn exec(string, []NamedValue) ExecResult
fn query(string, []NamedValue) RowsResult
fn close() string
fn dup() Conn
fn prepare(string) Stmt
fn prepare_context(&context.Context, string) Stmt
fn begin() Tx
fn begin_tx(int, bool) Tx
fn reset_session(&context.Context) string
fn is_valid() bool
}
Purpose
Method-set constraint `Conn`. Implementing types must provide the methods below. Not an interface value.
Parameters
ping fn ping() string- Call `ping` on `Conn`.
exec fn exec(string, []NamedValue) ExecResult- Call `exec` on `Conn`.
query fn query(string, []NamedValue) RowsResult- Call `query` on `Conn`.
close fn close() string- Method on `Conn`: close the resource.
dup fn dup() Conn- Call `dup` on `Conn`.
prepare fn prepare(string) Stmt- Call `prepare` on `Conn`.
prepare_context fn prepare_context(&context.Context, string) Stmt- Method on `Conn`: prepare context.
begin fn begin() Tx- Call `begin` on `Conn`.
begin_tx fn begin_tx(int, bool) Tx- Method on `Conn`: begin tx.
reset_session fn reset_session(&context.Context) string- Method on `Conn`: reset session.
is_valid fn is_valid() bool- Method on `Conn`: whether it is valid.
(Conn) ping
Purpose
Call `ping` on `Conn`.
Parameters
self Self- receiver Self (value receiver)
Returns
string — result string
(Conn) exec
fn exec(string, []NamedValue) ExecResult
Purpose
Call `exec` on `Conn`.
Parameters
self Self- receiver Self (value receiver)
string string- string (string)
namedValue []NamedValue- namedValue ([]NamedValue)
Returns
ExecResult — a value of this type
(Conn) query
fn query(string, []NamedValue) RowsResult
Purpose
Call `query` on `Conn`.
Parameters
self Self- receiver Self (value receiver)
string string- string (string)
namedValue []NamedValue- namedValue ([]NamedValue)
Returns
RowsResult — a value of this type
(Conn) close
Purpose
Method on `Conn`: close the resource.
Parameters
self Self- receiver Self (value receiver)
Returns
string — result string
(Conn) dup
Purpose
Call `dup` on `Conn`.
Parameters
self Self- receiver Self (value receiver)
Returns
Conn — a value of this type
(Conn) prepare
Purpose
Call `prepare` on `Conn`.
Parameters
self Self- receiver Self (value receiver)
string string- string (string)
Returns
Stmt — a value of this type
(Conn) prepare_context
fn prepare_context(&context.Context, string) Stmt
Purpose
Method on `Conn`: prepare context.
Parameters
self Self- receiver Self (value receiver)
context &context.Context- context (borrowed; caller keeps it; type &context.Context)
string string- string (string)
Returns
Stmt — a value of this type
(Conn) begin
Purpose
Call `begin` on `Conn`.
Parameters
self Self- receiver Self (value receiver)
Returns
Tx — a value of this type
(Conn) begin_tx
fn begin_tx(int, bool) Tx
Purpose
Method on `Conn`: begin tx.
Parameters
self Self- receiver Self (value receiver)
int int- int (int)
bool bool- bool (bool)
Returns
Tx — a value of this type
(Conn) reset_session
fn reset_session(&context.Context) string
Purpose
Method on `Conn`: reset session.
Parameters
self Self- receiver Self (value receiver)
context &context.Context- context (borrowed; caller keeps it; type &context.Context)
Returns
string — result string
(Conn) is_valid
Purpose
Method on `Conn`: whether it is valid.
Parameters
self Self- receiver Self (value receiver)
Returns
bool — true or false
struct@ Driver
struct@ Driver {
fn open(string) Conn
fn dup() Driver
}
Purpose
Method-set constraint `Driver`. Implementing types must provide the methods below. Not an interface value.
Parameters
open fn open(string) Conn- Method on `Driver`: open.
dup fn dup() Driver- Call `dup` on `Driver`.
(Driver) open
Purpose
Method on `Driver`: open.
Parameters
self Self- receiver Self (value receiver)
string string- string (string)
Returns
Conn — a value of this type
(Driver) dup
Purpose
Call `dup` on `Driver`.
Parameters
self Self- receiver Self (value receiver)
Returns
Driver — a value of this type
struct@ Connector
struct@ Connector {
fn connect(&context.Context) Conn
fn driver() Driver
}
Purpose
Method-set constraint `Connector`. Implementing types must provide the methods below. Not an interface value.
Parameters
connect fn connect(&context.Context) Conn- Call `connect` on `Connector`.
driver fn driver() Driver- Call `driver` on `Connector`.
(Connector) connect
fn connect(&context.Context) Conn
Purpose
Call `connect` on `Connector`.
Parameters
self Self- receiver Self (value receiver)
context &context.Context- context (borrowed; caller keeps it; type &context.Context)
Returns
Conn — a value of this type
(Connector) driver
Purpose
Call `driver` on `Connector`.
Parameters
self Self- receiver Self (value receiver)
Returns
Driver — a value of this type
encode_value
pub fn encode_value(v temp) string
Purpose
Encode.
Parameters
v temp- value (temp)
Returns
string — result string
decode_value
pub fn decode_value(s string) temp
Purpose
Decode.
Parameters
s string- source string (string)
Returns
temp — a value of this type
exec_ok
pub fn exec_ok(id int, n int) ExecResult
Purpose
Exec ok.
Parameters
id int- id (int)
n int- count, length, or limit (int)
Returns
ExecResult — a value of this type
exec_err
pub fn exec_err(msg string) ExecResult
Purpose
Exec err.
Parameters
msg string- message (string)
Returns
ExecResult — a value of this type
rows_err
pub fn rows_err(msg string) RowsResult
Purpose
Rows err.
Parameters
msg string- message (string)
Returns
RowsResult — a value of this type
err_bad_conn
pub fn err_bad_conn() string
Purpose
`driver.ErrBadConn`. sql retries with a new connection.
Parameters
none
Returns
string — result string
is_bad_conn
pub fn is_bad_conn(msg string) bool
Purpose
Whether it is bad conn.
Parameters
msg string- message (string)
Returns
bool — true or false