postgresql

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: MIT Imports: 7 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(db *sql.DB, info DbInfo) (err error)

func (Database) Drop

func (d Database) Drop(db *sql.DB) error

func (Database) Exists added in v0.1.0

func (d Database) Exists(db *sql.DB) (bool, error)

func (*Database) Read added in v0.1.0

func (d *Database) Read(db *sql.DB) error

func (Database) Update

func (d Database) Update(db *sql.DB) error

type DbInfo

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

func CalcDbConnectionInfo

func CalcDbConnectionInfo(db *sql.DB) (*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(db *sql.DB) error

func (Role) Exists added in v0.1.0

func (r Role) Exists(db *sql.DB) (bool, error)

func (Role) Read added in v0.1.0

func (r Role) Read(db *sql.DB) error

type TempGrant

type TempGrant struct {
	Tx          *sql.Tx
	Role        string
	CurrentUser string
}

func (TempGrant) Revoke

func (t TempGrant) Revoke(db *sql.DB) 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(db *sql.DB) (*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