Documentation
¶
Index ¶
- Constants
- func AlterDatabaseOwner(pgpool PGPoolInterface, database, owner string) (err error)
- func AlterRole(pgpool PGPoolInterface, role *Role) (err error)
- func AlterSchemaOwner(pgpool PGPoolInterface, schema, owner string) (err error)
- func CreateDatabase(pgpool PGPoolInterface, database string) (err error)
- func CreateExtension(pgpool PGPoolInterface, name string) (err error)
- func CreateRole(pgpool PGPoolInterface, role *Role) (err error)
- func CreateSchema(pgpool PGPoolInterface, name string) (err error)
- func DropDatabase(pgpool PGPoolInterface, database string) (err error)
- func DropDatabaseConnections(pgpool PGPoolInterface, name string) (err error)
- func DropExtension(pgpool PGPoolInterface, name string) (err error)
- func DropRole(pgpool PGPoolInterface, name string) (err error)
- func DropSchema(pgpool PGPoolInterface, name string) (err error)
- func EnsurePGPoolExists(pgpools *PGPools, database string) (err error)
- func GetDatabaseRolePrivileges(pgpool PGPoolInterface, database, role string) (existingPrivileges []string, err error)
- func GetExtensions(pgpool PGPoolInterface) (extensions []string, err error)
- func GetRoleMembership(pgpool PGPoolInterface, role string) (membership []string, err error)
- func GetSchemaRolePrivileges(pgpool PGPoolInterface, schema, role string) (existingPrivileges []string, err error)
- func GrantDatabaseRolePrivilege(pgpool PGPoolInterface, database, role, privilege string) (err error)
- func GrantRoleMembership(pgpool PGPoolInterface, groupRole, role string) (err error)
- func GrantSchemaRolePrivilege(pgpool PGPoolInterface, schema, role, privilege string) (err error)
- func ListDatabaseAvailablePrivileges() []string
- func ListSchemaAvailablePrivileges() []string
- func RevokeDatabaseRolePrivilege(pgpool PGPoolInterface, database, role, privilege string) (err error)
- func RevokeRoleMembership(pgpool PGPoolInterface, groupRole, role string) (err error)
- func RevokeSchemaRolePrivilege(pgpool PGPoolInterface, schema, role, privilege string) (err error)
- type Database
- type PGPoolInterface
- type PGPools
- type Role
- type Schema
Constants ¶
View Source
const GetDatabaseSQLStatement = "SELECT d.datname, pg_catalog.pg_get_userbyid(d.datdba) as owner FROM pg_catalog.pg_database d WHERE d.datname = $1"
View Source
const GetRoleMembershipStatement = "SELECT roleid::regrole::text AS group_role FROM pg_auth_members WHERE member::regrole::text = $1"
View Source
const GetRoleSQLStatement = "" /* 140-byte string literal not displayed */
View Source
const GetSchemaSQLStatement = "SELECT schema_name as name, schema_owner as owner FROM information_schema.schemata WHERE schema_name = $1"
Variables ¶
This section is empty.
Functions ¶
func AlterDatabaseOwner ¶
func AlterDatabaseOwner(pgpool PGPoolInterface, database, owner string) (err error)
func AlterRole ¶
func AlterRole(pgpool PGPoolInterface, role *Role) (err error)
func AlterSchemaOwner ¶
func AlterSchemaOwner(pgpool PGPoolInterface, schema, owner string) (err error)
func CreateDatabase ¶
func CreateDatabase(pgpool PGPoolInterface, database string) (err error)
func CreateExtension ¶
func CreateExtension(pgpool PGPoolInterface, name string) (err error)
func CreateRole ¶
func CreateRole(pgpool PGPoolInterface, role *Role) (err error)
func CreateSchema ¶
func CreateSchema(pgpool PGPoolInterface, name string) (err error)
func DropDatabase ¶
func DropDatabase(pgpool PGPoolInterface, database string) (err error)
func DropDatabaseConnections ¶
func DropDatabaseConnections(pgpool PGPoolInterface, name string) (err error)
func DropExtension ¶
func DropExtension(pgpool PGPoolInterface, name string) (err error)
func DropRole ¶
func DropRole(pgpool PGPoolInterface, name string) (err error)
func DropSchema ¶
func DropSchema(pgpool PGPoolInterface, name string) (err error)
func EnsurePGPoolExists ¶
func GetDatabaseRolePrivileges ¶
func GetDatabaseRolePrivileges(pgpool PGPoolInterface, database, role string) (existingPrivileges []string, err error)
func GetExtensions ¶
func GetExtensions(pgpool PGPoolInterface) (extensions []string, err error)
func GetRoleMembership ¶
func GetRoleMembership(pgpool PGPoolInterface, role string) (membership []string, err error)
func GetSchemaRolePrivileges ¶
func GetSchemaRolePrivileges(pgpool PGPoolInterface, schema, role string) (existingPrivileges []string, err error)
func GrantDatabaseRolePrivilege ¶
func GrantDatabaseRolePrivilege(pgpool PGPoolInterface, database, role, privilege string) (err error)
func GrantRoleMembership ¶
func GrantRoleMembership(pgpool PGPoolInterface, groupRole, role string) (err error)
func GrantSchemaRolePrivilege ¶
func GrantSchemaRolePrivilege(pgpool PGPoolInterface, schema, role, privilege string) (err error)
func ListDatabaseAvailablePrivileges ¶
func ListDatabaseAvailablePrivileges() []string
func ListSchemaAvailablePrivileges ¶
func ListSchemaAvailablePrivileges() []string
func RevokeDatabaseRolePrivilege ¶
func RevokeDatabaseRolePrivilege(pgpool PGPoolInterface, database, role, privilege string) (err error)
func RevokeRoleMembership ¶
func RevokeRoleMembership(pgpool PGPoolInterface, groupRole, role string) (err error)
func RevokeSchemaRolePrivilege ¶
func RevokeSchemaRolePrivilege(pgpool PGPoolInterface, schema, role, privilege string) (err error)
Types ¶
type Database ¶
type Database struct {
Name string `db:"datname"`
Owner string `db:"owner"`
Extensions []string `db:"-"`
}
func GetDatabase ¶
func GetDatabase(pgpool PGPoolInterface, name string) (database *Database, err error)
type PGPoolInterface ¶
type PGPoolInterface interface {
Acquire(ctx context.Context) (c *pgxpool.Conn, err error)
Begin(ctx context.Context) (pgx.Tx, error)
BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
Close()
Config() *pgxpool.Config
Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)
}
type PGPools ¶
type PGPools struct {
Default PGPoolInterface
Databases map[string]PGPoolInterface
}
type Role ¶
type Role struct {
Name string `db:"rolname"`
SuperUser bool `db:"rolsuper"`
Inherit bool `db:"rolinherit"`
CreateRole bool `db:"rolcreaterole"`
CreateDB bool `db:"rolcreatedb"`
Login bool `db:"rolcanlogin"`
Replication bool `db:"rolreplication"`
BypassRLS bool `db:"rolbypassrls"`
Password string `db:"-"`
}
Click to show internal directories.
Click to hide internal directories.