postgresql

package
v0.0.0-...-560737a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

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 EnsurePGPoolExists(pgpools *PGPools, database string) (err error)

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:"-"`
}

func GetRole

func GetRole(pgpool PGPoolInterface, name string) (role *Role, err error)

type Schema

type Schema struct {
	Database string `db:"-"`
	Name     string `db:"name"`
	Owner    string `db:"owner"`
}

func GetSchema

func GetSchema(pgpool PGPoolInterface, name string) (schema *Schema, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL