postgresql

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	Name             string
	Owner            string
	Template         string
	Encoding         string
	Collation        string
	LcCtype          string
	TablespaceName   string
	ConnectionLimit  int
	IsTemplate       bool
	AllowConnections bool
}

func DefaultDatabase

func DefaultDatabase() Database

func (Database) Create

func (d Database) Create(conn *pgx.Conn, info DbInfo) (err error)

func (Database) Drop

func (d Database) Drop() error

func (Database) Update

func (d Database) Update() error

type DbInfo

type DbInfo struct {
	DbVersion         semver.Version
	SupportedFeatures Features
	IsSuperuser       bool
	CurrentUser       string
}

func CalcDbConnectionInfo

func CalcDbConnectionInfo(conn *pgx.Conn) (*DbInfo, error)

type FeatureName

type FeatureName uint
const (
	FeatureCreateRoleWith FeatureName = iota
	FeatureDBAllowConnections
	FeatureDBIsTemplate
	FeatureFallbackApplicationName
	FeatureRLS
	FeatureSchemaCreateIfNotExist
	FeatureReplication
	FeatureExtension
	FeaturePrivileges
	FeatureForceDropDatabase
	FeaturePid
)

type Features

type Features map[FeatureName]bool

func CalcSupportedFeatures

func CalcSupportedFeatures(dbVersion semver.Version) Features

func (Features) IsSupported

func (f Features) IsSupported(name FeatureName) bool

type Role

type Role struct {
	Name     string
	Password string
}

func (Role) Create

func (r Role) Create(conn *pgx.Conn) error

type TempGrant

type TempGrant struct {
	Tx          pgx.Tx
	Role        string
	CurrentUser string
}

func (TempGrant) Revoke

func (t TempGrant) Revoke(conn *pgx.Conn) error

Revoke revokes the role *role* from the user *member*. It returns false if the revoke is not needed because the user is not a member of this role.

type TempRoleMembership

type TempRoleMembership struct {
	Role        string
	CurrentUser string
}

TempRoleMembership grants role membership of the target Role to the CurrentUser This is used to perform commands if user is not a superuser For instance, when using AWS RDS, user is not given superuser

func (TempRoleMembership) Grant

func (t TempRoleMembership) Grant(conn *pgx.Conn) (*TempGrant, error)

Grant grants the role *role* to the user *member*. It returns false if the grant is not needed because the user is already a member of this role.

Jump to

Keyboard shortcuts

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