postgres

package
v0.61.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: BSD-2-Clause, BSD-3-Clause, PostgreSQL Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const HelperReadLogFile = `` /* 220-byte string literal not displayed */
View Source
const LogFileSql = "SELECT name FROM pg_catalog.pg_ls_logdir() WHERE modification > pg_catalog.now() - '2 minute'::interval"
View Source
const QueryMarkerSQL string = "/* pganalyze-collector */ "
View Source
const SuperUserReadLogFileSql = `` /* 330-byte string literal not displayed */

Read at most the trailing 10 megabytes of each file

Variables

This section is empty.

Functions

func CurrentDatabaseName

func CurrentDatabaseName(ctx context.Context, db *sql.DB) (result string, err error)

CurrentDatabaseName - Get name of the database we're currently connected to

func CurrentDatabaseOid

func CurrentDatabaseOid(ctx context.Context, db *sql.DB) (result state.Oid, err error)

CurrentDatabaseOid - Find OID of the database we're currently connected to

func EstablishConnection

func EstablishConnection(ctx context.Context, server *state.Server, logger *util.Logger, globalCollectionOpts state.CollectionOpts, databaseName string) (connection *sql.DB, err error)

func GetBackendCounts

func GetBackendCounts(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, systemType string) ([]state.PostgresBackendCount, error)

func GetBackends

func GetBackends(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, systemType string, collectPostgresLocks bool) ([]state.PostgresBackend, error)

func GetColumnStats added in v0.41.0

func GetColumnStats(ctx context.Context, logger *util.Logger, db *sql.DB, globalCollectionOpts state.CollectionOpts, systemType string, dbName string, server *state.Server, postgresVersion state.PostgresVersion) (state.PostgresColumnStatsMap, error)

func GetDataDirectory added in v0.52.0

func GetDataDirectory(server *state.Server, settings []state.PostgresSetting) string

GetDataDirectory - Finds the data_directory in the list of settings and returns its current value. Returns an empty string if not found (e.g., the setting is not present due to permissions issues)

func GetDatabases

func GetDatabases(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion) ([]state.PostgresDatabase, state.PostgresDatabaseStatsMap, error)

func GetDatabasesToCollect added in v0.56.0

func GetDatabasesToCollect(server *state.Server, databases []state.PostgresDatabase) []string

func GetExtensions added in v0.45.0

func GetExtensions(ctx context.Context, db *sql.DB, currentDatabaseOid state.Oid) ([]state.PostgresExtension, error)

func GetFunctionStats

func GetFunctionStats(ctx context.Context, db *sql.DB, postgresVersion state.PostgresVersion, ignoreRegexp string) (functionStats state.PostgresFunctionStatsMap, err error)

func GetFunctions

func GetFunctions(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, currentDatabaseOid state.Oid, ignoreRegexp string) ([]state.PostgresFunction, error)

func GetIndexStats

func GetIndexStats(ctx context.Context, db *sql.DB, postgresVersion state.PostgresVersion, server *state.Server) (indexStats state.PostgresIndexStatsMap, err error)

func GetIsAwsAurora

func GetIsAwsAurora(ctx context.Context, db *sql.DB) (bool, error)

func GetIsReplica

func GetIsReplica(ctx context.Context, logger *util.Logger, db *sql.DB) (bool, error)

func GetPostgresSetting

func GetPostgresSetting(ctx context.Context, settingName string, server *state.Server, globalCollectionOpts state.CollectionOpts, prefixedLogger *util.Logger) (string, error)

func GetPostgresVersion

func GetPostgresVersion(ctx context.Context, logger *util.Logger, db *sql.DB) (version state.PostgresVersion, err error)

GetPostgresVersion - Reads the version of the connected PostgreSQL server

func GetRelationStats

func GetRelationStats(ctx context.Context, db *sql.DB, postgresVersion state.PostgresVersion, server *state.Server) (relStats state.PostgresRelationStatsMap, err error)

func GetRelationStatsExtended added in v0.53.0

func GetRelationStatsExtended(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, server *state.Server, globalCollectionOpts state.CollectionOpts, systemType string, dbName string) (state.PostgresRelationStatsExtendedMap, error)

func GetRelations

func GetRelations(ctx context.Context, db *sql.DB, postgresVersion state.PostgresVersion, currentDatabaseOid state.Oid, ignoreRegexp string) ([]state.PostgresRelation, error)

func GetReplication

func GetReplication(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, systemType string) (state.PostgresReplication, error)

func GetRoles

func GetRoles(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion) ([]state.PostgresRole, error)

func GetServerStats added in v0.47.0

func GetServerStats(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, systemType string) (state.PostgresServerStats, error)

func GetSettings

func GetSettings(ctx context.Context, db *sql.DB) ([]state.PostgresSetting, error)

func GetStatements

func GetStatements(ctx context.Context, server *state.Server, logger *util.Logger, db *sql.DB, globalCollectionOpts state.CollectionOpts, postgresVersion state.PostgresVersion, showtext bool, systemType string) (state.PostgresStatementMap, state.PostgresStatementTextMap, state.PostgresStatementStatsMap, error)

func GetTypes added in v0.41.0

func GetTypes(ctx context.Context, db *sql.DB, postgresVersion state.PostgresVersion, currentDatabaseOid state.Oid) ([]state.PostgresType, error)

func GetVacuumProgress

func GetVacuumProgress(ctx context.Context, logger *util.Logger, db *sql.DB, postgresVersion state.PostgresVersion, ignoreRegexp string) ([]state.PostgresVacuumProgress, error)

func LogPgReadFile added in v0.45.0

func LogPgReadFile(ctx context.Context, server *state.Server, globalCollectionOpts state.CollectionOpts, logger *util.Logger) (state.PersistedLogState, []state.LogFile, []state.PostgresQuerySample, error)

LogPgReadFile - Gets log files using the pg_read_file function

func ResetStatements

func ResetStatements(ctx context.Context, logger *util.Logger, db *sql.DB, systemType string) error

func RunExplain

func RunExplain(ctx context.Context, server *state.Server, inputs []state.PostgresQuerySample, collectionOpts state.CollectionOpts, logger *util.Logger) (outputs []state.PostgresQuerySample)

func SetDefaultStatementTimeout

func SetDefaultStatementTimeout(ctx context.Context, connection *sql.DB, logger *util.Logger, server *state.Server) error

func SetQueryTextStatementTimeout

func SetQueryTextStatementTimeout(ctx context.Context, connection *sql.DB, logger *util.Logger, server *state.Server) error

func SetStatementTimeout

func SetStatementTimeout(ctx context.Context, connection *sql.DB, statementTimeoutMs int32) error

func StatsHelperExists added in v0.43.0

func StatsHelperExists(ctx context.Context, db *sql.DB, statsHelper string) bool

func StatsHelperReturnType added in v0.60.0

func StatsHelperReturnType(ctx context.Context, db *sql.DB, statsHelper string) string

Types

type FunctionSignature added in v0.59.0

type FunctionSignature struct {
	SchemaName   string
	FunctionName string
	Arguments    string
}

Jump to

Keyboard shortcuts

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