sqlserver

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 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
	DisableConnections bool
}

func (Database) Create

func (d Database) Create(db *sql.DB, info DbInfo) error

func (Database) Drop

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

func (Database) Ensure

func (d Database) Ensure(db *sql.DB, info DbInfo) error

func (Database) Exists

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

func (*Database) Read

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 NoopRevoker

type NoopRevoker struct {
}

func (NoopRevoker) Revoke

func (t NoopRevoker) Revoke(db *sql.DB) error

type Revoker

type Revoker interface {
	Revoke(db *sql.DB) error
}

type Role

type Role struct {
	Name     string
	Password string
}

func (Role) Create

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

func (Role) Ensure

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

func (Role) Exists

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

func (Role) Read

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

type RoleGrant

type RoleGrant struct {
	// Member receives all the permissions for Target
	Member string

	// Target is the role that gains an additional Member
	Target string

	// WithAdminOption permits Member to grant it to others
	WithAdminOption bool
}

RoleGrant adds Member to the Target role

func (RoleGrant) Create

func (g RoleGrant) Create(db *sql.DB) error

func (RoleGrant) Ensure

func (g RoleGrant) Ensure(db *sql.DB) error

func (RoleGrant) Exists

func (g RoleGrant) Exists(db *sql.DB) (bool, error)

func (RoleGrant) Read

func (g RoleGrant) Read(db *sql.DB) error

type TempGrant

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

func GrantRoleMembership

func GrantRoleMembership(db *sql.DB, role string, currentUser string) (*TempGrant, error)

GrantRoleMembership 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 It returns false if the grant is not needed because the user is already a member of this role.

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.

Jump to

Keyboard shortcuts

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