Documentation
¶
Index ¶
- func GetConn(conn interface{}) (sdk.Conn, error)
- func NewConnector(connContext *bytehouse.ConnectionContext, dsn string) (driver.Connector, error)
- func RunConn(ctx context.Context, db *sql.DB, callback func(conn sdk.Conn) error) error
- type CHConn
- func (c *CHConn) Begin() (driver.Tx, error)
- func (c *CHConn) CheckNamedValue(nv *driver.NamedValue) error
- func (c *CHConn) Close() error
- func (c *CHConn) Commit() error
- func (c *CHConn) Exec(query string, args []driver.Value) (driver.Result, error)
- func (c *CHConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *CHConn) Ping(ctx context.Context) error
- func (c *CHConn) Prepare(query string) (driver.Stmt, error)
- func (c *CHConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
- func (c *CHConn) Query(query string, args []driver.Value) (driver.Rows, error)
- func (c *CHConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- func (c *CHConn) ResetSession(ctx context.Context) error
- func (c *CHConn) Rollback() error
- type GatewayDriver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConnector ¶
NewConnector returns new driver.Connector.
Types ¶
type CHConn ¶
CHConn implements Conn interface from database/sql library
func (*CHConn) CheckNamedValue ¶
func (c *CHConn) CheckNamedValue(nv *driver.NamedValue) error
NamedValueChecker may be optionally implemented by CHConn or Stmt. It provides the driver more control to handle Go and database types beyond the default Values types allowed.
The sql package checks for value checkers in the following order, stopping at the first found match: Stmt.NamedValueChecker, CHConn.NamedValueChecker, Stmt.ColumnConverter, DefaultParameterConverter.
If CheckNamedValue returns ErrRemoveArgument, the NamedValue will not be included in the final query arguments. This may be used to pass special options to the query itself.
If ErrSkip is returned the column converter error checking path is used for the argument. Drivers may wish to return ErrSkip after they have exhausted their own special cases.
CheckNamedValue is called before passing arguments to the driver and is called in place of any ColumnConverter. CheckNamedValue must do type validation and conversion as appropriate for the driver.
func (*CHConn) Close ¶
Close invalidates and potentially stops any current prepared statements and transactions, marking this connection as no longer in use.
Because the sql package maintains a free pool of connections and only calls Close when there's a surplus of idle connections, it shouldn't be necessary for drivers to do their own connection caching.
Drivers must ensure all network calls made by Close do not block indefinitely (e.g. apply a timeout).
func (*CHConn) ExecContext ¶
func (*CHConn) Ping ¶
Ping implements Pinger interface If CHConn.Ping returns ErrBadConn, DB.Ping and DB.PingContext will remove the CHConn from pool.
func (*CHConn) PrepareContext ¶
func (*CHConn) QueryContext ¶
func (c *CHConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
QueryContext runs a query and returns it's results
func (*CHConn) ResetSession ¶
ResetSession is called prior to executing a query on the connection if the connection has been used before. If the driver returns ErrBadConn the connection is discarded.
type GatewayDriver ¶
type GatewayDriver struct{}
GatewayDriver implements the sql Driver interface See https://golang.org/pkg/database/sql/driver/#Driver
func (GatewayDriver) Open ¶
func (d GatewayDriver) Open(dsn string) (driver.Conn, error)
Open returns a new connection to the database. The name is a string in a driver-specific format.
OpenConfig may return a cached connection (one previously closed), but doing so is unnecessary; the sql package maintains a pool of idle connections for efficient re-use.
The returned connection is only used by one goroutine at a time.
func (GatewayDriver) OpenConnector ¶
func (d GatewayDriver) OpenConnector(dsn string) (driver.Connector, error)
OpenConnector implements driver.DriverContext. sql.DB will call OpenConnector to obtain a Connector and then invoke that Connector's Connect method to obtain each needed connection, instead of invoking the Driver's OpenConfig method for each connection. The two-step sequence allows drivers to parse the name just once and also provides access to per-Conn contexts.