volatility

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type V

type V int8

V indicates whether the result of a function is dependent *only* on the values of its explicit arguments, or can change due to outside factors (such as parameter variables or table contents).

The values are ordered with smaller values being strictly more restrictive than larger values.

NOTE: functions having side-effects, such as setval(), must be labeled volatile to ensure they will not get optimized away, even if the actual return value is not changeable.

const (
	// Leakproof means that the operator cannot modify the database, the
	// transaction state, or any other state. It cannot depend on configuration
	// settings and is guaranteed to return the same results given the same
	// arguments in any context. In addition, no information about the arguments
	// is conveyed except via the return value. Any function that might throw an
	// error depending on the values of its arguments is not leakproof.
	//
	// USE THIS WITH CAUTION! The optimizer might call operators that are leak
	// proof on inputs that they wouldn't normally be called on (e.g. pulling
	// expressions out of a CASE). In the future, they may even run on rows that
	// the user doesn't have permission to access.
	//
	// Note: Leakproof is strictly stronger than Immutable. In
	// principle it could be possible to have leakproof stable or volatile
	// functions (perhaps now()); but this is not useful in practice as very few
	// operators are marked leakproof.
	// Examples: integer comparison.
	Leakproof V = 1 + iota
	// Immutable means that the operator cannot modify the database, the
	// transaction state, or any other state. It cannot depend on configuration
	// settings and is guaranteed to return the same results given the same
	// arguments in any context. ImmutableCopy operators can be constant folded.
	// Examples: log, from_json.
	Immutable
	// Stable means that the operator cannot modify the database or the
	// transaction state and is guaranteed to return the same results given the
	// same arguments whenever it is evaluated within the same statement. Multiple
	// calls to a stable operator can be optimized to a single call.
	// Examples: current_timestamp, current_date.
	Stable
	// Volatile means that the operator can do anything, including
	// modifying database state.
	// Examples: random, crdb_internal.force_error, nextval.
	Volatile
)

func FromPostgres

func FromPostgres(provolatile string, proleakproof bool) (V, error)

FromPostgres returns a Volatility that matches the postgres provolatile/proleakproof settings.

func (V) String

func (v V) String() string

String returns the byte representation of Volatility as a string.

func (V) TitleString

func (v V) TitleString() string

TitleString returns the byte representation of Volatility as a title-cased string.

func (V) ToPostgres

func (v V) ToPostgres() (provolatile string, proleakproof bool)

ToPostgres returns the postgres "provolatile" string ("i" or "s" or "v") and the "proleakproof" flag.

Jump to

Keyboard shortcuts

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