Documentation ¶
Overview ¶
Package pgutil contains utilities for postgres
Index ¶
- func ByteaArray(bytesArray [][]byte) *pgtype.ByteaArray
- func CheckApplicationName(s string, app string) (string, error)
- func ConnstrWithSchema(connstr, schema string) string
- func CreateRandomTestingSchemaName(n int) string
- func CreateSchema(ctx context.Context, db Execer, schema string) (err error)
- func DropSchema(ctx context.Context, db Execer, schema string) error
- func Float8Array(floats []float64) *pgtype.Float8Array
- func Int4Array(ints []int32) *pgtype.Int4Array
- func Int8Array(bigInts []int64) *pgtype.Int8Array
- func IsConstraintError(err error) bool
- func NodeIDArray(nodeIDs []storj.NodeID) *pgtype.ByteaArray
- func OpenUnique(ctx context.Context, connstr string, schemaPrefix string) (*dbutil.TempDatabase, error)
- func ParseSchemaFromConnstr(connstr string) (string, error)
- func QueryData(ctx context.Context, db dbschema.Queryer, schema *dbschema.Schema) (*dbschema.Data, error)
- func QuerySchema(ctx context.Context, db dbschema.Queryer) (*dbschema.Schema, error)
- func QuerySnapshot(ctx context.Context, db dbschema.Queryer) (*dbschema.Snapshot, error)
- func QuoteIdentifier(ident string) string
- func QuoteSchema(schema string) string
- func TextArray(stringSlice []string) *pgtype.TextArray
- func TimestampTZArray(timeSlice []time.Time) *pgtype.TimestamptzArray
- func UnquoteIdentifier(quotedIdent string) string
- type Execer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteaArray ¶ added in v1.8.1
func ByteaArray(bytesArray [][]byte) *pgtype.ByteaArray
ByteaArray returns an object usable by pg drivers for passing a [][]byte slice into a database as type BYTEA[].
func CheckApplicationName ¶
CheckApplicationName ensures that the Connection String contains an application name.
func ConnstrWithSchema ¶
ConnstrWithSchema adds schema to a connection string.
func CreateRandomTestingSchemaName ¶
CreateRandomTestingSchemaName creates a random schema name string.
func CreateSchema ¶
CreateSchema creates a schema if it doesn't exist.
func DropSchema ¶
DropSchema drops the named schema.
func Float8Array ¶ added in v1.8.1
func Float8Array(floats []float64) *pgtype.Float8Array
Float8Array returns an object usable by pg drivers for passing a []float64 slice into a database as type FLOAT8[].
func Int4Array ¶ added in v1.8.1
Int4Array returns an object usable by pg drivers for passing a []int32 slice into a database as type INT4[].
func Int8Array ¶ added in v1.8.1
Int8Array returns an object usable by pg drivers for passing a []int64 slice into a database as type INT8[].
func IsConstraintError ¶
IsConstraintError checks if given error is about constraint violation.
func NodeIDArray ¶ added in v1.8.1
func NodeIDArray(nodeIDs []storj.NodeID) *pgtype.ByteaArray
NodeIDArray returns an object usable by pg drivers for passing a []storj.NodeID slice into a database as type BYTEA[].
func OpenUnique ¶ added in v0.27.0
func OpenUnique(ctx context.Context, connstr string, schemaPrefix string) (*dbutil.TempDatabase, error)
OpenUnique opens a postgres database with a temporary unique schema, which will be cleaned up when closed. It is expected that this should normally be used by way of "storj.io/storj/private/dbutil/tempdb".OpenUnique() instead of calling it directly.
func ParseSchemaFromConnstr ¶
ParseSchemaFromConnstr returns the name of the schema parsed from the connection string if one is provided.
func QueryData ¶
func QueryData(ctx context.Context, db dbschema.Queryer, schema *dbschema.Schema) (*dbschema.Data, error)
QueryData loads all data from tables.
func QuerySchema ¶
QuerySchema loads the schema from postgres database.
func QuerySnapshot ¶
QuerySnapshot loads snapshot from database.
func QuoteIdentifier ¶ added in v1.8.1
QuoteIdentifier quotes an identifier for use in an interpolated SQL string.
func TextArray ¶ added in v1.14.1
TextArray returns an object usable by pg drivers for passing a []string slice into a database as type TEXT[].
func TimestampTZArray ¶ added in v1.8.1
func TimestampTZArray(timeSlice []time.Time) *pgtype.TimestamptzArray
TimestampTZArray returns an object usable by pg drivers for passing a []time.Time slice into a database as type TIMESTAMPTZ[].
func UnquoteIdentifier ¶ added in v0.27.0
UnquoteIdentifier is the analog of QuoteIdentifier.