Documentation ¶
Overview ¶
Package pgutil contains utilities for postgres
Index ¶
- func CheckApplicationName(s string) (r string)
- func ConnstrWithSchema(connstr, schema string) string
- func CreateRandomTestingSchemaName(n int) string
- func CreateSchema(db Execer, schema string) (err error)
- func DropSchema(db Execer, schema string) error
- func IsConstraintError(err error) bool
- func OpenUnique(connstr string, schemaPrefix string) (*dbutil.TempDatabase, error)
- func ParseSchemaFromConnstr(connstr string) (string, error)
- func QueryData(db dbschema.Queryer, schema *dbschema.Schema) (*dbschema.Data, error)
- func QuerySchema(db dbschema.Queryer) (*dbschema.Schema, error)
- func QuerySnapshot(db dbschema.Queryer) (*dbschema.Snapshot, error)
- func QuoteSchema(schema string) string
- func UnquoteIdentifier(quotedIdent string) string
- type Execer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 IsConstraintError ¶
IsConstraintError checks if given error is about constraint violation
func OpenUnique ¶ added in v0.27.0
func OpenUnique(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 QuerySchema ¶
QuerySchema loads the schema from postgres database.
func QuerySnapshot ¶
QuerySnapshot loads snapshot from database
func UnquoteIdentifier ¶ added in v0.27.0
UnquoteIdentifier is the analog of pq.QuoteIdentifier.