Documentation ¶
Index ¶
- func MustSelectString(connection *DBConn, query string, whichConn ...int) string
- func MustSelectStringSlice(connection *DBConn, query string, whichConn ...int) []string
- func SelectString(connection *DBConn, query string, whichConn ...int) (string, error)
- func SelectStringSlice(connection *DBConn, query string, whichConn ...int) ([]string, error)
- func StringToSemVerRange(versionStr string) semver.Range
- type DBConn
- func (dbconn *DBConn) Begin(whichConn ...int) error
- func (dbconn *DBConn) Close()
- func (dbconn *DBConn) Commit(whichConn ...int) error
- func (dbconn *DBConn) Connect(numConns int, utilityMode ...bool) error
- func (dbconn *DBConn) ConnectInUtilityMode(numConns int) error
- func (dbconn *DBConn) Exec(query string, whichConn ...int) (sql.Result, error)
- func (dbconn *DBConn) ExecContext(queryContext context.Context, query string, whichConn ...int) (sql.Result, error)
- func (dbconn *DBConn) Get(destination interface{}, query string, whichConn ...int) error
- func (dbconn *DBConn) GetWithArgs(destination interface{}, query string, args ...interface{}) error
- func (dbconn *DBConn) MustBegin(whichConn ...int)
- func (dbconn *DBConn) MustCommit(whichConn ...int)
- func (dbconn *DBConn) MustConnect(numConns int)
- func (dbconn *DBConn) MustConnectInUtilityMode(numConns int)
- func (dbconn *DBConn) MustExec(query string, whichConn ...int)
- func (dbconn *DBConn) MustExecContext(queryContext context.Context, query string, whichConn ...int)
- func (dbconn *DBConn) MustRollback(whichConn ...int)
- func (dbconn *DBConn) Query(query string, whichConn ...int) (*sqlx.Rows, error)
- func (dbconn *DBConn) QueryWithArgs(query string, args ...interface{}) (*sqlx.Rows, error)
- func (dbconn *DBConn) Rollback(whichConn ...int) error
- func (dbconn *DBConn) Select(destination interface{}, query string, whichConn ...int) error
- func (dbconn *DBConn) SelectWithArgs(destination interface{}, query string, args ...interface{}) error
- func (dbconn *DBConn) ValidateConnNum(whichConn ...int) int
- type DBDriver
- type GPDBDriver
- type GPDBVersion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustSelectString ¶
* This is a convenience function for Select() when we're selecting a single * string that may be NULL or not exist. We can't use Get() because that * expects exactly one string and will panic if no rows are returned, even if * using a sql.NullString. * * SelectString calls SelectStringSlice and returns the first value instead of * calling QueryRowx because that function doesn't indicate if there were more * rows available to be returned, and we don't want to silently ignore that if * only one row was expected for a given query but multiple were returned.
func MustSelectStringSlice ¶
* This is a convenience function for Select() when we're selecting a single * column of strings that may be NULL. Select requires defining a struct for * each call, and this function uses the underlying sql functions instead of * sqlx functions to avoid needing to "SELECT [column] AS [struct field]" with * a generic struct or the like. * * It also gives a nicer error message in the event that a query is called with * multiple columns, where using a generic struct gives an opaque "missing * destination name" error.
func SelectString ¶
func SelectStringSlice ¶
func StringToSemVerRange ¶
Types ¶
type DBConn ¶
type DBConn struct { ConnPool []*sqlx.DB NumConns int Driver DBDriver User string DBName string Host string Port int Tx []*sqlx.Tx Version GPDBVersion }
* While the sqlx.DB struct (and indirectly the sql.DB struct) maintains its own * connection pool, there is no guarantee of session-level consistency between * queries and we require that level of control in some cases. Also, while * sql.Conn is a struct that represents a single session, there is no * sqlx.Conn equivalent we could use. * * Thus, DBConn maintains its own connection pool of sqlx.DBs (all set to have * exactly one database connection each) in an array, such that callers can * create NumConns goroutines and assign each an index from 0 to NumConns to * guarantee that each goroutine gets its own connection that exhibits single- * session behavior. The Exec, Select, and Get functions are set up to default * to the first connection (index 0), so the DBConn will still exhibit session- * like behavior if no connection is specified, and other functions that want to * execute in serial should pass in a 0 wherever a connection number is needed.
func (*DBConn) ConnectInUtilityMode ¶
func (*DBConn) ExecContext ¶
func (*DBConn) GetWithArgs ¶
func (*DBConn) MustCommit ¶
func (*DBConn) MustConnect ¶
func (*DBConn) MustConnectInUtilityMode ¶
func (*DBConn) MustExecContext ¶
func (*DBConn) MustRollback ¶
func (*DBConn) QueryWithArgs ¶
func (*DBConn) SelectWithArgs ¶
func (*DBConn) ValidateConnNum ¶
* Ensure there isn't a mismatch between the connection pool size and number of * jobs, and default to using the first connection if no number is given.
type GPDBDriver ¶
type GPDBDriver struct { }
type GPDBVersion ¶
func InitializeVersion ¶
func InitializeVersion(dbconn *DBConn) (dbversion GPDBVersion, err error)
func NewVersion ¶
func NewVersion(versionStr string) GPDBVersion
* This constructor is intended as a convenience function for testing and * setting defaults; the dbconn.Connect function will automatically initialize * the version of the database to which it is connecting. * * The versionStr argument here should be a semantic version in the form X.Y.Z, * not a GPDB version string like the one returned by "SELECT version()". If * an invalid semantic version is passed, that is considered programmer error * and the function will panic.
func (GPDBVersion) AtLeast ¶
func (dbversion GPDBVersion) AtLeast(targetVersion string) bool
func (GPDBVersion) Before ¶
func (dbversion GPDBVersion) Before(targetVersion string) bool
func (GPDBVersion) Is ¶
func (dbversion GPDBVersion) Is(targetVersion string) bool