config

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidValue          = errors.NewKind("ERROR:  invalid value for parameter \"%s\": \"%s\"")
	ErrCannotChangeAtRuntime = errors.NewKind("ERROR:  parameter \"%s\" cannot be changed now")
)

Functions

func Init added in v0.7.0

func Init()

Init initializes or appends to SystemVariables as it functions as a global variable. Currently, we append all of postgres configuration parameters to sql.SystemVariables. This means that all of mysql system variables and postgres config parameters will be stored together. TODO: get rid of me, use an integration point to define new sysvars

func IsValidPostgresConfigParameter

func IsValidPostgresConfigParameter(name string) bool

func TzOffsetToDuration

func TzOffsetToDuration(d string) (time.Duration, error)

TzOffsetToDuration takes in a timezone offset (e.g. "+01:00") and returns it as a time.Duration. If any problems are encountered, an error is returned.

Types

type Parameter

type Parameter struct {
	Name         string
	Default      any
	Category     string
	ShortDesc    string
	Context      ParameterContext
	Type         sql.Type
	Source       ParameterSource
	ResetVal     any
	Scope        sql.SystemVariableScope
	ValidateFunc func(any) (any, bool)
}

func (*Parameter) DisplayString

func (p *Parameter) DisplayString(_ string) string

DisplayString implements sql.SystemVariable.

func (*Parameter) GetDefault

func (p *Parameter) GetDefault() any

GetDefault implements sql.SystemVariable.

func (*Parameter) GetName

func (p *Parameter) GetName() string

GetName implements sql.SystemVariable.

func (*Parameter) GetSessionScope

func (p *Parameter) GetSessionScope() sql.SystemVariableScope

GetSessionScope implements sql.SystemVariable.

func (*Parameter) GetType

func (p *Parameter) GetType() sql.Type

GetType implements sql.SystemVariable.

func (*Parameter) InitValue

func (p *Parameter) InitValue(val any, global bool) (sql.SystemVarValue, error)

InitValue implements sql.SystemVariable.

func (*Parameter) IsGlobalOnly

func (p *Parameter) IsGlobalOnly() bool

IsGlobalOnly implements sql.SystemVariable.

func (*Parameter) IsReadOnly

func (p *Parameter) IsReadOnly() bool

IsReadOnly implements sql.SystemVariable.

func (*Parameter) SetDefault

func (p *Parameter) SetDefault(a any)

SetDefault implements sql.SystemVariable.

func (*Parameter) SetValue

func (p *Parameter) SetValue(val any, global bool) (sql.SystemVarValue, error)

SetValue implements sql.SystemVariable.

type ParameterContext

type ParameterContext string

ParameterContext sets level of difficulty of changing the parameter settings. For more detailed description on how to change the settings of specific context, https://www.postgresql.org/docs/current/view-pg-settings.html

const (
	ParameterContextInternal         ParameterContext = "internal"
	ParameterContextPostmaster       ParameterContext = "postmaster"
	ParameterContextSighup           ParameterContext = "sighup"
	ParameterContextSuperUserBackend ParameterContext = "superuser-backend"
	ParameterContextBackend          ParameterContext = "backend"
	ParameterContextSuperUser        ParameterContext = "superuser"
	ParameterContextUser             ParameterContext = "user"
)

The following constants are in order of decreasing difficulty of changing the setting.

type ParameterSource

type ParameterSource string

ParameterSource sets the source of the current parameter value.

const (
	ParameterSourceClient ParameterSource = "client"
	// ParameterSourceConfigurationFile means that the parameter needs to set
	// its Default and ResetVal to what's defined in the given config file.
	ParameterSourceConfigurationFile ParameterSource = "configuration file"
	ParameterSourceDefault           ParameterSource = "default"
	// ParameterSourceOverride means the default and reset value needs to be set at server start time
	// TODO: currently the default and reset values are dummy values.
	ParameterSourceOverride ParameterSource = "override"
)

type PgsqlScope

type PgsqlScope struct {
	Type PgsqlScopeType
}

PgsqlScope represents the scope of a PostgreSQL configuration parameter.

func (*PgsqlScope) GetValue

func (p *PgsqlScope) GetValue(ctx *sql.Context, name string, _ sql.CollationID) (any, error)

GetValue implements sql.SystemVariableScope.

func (*PgsqlScope) IsGlobalOnly

func (p *PgsqlScope) IsGlobalOnly() bool

IsGlobalOnly implements sql.SystemVariableScope.

func (*PgsqlScope) IsSessionOnly

func (p *PgsqlScope) IsSessionOnly() bool

IsSessionOnly implements sql.SystemVariableScope.

func (*PgsqlScope) SetValue

func (p *PgsqlScope) SetValue(ctx *sql.Context, name string, val any) error

SetValue implements sql.SystemVariableScope.

type PgsqlScopeType

type PgsqlScopeType byte

PgsqlScopeType represents the scope of a configuration parameter.

const (
	// PsqlScopeSession is set when the configuration parameter exists only in the session context.
	PsqlScopeSession PgsqlScopeType = iota
	// PsqlScopeLocal is set when the configuration parameter exists only in the local context.
	PsqlScopeLocal
)

Jump to

Keyboard shortcuts

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