schema

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DatabaseListLimit        = 50
	ConnectionListLimit      = 50
	ExtensionListLimit       = 50
	SchemaListLimit          = 20
	ObjectListLimit          = 20
	SettingListLimit         = 100
	RoleListLimit            = 50
	TablespaceListLimit      = 50
	ReplicationSlotListLimit = 50
	StatementListLimit       = 50
)
View Source
const (
	CatalogSchema  = "pg_catalog"
	DefaultAclRole = "PUBLIC"
)
View Source
const (
	ExtensionDef = `` /* 171-byte string literal not displayed */

)
View Source
const (
	ObjectDef = `` /* 198-byte string literal not displayed */

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

Variables

This section is empty.

Functions

func CommentOn added in v1.5.0

func CommentOn(ctx context.Context, conn pg.Conn, typ, name, comment string) error

CommentOn sets the comment of an object, of a type, such as DATABASE, or SCHEMA, by its name, or removes it, when it's empty

func GrantGroupMembership

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

GrantGroupMembership grants group membership to a role. Both group and member must be valid role names.

func RevokeGroupMembership

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

RevokeGroupMembership revokes group membership from a role. Both group and member must be valid role names.

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)

NewACLItem creates a new ACLItem from a PostgreSQL ACL string.

func ParseACLItem

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

ParseACLItem parses 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

GrantDatabase grants access privileges to a database.

func (ACLItem) GrantSchema

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

GrantSchema grants access privileges to a schema.

func (ACLItem) GrantTablespace

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

GrantTablespace grants access privileges to a tablespace.

func (ACLItem) IsAll

func (acl ACLItem) IsAll() bool

IsAll returns true if the ACL has ALL privileges.

func (ACLItem) MarshalText

func (a ACLItem) MarshalText() ([]byte, error)

MarshalText returns the ACLItem as text in the format role:priv,priv,...

func (ACLItem) RevokeDatabase

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

RevokeDatabase revokes access privileges from a database.

func (ACLItem) RevokeSchema

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

RevokeSchema revokes access privileges from a schema.

func (ACLItem) RevokeTablespace

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

RevokeTablespace revokes access privileges from 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. If an item with the same role already exists, the privileges are merged.

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

UnmarshalJSON reads a list of access privileges, which is empty, rather than nil, for [], which revokes them all, unlike null, or none, which leaves them

func (*ACLList) UnmarshalText

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

type BootstrapResult

type BootstrapResult struct {
	// StatStatementsAvailable indicates if pg_stat_statements extension is available
	StatStatementsAvailable bool

	// Replica is true when the server is a replica, in recovery, which is
	// read only, so nothing is created, as it's the primary's
	Replica bool
}

BootstrapResult contains the result of the bootstrap process

func Bootstrap

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

Bootstrap creates required extensions for the manager. - dblink: Required for remote database queries - pg_stat_statements: Optional, for query statistics (requires shared_preload_libraries) This should be called once when initializing the manager.

type Cluster

type Cluster struct {
	Name string
}

func (*Cluster) Scan

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

func (Cluster) Select

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

type ConfigLoadTime added in v1.5.0

type ConfigLoadTime time.Time

ConfigLoadTime is when the session last loaded the configuration files

func (*ConfigLoadTime) Scan added in v1.5.0

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

func (ConfigLoadTime) Select added in v1.5.0

func (ConfigLoadTime) Select(bind *pg.Bind, op pg.Op) (string, 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"`

	// Current is true for the connection which reads it, which can't be
	// ended, or cancelled
	Current bool `json:"current,omitempty" help:"The connection which reads it"`
}

func (Connection) Cell

func (r Connection) Cell(col int) tui.CellText

func (Connection) Header

func (r Connection) Header() []string

func (*Connection) Scan

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

Scan reads a connection. A connection by a Unix socket has no client address or port, and one which hasn't run a query has no query start.

func (Connection) String

func (c Connection) String() string

func (Connection) Width

func (r Connection) Width(col int) int

type ConnectionCancel added in v1.5.0

type ConnectionCancel uint64

ConnectionCancel is a connection, by its pid, whose query is cancelled, with Get, which returns it

func (ConnectionCancel) Select added in v1.5.0

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

type ConnectionList

type ConnectionList struct {
	ConnectionListRequest
	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"`

	// Sort is what the connections are sorted by, which is the pid when it's
	// empty, and Order its direction, asc or desc, which is asc when it's
	// empty
	Sort  string `json:"sort,omitempty" help:"Sort by database, role, application, client, state, conn_start or query_start"`
	Order string `json:"order,omitempty" help:"Order of the sort (asc or desc)"`
}

func (ConnectionListRequest) Query

func (q ConnectionListRequest) Query() url.Values

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

	// Current is true for the database pgmanager is connected to, which
	// can't be deleted
	Current bool `json:"current,omitempty" help:"The database pgmanager is connected to"`
}

func (Database) Cell

func (r Database) Cell(col int) tui.CellText

func (Database) Header

func (r Database) Header() []string

func (*Database) Scan

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

func (Database) String

func (d Database) String() string

func (Database) Width

func (r Database) Width(col int) int

type DatabaseList

type DatabaseList struct {
	DatabaseListRequest
	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) Query

func (d DatabaseListRequest) Query() url.Values

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 of the database"`
	Owner   string  `json:"owner,omitempty" help:"Owner"`
	Acl     ACLList `json:"acl,omitempty" help:"Access privileges"`
	Comment *string `json:"comment,omitempty" help:"Comment, which an empty one removes"`
}

func (DatabaseMeta) Altered added in v1.5.0

func (d DatabaseMeta) Altered() bool

Altered is true when the database's name, or owner, is changed, rather than only its access privileges, or comment, which ALTER DATABASE doesn't change

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

func (DatabaseMeta) Validate

func (d DatabaseMeta) Validate() error

Validate checks the DatabaseMeta for valid name and owner

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 Extension

type Extension struct {
	Oid *uint32 `json:"oid,omitempty"`
	ExtensionMeta
	DefaultVersion   string   `json:"default_version,omitempty"`
	InstalledVersion *string  `json:"installed_version,omitempty"`
	Relocatable      *bool    `json:"relocatable,omitempty"`
	Comment          string   `json:"comment,omitempty"`
	Requires         []string `json:"requires,omitempty"`
}

func (Extension) Cell

func (r Extension) Cell(col int) tui.CellText

func (Extension) Header

func (r Extension) Header() []string

func (*Extension) Scan

func (e *Extension) Scan(row pg.Row) error

func (Extension) String

func (e Extension) String() string

func (Extension) Width

func (r Extension) Width(col int) int

type ExtensionList

type ExtensionList struct {
	ExtensionListRequest
	Count uint64      `json:"count"`
	Body  []Extension `json:"body,omitempty"`
}

func (*ExtensionList) Scan

func (e *ExtensionList) Scan(row pg.Row) error

func (*ExtensionList) ScanCount

func (e *ExtensionList) ScanCount(row pg.Row) error

func (ExtensionList) String

func (e ExtensionList) String() string

type ExtensionListRequest

type ExtensionListRequest struct {
	Database  *string `json:"database,omitempty" help:"Database"`
	Installed *bool   `json:"installed,omitempty" help:"Filter by installed status"`
	pg.OffsetLimit

	// Sort is what the extensions are sorted by, and Order its direction, asc or
	// desc, which is asc when it's empty. Empty values are last, either way.
	Sort  string `json:"sort,omitempty" help:"Sort by name, version, default_version or schema"`
	Order string `json:"order,omitempty" help:"Order of the sort (asc or desc)"`
}

func (ExtensionListRequest) Query

func (q ExtensionListRequest) Query() url.Values

func (*ExtensionListRequest) Select

func (e *ExtensionListRequest) Select(bind *pg.Bind, op pg.Op) (string, error)

func (ExtensionListRequest) String

func (e ExtensionListRequest) String() string

type ExtensionMeta

type ExtensionMeta struct {
	Name     string `json:"name,omitempty" arg:"" help:"Extension name"`
	Database string `json:"database,omitempty" help:"Database to install extension into"`
	Schema   string `json:"schema,omitempty" help:"Schema to install extension into"`
	Owner    string `json:"owner,omitempty"`
	Version  string `json:"version,omitempty" name:"ver" help:"Extension version"`
}

func (ExtensionMeta) Insert

func (e ExtensionMeta) Insert(bind *pg.Bind) (string, error)

func (ExtensionMeta) String

func (e ExtensionMeta) String() string

func (ExtensionMeta) Update

func (e ExtensionMeta) Update(bind *pg.Bind) error

func (ExtensionMeta) UpdateQuery

func (e ExtensionMeta) UpdateQuery(bind *pg.Bind) (string, error)

UpdateQuery returns the SQL for updating an extension

type ExtensionName

type ExtensionName string

func (ExtensionName) Select

func (e ExtensionName) Select(bind *pg.Bind, op pg.Op) (string, 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"`
	Table      *TableMeta `json:"table,omitempty" help:"Table-specific metadata"`
}

func (Object) Cell

func (r Object) Cell(col int) tui.CellText

func (Object) Header

func (r Object) Header() []string

func (*Object) Scan

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

func (Object) String

func (o Object) String() string

func (Object) Width

func (r Object) Width(col int) int

type ObjectList

type ObjectList struct {
	ObjectListRequest
	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) Query

func (d ObjectListRequest) Query() url.Values

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     ACLList `json:"acl,omitempty" help:"Access privileges"`
	Comment *string `json:"comment,omitempty" help:"Comment, which an empty one removes"`
}

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

func (ObjectName) Validate

func (o ObjectName) Validate() error

Validate checks that the ObjectName has valid schema and name.

type Postmaster added in v1.5.0

type Postmaster struct {
	Started time.Time
}

Postmaster is when the server started, which is later once it's restarted

func (*Postmaster) Scan added in v1.5.0

func (p *Postmaster) Scan(row pg.Row) error

func (Postmaster) Select added in v1.5.0

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

type ReplicationSlot

type ReplicationSlot struct {
	ReplicationSlotMeta

	// Combined status: inactive, streaming, catchup, lost
	Status string `json:"status"`

	// Connected replica info (when streaming/catchup)
	ClientAddr string   `json:"client_addr,omitempty"`
	LagBytes   *int64   `json:"lag_bytes,omitempty"`
	LagMs      *float64 `json:"lag_ms,omitempty"`
}

ReplicationSlot represents a replication slot with its status

func (ReplicationSlot) Cell

func (r ReplicationSlot) Cell(col int) tui.CellText

func (ReplicationSlot) Header

func (r ReplicationSlot) Header() []string

func (*ReplicationSlot) Scan

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

func (ReplicationSlot) String

func (s ReplicationSlot) String() string

func (ReplicationSlot) Width

func (r ReplicationSlot) Width(col int) int

type ReplicationSlotList

type ReplicationSlotList struct {
	ReplicationSlotListRequest
	Count uint64            `json:"count"`
	Body  []ReplicationSlot `json:"body,omitempty"`
}

ReplicationSlotList is a list of replication slots with a total count

func (*ReplicationSlotList) Scan

func (l *ReplicationSlotList) Scan(row pg.Row) error

func (*ReplicationSlotList) ScanCount

func (l *ReplicationSlotList) ScanCount(row pg.Row) error

func (ReplicationSlotList) String

func (l ReplicationSlotList) String() string

type ReplicationSlotListRequest

type ReplicationSlotListRequest struct {
	pg.OffsetLimit

	// Sort is what the slots are sorted by, and Order its direction, asc or
	// desc, which is asc when it's empty. Empty values are last, either way.
	Sort  string `json:"sort,omitempty" help:"Sort by name, type, database, plugin, status or lag"`
	Order string `json:"order,omitempty" help:"Order of the sort (asc or desc)"`
}

ReplicationSlotListRequest contains parameters for listing replication slots

func (ReplicationSlotListRequest) Query

func (*ReplicationSlotListRequest) Select

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

type ReplicationSlotMeta

type ReplicationSlotMeta struct {
	Name      string `json:"name" arg:"" help:"Name of the replication slot"`
	Type      string `json:"type" enum:"physical,logical" required:"" help:"Type of the replication slot"`
	Plugin    string `json:"plugin,omitempty" help:"Plugin for logical replication slots (e.g., pgoutput)"`
	Database  string `json:"database,omitempty" help:"Database for logical replication slots"`
	Temporary bool   `json:"temporary,omitempty" negatable:"" help:"If true, slot will be dropped on disconnect; logical slots only"`
	TwoPhase  bool   `` /* 126-byte string literal not displayed */
}

ReplicationSlotMeta contains parameters for creating a replication slot

func (ReplicationSlotMeta) Insert

func (m ReplicationSlotMeta) Insert(bind *pg.Bind) (string, error)

func (ReplicationSlotMeta) String

func (s ReplicationSlotMeta) String() string

func (ReplicationSlotMeta) Update

func (m ReplicationSlotMeta) Update(_ *pg.Bind) error

func (ReplicationSlotMeta) Validate

func (m ReplicationSlotMeta) Validate() error

type ReplicationSlotName

type ReplicationSlotName string

ReplicationSlotName is used for get/delete operations

func (ReplicationSlotName) Select

func (n ReplicationSlotName) Select(bind *pg.Bind, op pg.Op) (string, error)

type Restart added in v1.5.0

type Restart struct {
	Started time.Time `json:"started"`
}

Restart is the server, once it's restarted: when it started

func (Restart) String added in v1.5.0

func (r Restart) String() string

type Role

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

	// Predefined is true for PostgreSQL's own roles, such as pg_monitor,
	// whose names start with pg_, which is reserved
	Predefined bool `json:"predefined,omitempty" help:"PostgreSQL's own role, such as pg_monitor"`

	// Current is true for the role pgmanager runs as, which can't be
	// deleted
	Current bool `json:"current,omitempty" help:"The role pgmanager runs as"`
}

func (Role) Cell

func (r Role) Cell(col int) tui.CellText

func (Role) Header

func (r Role) Header() []string

func (*Role) Scan

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

func (Role) String

func (r Role) String() string

func (Role) Width

func (r Role) Width(col int) int

type RoleList

type RoleList struct {
	RoleListRequest
	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

	// Predefined lists PostgreSQL's own roles, such as pg_monitor, rather
	// than the others, which are listed when it's false, or not set
	Predefined *bool `json:"predefined,omitempty" help:"List PostgreSQL's own roles, such as pg_monitor, rather than the others" negatable:""`

	// Sort is what the roles are sorted by, and Order its direction, asc or
	// desc, which is asc when it's empty. Empty values are last, either way.
	Sort  string `json:"sort,omitempty" help:"Sort by name, conlimit, expires or login"`
	Order string `json:"order,omitempty" help:"Order of the sort (asc or desc)"`
}

func (RoleListRequest) Query

func (d RoleListRequest) Query() url.Values

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" name:"super" help:"Superuser permission" negatable:""`
	Inherit                *bool      `json:"inherit,omitempty" help:"Inherit permissions" negatable:""`
	CreateRoles            *bool      `json:"createrole,omitempty" help:"Create roles permission" negatable:""`
	CreateDatabases        *bool      `json:"createdb,omitempty" help:"Create databases permission" negatable:""`
	Replication            *bool      `json:"replication,omitempty" help:"Replication permission" negatable:""`
	ConnectionLimit        *int64     `json:"conlimit,omitempty" help:"Connection limit, or -1 for no limit"`
	BypassRowLevelSecurity *bool      `json:"bypassrls,omitempty" help:"Bypass row-level security" negatable:""`
	Login                  *bool      `json:"login,omitempty" help:"Login permission" negatable:""`
	Password               *string    `json:"password,omitempty" help:"Password"`
	Expires                *time.Time `json:"expires,omitempty" help:"Password expiration, or the zero time for none"`
	Groups                 []string   `json:"memberof,omitempty" help:"Group memberships"`
	Comment                *string    `json:"comment,omitempty" help:"Comment, which an empty one removes"`
}

func (RoleMeta) Altered added in v1.5.0

func (r RoleMeta) Altered() bool

Altered is true when the role's permissions, password, or limits are changed, rather than only its memberships, or comment, which ALTER ROLE doesn't change

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

func (RoleMeta) Validate

func (r RoleMeta) Validate() error

Validate checks that the RoleMeta has valid values. Returns an error if the name is empty, has a reserved prefix, or is not a valid identifier.

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) Cell

func (r Schema) Cell(col int) tui.CellText

func (Schema) Header

func (r Schema) Header() []string

func (*Schema) Scan

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

func (Schema) String

func (s Schema) String() string

func (Schema) Width

func (r Schema) Width(col int) int

type SchemaList

type SchemaList struct {
	SchemaListRequest
	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" arg:"" optional:"" help:"Database"`
	pg.OffsetLimit
}

func (SchemaListRequest) Query

func (s SchemaListRequest) Query() url.Values

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:"schema,omitempty" arg:"" help:"Schema name"`
	Owner   string  `json:"owner,omitempty" help:"Owner"`
	Acl     ACLList `json:"acl,omitempty" help:"Access privileges"`
	Comment *string `json:"comment,omitempty" help:"Comment, which an empty one removes"`
}

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 Setting

type Setting struct {
	Name string `json:"name"`
	SettingMeta
	Unit        *string `json:"unit,omitempty"`
	Category    string  `json:"category"`
	Context     string  `json:"context"` // internal, postmaster, sighup, superuser, user
	Description string  `json:"description,omitempty"`
	ExtraDesc   string  `json:"extra_desc,omitempty"`

	// Changed is true when the setting is set for the server, such as in its
	// configuration file, or by ALTER SYSTEM, rather than its default, or
	// this connection's
	Changed bool `json:"changed,omitempty"`

	// Type is the setting's type: bool, enum, integer, real or string
	Type string `json:"type"`

	// Min and Max are the limits of an integer or real, in its unit
	Min *string `json:"min,omitempty"`
	Max *string `json:"max,omitempty"`

	// Values are the values an enum can be
	Values []string `json:"values,omitempty"`

	// Default is the value it has when it isn't set, which PostgreSQL is
	// built with, in its unit
	Default *string `json:"default,omitempty"`

	// Source is where its value is from, such as default, configuration file,
	// or command line
	Source string `json:"source"`

	// PendingRestart is true when it's changed in the configuration, but the
	// server needs to restart before it takes effect
	PendingRestart bool `json:"pending_restart,omitempty"`

	// Config is its value in the configuration files, such as
	// postgresql.conf, and Override its value set by ALTER SYSTEM, in
	// postgresql.auto.conf, which is used rather than the configuration
	// files'. They're read for a setting by its name, by a role which can
	// read the configuration files, and are in its unit, or as they're
	// written, such as 128MB.
	Config   *string `json:"config,omitempty"`
	Override *string `json:"override,omitempty"`
}

Setting represents a PostgreSQL server setting

func (Setting) Cell

func (r Setting) Cell(col int) tui.CellText

func (Setting) Header

func (r Setting) Header() []string

func (*Setting) Scan

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

func (Setting) String

func (s Setting) String() string

func (Setting) Width

func (r Setting) Width(col int) int

type SettingCategory added in v1.5.0

type SettingCategory struct {
	Name    string `json:"name"`
	Count   uint64 `json:"count"`
	Changed uint64 `json:"changed"`
}

SettingCategory is a top level of the settings' categories, which are two levels, such as "Client Connection Defaults / Locale and Formatting", with how many settings it has, and how many of them are changed

func (SettingCategory) Cell added in v1.5.0

func (r SettingCategory) Cell(col int) tui.CellText

func (SettingCategory) Header added in v1.5.0

func (r SettingCategory) Header() []string

func (SettingCategory) Width added in v1.5.0

func (r SettingCategory) Width(col int) int

type SettingCategoryList

type SettingCategoryList struct {
	Count          uint64            `json:"count"`
	Body           []SettingCategory `json:"body,omitempty"`
	PendingRestart []string          `json:"pending_restart,omitempty"`
	Restart        bool              `json:"restart,omitempty"`
}

SettingCategoryList contains the top levels of the settings' categories, with the settings which wait for the server to restart, and whether it can be restarted

func (*SettingCategoryList) Scan

func (l *SettingCategoryList) Scan(row pg.Row) error

func (*SettingCategoryList) ScanCount

func (l *SettingCategoryList) ScanCount(row pg.Row) error

func (SettingCategoryList) String

func (s SettingCategoryList) String() string

type SettingCategoryListRequest

type SettingCategoryListRequest struct{}

SettingCategoryListRequest is used to retrieve the top levels of the settings' categories

func (SettingCategoryListRequest) Query

func (SettingCategoryListRequest) Select

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

type SettingFileAccess added in v1.5.0

type SettingFileAccess bool

SettingFileAccess is whether the configuration files can be read

func (*SettingFileAccess) Scan added in v1.5.0

func (a *SettingFileAccess) Scan(row pg.Row) error

func (SettingFileAccess) Select added in v1.5.0

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

type SettingFileError added in v1.5.0

type SettingFileError struct {
	File  string `json:"file"`
	Line  int    `json:"line"`
	Name  string `json:"name,omitempty"`
	Error string `json:"error"`
	// contains filtered or unexported fields
}

SettingFileError is an error in a configuration file, at a line, of a setting, unless the line can't be read

func (SettingFileError) RestartOnly added in v1.5.0

func (e SettingFileError) RestartOnly() bool

RestartOnly is true when the error is only that the setting waits for the server to restart, which PostgreSQL doesn't tell apart from a value which is invalid: the setting needs a restart, waits for one, and its value in the file is one of its type, within its limits, or with a unit, which the server checks. A value which isn't, or can't be told, is an error.

type SettingFileErrors added in v1.5.0

type SettingFileErrors []SettingFileError

SettingFileErrors are the errors in the configuration files

func (*SettingFileErrors) Scan added in v1.5.0

func (e *SettingFileErrors) Scan(row pg.Row) error

func (SettingFileErrors) Select added in v1.5.0

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

type SettingFileRequest added in v1.5.0

type SettingFileRequest string

SettingFileRequest is the values of a setting, by its name, in the configuration files

func (SettingFileRequest) Select added in v1.5.0

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

type SettingFiles added in v1.5.0

type SettingFiles struct {
	Config   *string
	Override *string
}

SettingFiles are the values of a setting in the configuration files, the last of which in each file is used

func (*SettingFiles) Scan added in v1.5.0

func (f *SettingFiles) Scan(row pg.Row) error

Scan is a value in a configuration file: postgresql.auto.conf's are the override, and the others' the configuration's, and the last of each is used

type SettingList

type SettingList struct {
	SettingListRequest
	Count uint64    `json:"count"`
	Body  []Setting `json:"body,omitempty"`
}

SettingList contains the list of settings

func (*SettingList) Scan

func (l *SettingList) Scan(row pg.Row) error

func (*SettingList) ScanCount

func (l *SettingList) ScanCount(row pg.Row) error

func (SettingList) String

func (s SettingList) String() string

type SettingListRequest

type SettingListRequest struct {
	pg.OffsetLimit

	// Category is a category, such as "Client Connection Defaults / Locale and
	// Formatting", or a top level of them, such as "Client Connection
	// Defaults", which is every category under it
	Category *string `json:"category,omitempty" help:"Filter by category, or a top level of them"`

	// Sort is what the settings are sorted by, and Order its direction, asc or
	// desc, which is asc when it's empty. Empty values are last, either way.
	Sort  string `json:"sort,omitempty" help:"Sort by name, category, context or changed"`
	Order string `json:"order,omitempty" help:"Order of the sort (asc or desc)"`
}

SettingListRequest is used to retrieve server settings

func (SettingListRequest) Query

func (d SettingListRequest) Query() url.Values

func (*SettingListRequest) Select

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

type SettingMeta

type SettingMeta struct {
	Value *string `json:"value"`
}

SettingMeta represents the mutable parts of a setting

func (SettingMeta) Insert

func (m SettingMeta) Insert(_ *pg.Bind) (string, error)

Insert is not supported for settings - they cannot be created, only updated.

func (SettingMeta) Update

func (m SettingMeta) Update(bind *pg.Bind) error

type SettingName

type SettingName string

SettingName is a setting name identifier

func (SettingName) Select

func (n SettingName) Select(bind *pg.Bind, op pg.Op) (string, error)

type SettingPendingRestart added in v1.5.0

type SettingPendingRestart []string

SettingPendingRestart are the names of the settings which wait for the server to restart

func (*SettingPendingRestart) Scan added in v1.5.0

func (p *SettingPendingRestart) Scan(row pg.Row) error

func (SettingPendingRestart) Select added in v1.5.0

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

type SettingReload added in v1.5.0

type SettingReload struct {
	Loaded         time.Time          `json:"loaded"`
	PendingRestart []string           `json:"pending_restart,omitempty"`
	Errors         []SettingFileError `json:"errors,omitempty"`
}

SettingReload is the configuration, once it's reloaded: when it was loaded, the settings which wait for the server to restart, and the errors in the configuration files, whose settings are skipped, which are read by a role which can read the configuration files

func (SettingReload) String added in v1.5.0

func (r SettingReload) String() string

type Statement

type Statement struct {
	Role     string  `json:"role,omitempty"`     // Name of the role who executed the statement
	Database string  `json:"database,omitempty"` // Name of the database in which the statement was executed
	QueryID  string  `json:"query_id"`           // Hash code to identify identical normalized queries, in decimal, as PostgreSQL shows it, and as a string, as it's 64 bits
	Query    string  `json:"query"`              // Text of a representative statement
	Calls    int64   `json:"calls"`              // Number of times the statement was executed
	Rows     int64   `json:"rows"`               // Total number of rows retrieved or affected by the statement
	Total    float64 `json:"total_ms"`           // Total time spent executing the statement, in milliseconds
	Min      float64 `json:"min_ms"`             // Minimum time spent executing the statement, in milliseconds
	Max      float64 `json:"max_ms"`             // Maximum time spent executing the statement, in milliseconds
	Mean     float64 `json:"mean_ms"`            // Mean time spent executing the statement, in milliseconds
}

Statement represents a row from pg_stat_statements

func (Statement) Cell

func (r Statement) Cell(col int) tui.CellText

func (Statement) Header

func (r Statement) Header() []string

func (*Statement) Scan

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

func (Statement) String

func (s Statement) String() string

func (Statement) Width

func (r Statement) Width(col int) int

type StatementList

type StatementList struct {
	StatementListRequest
	Count uint64      `json:"count"`
	Body  []Statement `json:"body"`
}

StatementList is a list of statements with a total count

func (*StatementList) Scan

func (l *StatementList) Scan(row pg.Row) error

func (*StatementList) ScanCount

func (l *StatementList) ScanCount(row pg.Row) error

func (StatementList) String

func (l StatementList) String() string

type StatementListRequest

type StatementListRequest struct {
	pg.OffsetLimit

	// Filter by database name
	Database *string `json:"database,omitempty"`

	// Filter by role name
	Role *string `json:"role,omitempty"`

	// Sort by field (calls, rows, total_ms, min_ms, max_ms, mean_ms)
	// All sort DESC except min_ms which sorts ASC
	Sort string `json:"sort,omitempty" enum:"calls,rows,total_ms,min_ms,max_ms,mean_ms" default:"max_ms"`

	// Order is the direction of the sort, asc or desc, which is the sort's
	// own direction when it's empty
	Order string `json:"order,omitempty" help:"Order of the sort (asc or desc)"`
}

StatementListRequest contains parameters for listing statements

func (StatementListRequest) Query

func (s StatementListRequest) Query() url.Values

func (*StatementListRequest) Select

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

func (StatementListRequest) String

func (l StatementListRequest) String() string

type TableMeta

type TableMeta struct {
	LiveTuples *int64 `json:"live_tuples,omitempty" help:"Number of live tuples"`
	DeadTuples *int64 `json:"dead_tuples,omitempty" help:"Number of dead tuples"`
}

TableMeta contains metadata specific to tables

func (TableMeta) String

func (t TableMeta) String() string

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

	// Databases are those with files in it, as their default, or for some
	// of their tables, or indexes, which it can't be deleted while it has
	Databases []string `json:"databases,omitempty" help:"Databases with files in the tablespace"`
}

func (Tablespace) Cell

func (r Tablespace) Cell(col int) tui.CellText

func (Tablespace) Header

func (r Tablespace) Header() []string

func (*Tablespace) Scan

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

func (Tablespace) String

func (t Tablespace) String() string

func (Tablespace) Width

func (r Tablespace) Width(col int) int

type TablespaceList

type TablespaceList struct {
	TablespaceListRequest
	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

	// Sort is what the tablespaces are sorted by, and Order its direction, asc or
	// desc, which is asc when it's empty. Empty values are last, either way.
	Sort  string `json:"sort,omitempty" help:"Sort by name, owner, location or size"`
	Order string `json:"order,omitempty" help:"Order of the sort (asc or desc)"`
}

func (TablespaceListRequest) Query

func (d TablespaceListRequest) Query() url.Values

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" arg:"" help:"Name"`
	Owner   string  `json:"owner,omitempty" help:"Owner"`
	Acl     ACLList `json:"acl,omitempty" help:"Access privileges"`
	Comment *string `json:"comment,omitempty" help:"Comment, which an empty one removes"`
}

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