schema

package
v1.5.17 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CatalogSchema  = "pg_catalog"
	APIPrefix      = "/pg/v1"
	DefaultAclRole = "PUBLIC"
)
View Source
const (
	// Maximum number of items to return in a list query, for each type
	RoleListLimit       = 100
	DatabaseListLimit   = 100
	SchemaListLimit     = 100
	ObjectListLimit     = 100
	ConnectionListLimit = 100
	TablespaceListLimit = 100
)
View Source
const (
	ObjectDef = `` /* 140-byte string literal not displayed */

)
View Source
const (
	SchemaDef = `schema ("oid" OID, "database" TEXT, "name" TEXT, "owner" TEXT, "acl" TEXT[], "size" BIGINT)`
)

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(ctx context.Context, conn pg.PoolConn) error

func GrantGroupMembership

func GrantGroupMembership(ctx context.Context, conn pg.Conn, group, member string) error

func RevokeGroupMembership

func RevokeGroupMembership(ctx context.Context, conn pg.Conn, group, member string) error

Types

type ACLItem

type ACLItem struct {
	Role    string   `json:"role,omitempty" help:"Role name"`
	Priv    []string `json:"priv,omitempty" help:"Access privileges"`
	Grantor string   `json:"-" help:"Grantor"` // Ignore field for now
}

func NewACLItem

func NewACLItem(v string) (*ACLItem, error)

Create a new ACLItem from a postgresql ACL string

func ParseACLItem

func ParseACLItem(v string) (*ACLItem, error)

Parse an ACLItem from a command-line flag, like <role>:<priv>,<priv>,<priv>...

func (ACLItem) GrantDatabase

func (acl ACLItem) GrantDatabase(ctx context.Context, conn pg.Conn, name string) error

Grant access privileges to a database

func (ACLItem) GrantSchema

func (acl ACLItem) GrantSchema(ctx context.Context, conn pg.Conn, name string) error

Grant access privileges to a schema

func (ACLItem) GrantTablespace

func (acl ACLItem) GrantTablespace(ctx context.Context, conn pg.Conn, name string) error

Grant access privileges to a tablespace

func (ACLItem) IsAll

func (acl ACLItem) IsAll() bool

Determine if has ALL privileges

func (ACLItem) RevokeDatabase

func (acl ACLItem) RevokeDatabase(ctx context.Context, conn pg.Conn, name string) error

Revoke access privileges to a database

func (ACLItem) RevokeSchema

func (acl ACLItem) RevokeSchema(ctx context.Context, conn pg.Conn, name string) error

Revoke access privileges to a schema

func (ACLItem) RevokeTablespace

func (acl ACLItem) RevokeTablespace(ctx context.Context, conn pg.Conn, name string) error

Revoke access privileges to a tablespace

func (ACLItem) String

func (a ACLItem) String() string

func (*ACLItem) UnmarshalJSON

func (acl *ACLItem) UnmarshalJSON(data []byte) error

func (*ACLItem) UnmarshalText

func (acl *ACLItem) UnmarshalText(data []byte) error

func (ACLItem) WithPriv

func (a ACLItem) WithPriv(priv ...string) *ACLItem

type ACLList

type ACLList []*ACLItem

func (*ACLList) Append

func (acl *ACLList) Append(item *ACLItem)

Append an ACLItem to the list

func (*ACLList) Find

func (acl *ACLList) Find(role string) *ACLItem

Find an ACLItem in the list by role

func (*ACLList) UnmarshalJSON

func (acl *ACLList) UnmarshalJSON(data []byte) error

func (*ACLList) UnmarshalText

func (acl *ACLList) UnmarshalText(data []byte) error

type Connection

type Connection struct {
	Pid         uint32    `json:"pid" help:"Process ID"`
	Database    string    `json:"database" help:"Database"`
	Role        string    `json:"role" help:"Role"`
	Application *string   `json:"application,omitempty" help:"Application"`
	ClientAddr  string    `json:"client_addr,omitempty" help:"Client address"`
	ClientPort  uint16    `json:"client_port,omitempty" help:"Client port"`
	ConnStart   time.Time `json:"conn_start,omitempty" help:"Connection start"`
	QueryStart  time.Time `json:"query_start,omitempty" help:"Query start"`
	Query       string    `json:"query,omitempty" help:"Query"`
	State       string    `json:"state,omitempty" help:"State"`
}

func (*Connection) Scan

func (c *Connection) Scan(row pg.Row) error

func (Connection) String

func (c Connection) String() string

type ConnectionList

type ConnectionList struct {
	Count uint64       `json:"count"`
	Body  []Connection `json:"body,omitempty"`
}

func (*ConnectionList) Scan

func (c *ConnectionList) Scan(row pg.Row) error

func (*ConnectionList) ScanCount

func (c *ConnectionList) ScanCount(row pg.Row) error

func (ConnectionList) String

func (c ConnectionList) String() string

type ConnectionListRequest

type ConnectionListRequest struct {
	pg.OffsetLimit
	Database *string `json:"database,omitempty" help:"Database"`
	Role     *string `json:"role,omitempty" help:"Role"`
	State    *string `json:"state,omitempty" help:"State"`
}

func (ConnectionListRequest) Select

func (c ConnectionListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (ConnectionListRequest) String

func (c ConnectionListRequest) String() string

type ConnectionPid

type ConnectionPid uint64

func (ConnectionPid) Select

func (c ConnectionPid) Select(bind *pg.Bind, op pg.Op) (string, error)

type Database

type Database struct {
	Oid uint32 `json:"oid"`
	DatabaseMeta
	Size uint64 `json:"bytes,omitempty" help:"Size of database in bytes"`
}

func (*Database) Scan

func (d *Database) Scan(row pg.Row) error

func (Database) String

func (d Database) String() string

type DatabaseList

type DatabaseList struct {
	Count uint64     `json:"count"`
	Body  []Database `json:"body,omitempty"`
}

func (*DatabaseList) Scan

func (n *DatabaseList) Scan(row pg.Row) error

func (*DatabaseList) ScanCount

func (n *DatabaseList) ScanCount(row pg.Row) error

func (DatabaseList) String

func (d DatabaseList) String() string

type DatabaseListRequest

type DatabaseListRequest struct {
	pg.OffsetLimit
}

func (DatabaseListRequest) Select

func (d DatabaseListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (DatabaseListRequest) String

func (d DatabaseListRequest) String() string

type DatabaseMeta

type DatabaseMeta struct {
	Name  string  `json:"name,omitempty" arg:"" help:"Name"`
	Owner string  `json:"owner,omitempty" help:"Owner"`
	Acl   ACLList `json:"acl,omitempty" help:"Access privileges"`
}

func (DatabaseMeta) Insert

func (d DatabaseMeta) Insert(bind *pg.Bind) (string, error)

func (DatabaseMeta) Select

func (d DatabaseMeta) Select(bind *pg.Bind, op pg.Op) (string, error)

func (DatabaseMeta) String

func (d DatabaseMeta) String() string

func (DatabaseMeta) Update

func (d DatabaseMeta) Update(bind *pg.Bind) error

type DatabaseName

type DatabaseName string

func (DatabaseName) Insert

func (d DatabaseName) Insert(bind *pg.Bind) (string, error)

func (DatabaseName) Select

func (d DatabaseName) Select(bind *pg.Bind, op pg.Op) (string, error)

func (DatabaseName) Update

func (d DatabaseName) Update(bind *pg.Bind) error

type Object

type Object struct {
	Oid      uint32 `json:"oid"`
	Database string `json:"database,omitempty" help:"Database"`
	Schema   string `json:"schema,omitempty" help:"Schema"`
	Type     string `json:"type,omitempty" help:"Type"`
	ObjectMeta
	Tablespace *string `json:"tablespace,omitempty" help:"Tablespace"`
	Size       uint64  `json:"bytes,omitempty" help:"Size of object in bytes"`
}

func (*Object) Scan

func (o *Object) Scan(row pg.Row) error

func (Object) String

func (o Object) String() string

type ObjectList

type ObjectList struct {
	Count uint64   `json:"count"`
	Body  []Object `json:"body,omitempty"`
}

func (*ObjectList) Scan

func (o *ObjectList) Scan(row pg.Row) error

func (*ObjectList) ScanCount

func (o *ObjectList) ScanCount(row pg.Row) error

func (ObjectList) String

func (o ObjectList) String() string

type ObjectListRequest

type ObjectListRequest struct {
	Database *string `json:"database,omitempty" help:"Database"`
	Schema   *string `json:"schema,omitempty" help:"Schema"`
	Type     *string `json:"type,omitempty" help:"Object Type"`
	pg.OffsetLimit
}

func (ObjectListRequest) Select

func (o ObjectListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (ObjectListRequest) String

func (o ObjectListRequest) String() string

type ObjectMeta

type ObjectMeta struct {
	Name  string     `json:"name,omitempty" arg:"" help:"Name"`
	Owner string     `json:"owner,omitempty" help:"Owner"`
	Acl   []*ACLItem `json:"acl,omitempty" help:"Access privileges"`
}

func (ObjectMeta) String

func (o ObjectMeta) String() string

type ObjectName

type ObjectName struct {
	Schema string `json:"schema,omitempty" help:"Schema"`
	Name   string `json:"name,omitempty" arg:"" help:"Name"`
}

func (ObjectName) Select

func (o ObjectName) Select(bind *pg.Bind, op pg.Op) (string, error)

func (ObjectName) String

func (o ObjectName) String() string

type Role

type Role struct {
	Oid uint32 `json:"oid"`
	RoleMeta
}

func (*Role) Scan

func (r *Role) Scan(row pg.Row) error

func (Role) String

func (r Role) String() string

type RoleList

type RoleList struct {
	Count uint64 `json:"count"`
	Body  []Role `json:"body,omitempty"`
}

func (*RoleList) Scan

func (n *RoleList) Scan(row pg.Row) error

func (*RoleList) ScanCount

func (n *RoleList) ScanCount(row pg.Row) error

func (RoleList) String

func (r RoleList) String() string

type RoleListRequest

type RoleListRequest struct {
	pg.OffsetLimit
}

func (RoleListRequest) Select

func (r RoleListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (RoleListRequest) String

func (r RoleListRequest) String() string

type RoleMeta

type RoleMeta struct {
	Name                   string     `json:"name,omitempty" arg:"" help:"Role name"`
	Superuser              *bool      `json:"super,omitempty" help:"Superuser permission"`
	Inherit                *bool      `json:"inherit,omitempty" help:"Inherit permissions"`
	CreateRoles            *bool      `json:"createrole,omitempty" help:"Create roles permission"`
	CreateDatabases        *bool      `json:"createdb,omitempty" help:"Create databases permission"`
	Replication            *bool      `json:"replication,omitempty" help:"Replication permission"`
	ConnectionLimit        *uint64    `json:"conlimit,omitempty" help:"Connection limit"`
	BypassRowLevelSecurity *bool      `json:"bypassrls,omitempty" help:"Bypass row-level security"`
	Login                  *bool      `json:"login,omitempty" help:"Login permission"`
	Password               *string    `json:"password,omitempty" help:"Password"`
	Expires                *time.Time `json:"expires,omitzero" help:"Password expiration"`
	Groups                 []string   `json:"memberof,omitempty" help:"Group memberships"`
}

func (RoleMeta) Insert

func (r RoleMeta) Insert(bind *pg.Bind) (string, error)

func (RoleMeta) Select

func (r RoleMeta) Select(bind *pg.Bind, op pg.Op) (string, error)

func (RoleMeta) String

func (r RoleMeta) String() string

func (RoleMeta) Update

func (r RoleMeta) Update(bind *pg.Bind) error

type RoleName

type RoleName string

func (RoleName) Insert

func (r RoleName) Insert(bind *pg.Bind) (string, error)

func (RoleName) Select

func (r RoleName) Select(bind *pg.Bind, op pg.Op) (string, error)

func (RoleName) Update

func (r RoleName) Update(bind *pg.Bind) error

type Schema

type Schema struct {
	Oid      uint32 `json:"oid"`
	Database string `json:"database,omitempty" help:"Database"`
	SchemaMeta
	Size uint64 `json:"bytes,omitempty" help:"Size of schema in bytes"`
}

func (*Schema) Scan

func (s *Schema) Scan(row pg.Row) error

func (Schema) String

func (s Schema) String() string

type SchemaList

type SchemaList struct {
	Count uint64   `json:"count"`
	Body  []Schema `json:"body,omitempty"`
}

func (*SchemaList) Scan

func (s *SchemaList) Scan(row pg.Row) error

func (*SchemaList) ScanCount

func (s *SchemaList) ScanCount(row pg.Row) error

func (SchemaList) String

func (s SchemaList) String() string

type SchemaListRequest

type SchemaListRequest struct {
	Database *string `json:"database,omitempty" help:"Database"`
	pg.OffsetLimit
}

func (SchemaListRequest) Select

func (d SchemaListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (SchemaListRequest) String

func (s SchemaListRequest) String() string

type SchemaMeta

type SchemaMeta struct {
	Name  string  `json:"name,omitempty" arg:"" help:"Name"`
	Owner string  `json:"owner,omitempty" help:"Owner"`
	Acl   ACLList `json:"acl,omitempty" help:"Access privileges"`
}

func (SchemaMeta) Insert

func (s SchemaMeta) Insert(bind *pg.Bind) (string, error)

func (SchemaMeta) Select

func (s SchemaMeta) Select(bind *pg.Bind, op pg.Op) (string, error)

func (SchemaMeta) String

func (s SchemaMeta) String() string

func (SchemaMeta) Update

func (s SchemaMeta) Update(bind *pg.Bind) error

type SchemaName

type SchemaName string

func (SchemaName) Insert

func (d SchemaName) Insert(bind *pg.Bind) (string, error)

func (SchemaName) Select

func (s SchemaName) Select(bind *pg.Bind, op pg.Op) (string, error)

func (SchemaName) Update

func (d SchemaName) Update(bind *pg.Bind) error

type Tablespace

type Tablespace struct {
	Oid uint32 `json:"oid"`
	TablespaceMeta
	Location string   `json:"location,omitempty" help:"Location"`
	Options  []string `json:"options,omitempty" help:"Options"`
	Size     uint64   `json:"bytes,omitempty" help:"Size of schema in bytes"`
}

func (*Tablespace) Scan

func (t *Tablespace) Scan(row pg.Row) error

func (Tablespace) String

func (t Tablespace) String() string

type TablespaceList

type TablespaceList struct {
	Count uint64       `json:"count"`
	Body  []Tablespace `json:"body,omitempty"`
}

func (*TablespaceList) Scan

func (t *TablespaceList) Scan(row pg.Row) error

func (*TablespaceList) ScanCount

func (t *TablespaceList) ScanCount(row pg.Row) error

func (TablespaceList) String

func (t TablespaceList) String() string

type TablespaceListRequest

type TablespaceListRequest struct {
	pg.OffsetLimit
}

func (TablespaceListRequest) Select

func (t TablespaceListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (TablespaceListRequest) String

func (t TablespaceListRequest) String() string

type TablespaceMeta

type TablespaceMeta struct {
	Name  *string `json:"name,omitempty" help:"Tablespace name"`
	Owner *string `json:"owner,omitempty" help:"Owner"`
	Acl   ACLList `json:"acl,omitempty" help:"Access privileges"`
}

func (TablespaceMeta) Insert

func (t TablespaceMeta) Insert(bind *pg.Bind) (string, error)

func (TablespaceMeta) Select

func (t TablespaceMeta) Select(bind *pg.Bind, op pg.Op) (string, error)

func (TablespaceMeta) String

func (t TablespaceMeta) String() string

func (TablespaceMeta) Update

func (t TablespaceMeta) Update(bind *pg.Bind) error

type TablespaceName

type TablespaceName string

func (TablespaceName) Insert

func (t TablespaceName) Insert(bind *pg.Bind) (string, error)

func (TablespaceName) Select

func (t TablespaceName) Select(bind *pg.Bind, op pg.Op) (string, error)

func (TablespaceName) Update

func (t TablespaceName) Update(bind *pg.Bind) error

Jump to

Keyboard shortcuts

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