Documentation
¶
Index ¶
- Constants
- func GrantGroupMembership(ctx context.Context, conn pg.Conn, group, member string) error
- func RevokeGroupMembership(ctx context.Context, conn pg.Conn, group, member string) error
- type ACLItem
- func (acl ACLItem) GrantDatabase(ctx context.Context, conn pg.Conn, name string) error
- func (acl ACLItem) GrantSchema(ctx context.Context, conn pg.Conn, name string) error
- func (acl ACLItem) GrantTablespace(ctx context.Context, conn pg.Conn, name string) error
- func (acl ACLItem) IsAll() bool
- func (a ACLItem) MarshalText() ([]byte, error)
- func (acl ACLItem) RevokeDatabase(ctx context.Context, conn pg.Conn, name string) error
- func (acl ACLItem) RevokeSchema(ctx context.Context, conn pg.Conn, name string) error
- func (acl ACLItem) RevokeTablespace(ctx context.Context, conn pg.Conn, name string) error
- func (a ACLItem) String() string
- func (acl *ACLItem) UnmarshalJSON(data []byte) error
- func (acl *ACLItem) UnmarshalText(data []byte) error
- func (a ACLItem) WithPriv(priv ...string) *ACLItem
- type ACLList
- type BootstrapResult
- type CategoryName
- type Cluster
- type Connection
- type ConnectionList
- type ConnectionListRequest
- type ConnectionPid
- type Database
- type DatabaseList
- type DatabaseListRequest
- type DatabaseMeta
- type DatabaseName
- type Extension
- type ExtensionList
- type ExtensionListRequest
- type ExtensionMeta
- type ExtensionName
- type Object
- type ObjectList
- type ObjectListRequest
- type ObjectMeta
- type ObjectName
- type ReplicationSlot
- type ReplicationSlotList
- type ReplicationSlotListRequest
- type ReplicationSlotMeta
- type ReplicationSlotName
- type Role
- type RoleList
- type RoleListRequest
- type RoleMeta
- type RoleName
- type Schema
- type SchemaList
- type SchemaListRequest
- type SchemaMeta
- type SchemaName
- type Setting
- type SettingCategoryList
- type SettingCategoryListRequest
- type SettingList
- type SettingListRequest
- type SettingMeta
- type SettingName
- type Statement
- type StatementList
- type StatementListRequest
- type TableMeta
- type Tablespace
- type TablespaceList
- type TablespaceListRequest
- type TablespaceMeta
- type TablespaceName
Constants ¶
const ( DatabaseListLimit = 50 ConnectionListLimit = 50 ExtensionListLimit = 50 SchemaListLimit = 20 ObjectListLimit = 20 SettingListLimit = 100 RoleListLimit = 50 TablespaceListLimit = 50 ReplicationSlotListLimit = 50 StatementListLimit = 50 )
const ( CatalogSchema = "pg_catalog" DefaultAclRole = "PUBLIC" )
const (
ExtensionDef = `` /* 171-byte string literal not displayed */
)
const (
ObjectDef = `` /* 182-byte string literal not displayed */
)
const (
SchemaDef = `schema ("oid" OID, "database" TEXT, "name" TEXT, "owner" TEXT, "acl" TEXT[], "size" BIGINT)`
)
Variables ¶
This section is empty.
Functions ¶
func GrantGroupMembership ¶
GrantGroupMembership grants group membership to 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 ¶
NewACLItem creates a new ACLItem from a PostgreSQL ACL string.
func ParseACLItem ¶
ParseACLItem parses an ACLItem from a command-line flag, like <role>:<priv>,<priv>,<priv>...
func (ACLItem) GrantDatabase ¶
GrantDatabase grants access privileges to a database.
func (ACLItem) GrantSchema ¶
GrantSchema grants access privileges to a schema.
func (ACLItem) GrantTablespace ¶
GrantTablespace grants access privileges to a tablespace.
func (ACLItem) MarshalText ¶
MarshalText returns the ACLItem as text in the format role:priv,priv,...
func (ACLItem) RevokeDatabase ¶
RevokeDatabase revokes access privileges from a database.
func (ACLItem) RevokeSchema ¶
RevokeSchema revokes access privileges from a schema.
func (ACLItem) RevokeTablespace ¶
RevokeTablespace revokes access privileges from a tablespace.
func (*ACLItem) UnmarshalJSON ¶
func (*ACLItem) UnmarshalText ¶
type ACLList ¶
type ACLList []*ACLItem
func (*ACLList) Append ¶
Append an ACLItem to the list. If an item with the same role already exists, the privileges are merged.
func (*ACLList) UnmarshalJSON ¶
func (*ACLList) UnmarshalText ¶
type BootstrapResult ¶
type BootstrapResult struct {
// StatStatementsAvailable indicates if pg_stat_statements extension is available
StatStatementsAvailable bool
}
BootstrapResult contains the result of the bootstrap process
type CategoryName ¶
type CategoryName string
CategoryName is a setting category identifier
func (CategoryName) Cell ¶
func (r CategoryName) Cell(col int) string
func (CategoryName) Header ¶
func (r CategoryName) Header() []string
func (CategoryName) Width ¶
func (r CategoryName) Width(col int) int
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) Cell ¶
func (r Connection) Cell(col int) string
func (Connection) Header ¶
func (r Connection) Header() []string
func (Connection) String ¶
func (c Connection) String() string
func (Connection) Width ¶
func (r Connection) Width(col int) int
type ConnectionList ¶
type ConnectionList struct {
ConnectionListRequest
Count uint64 `json:"count"`
Body []Connection `json:"body,omitempty"`
}
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) Query ¶
func (q ConnectionListRequest) Query() url.Values
func (ConnectionListRequest) String ¶
func (c ConnectionListRequest) String() string
type ConnectionPid ¶
type ConnectionPid uint64
type Database ¶
type Database struct {
Oid uint32 `json:"oid"`
DatabaseMeta
Size uint64 `json:"bytes,omitempty" help:"Size of database in bytes"`
}
type DatabaseList ¶
type DatabaseList struct {
DatabaseListRequest
Count uint64 `json:"count"`
Body []Database `json:"body,omitempty"`
}
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) 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"`
}
func (DatabaseMeta) String ¶
func (d DatabaseMeta) String() string
func (DatabaseMeta) Validate ¶
func (d DatabaseMeta) Validate() error
Validate checks the DatabaseMeta for valid name and owner
type DatabaseName ¶
type DatabaseName string
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"`
}
type ExtensionList ¶
type ExtensionList struct {
ExtensionListRequest
Count uint64 `json:"count"`
Body []Extension `json:"body,omitempty"`
}
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
}
func (ExtensionListRequest) Query ¶
func (q ExtensionListRequest) Query() url.Values
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) String ¶
func (e ExtensionMeta) String() string
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
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"`
}
type ObjectList ¶
type ObjectList struct {
ObjectListRequest
Count uint64 `json:"count"`
Body []Object `json:"body,omitempty"`
}
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) 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"`
}
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) 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 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) string
func (ReplicationSlot) Header ¶
func (r ReplicationSlot) Header() []string
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) String ¶
func (l ReplicationSlotList) String() string
type ReplicationSlotListRequest ¶
type ReplicationSlotListRequest struct {
pg.OffsetLimit
}
ReplicationSlotListRequest contains parameters for listing replication slots
func (ReplicationSlotListRequest) Query ¶
func (d ReplicationSlotListRequest) Query() url.Values
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) Validate ¶
func (m ReplicationSlotMeta) Validate() error
type ReplicationSlotName ¶
type ReplicationSlotName string
ReplicationSlotName is used for get/delete operations
type RoleList ¶
type RoleList struct {
RoleListRequest
Count uint64 `json:"count"`
Body []Role `json:"body,omitempty"`
}
type RoleListRequest ¶
type RoleListRequest struct {
pg.OffsetLimit
}
func (RoleListRequest) Query ¶
func (d RoleListRequest) Query() url.Values
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 *uint64 `json:"conlimit,omitempty" help:"Connection 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,omitzero" help:"Password expiration"`
Groups []string `json:"memberof,omitempty" help:"Group memberships"`
}
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"`
}
type SchemaList ¶
type SchemaList struct {
SchemaListRequest
Count uint64 `json:"count"`
Body []Schema `json:"body,omitempty"`
}
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) 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"`
}
func (SchemaMeta) String ¶
func (s SchemaMeta) String() string
type SchemaName ¶
type SchemaName string
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"`
}
Setting represents a PostgreSQL server setting
type SettingCategoryList ¶
type SettingCategoryList struct {
Count uint64 `json:"count"`
Body []string `json:"body,omitempty"`
}
SettingCategoryList contains the list of setting categories
func (SettingCategoryList) String ¶
func (s SettingCategoryList) String() string
type SettingCategoryListRequest ¶
type SettingCategoryListRequest struct{}
SettingCategoryListRequest is used to retrieve distinct setting categories
func (SettingCategoryListRequest) Query ¶
func (d SettingCategoryListRequest) Query() url.Values
type SettingList ¶
type SettingList struct {
SettingListRequest
Count uint64 `json:"count"`
Body []Setting `json:"body,omitempty"`
}
SettingList contains the list of settings
func (SettingList) String ¶
func (s SettingList) String() string
type SettingListRequest ¶
type SettingListRequest struct {
pg.OffsetLimit
Category *string `json:"category,omitempty" help:"Filter by category"`
}
SettingListRequest is used to retrieve server settings
func (SettingListRequest) Query ¶
func (d SettingListRequest) Query() url.Values
type SettingMeta ¶
type SettingMeta struct {
Value *string `json:"value"`
}
SettingMeta represents the mutable parts of a setting
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 uint64 `json:"query_id"` // Hash code to identify identical normalized queries
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
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) 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"`
}
StatementListRequest contains parameters for listing statements
func (StatementListRequest) Query ¶
func (s StatementListRequest) Query() url.Values
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
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) Cell ¶
func (r Tablespace) Cell(col int) string
func (Tablespace) Header ¶
func (r Tablespace) Header() []string
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) String ¶
func (t TablespaceList) String() string
type TablespaceListRequest ¶
type TablespaceListRequest struct {
pg.OffsetLimit
}
func (TablespaceListRequest) Query ¶
func (d TablespaceListRequest) Query() url.Values
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"`
}
func (TablespaceMeta) String ¶
func (t TablespaceMeta) String() string