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)
- 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) 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) 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 DBType
- type GPDBDriver
- type GPDBVersion
- func (dbversion GPDBVersion) AtLeast(targetVersion string) bool
- func (dbversion GPDBVersion) Before(targetVersion string) bool
- func (srcVersion GPDBVersion) Equals(destVersion GPDBVersion) bool
- func (dbversion GPDBVersion) Is(targetVersion string) bool
- func (dbversion GPDBVersion) IsACBDB() bool
- func (dbversion GPDBVersion) IsCBDB() bool
- func (dbversion GPDBVersion) IsCBDBFamily() bool
- func (dbversion GPDBVersion) IsCBEDB() bool
- func (dbversion GPDBVersion) IsGPDB() bool
- func (dbversion GPDBVersion) IsHDW() bool
- func (dbversion GPDBVersion) IsPGSQL() bool
- func (dbversion *GPDBVersion) ParseVersionInfo(versionString string)
- func (dbversion GPDBVersion) StringToSemVerRange(versionStr string) semver.Range
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 ¶
Types ¶
type DBConn ¶
type DBConn struct {
ConnPool []*sqlx.DB
NumConns int
Driver DBDriver
User string
Password string // extra, vs go-common-go-lib DBConn
DBName string
Host string
Port int
Tx []*sqlx.Tx
Version GPDBVersion
}
DBConn -- changed
func NewDBConnWithPassword ¶
func (*DBConn) ExecContext ¶
func (*DBConn) GetWithArgs ¶
func (*DBConn) MustCommit ¶
func (*DBConn) MustConnect ¶
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 ¶
GPDBVersion represents version information for a database
func InitializeVersion ¶
func InitializeVersion(dbconn *DBConn) (dbversion GPDBVersion, err error)
InitializeVersion parses database version string and returns version information Version string samples for different databases:
HashData:
PostgreSQL 9.4.26 (Greenplum Database 6.20.0 build 9999) (HashData Warehouse 3.13.8 build 27594) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11), 64-bit compiled on Feb 10 2023 17:22:03
Cloudberry:
PostgreSQL 14.4 (Cloudberry Database 1.2.0 build commit:5b5ae3f8aa638786f01bbd08307b6474a1ba1997) on x86_64-pc-linux-gnu, compiled by gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11), 64-bit compiled on Feb 16 2023 23:44:39
Cloudberry Enterprise:
PostgreSQL 14.4 (Cloudberry Database 1.1.5 build dev) (HashData Enterprise 1.1.5 build dev) on aarch64-unknown-linux-gnu, compiled by gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11), 64-bit compiled on Feb 13 2025 14:37:41
Apache Cloudberry:
PostgreSQL 14.4 (Apache Cloudberry 2.0.0 build commit:a071e3f8aa638786f01bbd08307b6474a1ba7890) on x86_64-pc-linux-gnu, compiled by gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11), 64-bit compiled on Jun 10 2025 15:42:54
Greenplum:
PostgreSQL 12.12 (Greenplum Database 7.0.0 build commit:bf073b87c0bac9759631746dca1c4c895a304afb) on x86_64-pc-linux-gnu, compiled by gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11), 64-bit compiled on May 6 2023 16:12:25
PostgreSQL:
PostgreSQL 12.18 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0, 64-bit
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) Equals ¶
func (srcVersion GPDBVersion) Equals(destVersion GPDBVersion) bool
func (GPDBVersion) Is ¶
func (dbversion GPDBVersion) Is(targetVersion string) bool
func (GPDBVersion) IsACBDB ¶
func (dbversion GPDBVersion) IsACBDB() bool
func (GPDBVersion) IsCBDB ¶
func (dbversion GPDBVersion) IsCBDB() bool
func (GPDBVersion) IsCBDBFamily ¶
func (dbversion GPDBVersion) IsCBDBFamily() bool
func (GPDBVersion) IsCBEDB ¶
func (dbversion GPDBVersion) IsCBEDB() bool
func (GPDBVersion) IsGPDB ¶
func (dbversion GPDBVersion) IsGPDB() bool
func (GPDBVersion) IsHDW ¶
func (dbversion GPDBVersion) IsHDW() bool
func (GPDBVersion) IsPGSQL ¶
func (dbversion GPDBVersion) IsPGSQL() bool
func (*GPDBVersion) ParseVersionInfo ¶
func (dbversion *GPDBVersion) ParseVersionInfo(versionString string)
func (GPDBVersion) StringToSemVerRange ¶
func (dbversion GPDBVersion) StringToSemVerRange(versionStr string) semver.Range