queries

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PgPreparedXactsName     = "pg_prepared_xacts"
	PgPreparedXactsInterval = 1 * time.Minute
)
View Source
const (
	PgReplicationSlotsName     = "pg_replication_slots"
	PgReplicationSlotsInterval = 1 * time.Minute
)
View Source
const (
	PgStatActivityName     = "pg_stat_activity"
	PgStatActivityInterval = 1 * time.Minute
)
View Source
const (
	PgStatArchiverName     = "pg_stat_archiver"
	PgStatArchiverInterval = 1 * time.Minute
)
View Source
const (
	PgStatBgwriterName     = "pg_stat_bgwriter"
	PgStatBgwriterInterval = 1 * time.Minute
)
View Source
const (
	PgStatCheckpointerName     = "pg_stat_checkpointer"
	PgStatCheckpointerInterval = 1 * time.Minute
)
View Source
const (
	PgStatDatabaseName     = "pg_stat_database"
	PgStatDatabaseInterval = 1 * time.Minute
)
View Source
const (
	PgStatDatabaseConflictsName     = "pg_stat_database_conflicts"
	PgStatDatabaseConflictsInterval = 1 * time.Minute
)
View Source
const (
	PgStatIOName     = "pg_stat_io"
	PgStatIOInterval = 1 * time.Minute
)
View Source
const (
	PgStatProgressAnalyzeName     = "pg_stat_progress_analyze"
	PgStatProgressAnalyzeInterval = 30 * time.Second
)
View Source
const (
	PgStatProgressCreateIndexName     = "pg_stat_progress_create_index"
	PgStatProgressCreateIndexInterval = 30 * time.Second
)
View Source
const (
	PgStatProgressVacuumName     = "pg_stat_progress_vacuum"
	PgStatProgressVacuumInterval = 30 * time.Second
)
View Source
const (
	PgStatRecoveryPrefetchName     = "pg_stat_recovery_prefetch"
	PgStatRecoveryPrefetchInterval = 1 * time.Minute
)
View Source
const (
	PgStatReplicationName     = "pg_stat_replication"
	PgStatReplicationInterval = 1 * time.Minute
)
View Source
const (
	PgStatReplicationSlotsName     = "pg_stat_replication_slots"
	PgStatReplicationSlotsInterval = 1 * time.Minute
)
View Source
const (
	PgStatSlruName     = "pg_stat_slru"
	PgStatSlruInterval = 1 * time.Minute
)
View Source
const (
	PgStatSubscriptionName     = "pg_stat_subscription"
	PgStatSubscriptionInterval = 1 * time.Minute
)
View Source
const (
	PgStatSubscriptionStatsName     = "pg_stat_subscription_stats"
	PgStatSubscriptionStatsInterval = 1 * time.Minute
)
View Source
const (
	PgStatWalName     = "pg_stat_wal"
	PgStatWalInterval = 1 * time.Minute
)
View Source
const (
	PgStatWalReceiverName     = "pg_stat_wal_receiver"
	PgStatWalReceiverInterval = 1 * time.Minute
)

Variables

This section is empty.

Functions

func CollectView

func CollectView[T any](ctx context.Context, pool *pgxpool.Pool, query string, viewName string, scanner *pgxutil.Scanner[T]) ([]T, error)

CollectView queries a pg catalog view and scans the results into a slice of structs using the provided scanner. The caller must set a deadline on ctx.

Types

type Anyarray

type Anyarray = json.RawMessage

Anyarray and Float4Array remain json.RawMessage — they require special conversion logic in pg_stats.go.

type Bigint

type Bigint int64 // pg: bigint / int8

type Boolean

type Boolean bool // pg: boolean

type CatalogCollector

type CatalogCollector struct {
	Name          string
	Interval      time.Duration
	Collect       func(ctx context.Context) (*CollectResult, error)
	SkipUnchanged bool // When true, skip send if payload hash matches previous
}

CatalogCollector defines a periodic catalog collection task.

func NewCollector

func NewCollector[T any](
	pool *pgxpool.Pool,
	prepareCtx PrepareCtx,
	name string,
	interval time.Duration,
	query string,
	opts ...CollectorOption,
) CatalogCollector

NewCollector creates a CatalogCollector for a catalog view query. JSON is marshaled once per collection; when SkipUnchanged is set, an xxhash of the bytes is compared to the previous collection to avoid redundant sends. Even when unchanged, a send is forced every skipUnchangedForceMultiplier collection intervals to act as a heartbeat.

func PgPreparedXactsCollector

func PgPreparedXactsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgReplicationSlotsCollector

func PgReplicationSlotsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgStatActivityCollector

func PgStatActivityCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector

func PgStatArchiverCollector

func PgStatArchiverCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgStatBgwriterCollector

func PgStatBgwriterCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgStatCheckpointerCollector

func PgStatCheckpointerCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector

func PgStatDatabaseCollector

func PgStatDatabaseCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgStatDatabaseConflictsCollector

func PgStatDatabaseConflictsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgStatIOCollector

func PgStatIOCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector

func PgStatProgressAnalyzeCollector

func PgStatProgressAnalyzeCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgStatProgressCreateIndexCollector

func PgStatProgressCreateIndexCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgStatProgressVacuumCollector

func PgStatProgressVacuumCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgStatRecoveryPrefetchCollector

func PgStatRecoveryPrefetchCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector

func PgStatReplicationCollector

func PgStatReplicationCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgStatReplicationSlotsCollector

func PgStatReplicationSlotsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector

func PgStatSlruCollector

func PgStatSlruCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgStatSubscriptionCollector

func PgStatSubscriptionCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

func PgStatSubscriptionStatsCollector

func PgStatSubscriptionStatsCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector

func PgStatWalCollector

func PgStatWalCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx, pgMajorVersion int) CatalogCollector

func PgStatWalReceiverCollector

func PgStatWalReceiverCollector(pool *pgxpool.Pool, prepareCtx PrepareCtx) CatalogCollector

type CollectResult

type CollectResult struct {
	JSON []byte // Pre-marshaled JSON of the payload
}

CollectResult holds both the typed payload and its pre-marshaled JSON bytes. JSON is marshaled once at collection time so the sending pipeline can reuse the bytes without re-serializing.

func (*CollectResult) Hash

func (r *CollectResult) Hash() string

Hash returns a hex string of the xxhash of the JSON bytes, suitable for sending to the backend as a change-detection token.

type CollectorOption

type CollectorOption func(*collectorOpts)

CollectorOption configures optional behavior for NewCollector.

func WithMinPGVersion

func WithMinPGVersion(pgMajorVersion, minVersion int) CollectorOption

WithMinPGVersion skips collection when pgMajorVersion is below minVersion.

func WithSkipUnchanged

func WithSkipUnchanged() CollectorOption

WithSkipUnchanged marks the collector to skip sending if the JSON payload hash matches the previous collection.

type DoublePrecision

type DoublePrecision float64 // pg: double precision / float8

type Float4Array

type Float4Array = json.RawMessage

type Inet

type Inet string

Inet wraps string for pg inet columns. Implements pgtype.NetipPrefixScanner so InetCodec's binary scan matches.

func (*Inet) ScanNetipPrefix

func (i *Inet) ScanNetipPrefix(v netip.Prefix) error

type Integer

type Integer int64 // pg: integer / int4

type Interval

type Interval int64

Interval stores a pg interval as total microseconds. Implements pgtype.IntervalScanner so IntervalCodec's binary scan matches. PostgreSQL intervals have independent months/days/microseconds components; this type normalises them to a single microsecond count using the same conversion factors as PostgreSQL's EXTRACT(EPOCH): 1 month = 30 days, 1 day = 24 hours.

func (*Interval) ScanInterval

func (iv *Interval) ScanInterval(v pgtype.Interval) error

type Name

type Name string // pg: name — 63-byte SQL identifier

type Oid

type Oid uint32 // pg: oid — object identifier

type Payload

type Payload[T any] struct {
	Rows []T `json:"rows"`
}

Payload wraps a slice of rows collected from a catalog view.

type PgLsn

type PgLsn string // pg: pg_lsn — log sequence number

type PgPreparedXactsRow

type PgPreparedXactsRow struct {
	Transaction *Xid         `json:"transaction" db:"transaction"`
	GID         *Text        `json:"gid" db:"gid"`
	Prepared    *TimestampTZ `json:"prepared" db:"prepared"`
	Owner       *Name        `json:"owner" db:"owner"`
	Database    *Name        `json:"database" db:"database"`
}

PgPreparedXactsRow represents a row from pg_prepared_xacts.

type PgReplicationSlotsRow

type PgReplicationSlotsRow struct {
	SlotName           *Name    `json:"slot_name" db:"slot_name"`
	Plugin             *Name    `json:"plugin" db:"plugin"`
	SlotType           *Text    `json:"slot_type" db:"slot_type"`
	DatOID             *Oid     `json:"datoid" db:"datoid"`
	Database           *Name    `json:"database" db:"database"`
	Temporary          *Boolean `json:"temporary" db:"temporary"`
	Active             *Boolean `json:"active" db:"active"`
	ActivePID          *Integer `json:"active_pid" db:"active_pid"`
	Xmin               *Xid     `json:"xmin" db:"xmin"`
	CatalogXmin        *Xid     `json:"catalog_xmin" db:"catalog_xmin"`
	RestartLsn         *PgLsn   `json:"restart_lsn" db:"restart_lsn"`
	ConfirmedFlushLsn  *PgLsn   `json:"confirmed_flush_lsn" db:"confirmed_flush_lsn"`
	WalStatus          *Text    `json:"wal_status" db:"wal_status"`
	SafeWalSize        *Bigint  `json:"safe_wal_size" db:"safe_wal_size"`
	TwoPhase           *Boolean `json:"two_phase" db:"two_phase"`
	Conflicting        *Boolean `json:"conflicting" db:"conflicting"`
	InvalidationReason *Text    `json:"invalidation_reason" db:"invalidation_reason"`
	Failover           *Boolean `json:"failover" db:"failover"` // PG 17+
	Synced             *Boolean `json:"synced" db:"synced"`     // PG 17+
}

PgReplicationSlotsRow represents a row from pg_replication_slots.

type PgStatActivityRow

type PgStatActivityRow struct {
	DatID           *Oid         `json:"datid" db:"datid"`
	DatName         *Name        `json:"datname" db:"datname"`
	PID             *Integer     `json:"pid" db:"pid"`
	LeaderPID       *Integer     `json:"leader_pid" db:"leader_pid"`
	UseSysID        *Oid         `json:"usesysid" db:"usesysid"`
	UseName         *Name        `json:"usename" db:"usename"`
	ApplicationName *Text        `json:"application_name" db:"application_name"`
	ClientAddr      *Inet        `json:"client_addr" db:"client_addr"`
	ClientHostname  *Text        `json:"client_hostname" db:"client_hostname"`
	ClientPort      *Integer     `json:"client_port" db:"client_port"`
	BackendStart    *TimestampTZ `json:"backend_start" db:"backend_start"`
	XactStart       *TimestampTZ `json:"xact_start" db:"xact_start"`
	QueryStart      *TimestampTZ `json:"query_start" db:"query_start"`
	StateChange     *TimestampTZ `json:"state_change" db:"state_change"`
	WaitEventType   *Text        `json:"wait_event_type" db:"wait_event_type"`
	WaitEvent       *Text        `json:"wait_event" db:"wait_event"`
	State           *Text        `json:"state" db:"state"`
	BackendXID      *Xid         `json:"backend_xid" db:"backend_xid"`
	BackendXmin     *Xid         `json:"backend_xmin" db:"backend_xmin"`
	QueryID         *Text        `json:"query_id" db:"query_id"` // PG 14+: composite queryid_usesysid_datid (matches pg_stat_statements key)
	BackendType     *Text        `json:"backend_type" db:"backend_type"`
}

PgStatActivityRow represents a row from pg_stat_activity.

type PgStatArchiverRow

type PgStatArchiverRow struct {
	ArchivedCount    *Bigint      `json:"archived_count" db:"archived_count"`
	LastArchivedWal  *Text        `json:"last_archived_wal" db:"last_archived_wal"`
	LastArchivedTime *TimestampTZ `json:"last_archived_time" db:"last_archived_time"`
	FailedCount      *Bigint      `json:"failed_count" db:"failed_count"`
	LastFailedWal    *Text        `json:"last_failed_wal" db:"last_failed_wal"`
	LastFailedTime   *TimestampTZ `json:"last_failed_time" db:"last_failed_time"`
	StatsReset       *TimestampTZ `json:"stats_reset" db:"stats_reset"`
}

PgStatArchiverRow represents a row from pg_stat_archiver.

type PgStatBgwriterRow

type PgStatBgwriterRow struct {
	CheckpointsTimed    *Bigint          `json:"checkpoints_timed" db:"checkpoints_timed"`
	CheckpointsReq      *Bigint          `json:"checkpoints_req" db:"checkpoints_req"`
	CheckpointWriteTime *DoublePrecision `json:"checkpoint_write_time" db:"checkpoint_write_time"`
	CheckpointSyncTime  *DoublePrecision `json:"checkpoint_sync_time" db:"checkpoint_sync_time"`
	BuffersCheckpoint   *Bigint          `json:"buffers_checkpoint" db:"buffers_checkpoint"`
	BuffersClean        *Bigint          `json:"buffers_clean" db:"buffers_clean"`
	MaxwrittenClean     *Bigint          `json:"maxwritten_clean" db:"maxwritten_clean"`
	BuffersBackend      *Bigint          `json:"buffers_backend" db:"buffers_backend"`
	BuffersBackendFsync *Bigint          `json:"buffers_backend_fsync" db:"buffers_backend_fsync"`
	BuffersAlloc        *Bigint          `json:"buffers_alloc" db:"buffers_alloc"`
	StatsReset          *TimestampTZ     `json:"stats_reset" db:"stats_reset"`
}

PgStatBgwriterRow represents a row from pg_stat_bgwriter.

type PgStatCheckpointerRow

type PgStatCheckpointerRow struct {
	NumTimed           *Bigint          `json:"num_timed" db:"num_timed"`
	NumRequested       *Bigint          `json:"num_requested" db:"num_requested"`
	RestartpointsTimed *Bigint          `json:"restartpoints_timed" db:"restartpoints_timed"`
	RestartpointsReq   *Bigint          `json:"restartpoints_req" db:"restartpoints_req"`
	RestartpointsDone  *Bigint          `json:"restartpoints_done" db:"restartpoints_done"`
	WriteTime          *DoublePrecision `json:"write_time" db:"write_time"`
	SyncTime           *DoublePrecision `json:"sync_time" db:"sync_time"`
	BuffersWritten     *Bigint          `json:"buffers_written" db:"buffers_written"`
	StatsReset         *TimestampTZ     `json:"stats_reset" db:"stats_reset"`
	SlruWritten        *Bigint          `json:"slru_written" db:"slru_written"`
}

PgStatCheckpointerRow represents a row from pg_stat_checkpointer (PG 17+).

type PgStatDatabaseConflictsRow

type PgStatDatabaseConflictsRow struct {
	DatID            *Oid    `json:"datid" db:"datid"`
	DatName          *Name   `json:"datname" db:"datname"`
	ConflTablespace  *Bigint `json:"confl_tablespace" db:"confl_tablespace"`
	ConflLock        *Bigint `json:"confl_lock" db:"confl_lock"`
	ConflSnapshot    *Bigint `json:"confl_snapshot" db:"confl_snapshot"`
	ConflBufferpin   *Bigint `json:"confl_bufferpin" db:"confl_bufferpin"`
	ConflDeadlock    *Bigint `json:"confl_deadlock" db:"confl_deadlock"`
	ConflLogicalSlot *Bigint `json:"confl_active_logicalslot" db:"confl_active_logicalslot"`
}

PgStatDatabaseConflictsRow represents a row from pg_stat_database_conflicts.

type PgStatDatabaseRow

type PgStatDatabaseRow struct {
	DatID                 *Oid             `json:"datid" db:"datid"`
	DatName               *Name            `json:"datname" db:"datname"`
	NumBackends           *Integer         `json:"numbackends" db:"numbackends"`
	XactCommit            *Bigint          `json:"xact_commit" db:"xact_commit"`
	XactRollback          *Bigint          `json:"xact_rollback" db:"xact_rollback"`
	BlksRead              *Bigint          `json:"blks_read" db:"blks_read"`
	BlksHit               *Bigint          `json:"blks_hit" db:"blks_hit"`
	TupReturned           *Bigint          `json:"tup_returned" db:"tup_returned"`
	TupFetched            *Bigint          `json:"tup_fetched" db:"tup_fetched"`
	TupInserted           *Bigint          `json:"tup_inserted" db:"tup_inserted"`
	TupUpdated            *Bigint          `json:"tup_updated" db:"tup_updated"`
	TupDeleted            *Bigint          `json:"tup_deleted" db:"tup_deleted"`
	Conflicts             *Bigint          `json:"conflicts" db:"conflicts"`
	TempFiles             *Bigint          `json:"temp_files" db:"temp_files"`
	TempBytes             *Bigint          `json:"temp_bytes" db:"temp_bytes"`
	Deadlocks             *Bigint          `json:"deadlocks" db:"deadlocks"`
	ChecksumFailures      *Bigint          `json:"checksum_failures" db:"checksum_failures"`
	ChecksumLastFailure   *TimestampTZ     `json:"checksum_last_failure" db:"checksum_last_failure"`
	BlkReadTime           *DoublePrecision `json:"blk_read_time" db:"blk_read_time"`
	BlkWriteTime          *DoublePrecision `json:"blk_write_time" db:"blk_write_time"`
	SessionTime           *DoublePrecision `json:"session_time" db:"session_time"`
	ActiveTime            *DoublePrecision `json:"active_time" db:"active_time"`
	IdleInTransactionTime *DoublePrecision `json:"idle_in_transaction_time" db:"idle_in_transaction_time"`
	Sessions              *Bigint          `json:"sessions" db:"sessions"`
	SessionsAbandoned     *Bigint          `json:"sessions_abandoned" db:"sessions_abandoned"`
	SessionsFatal         *Bigint          `json:"sessions_fatal" db:"sessions_fatal"`
	SessionsKilled        *Bigint          `json:"sessions_killed" db:"sessions_killed"`
	StatsReset            *TimestampTZ     `json:"stats_reset" db:"stats_reset"`
	ParallelWorkers       *Bigint          `json:"parallel_workers" db:"parallel_workers"`
	TempBytesRead         *Bigint          `json:"temp_bytes_read" db:"temp_bytes_read"`
	TempBytesWritten      *Bigint          `json:"temp_bytes_written" db:"temp_bytes_written"`
	TempFilesRead         *Bigint          `json:"temp_files_read" db:"temp_files_read"`
	TempFilesWritten      *Bigint          `json:"temp_files_written" db:"temp_files_written"`
}

PgStatDatabaseRow represents a row from pg_stat_database.

type PgStatIORow

type PgStatIORow struct {
	BackendType   *Text            `json:"backend_type" db:"backend_type"`
	Object        *Text            `json:"object" db:"object"`
	Context       *Text            `json:"context" db:"context"`
	Reads         *Bigint          `json:"reads" db:"reads"`
	ReadTime      *DoublePrecision `json:"read_time" db:"read_time"`
	Writes        *Bigint          `json:"writes" db:"writes"`
	WriteTime     *DoublePrecision `json:"write_time" db:"write_time"`
	Writebacks    *Bigint          `json:"writebacks" db:"writebacks"`
	WritebackTime *DoublePrecision `json:"writeback_time" db:"writeback_time"`
	Extends       *Bigint          `json:"extends" db:"extends"`
	ExtendTime    *DoublePrecision `json:"extend_time" db:"extend_time"`
	OpBytes       *Bigint          `json:"op_bytes" db:"op_bytes"`
	Hits          *Bigint          `json:"hits" db:"hits"`
	Evictions     *Bigint          `json:"evictions" db:"evictions"`
	Reuses        *Bigint          `json:"reuses" db:"reuses"`
	Fsyncs        *Bigint          `json:"fsyncs" db:"fsyncs"`
	FsyncTime     *DoublePrecision `json:"fsync_time" db:"fsync_time"`
	StatsReset    *TimestampTZ     `json:"stats_reset" db:"stats_reset"`
}

PgStatIORow represents a row from pg_stat_io (PG 16+).

type PgStatProgressAnalyzeRow

type PgStatProgressAnalyzeRow struct {
	PID                    *Integer `json:"pid" db:"pid"`
	DatID                  *Oid     `json:"datid" db:"datid"`
	DatName                *Name    `json:"datname" db:"datname"`
	RelID                  *Oid     `json:"relid" db:"relid"`
	Phase                  *Text    `json:"phase" db:"phase"`
	SampleBlksTotal        *Bigint  `json:"sample_blks_total" db:"sample_blks_total"`
	SampleBlksScanned      *Bigint  `json:"sample_blks_scanned" db:"sample_blks_scanned"`
	ExtStatsTotal          *Bigint  `json:"ext_stats_total" db:"ext_stats_total"`
	ExtStatsComputed       *Bigint  `json:"ext_stats_computed" db:"ext_stats_computed"`
	ChildTablesTotal       *Bigint  `json:"child_tables_total" db:"child_tables_total"`
	ChildTablesDone        *Bigint  `json:"child_tables_done" db:"child_tables_done"`
	CurrentChildTableRelID *Oid     `json:"current_child_table_relid" db:"current_child_table_relid"`
}

PgStatProgressAnalyzeRow represents a row from pg_stat_progress_analyze (PG 13+).

type PgStatProgressCreateIndexRow

type PgStatProgressCreateIndexRow struct {
	PID              *Integer `json:"pid" db:"pid"`
	DatID            *Oid     `json:"datid" db:"datid"`
	DatName          *Name    `json:"datname" db:"datname"`
	RelID            *Oid     `json:"relid" db:"relid"`
	IndexRelID       *Oid     `json:"index_relid" db:"index_relid"`
	Command          *Text    `json:"command" db:"command"`
	Phase            *Text    `json:"phase" db:"phase"`
	LockersTotal     *Bigint  `json:"lockers_total" db:"lockers_total"`
	LockersDone      *Bigint  `json:"lockers_done" db:"lockers_done"`
	CurrentLockerPID *Bigint  `json:"current_locker_pid" db:"current_locker_pid"`
	BlocksTotal      *Bigint  `json:"blocks_total" db:"blocks_total"`
	BlocksDone       *Bigint  `json:"blocks_done" db:"blocks_done"`
	TuplesTotal      *Bigint  `json:"tuples_total" db:"tuples_total"`
	TuplesDone       *Bigint  `json:"tuples_done" db:"tuples_done"`
	PartitionsTotal  *Bigint  `json:"partitions_total" db:"partitions_total"`
	PartitionsDone   *Bigint  `json:"partitions_done" db:"partitions_done"`
}

PgStatProgressCreateIndexRow represents a row from pg_stat_progress_create_index.

type PgStatProgressVacuumRow

type PgStatProgressVacuumRow struct {
	PID              *Integer `json:"pid" db:"pid"`
	DatID            *Oid     `json:"datid" db:"datid"`
	DatName          *Name    `json:"datname" db:"datname"`
	RelID            *Oid     `json:"relid" db:"relid"`
	Phase            *Text    `json:"phase" db:"phase"`
	HeapBlksTotal    *Bigint  `json:"heap_blks_total" db:"heap_blks_total"`
	HeapBlksScanned  *Bigint  `json:"heap_blks_scanned" db:"heap_blks_scanned"`
	HeapBlksVacuumed *Bigint  `json:"heap_blks_vacuumed" db:"heap_blks_vacuumed"`
	IndexVacuumCount *Bigint  `json:"index_vacuum_count" db:"index_vacuum_count"`
	MaxDeadTuples    *Bigint  `json:"max_dead_tuples" db:"max_dead_tuples"`
	NumDeadTuples    *Bigint  `json:"num_dead_tuples" db:"num_dead_tuples"`
}

PgStatProgressVacuumRow represents a row from pg_stat_progress_vacuum.

type PgStatRecoveryPrefetchRow

type PgStatRecoveryPrefetchRow struct {
	StatsReset    *TimestampTZ `json:"stats_reset" db:"stats_reset"`
	Prefetch      *Bigint      `json:"prefetch" db:"prefetch"`
	Hit           *Bigint      `json:"hit" db:"hit"`
	SkipInit      *Bigint      `json:"skip_init" db:"skip_init"`
	SkipNew       *Bigint      `json:"skip_new" db:"skip_new"`
	SkipFpw       *Bigint      `json:"skip_fpw" db:"skip_fpw"`
	SkipRep       *Bigint      `json:"skip_rep" db:"skip_rep"`
	WalDistance   *Integer     `json:"wal_distance" db:"wal_distance"`
	BlockDistance *Integer     `json:"block_distance" db:"block_distance"`
	IoDepth       *Integer     `json:"io_depth" db:"io_depth"`
}

PgStatRecoveryPrefetchRow represents a row from pg_stat_recovery_prefetch (PG 15+).

type PgStatReplicationRow

type PgStatReplicationRow struct {
	PID             *Integer     `json:"pid" db:"pid"`
	UseSysID        *Oid         `json:"usesysid" db:"usesysid"`
	UseName         *Name        `json:"usename" db:"usename"`
	ApplicationName *Text        `json:"application_name" db:"application_name"`
	ClientAddr      *Inet        `json:"client_addr" db:"client_addr"`
	ClientHostname  *Text        `json:"client_hostname" db:"client_hostname"`
	ClientPort      *Integer     `json:"client_port" db:"client_port"`
	BackendStart    *TimestampTZ `json:"backend_start" db:"backend_start"`
	BackendXmin     *Xid         `json:"backend_xmin" db:"backend_xmin"`
	State           *Text        `json:"state" db:"state"`
	SentLsn         *PgLsn       `json:"sent_lsn" db:"sent_lsn"`
	WriteLsn        *PgLsn       `json:"write_lsn" db:"write_lsn"`
	FlushLsn        *PgLsn       `json:"flush_lsn" db:"flush_lsn"`
	ReplayLsn       *PgLsn       `json:"replay_lsn" db:"replay_lsn"`
	WriteLag        *Interval    `json:"write_lag" db:"write_lag"`
	FlushLag        *Interval    `json:"flush_lag" db:"flush_lag"`
	ReplayLag       *Interval    `json:"replay_lag" db:"replay_lag"`
	SyncPriority    *Integer     `json:"sync_priority" db:"sync_priority"`
	SyncState       *Text        `json:"sync_state" db:"sync_state"`
	ReplyTime       *TimestampTZ `json:"reply_time" db:"reply_time"`
}

PgStatReplicationRow represents a row from pg_stat_replication.

type PgStatReplicationSlotsRow

type PgStatReplicationSlotsRow struct {
	SlotName    *Name        `json:"slot_name" db:"slot_name"`
	SpillTxns   *Bigint      `json:"spill_txns" db:"spill_txns"`
	SpillCount  *Bigint      `json:"spill_count" db:"spill_count"`
	SpillBytes  *Bigint      `json:"spill_bytes" db:"spill_bytes"`
	StreamTxns  *Bigint      `json:"stream_txns" db:"stream_txns"`
	StreamCount *Bigint      `json:"stream_count" db:"stream_count"`
	StreamBytes *Bigint      `json:"stream_bytes" db:"stream_bytes"`
	TotalTxns   *Bigint      `json:"total_txns" db:"total_txns"`
	TotalBytes  *Bigint      `json:"total_bytes" db:"total_bytes"`
	StatsReset  *TimestampTZ `json:"stats_reset" db:"stats_reset"`
}

PgStatReplicationSlotsRow represents a row from pg_stat_replication_slots (PG 14+).

type PgStatSlruRow

type PgStatSlruRow struct {
	Name        *Text        `json:"name" db:"name"`
	BlksZeroed  *Bigint      `json:"blks_zeroed" db:"blks_zeroed"`
	BlksHit     *Bigint      `json:"blks_hit" db:"blks_hit"`
	BlksRead    *Bigint      `json:"blks_read" db:"blks_read"`
	BlksWritten *Bigint      `json:"blks_written" db:"blks_written"`
	BlksExists  *Bigint      `json:"blks_exists" db:"blks_exists"`
	Flushes     *Bigint      `json:"flushes" db:"flushes"`
	Truncates   *Bigint      `json:"truncates" db:"truncates"`
	StatsReset  *TimestampTZ `json:"stats_reset" db:"stats_reset"`
}

PgStatSlruRow represents a row from pg_stat_slru.

type PgStatSubscriptionRow

type PgStatSubscriptionRow struct {
	SubID              *Oid         `json:"subid" db:"subid"`
	SubName            *Name        `json:"subname" db:"subname"`
	PID                *Integer     `json:"pid" db:"pid"`
	LeaderPID          *Integer     `json:"leader_pid" db:"leader_pid"`
	RelID              *Oid         `json:"relid" db:"relid"`
	ReceivedLsn        *PgLsn       `json:"received_lsn" db:"received_lsn"`
	LastMsgSendTime    *TimestampTZ `json:"last_msg_send_time" db:"last_msg_send_time"`
	LastMsgReceiptTime *TimestampTZ `json:"last_msg_receipt_time" db:"last_msg_receipt_time"`
	LatestEndLsn       *PgLsn       `json:"latest_end_lsn" db:"latest_end_lsn"`
	LatestEndTime      *TimestampTZ `json:"latest_end_time" db:"latest_end_time"`
	WorkerType         *Text        `json:"worker_type" db:"worker_type"`
}

PgStatSubscriptionRow represents a row from pg_stat_subscription.

type PgStatSubscriptionStatsRow

type PgStatSubscriptionStatsRow struct {
	SubID           *Oid         `json:"subid" db:"subid"`
	SubName         *Name        `json:"subname" db:"subname"`
	ApplyErrorCount *Bigint      `json:"apply_error_count" db:"apply_error_count"`
	SyncErrorCount  *Bigint      `json:"sync_error_count" db:"sync_error_count"`
	StatsReset      *TimestampTZ `json:"stats_reset" db:"stats_reset"`
}

PgStatSubscriptionStatsRow represents a row from pg_stat_subscription_stats (PG 15+).

type PgStatWalReceiverRow

type PgStatWalReceiverRow struct {
	PID                *Integer     `json:"pid" db:"pid"`
	Status             *Text        `json:"status" db:"status"`
	ReceiveStartLsn    *PgLsn       `json:"receive_start_lsn" db:"receive_start_lsn"`
	ReceiveStartTli    *Integer     `json:"receive_start_tli" db:"receive_start_tli"`
	WrittenLsn         *PgLsn       `json:"written_lsn" db:"written_lsn"`
	FlushedLsn         *PgLsn       `json:"flushed_lsn" db:"flushed_lsn"`
	ReceivedTli        *Integer     `json:"received_tli" db:"received_tli"`
	LastMsgSendTime    *TimestampTZ `json:"last_msg_send_time" db:"last_msg_send_time"`
	LastMsgReceiptTime *TimestampTZ `json:"last_msg_receipt_time" db:"last_msg_receipt_time"`
	LatestEndLsn       *PgLsn       `json:"latest_end_lsn" db:"latest_end_lsn"`
	LatestEndTime      *TimestampTZ `json:"latest_end_time" db:"latest_end_time"`
	SlotName           *Text        `json:"slot_name" db:"slot_name"`
	SenderHost         *Text        `json:"sender_host" db:"sender_host"`
	SenderPort         *Integer     `json:"sender_port" db:"sender_port"`
}

PgStatWalReceiverRow represents a row from pg_stat_wal_receiver (no conninfo).

type PgStatWalRow

type PgStatWalRow struct {
	WalRecords     *Bigint          `json:"wal_records" db:"wal_records"`
	WalFpi         *Bigint          `json:"wal_fpi" db:"wal_fpi"`
	WalBytes       *Bigint          `json:"wal_bytes" db:"wal_bytes"` // pg numeric, but int64 suffices (~9.2 EB max)
	WalBuffersFull *Bigint          `json:"wal_buffers_full" db:"wal_buffers_full"`
	WalWrite       *Bigint          `json:"wal_write" db:"wal_write"`
	WalSync        *Bigint          `json:"wal_sync" db:"wal_sync"`
	WalWriteTime   *DoublePrecision `json:"wal_write_time" db:"wal_write_time"`
	WalSyncTime    *DoublePrecision `json:"wal_sync_time" db:"wal_sync_time"`
	StatsReset     *TimestampTZ     `json:"stats_reset" db:"stats_reset"`
}

PgStatWalRow represents a row from pg_stat_wal (PG 14+).

type PrepareCtx

type PrepareCtx func(ctx context.Context) (context.Context, error)

PrepareCtx is a hook called before each catalog query to allow adapters (e.g. CNPG, Patroni) to perform failover checks or replace the context.

type Real

type Real float64 // pg: real / float4

type Smallint

type Smallint int64 // pg: smallint / int2

type Text

type Text string // pg: text — variable-length string

type TimestampTZ

type TimestampTZ time.Time

TimestampTZ wraps time.Time for pg timestamptz columns. Implements pgtype.TimestamptzScanner so TimestamptzCodec's binary scan matches.

func (TimestampTZ) MarshalJSON

func (t TimestampTZ) MarshalJSON() ([]byte, error)

func (*TimestampTZ) ScanTimestamptz

func (t *TimestampTZ) ScanTimestamptz(v pgtype.Timestamptz) error

type Xid

type Xid string

Xid wraps string for pg xid (transaction ID) columns. Implements pgtype.TextScanner so Uint32Codec's binary scan matches.

func (*Xid) ScanText

func (x *Xid) ScanText(v pgtype.Text) error

Jump to

Keyboard shortcuts

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