postgres

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: PostgreSQL Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGUCs

func DefaultGUCs() map[string]any

func DefaultTunableGUCs

func DefaultTunableGUCs(memBytes uint64, cpus float64, clusterSize int) map[string]any

func ReplicationSlotName

func ReplicationSlotName(databaseName, providerName, subscriberName string) string

func SnowflakeLolorGUCs

func SnowflakeLolorGUCs(nodeOrdinal int) (map[string]any, error)

func Spock4DefaultGUCs

func Spock4DefaultGUCs() map[string]any

Types

type BuiltinRoleOptions

type BuiltinRoleOptions struct {
	PGVersion    string
	DBName       string
	ExtraSchemas []string
}

func (BuiltinRoleOptions) Schemas

func (o BuiltinRoleOptions) Schemas() []string

type ConditionalStatement

type ConditionalStatement struct {
	If   Query[bool]
	Then IStatement
	Else IStatement
}

func CreateDatabase

func CreateDatabase(name string) ConditionalStatement

func CreateReplicationSlot

func CreateReplicationSlot(databaseName, providerNode, subscriberNode string) ConditionalStatement

func CreateSubscription

func CreateSubscription(providerName, subscriberName string, providerDSN *DSN, disabled bool, syncStructure bool, syncData bool) ConditionalStatement

func EnableSubscription

func EnableSubscription(providerNode, subscriberNode string, disabled bool) ConditionalStatement

func RenameDB

func RenameDB(oldName, newName string) ConditionalStatement

func (ConditionalStatement) Exec

type DSN

type DSN struct {
	Hosts           []string
	Ports           []int
	User            string
	Password        string
	DBName          string
	SSLCert         string
	SSLKey          string
	SSLRootCert     string
	ApplicationName string
	Extra           map[string]string
}

func (*DSN) String

func (d *DSN) String() string

type Executor

type Executor interface {
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, arguments ...any) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, arguments ...any) pgx.Row
}

type IStatement

type IStatement interface {
	Exec(ctx context.Context, conn Executor) error
}

type Query

type Query[T any] struct {
	SQL  string
	Args pgx.NamedArgs
}

func CurrentReplicationSlotLSN

func CurrentReplicationSlotLSN(databaseName, providerNode, subscriberNode string) Query[string]

func GetPostgresVersion

func GetPostgresVersion() Query[string]

func GetReplicationSetTables

func GetReplicationSetTables() Query[ReplicationSetTable]

func GetReplicationSets

func GetReplicationSets() Query[ReplicationSet]

func GetReplicationSlotLSNFromCommitTS

func GetReplicationSlotLSNFromCommitTS(databaseName, providerNode, subscriberNode string, commitTS time.Time) Query[string]

func GetSpockReadOnly

func GetSpockReadOnly() Query[string]

func GetSpockVersion

func GetSpockVersion() Query[string]

func GetSubscriptionStatuses

func GetSubscriptionStatuses() Query[SubscriptionStatus]

func IsSpockEnabled

func IsSpockEnabled() Query[bool]

func LagTrackerCommitTimestamp

func LagTrackerCommitTimestamp(originNode, receiverNode string) Query[time.Time]

func ReplicationSlotNeedsCreate

func ReplicationSlotNeedsCreate(databaseName, providerNode, subscriberNode string) Query[bool]

func SubscriptionDsnNeedsUpdate

func SubscriptionDsnNeedsUpdate(providerName, subscriberName string, providerDSN *DSN) Query[bool]

func SubscriptionNeedsCreate

func SubscriptionNeedsCreate(providerName, subscriberName string) Query[bool]

func SubscriptionNeedsEnable

func SubscriptionNeedsEnable(providerName, subscriberName string, disabled bool) Query[bool]

func SyncEvent

func SyncEvent() Query[string]

func (Query[T]) Scalar

func (q Query[T]) Scalar(ctx context.Context, conn Executor) (T, error)

func (Query[T]) Scalars

func (q Query[T]) Scalars(ctx context.Context, conn Executor) ([]T, error)

func (Query[T]) Structs

func (q Query[T]) Structs(ctx context.Context, conn Executor) ([]T, error)

type ReplicationSet

type ReplicationSet struct {
	SetID       uint32
	SetNodeID   uint32
	SetName     string
	RepInsert   bool
	RepUpdate   bool
	RepDelete   bool
	RepTruncate bool
}

type ReplicationSetTable

type ReplicationSetTable struct {
	SetID        uint32
	SetRelOID    uint32
	SetAttList   []string
	SetRowFilter string
}

type Statement

type Statement struct {
	SQL  string
	Args pgx.NamedArgs
}

func AddReplicationSetTable

func AddReplicationSetTable(
	setName string,
	relOID uint32,
	columns []string,
	rowFilter string,
	sync bool,
	includePartitions bool,
) Statement

https://docs.pgedge.com/spock_ext/spock_functions/functions/spock_repset_add_table

func AdvanceReplicationSlotToLSN

func AdvanceReplicationSlotToLSN(databaseName, providerNode, subscriberNode string, targetLSN string) Statement

func DropAllSubscriptions

func DropAllSubscriptions() Statement

func DropSubscription

func DropSubscription(providerName, subscriberName string) Statement

func EnableRepairMode

func EnableRepairMode() Statement

func TerminateOtherConnections

func TerminateOtherConnections(dbName string) Statement

func WaitForSyncEvent

func WaitForSyncEvent(originNode, lsn string, timeoutSeconds int) Statement

func (Statement) Exec

func (s Statement) Exec(ctx context.Context, conn Executor) error

type Statements

type Statements []IStatement

func CreateApplicationReadOnlyRole

func CreateApplicationReadOnlyRole(opts BuiltinRoleOptions) Statements

func CreateApplicationRole

func CreateApplicationRole(opts BuiltinRoleOptions) Statements

func CreateBuiltInRoles

func CreateBuiltInRoles(opts BuiltinRoleOptions) (Statements, error)

func CreatePgEdgeSuperuserRole

func CreatePgEdgeSuperuserRole(opts BuiltinRoleOptions) (Statements, error)

func CreateUserRole

func CreateUserRole(opts UserRoleOptions) (Statements, error)

func DropSpockAndCleanupSlots

func DropSpockAndCleanupSlots(dbName string) Statements

func InitializePgEdgeExtensions

func InitializePgEdgeExtensions(nodeName string, dsn *DSN) Statements

func RestoreReplicationSets

func RestoreReplicationSets(sets []ReplicationSet, tabs []ReplicationSetTable) Statements

func (Statements) Exec

func (s Statements) Exec(ctx context.Context, conn Executor) error

type SubscriptionStatus

type SubscriptionStatus struct {
	SubscriptionName string   `json:"subscription_name"`
	Status           string   `json:"status"`
	ProviderNode     string   `json:"provider_node"`
	ProviderDSN      string   `json:"provider_dsn"`
	SlotName         string   `json:"slot_name"`
	ReplicationSets  []string `json:"replication_sets"`
	ForwardOrigins   []string `json:"forward_origins"`
}

type UserRoleOptions

type UserRoleOptions struct {
	Name       string
	Password   string
	DBName     string
	DBOwner    bool
	Attributes []string
	Roles      []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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