tree

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SeqOptAs        = "AS"
	SeqOptCycle     = "CYCLE"
	SeqOptNoCycle   = "NO CYCLE"
	SeqOptOwnedBy   = "OWNED BY"
	SeqOptCache     = "CACHE"
	SeqOptIncrement = "INCREMENT BY"
	SeqOptMinValue  = "MINVALUE"
	SeqOptMaxValue  = "MAXVALUE"
	SeqOptStart     = "START WITH"

	// SeqOptRestart is used for ALTER sequence option only
	SeqOptRestart = "RESTART"
)

Names of options on CREATE SEQUENCE.

View Source
const (
	// TimestampTZOutputFormat is used to output all TimestampTZs.
	TimestampTZOutputFormat = "2006-01-02 15:04:05.999999-07:00"
	// TimestampOutputFormat is used to output all Timestamps.
	TimestampOutputFormat = "2006-01-02 15:04:05.999999"
)

time.Time formats.

View Source
const (
	DistinctFuncType funcType
	AllFuncType
)

FuncExpr.Type

View Source
const (
	CastExplicit castSyntaxMode = iota
	CastShort
	CastPrepend
)

These constants separate the syntax X::Y from CAST(X AS Y).

View Source
const (
	AnnotateExplicit annotateSyntaxMode = iota
	AnnotateShort
)

These constants separate the syntax X:::Y from ANNOTATE_TYPE(X, Y)

View Source
const (
	// FmtSimple instructs the pretty-printer to produce
	// a straightforward representation.
	FmtSimple FmtFlags = 0

	// FmtBareStrings instructs the pretty-printer to print strings and
	// other values without wrapping quotes. If the value is a SQL
	// string, the quotes will only be omitted if the string contains no
	// special characters. If it does contain special characters, the
	// string will be escaped and enclosed in e'...' regardless of
	// whether FmtBareStrings is specified. See FmtRawStrings below for
	// an alternative.
	FmtBareStrings = FmtFlags(lex.EncBareStrings)

	// FmtBareIdentifiers instructs the pretty-printer to print
	// identifiers without wrapping quotes in any case.
	FmtBareIdentifiers = FmtFlags(lex.EncBareIdentifiers)

	// FmtShowPasswords instructs the pretty-printer to not suppress passwords.
	// If not set, passwords are replaced by *****.
	FmtShowPasswords = FmtFlags(lex.EncFirstFreeFlagBit) << iota

	// FmtShowTypes instructs the pretty-printer to
	// annotate expressions with their resolved types.
	FmtShowTypes

	// FmtHideConstants instructs the pretty-printer to produce a
	// representation that does not disclose query-specific data. It
	// also shorten long lists in tuples, VALUES and array expressions.
	FmtHideConstants

	// FmtAnonymize instructs the pretty-printer to remove
	// any name but function names.
	// TODO(knz): temporary until a better solution is found for #13968
	FmtAnonymize

	// FmtAlwaysQualifyTableNames instructs the pretty-printer to
	// qualify table names, even if originally omitted.
	// Requires Annotations in the formatting context.
	FmtAlwaysQualifyTableNames

	// FmtAlwaysGroupExprs instructs the pretty-printer to enclose
	// sub-expressions between parentheses.
	// Used for testing.
	FmtAlwaysGroupExprs

	// FmtShowTableAliases reveals the table aliases.
	FmtShowTableAliases

	// FmtSymbolicSubqueries indicates that subqueries must be pretty-printed
	// using numeric notation (@S123).
	FmtSymbolicSubqueries

	// FmtParsableNumerics produces decimal and float representations
	// that are always parsable, even if they require a string
	// representation like -Inf. Negative values are preserved "inside"
	// the numeric by enclosing them within parentheses.
	FmtParsableNumerics

	// FmtPGCatalog is used to produce expressions formatted in a way that's as
	// close as possible to what clients expect to live in pg_catalog (e.g.
	// pg_attrdef.adbin and pg_constraint.condef columns). Specifically, this
	// strips type annotations, since Postgres doesn't know what those are, and
	// adds cast expressions for non-numeric constants.
	FmtPGCatalog

	// FmtPGIndexDef is used to produce CREATE INDEX statements that are
	// compatible with pg_get_indexdef.
	FmtPGIndexDef
)

Basic bit definitions for the FmtFlags bitmask.

View Source
const (
	// FmtPgwireText instructs the pretty-printer to use
	// a pg-compatible conversion to strings. See comments
	// in pgwire_encode.go.
	FmtPgwireText = fmtPgwireFormat | FmtFlags(lex.EncBareStrings)

	// FmtParsable instructs the pretty-printer to produce a representation that
	// can be parsed into an equivalent expression. If there is a chance that the
	// formatted data will be stored durably on disk or sent to other nodes,
	// then this formatting directive is not appropriate, and FmtSerializable
	// should be used instead.
	FmtParsable = fmtDisambiguateDatumTypes | FmtParsableNumerics

	// FmtSerializable instructs the pretty-printer to produce a representation
	// for expressions that can be serialized to disk. It serializes user defined
	// types using representations that are stable across changes of the type
	// itself. This should be used when serializing expressions that will be
	// stored on disk, like DEFAULT expressions of columns.
	FmtSerializable = FmtParsable | fmtStaticallyFormatUserDefinedTypes

	// FmtCheckEquivalence instructs the pretty-printer to produce a representation
	// that can be used to check equivalence of expressions. Specifically:
	//  - IndexedVars are formatted using symbolic notation (to disambiguate
	//    columns).
	//  - datum types are disambiguated with explicit type
	//    annotations. This is necessary because datums of different types
	//    can otherwise be formatted to the same string: (for example the
	//    DDecimal 1 and the DInt 1).
	//  - user defined types and datums of user defined types are formatted
	//    using static representations to avoid name resolution and invalidation
	//    due to changes in the underlying type.
	FmtCheckEquivalence = fmtSymbolicVars |
		fmtDisambiguateDatumTypes |
		FmtParsableNumerics |
		fmtStaticallyFormatUserDefinedTypes

	// FmtArrayToString is a special composite flag suitable
	// for the output of array_to_string(). This de-quotes
	// the strings enclosed in the array and skips the normal escaping
	// of strings. Special characters are hex-escaped.
	FmtArrayToString = FmtBareStrings | fmtRawStrings

	// FmtExport, if set, formats datums in a raw form suitable for
	// EXPORT, e.g. suitable for output into a CSV file. The intended
	// goal for this flag is to ensure values can be read back using the
	// ParseDatumStringAs() / ParseStringas() functions (IMPORT).
	//
	// We do not use FmtParsable for this purpose because FmtParsable
	// intends to preserve all the information useful to CockroachDB
	// internally, at the expense of readability by 3rd party tools.
	//
	// We also separate this set of flag from fmtArrayToString
	// because the behavior of array_to_string() is fixed for compatibility
	// with PostgreSQL, whereas EXPORT may evolve over time to support
	// other things (eg. fixing #33429).
	//
	// TODO(mjibson): Note that this is currently not suitable for
	// emitting arrays or tuples. See: #33429
	FmtExport = FmtBareStrings | fmtRawStrings
)

Composite/derived flag definitions follow.

View Source
const (
	// PublicSchema is the name of the physical schema in every
	// database/catalog.
	PublicSchema string = sessiondata.PublicSchemaName
	// PublicSchemaName is the same, typed as Name.
	PublicSchemaName = Name(PublicSchema)
)
View Source
const (
	// PrettyNoAlign disables alignment.
	PrettyNoAlign PrettyAlignMode = 0
	// PrettyAlignOnly aligns sub-clauses only and preserves the
	// hierarchy of logical operators.
	PrettyAlignOnly = 1
	// PrettyAlignAndDeindent does the work of PrettyAlignOnly and also
	// de-indents AND and OR operators.
	PrettyAlignAndDeindent = 2
	// PrettyAlignAndExtraIndent does the work of PrettyAlignOnly and
	// also extra indents the operands of AND and OR operators so
	// that they appear aligned but also indented.
	PrettyAlignAndExtraIndent = 3
)
View Source
const (
	// ScrubTable describes the SCRUB operation SCRUB TABLE.
	ScrubTable = iota
	// ScrubDatabase describes the SCRUB operation SCRUB DATABASE.
	ScrubDatabase = iota
)
View Source
const (
	AstFull  = "FULL"
	AstLeft  = "LEFT"
	AstRight = "RIGHT"
	AstCross = "CROSS"
	AstInner = "INNER"
)

JoinTableExpr.Join

View Source
const (
	AstHash   = "HASH"
	AstLookup = "LOOKUP"
	AstMerge  = "MERGE"
)

JoinTableExpr.Hint

View Source
const (
	AstWhere  = "WHERE"
	AstHaving = "HAVING"
)

Where.Type

View Source
const LikeTableOptAll = ^likeTableOptInvalid

LikeTableOptAll is the full LikeTableOpt bitmap.

View Source
const MaxPlaceholderIdx = math.MaxUint16

MaxPlaceholderIdx is the maximum allowed value of a PlaceholderIdx. The pgwire protocol is limited to 2^16 placeholders, so we limit the IDs to this range as well.

Variables

View Source
var (

	// NumValAvailInteger is the set of available integer types.
	NumValAvailInteger = append(intLikeTypes, decimalLikeTypes...)
	// NumValAvailDecimalNoFraction is the set of available integral numeric types.
	NumValAvailDecimalNoFraction = append(decimalLikeTypes, intLikeTypes...)
	// NumValAvailDecimalWithFraction is the set of available fractional numeric types.
	NumValAvailDecimalWithFraction = decimalLikeTypes
)
View Source
var (
	// StrValAvailAllParsable is the set of parsable string types.
	StrValAvailAllParsable = []*types.T{

		types.String,
		types.Bytes,
		types.Bool,
		types.Int,
		types.Float,
		types.Decimal,
		types.Date,
		types.StringArray,
		types.IntArray,
		types.Box2D,
		types.Geography,
		types.Geometry,
		types.DecimalArray,
		types.Time,
		types.TimeTZ,
		types.Timestamp,
		types.TimestampTZ,
		types.Interval,
		types.Uuid,
		types.INet,
		types.Jsonb,
		types.VarBit,
		types.AnyEnum,
	}
	// StrValAvailBytes is the set of types convertible to byte array.
	StrValAvailBytes = []*types.T{types.Bytes, types.Uuid, types.String, types.AnyEnum}
)
View Source
var (

	// DBoolTrue is a pointer to the DBool(true) value and can be used in
	// comparisons against Datum types.
	DBoolTrue = &constDBoolTrue
	// DBoolFalse is a pointer to the DBool(false) value and can be used in
	// comparisons against Datum types.
	DBoolFalse = &constDBoolFalse

	// DNull is the NULL Datum.
	DNull Datum = NullLiteral{}

	// DTimeMaxTimeRegex is a compiled regex for parsing the 24:00 time value.
	DTimeMaxTimeRegex = regexp.MustCompile(`^([0-9-]*(\s|T))?\s*24:00(:00(.0+)?)?\s*$`)

	// MaxSupportedTime is the maximum time we support parsing.
	MaxSupportedTime = time.Unix(9224318016000-1, 999999000).UTC() // 294276-12-31 23:59:59.999999
	// MinSupportedTime is the minimum time we support parsing.
	MinSupportedTime = time.Unix(-210866803200, 0).UTC() // 4714-11-24 00:00:00+00 BC

	// LibPQTimePrefix is the prefix lib/pq prints time-type datatypes with.
	LibPQTimePrefix = "0000-01-01"
)
View Source
var (
	// DecimalCtx is the default context for decimal operations. Any change
	// in the exponent limits must still guarantee a safe conversion to the
	// postgres binary decimal format in the wire protocol, which uses an
	// int16. See pgwire/types.go.
	DecimalCtx = &apd.Context{
		Precision:   20,
		Rounding:    apd.RoundHalfUp,
		MaxExponent: 2000,
		MinExponent: -2000,

		Traps: apd.DefaultTraps &^ apd.InvalidOperation,
	}
	// ExactCtx is a decimal context with exact precision.
	ExactCtx = DecimalCtx.WithPrecision(0)
	// HighPrecisionCtx is a decimal context with high precision.
	HighPrecisionCtx = DecimalCtx.WithPrecision(2000)
	// IntermediateCtx is a decimal context with additional precision for
	// intermediate calculations to protect against order changes that can
	// happen in dist SQL. The additional 5 allows the stress test to pass.
	// See #13689 for more analysis and other algorithms.
	IntermediateCtx = DecimalCtx.WithPrecision(DecimalCtx.Precision + 5)
	// RoundCtx is a decimal context with high precision and RoundHalfEven
	// rounding.
	RoundCtx = func() *apd.Context {
		ctx := *HighPrecisionCtx
		ctx.Rounding = apd.RoundHalfEven
		return &ctx
	}()
)
View Source
var AbsentReturningClause = &NoReturningClause{}

AbsentReturningClause is a ReturningClause variant representing the absence of a RETURNING clause.

View Source
var BinOps = map[BinaryOperator]binOpOverload{
	Bitand: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.VarBit,
			RightType:  types.VarBit,
			ReturnType: types.VarBit,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.INet,
			RightType:  types.INet,
			ReturnType: types.INet,
			Volatility: VolatilityImmutable,
		},
	},

	Bitor: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.VarBit,
			RightType:  types.VarBit,
			ReturnType: types.VarBit,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.INet,
			RightType:  types.INet,
			ReturnType: types.INet,
			Volatility: VolatilityImmutable,
		},
	},

	Bitxor: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.VarBit,
			RightType:  types.VarBit,
			ReturnType: types.VarBit,
			Volatility: VolatilityImmutable,
		},
	},

	Plus: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Float,
			RightType:  types.Float,
			ReturnType: types.Float,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Int,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Date,
			RightType:  types.Int,
			ReturnType: types.Date,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Date,
			ReturnType: types.Date,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Date,
			RightType:  types.Time,
			ReturnType: types.Timestamp,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Time,
			RightType:  types.Date,
			ReturnType: types.Timestamp,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Date,
			RightType:  types.TimeTZ,
			ReturnType: types.TimestampTZ,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.TimeTZ,
			RightType:  types.Date,
			ReturnType: types.TimestampTZ,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Time,
			RightType:  types.Interval,
			ReturnType: types.Time,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.Time,
			ReturnType: types.Time,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.TimeTZ,
			RightType:  types.Interval,
			ReturnType: types.TimeTZ,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.TimeTZ,
			ReturnType: types.TimeTZ,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Timestamp,
			RightType:  types.Interval,
			ReturnType: types.Timestamp,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.Timestamp,
			ReturnType: types.Timestamp,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.TimestampTZ,
			RightType:  types.Interval,
			ReturnType: types.TimestampTZ,
			Volatility: VolatilityStable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.TimestampTZ,
			ReturnType: types.TimestampTZ,
			Volatility: VolatilityStable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.Interval,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Date,
			RightType:  types.Interval,
			ReturnType: types.Timestamp,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.Date,
			ReturnType: types.Timestamp,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.INet,
			RightType:  types.Int,
			ReturnType: types.INet,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.INet,
			ReturnType: types.INet,
			Volatility: VolatilityImmutable,
		},
	},

	Minus: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Float,
			RightType:  types.Float,
			ReturnType: types.Float,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Int,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Date,
			RightType:  types.Int,
			ReturnType: types.Date,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Date,
			RightType:  types.Date,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Date,
			RightType:  types.Time,
			ReturnType: types.Timestamp,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Time,
			RightType:  types.Time,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Timestamp,
			RightType:  types.Timestamp,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.TimestampTZ,
			RightType:  types.TimestampTZ,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Timestamp,
			RightType:  types.TimestampTZ,
			ReturnType: types.Interval,
			Volatility: VolatilityStable,
		},
		&BinOp{
			LeftType:   types.TimestampTZ,
			RightType:  types.Timestamp,
			ReturnType: types.Interval,
			Volatility: VolatilityStable,
		},
		&BinOp{
			LeftType:   types.Time,
			RightType:  types.Interval,
			ReturnType: types.Time,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.TimeTZ,
			RightType:  types.Interval,
			ReturnType: types.TimeTZ,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Timestamp,
			RightType:  types.Interval,
			ReturnType: types.Timestamp,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.TimestampTZ,
			RightType:  types.Interval,
			ReturnType: types.TimestampTZ,
			Volatility: VolatilityStable,
		},
		&BinOp{
			LeftType:   types.Date,
			RightType:  types.Interval,
			ReturnType: types.Timestamp,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.Interval,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Jsonb,
			RightType:  types.String,
			ReturnType: types.Jsonb,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Jsonb,
			RightType:  types.Int,
			ReturnType: types.Jsonb,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Jsonb,
			RightType:  types.MakeArray(types.String),
			ReturnType: types.Jsonb,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.INet,
			RightType:  types.INet,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{

			LeftType:   types.INet,
			RightType:  types.Int,
			ReturnType: types.INet,
			Volatility: VolatilityImmutable,
		},
	},

	Mult: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Float,
			RightType:  types.Float,
			ReturnType: types.Float,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},

		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Int,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Interval,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.Int,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.Float,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Float,
			RightType:  types.Interval,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Interval,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.Decimal,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
	},

	Div: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Float,
			RightType:  types.Float,
			ReturnType: types.Float,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Int,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.Int,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Interval,
			RightType:  types.Float,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
	},

	FloorDiv: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Float,
			RightType:  types.Float,
			ReturnType: types.Float,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Int,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
	},

	Mod: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Float,
			RightType:  types.Float,
			ReturnType: types.Float,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Int,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
	},

	Concat: {
		&BinOp{
			LeftType:   types.String,
			RightType:  types.String,
			ReturnType: types.String,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Bytes,
			RightType:  types.Bytes,
			ReturnType: types.Bytes,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.VarBit,
			RightType:  types.VarBit,
			ReturnType: types.VarBit,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Jsonb,
			RightType:  types.Jsonb,
			ReturnType: types.Jsonb,
			Volatility: VolatilityImmutable,
		},
	},

	LShift: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.VarBit,
			RightType:  types.Int,
			ReturnType: types.VarBit,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.INet,
			RightType:  types.INet,
			ReturnType: types.Bool,
			Volatility: VolatilityImmutable,
		},
	},

	RShift: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.VarBit,
			RightType:  types.Int,
			ReturnType: types.VarBit,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.INet,
			RightType:  types.INet,
			ReturnType: types.Bool,
			Volatility: VolatilityImmutable,
		},
	},

	Pow: {
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Float,
			RightType:  types.Float,
			ReturnType: types.Float,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Decimal,
			RightType:  types.Int,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Int,
			RightType:  types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
	},

	JSONFetchVal: {
		&BinOp{
			LeftType:   types.Jsonb,
			RightType:  types.String,
			ReturnType: types.Jsonb,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Jsonb,
			RightType:  types.Int,
			ReturnType: types.Jsonb,
			Volatility: VolatilityImmutable,
		},
	},

	JSONFetchValPath: {
		&BinOp{
			LeftType:   types.Jsonb,
			RightType:  types.MakeArray(types.String),
			ReturnType: types.Jsonb,
			Volatility: VolatilityImmutable,
		},
	},

	JSONFetchText: {
		&BinOp{
			LeftType:   types.Jsonb,
			RightType:  types.String,
			ReturnType: types.String,
			Volatility: VolatilityImmutable,
		},
		&BinOp{
			LeftType:   types.Jsonb,
			RightType:  types.Int,
			ReturnType: types.String,
			Volatility: VolatilityImmutable,
		},
	},

	JSONFetchTextPath: {
		&BinOp{
			LeftType:   types.Jsonb,
			RightType:  types.MakeArray(types.String),
			ReturnType: types.String,
			Volatility: VolatilityImmutable,
		},
	},
}

BinOps contains the binary operations indexed by operation type.

View Source
var CmpOps = cmpOpFixups(map[ComparisonOperator]cmpOpOverload{
	EQ: {

		makeEqFn(types.AnyEnum, types.AnyEnum, VolatilityImmutable),
		makeEqFn(types.Bool, types.Bool, VolatilityLeakProof),
		makeEqFn(types.Bytes, types.Bytes, VolatilityLeakProof),
		makeEqFn(types.Date, types.Date, VolatilityLeakProof),
		makeEqFn(types.Decimal, types.Decimal, VolatilityImmutable),

		makeEqFn(types.AnyCollatedString, types.AnyCollatedString, VolatilityLeakProof),
		makeEqFn(types.Float, types.Float, VolatilityLeakProof),
		makeEqFn(types.Box2D, types.Box2D, VolatilityLeakProof),
		makeEqFn(types.Geography, types.Geography, VolatilityLeakProof),
		makeEqFn(types.Geometry, types.Geometry, VolatilityLeakProof),
		makeEqFn(types.INet, types.INet, VolatilityLeakProof),
		makeEqFn(types.Int, types.Int, VolatilityLeakProof),
		makeEqFn(types.Interval, types.Interval, VolatilityLeakProof),
		makeEqFn(types.Jsonb, types.Jsonb, VolatilityImmutable),
		makeEqFn(types.Oid, types.Oid, VolatilityLeakProof),
		makeEqFn(types.String, types.String, VolatilityLeakProof),
		makeEqFn(types.Time, types.Time, VolatilityLeakProof),
		makeEqFn(types.TimeTZ, types.TimeTZ, VolatilityLeakProof),
		makeEqFn(types.Timestamp, types.Timestamp, VolatilityLeakProof),
		makeEqFn(types.TimestampTZ, types.TimestampTZ, VolatilityLeakProof),
		makeEqFn(types.Uuid, types.Uuid, VolatilityLeakProof),
		makeEqFn(types.VarBit, types.VarBit, VolatilityLeakProof),

		makeEqFn(types.Date, types.Timestamp, VolatilityImmutable),
		makeEqFn(types.Date, types.TimestampTZ, VolatilityStable),
		makeEqFn(types.Decimal, types.Float, VolatilityLeakProof),
		makeEqFn(types.Decimal, types.Int, VolatilityLeakProof),
		makeEqFn(types.Float, types.Decimal, VolatilityLeakProof),
		makeEqFn(types.Float, types.Int, VolatilityLeakProof),
		makeEqFn(types.Int, types.Decimal, VolatilityLeakProof),
		makeEqFn(types.Int, types.Float, VolatilityLeakProof),
		makeEqFn(types.Int, types.Oid, VolatilityLeakProof),
		makeEqFn(types.Oid, types.Int, VolatilityLeakProof),
		makeEqFn(types.Timestamp, types.Date, VolatilityImmutable),
		makeEqFn(types.Timestamp, types.TimestampTZ, VolatilityStable),
		makeEqFn(types.TimestampTZ, types.Date, VolatilityStable),
		makeEqFn(types.TimestampTZ, types.Timestamp, VolatilityStable),
		makeEqFn(types.Time, types.TimeTZ, VolatilityStable),
		makeEqFn(types.TimeTZ, types.Time, VolatilityStable),

		&CmpOp{
			LeftType:   types.AnyTuple,
			RightType:  types.AnyTuple,
			Volatility: VolatilityImmutable,
		},
	},

	LT: {

		makeLtFn(types.AnyEnum, types.AnyEnum, VolatilityImmutable),
		makeLtFn(types.Bool, types.Bool, VolatilityLeakProof),
		makeLtFn(types.Bytes, types.Bytes, VolatilityLeakProof),
		makeLtFn(types.Date, types.Date, VolatilityLeakProof),
		makeLtFn(types.Decimal, types.Decimal, VolatilityImmutable),
		makeLtFn(types.AnyCollatedString, types.AnyCollatedString, VolatilityLeakProof),

		makeLtFn(types.Float, types.Float, VolatilityLeakProof),
		makeLtFn(types.Box2D, types.Box2D, VolatilityLeakProof),
		makeLtFn(types.Geography, types.Geography, VolatilityLeakProof),
		makeLtFn(types.Geometry, types.Geometry, VolatilityLeakProof),
		makeLtFn(types.INet, types.INet, VolatilityLeakProof),
		makeLtFn(types.Int, types.Int, VolatilityLeakProof),
		makeLtFn(types.Interval, types.Interval, VolatilityLeakProof),
		makeLtFn(types.Oid, types.Oid, VolatilityLeakProof),
		makeLtFn(types.String, types.String, VolatilityLeakProof),
		makeLtFn(types.Time, types.Time, VolatilityLeakProof),
		makeLtFn(types.TimeTZ, types.TimeTZ, VolatilityLeakProof),
		makeLtFn(types.Timestamp, types.Timestamp, VolatilityLeakProof),
		makeLtFn(types.TimestampTZ, types.TimestampTZ, VolatilityLeakProof),
		makeLtFn(types.Uuid, types.Uuid, VolatilityLeakProof),
		makeLtFn(types.VarBit, types.VarBit, VolatilityLeakProof),

		makeLtFn(types.Date, types.Timestamp, VolatilityImmutable),
		makeLtFn(types.Date, types.TimestampTZ, VolatilityStable),
		makeLtFn(types.Decimal, types.Float, VolatilityLeakProof),
		makeLtFn(types.Decimal, types.Int, VolatilityLeakProof),
		makeLtFn(types.Float, types.Decimal, VolatilityLeakProof),
		makeLtFn(types.Float, types.Int, VolatilityLeakProof),
		makeLtFn(types.Int, types.Decimal, VolatilityLeakProof),
		makeLtFn(types.Int, types.Float, VolatilityLeakProof),
		makeLtFn(types.Int, types.Oid, VolatilityLeakProof),
		makeLtFn(types.Oid, types.Int, VolatilityLeakProof),
		makeLtFn(types.Timestamp, types.Date, VolatilityImmutable),
		makeLtFn(types.Timestamp, types.TimestampTZ, VolatilityStable),
		makeLtFn(types.TimestampTZ, types.Date, VolatilityStable),
		makeLtFn(types.TimestampTZ, types.Timestamp, VolatilityStable),
		makeLtFn(types.Time, types.TimeTZ, VolatilityStable),
		makeLtFn(types.TimeTZ, types.Time, VolatilityStable),

		&CmpOp{
			LeftType:   types.AnyTuple,
			RightType:  types.AnyTuple,
			Volatility: VolatilityImmutable,
		},
	},

	LE: {

		makeLeFn(types.AnyEnum, types.AnyEnum, VolatilityImmutable),
		makeLeFn(types.Bool, types.Bool, VolatilityLeakProof),
		makeLeFn(types.Bytes, types.Bytes, VolatilityLeakProof),
		makeLeFn(types.Date, types.Date, VolatilityLeakProof),
		makeLeFn(types.Decimal, types.Decimal, VolatilityImmutable),

		makeLeFn(types.AnyCollatedString, types.AnyCollatedString, VolatilityLeakProof),
		makeLeFn(types.Float, types.Float, VolatilityLeakProof),
		makeLeFn(types.Box2D, types.Box2D, VolatilityLeakProof),
		makeLeFn(types.Geography, types.Geography, VolatilityLeakProof),
		makeLeFn(types.Geometry, types.Geometry, VolatilityLeakProof),
		makeLeFn(types.INet, types.INet, VolatilityLeakProof),
		makeLeFn(types.Int, types.Int, VolatilityLeakProof),
		makeLeFn(types.Interval, types.Interval, VolatilityLeakProof),
		makeLeFn(types.Oid, types.Oid, VolatilityLeakProof),
		makeLeFn(types.String, types.String, VolatilityLeakProof),
		makeLeFn(types.Time, types.Time, VolatilityLeakProof),
		makeLeFn(types.TimeTZ, types.TimeTZ, VolatilityLeakProof),
		makeLeFn(types.Timestamp, types.Timestamp, VolatilityLeakProof),
		makeLeFn(types.TimestampTZ, types.TimestampTZ, VolatilityLeakProof),
		makeLeFn(types.Uuid, types.Uuid, VolatilityLeakProof),
		makeLeFn(types.VarBit, types.VarBit, VolatilityLeakProof),

		makeLeFn(types.Date, types.Timestamp, VolatilityImmutable),
		makeLeFn(types.Date, types.TimestampTZ, VolatilityStable),
		makeLeFn(types.Decimal, types.Float, VolatilityLeakProof),
		makeLeFn(types.Decimal, types.Int, VolatilityLeakProof),
		makeLeFn(types.Float, types.Decimal, VolatilityLeakProof),
		makeLeFn(types.Float, types.Int, VolatilityLeakProof),
		makeLeFn(types.Int, types.Decimal, VolatilityLeakProof),
		makeLeFn(types.Int, types.Float, VolatilityLeakProof),
		makeLeFn(types.Int, types.Oid, VolatilityLeakProof),
		makeLeFn(types.Oid, types.Int, VolatilityLeakProof),
		makeLeFn(types.Timestamp, types.Date, VolatilityImmutable),
		makeLeFn(types.Timestamp, types.TimestampTZ, VolatilityStable),
		makeLeFn(types.TimestampTZ, types.Date, VolatilityStable),
		makeLeFn(types.TimestampTZ, types.Timestamp, VolatilityStable),
		makeLeFn(types.Time, types.TimeTZ, VolatilityStable),
		makeLeFn(types.TimeTZ, types.Time, VolatilityStable),

		&CmpOp{
			LeftType:   types.AnyTuple,
			RightType:  types.AnyTuple,
			Volatility: VolatilityImmutable,
		},
	},

	IsNotDistinctFrom: {
		&CmpOp{
			LeftType:     types.Unknown,
			RightType:    types.Unknown,
			NullableArgs: true,

			isPreferred: true,
			Volatility:  VolatilityLeakProof,
		},

		makeIsFn(types.AnyEnum, types.AnyEnum, VolatilityImmutable),
		makeIsFn(types.Bool, types.Bool, VolatilityLeakProof),
		makeIsFn(types.Bytes, types.Bytes, VolatilityLeakProof),
		makeIsFn(types.Date, types.Date, VolatilityLeakProof),
		makeIsFn(types.Decimal, types.Decimal, VolatilityImmutable),

		makeIsFn(types.AnyCollatedString, types.AnyCollatedString, VolatilityLeakProof),
		makeIsFn(types.Float, types.Float, VolatilityLeakProof),
		makeIsFn(types.Box2D, types.Box2D, VolatilityLeakProof),
		makeIsFn(types.Geography, types.Geography, VolatilityLeakProof),
		makeIsFn(types.Geometry, types.Geometry, VolatilityLeakProof),
		makeIsFn(types.INet, types.INet, VolatilityLeakProof),
		makeIsFn(types.Int, types.Int, VolatilityLeakProof),
		makeIsFn(types.Interval, types.Interval, VolatilityLeakProof),
		makeIsFn(types.Jsonb, types.Jsonb, VolatilityImmutable),
		makeIsFn(types.Oid, types.Oid, VolatilityLeakProof),
		makeIsFn(types.String, types.String, VolatilityLeakProof),
		makeIsFn(types.Time, types.Time, VolatilityLeakProof),
		makeIsFn(types.TimeTZ, types.TimeTZ, VolatilityLeakProof),
		makeIsFn(types.Timestamp, types.Timestamp, VolatilityLeakProof),
		makeIsFn(types.TimestampTZ, types.TimestampTZ, VolatilityLeakProof),
		makeIsFn(types.Uuid, types.Uuid, VolatilityLeakProof),
		makeIsFn(types.VarBit, types.VarBit, VolatilityLeakProof),

		makeIsFn(types.Date, types.Timestamp, VolatilityImmutable),
		makeIsFn(types.Date, types.TimestampTZ, VolatilityStable),
		makeIsFn(types.Decimal, types.Float, VolatilityLeakProof),
		makeIsFn(types.Decimal, types.Int, VolatilityLeakProof),
		makeIsFn(types.Float, types.Decimal, VolatilityLeakProof),
		makeIsFn(types.Float, types.Int, VolatilityLeakProof),
		makeIsFn(types.Int, types.Decimal, VolatilityLeakProof),
		makeIsFn(types.Int, types.Float, VolatilityLeakProof),
		makeIsFn(types.Int, types.Oid, VolatilityLeakProof),
		makeIsFn(types.Oid, types.Int, VolatilityLeakProof),
		makeIsFn(types.Timestamp, types.Date, VolatilityImmutable),
		makeIsFn(types.Timestamp, types.TimestampTZ, VolatilityStable),
		makeIsFn(types.TimestampTZ, types.Date, VolatilityStable),
		makeIsFn(types.TimestampTZ, types.Timestamp, VolatilityStable),
		makeIsFn(types.Time, types.TimeTZ, VolatilityStable),
		makeIsFn(types.TimeTZ, types.Time, VolatilityStable),

		&CmpOp{
			LeftType:     types.AnyTuple,
			RightType:    types.AnyTuple,
			NullableArgs: true,
			Volatility:   VolatilityImmutable,
		},
	},

	In: {
		makeEvalTupleIn(types.AnyEnum, VolatilityLeakProof),
		makeEvalTupleIn(types.Bool, VolatilityLeakProof),
		makeEvalTupleIn(types.Bytes, VolatilityLeakProof),
		makeEvalTupleIn(types.Date, VolatilityLeakProof),
		makeEvalTupleIn(types.Decimal, VolatilityLeakProof),
		makeEvalTupleIn(types.AnyCollatedString, VolatilityLeakProof),
		makeEvalTupleIn(types.AnyTuple, VolatilityLeakProof),
		makeEvalTupleIn(types.Float, VolatilityLeakProof),
		makeEvalTupleIn(types.Box2D, VolatilityLeakProof),
		makeEvalTupleIn(types.Geography, VolatilityLeakProof),
		makeEvalTupleIn(types.Geometry, VolatilityLeakProof),
		makeEvalTupleIn(types.INet, VolatilityLeakProof),
		makeEvalTupleIn(types.Int, VolatilityLeakProof),
		makeEvalTupleIn(types.Interval, VolatilityLeakProof),
		makeEvalTupleIn(types.Jsonb, VolatilityLeakProof),
		makeEvalTupleIn(types.Oid, VolatilityLeakProof),
		makeEvalTupleIn(types.String, VolatilityLeakProof),
		makeEvalTupleIn(types.Time, VolatilityLeakProof),
		makeEvalTupleIn(types.TimeTZ, VolatilityLeakProof),
		makeEvalTupleIn(types.Timestamp, VolatilityLeakProof),
		makeEvalTupleIn(types.TimestampTZ, VolatilityLeakProof),
		makeEvalTupleIn(types.Uuid, VolatilityLeakProof),
		makeEvalTupleIn(types.VarBit, VolatilityLeakProof),
	},

	Like: {
		&CmpOp{
			LeftType:   types.String,
			RightType:  types.String,
			Volatility: VolatilityLeakProof,
		},
	},

	ILike: {
		&CmpOp{
			LeftType:   types.String,
			RightType:  types.String,
			Volatility: VolatilityLeakProof,
		},
	},

	SimilarTo: {
		&CmpOp{
			LeftType:   types.String,
			RightType:  types.String,
			Volatility: VolatilityLeakProof,
		},
	},

	RegMatch: append(
		cmpOpOverload{
			&CmpOp{
				LeftType:   types.String,
				RightType:  types.String,
				Volatility: VolatilityImmutable,
			},
		},
		makeBox2DComparisonOperators(
			func(lhs, rhs *geo.CartesianBoundingBox) bool {
				return lhs.Covers(rhs)
			},
		)...,
	),

	RegIMatch: {
		&CmpOp{
			LeftType:   types.String,
			RightType:  types.String,
			Volatility: VolatilityImmutable,
		},
	},

	JSONExists: {
		&CmpOp{
			LeftType:   types.Jsonb,
			RightType:  types.String,
			Volatility: VolatilityImmutable,
		},
	},

	JSONSomeExists: {
		&CmpOp{
			LeftType:   types.Jsonb,
			RightType:  types.StringArray,
			Volatility: VolatilityImmutable,
		},
	},

	JSONAllExists: {
		&CmpOp{
			LeftType:   types.Jsonb,
			RightType:  types.StringArray,
			Volatility: VolatilityImmutable,
		},
	},

	Contains: {
		&CmpOp{
			LeftType:   types.AnyArray,
			RightType:  types.AnyArray,
			Volatility: VolatilityImmutable,
		},
		&CmpOp{
			LeftType:   types.Jsonb,
			RightType:  types.Jsonb,
			Volatility: VolatilityImmutable,
		},
	},

	ContainedBy: {
		&CmpOp{
			LeftType:   types.AnyArray,
			RightType:  types.AnyArray,
			Volatility: VolatilityImmutable,
		},
		&CmpOp{
			LeftType:   types.Jsonb,
			RightType:  types.Jsonb,
			Volatility: VolatilityImmutable,
		},
	},
	Overlaps: append(
		cmpOpOverload{
			&CmpOp{
				LeftType:   types.AnyArray,
				RightType:  types.AnyArray,
				Volatility: VolatilityImmutable,
			},
			&CmpOp{
				LeftType:   types.INet,
				RightType:  types.INet,
				Volatility: VolatilityImmutable,
			},
		},
		makeBox2DComparisonOperators(
			func(lhs, rhs *geo.CartesianBoundingBox) bool {
				return lhs.Intersects(rhs)
			},
		)...,
	),
})

CmpOps contains the comparison operations indexed by operation type.

View Source
var (

	// ErrAsOfSpecifiedWithReadWrite is returned when a statement attempts to set
	// a historical query to READ WRITE which conflicts with its implied READ ONLY
	// mode.
	ErrAsOfSpecifiedWithReadWrite = pgerror.New(pgcode.Syntax, "AS OF SYSTEM TIME specified with READ WRITE mode")
)
View Source
var (
	// ErrDivByZero is reported on a division by zero.
	ErrDivByZero = pgerror.New(pgcode.DivisionByZero, "division by zero")
)

FunDefs holds pre-allocated FunctionDefinition instances for every builtin function. Initialized by builtins.init().

View Source
var IsolationLevelMap = map[string]IsolationLevel{
	"serializable": SerializableIsolation,
}

IsolationLevelMap is a map from string isolation level name to isolation level, in the lowercase format that set isolation_level supports.

View Source
var JobCommandToStatement = map[JobCommand]string{
	PauseJob:  "PAUSE",
	CancelJob: "CANCEL",
	ResumeJob: "RESUME",
}

JobCommandToStatement translates a job command integer to a statement prefix.

View Source
var ReturningNothingClause = &ReturningNothing{}

ReturningNothingClause is a shared instance to avoid unnecessary allocations.

View Source
var UnaryOps = unaryOpFixups(map[UnaryOperator]unaryOpOverload{
	UnaryMinus: {
		&UnaryOp{
			Typ:        types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&UnaryOp{
			Typ:        types.Float,
			ReturnType: types.Float,
			Volatility: VolatilityImmutable,
		},
		&UnaryOp{
			Typ:        types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&UnaryOp{
			Typ:        types.Interval,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
	},

	UnaryComplement: {
		&UnaryOp{
			Typ:        types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&UnaryOp{
			Typ:        types.VarBit,
			ReturnType: types.VarBit,
			Volatility: VolatilityImmutable,
		},
		&UnaryOp{
			Typ:        types.INet,
			ReturnType: types.INet,
			Volatility: VolatilityImmutable,
		},
	},

	UnarySqrt: {
		&UnaryOp{
			Typ:        types.Float,
			ReturnType: types.Float,
			Volatility: VolatilityImmutable,
		},
		&UnaryOp{
			Typ:        types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
	},

	UnaryCbrt: {
		&UnaryOp{
			Typ:        types.Float,
			ReturnType: types.Float,
			Volatility: VolatilityImmutable,
		},
		&UnaryOp{
			Typ:        types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
	},

	UnaryAbsolute: {
		&UnaryOp{
			Typ:        types.Int,
			ReturnType: types.Int,
			Volatility: VolatilityImmutable,
		},
		&UnaryOp{
			Typ:        types.Float,
			ReturnType: types.Float,
			Volatility: VolatilityImmutable,
		},
		&UnaryOp{
			Typ:        types.Decimal,
			ReturnType: types.Decimal,
			Volatility: VolatilityImmutable,
		},
		&UnaryOp{
			Typ:        types.Interval,
			ReturnType: types.Interval,
			Volatility: VolatilityImmutable,
		},
	},
})

UnaryOps contains the unary operations indexed by operation type.

View Source
var UnknownReturnType *types.T

UnknownReturnType is returned from ReturnTypers when the arguments provided are not sufficient to determine a return type. This is necessary for cases like overload resolution, where the argument types are not resolved yet so the type-level function will be called without argument types. If a ReturnTyper returns unknownReturnType, then the candidate function set cannot be refined. This means that only ReturnTypers that never return unknownReturnType, like those created with FixedReturnType, can help reduce overload ambiguity.

Functions

func AsString

func AsString(n NodeFormatter) string

AsString pretty prints a node to a string.

func AsStringWithFQNames

func AsStringWithFQNames(n NodeFormatter, ann *Annotations) string

AsStringWithFQNames pretty prints a node to a string with the FmtAlwaysQualifyTableNames flag (which requires annotations).

func AsStringWithFlags

func AsStringWithFlags(n NodeFormatter, fl FmtFlags) string

AsStringWithFlags pretty prints a node to a string given specific flags; only flags that don't require Annotations can be used.

func CanModifySchema

func CanModifySchema(stmt Statement) bool

CanModifySchema returns true if the statement can modify the database schema.

func CanWriteData

func CanWriteData(stmt Statement) bool

CanWriteData returns true if the statement can modify data.

func CheckIsWindowOrAgg

func CheckIsWindowOrAgg(def *FunctionDefinition) error

CheckIsWindowOrAgg returns an error if the function definition is not a window function or an aggregate.

func ComputeColNameInternal

func ComputeColNameInternal(sp sessiondata.SearchPath, target Expr) (int, string, error)

ComputeColNameInternal is the workhorse for GetRenderColName. The return value indicates the strength of the confidence in the result: 0 - no information 1 - second-best name choice 2 - good name choice

The algorithm is borrowed from FigureColnameInternal in PostgreSQL 10, to be found in src/backend/parser/parse_target.c.

func ErrNameString

func ErrNameString(s string) string

ErrNameString escapes an identifier stored a string to a SQL identifier suitable for printing in error messages.

func ErrNameStringP

func ErrNameStringP(s *string) string

ErrNameStringP escapes an identifier stored a string to a SQL identifier suitable for printing in error messages, avoiding a heap allocation.

func ErrString

func ErrString(n NodeFormatter) string

ErrString pretty prints a node to a string. Identifiers are not quoted.

func ExprDebugString

func ExprDebugString(expr Expr) string

ExprDebugString generates a multi-line debug string with one node per line in Go format.

func FoldComparisonExpr

func FoldComparisonExpr(
	op ComparisonOperator, left, right Expr,
) (newOp ComparisonOperator, newLeft Expr, newRight Expr, flipped bool, not bool)

FoldComparisonExpr folds a given comparison operation and its expressions into an equivalent operation that will hit in the CmpOps map, returning this new operation, along with potentially flipped operands and "flipped" and "not" flags.

func GetEnumComponentsFromPhysicalRep

func GetEnumComponentsFromPhysicalRep(typ *types.T, rep []byte) ([]byte, string, error)

GetEnumComponentsFromPhysicalRep returns the physical and logical components for an enum of the requested type. It returns an error if it cannot find a matching physical representation.

func GetParamsAndReturnType

func GetParamsAndReturnType(impl overloadImpl) (TypeList, ReturnTyper)

GetParamsAndReturnType gets the parameters and return type of an overloadImpl.

func GetRenderColName

func GetRenderColName(searchPath sessiondata.SearchPath, target SelectExpr) (string, error)

GetRenderColName computes a name for a result column. A name specified with AS takes priority, otherwise a name is derived from the expression.

This function is meant to be used on untransformed syntax trees.

The algorithm is borrowed from FigureColName() in PostgreSQL 10, to be found in src/backend/parser/parse_target.c. We reuse this algorithm to provide names more compatible with PostgreSQL.

func GetStaticallyKnownType

func GetStaticallyKnownType(ref ResolvableTypeReference) (typ *types.T, ok bool)

GetStaticallyKnownType possibly promotes a ResolvableTypeReference into a *types.T if the reference is a statically known type. It is only safe to access the returned type if ok is true.

func HasReturningClause

func HasReturningClause(clause ReturningClause) bool

HasReturningClause determines if a ReturningClause is present, given a variant of the ReturningClause interface.

func IsReferenceSerialType

func IsReferenceSerialType(ref ResolvableTypeReference) bool

IsReferenceSerialType returns whether the input reference is a known serial type. It should only be used during parsing.

func IsStmtParallelized

func IsStmtParallelized(stmt Statement) bool

IsStmtParallelized determines if a given statement's execution should be parallelized. This means that its results should be mocked out, and that it should be run asynchronously and in parallel with other statements that are independent.

func LimitDecimalWidth

func LimitDecimalWidth(d *apd.Decimal, precision, scale int) error

LimitDecimalWidth limits d's precision (total number of digits) and scale (number of digits after the decimal point). Note that this any limiting will modify the decimal in-place.

func MockNameTypes

func MockNameTypes(types map[string]*types.T) func()

MockNameTypes populates presetTypesForTesting for a test.

func MustBeStaticallyKnownType

func MustBeStaticallyKnownType(ref ResolvableTypeReference) *types.T

MustBeStaticallyKnownType does the same thing as GetStaticallyKnownType but panics in the case that the reference is not statically known. This function is intended to be used in tests or in cases where it is not possible to have any unresolved type references.

func NameString

func NameString(s string) string

NameString escapes an identifier stored in a string to a SQL identifier.

func NameStringP

func NameStringP(s *string) string

NameStringP escapes an identifier stored in a heap string to a SQL identifier, avoiding a heap allocation.

func NewAggInAggError

func NewAggInAggError() error

NewAggInAggError creates an error for the case when an aggregate function is contained within another aggregate function.

func NewInvalidFunctionUsageError

func NewInvalidFunctionUsageError(class FunctionClass, context string) error

NewInvalidFunctionUsageError creates a rejection for a special function.

func NewInvalidNestedSRFError

func NewInvalidNestedSRFError(context string) error

NewInvalidNestedSRFError creates a rejection for a nested SRF.

func NewTypeIsNotCompositeError

func NewTypeIsNotCompositeError(resolvedType *types.T) error

NewTypeIsNotCompositeError generates an error suitable to report when a ColumnAccessExpr or TupleStar is applied to a non-composite type.

func Pretty

func Pretty(stmt NodeFormatter) string

Pretty pretty prints stmt with default options.

func ProcessPlaceholderAnnotations

func ProcessPlaceholderAnnotations(
	semaCtx *SemaContext, stmt Statement, typeHints PlaceholderTypes,
) error

ProcessPlaceholderAnnotations performs an order-independent global traversal of the provided Statement, annotating all placeholders with a type in either of the following situations:

  • the placeholder is the subject of an explicit type annotation in at least one of its occurrences. If it is subject to multiple explicit type annotations where the types are not all in agreement, or if the placeholder already has a type hint in the placeholder map which conflicts with the explicit type annotation type, an error will be thrown.

  • the placeholder is the subject to a cast of the same type in all occurrences of the placeholder. If the placeholder is subject to casts of multiple types, or if it has occurrences without a cast, no error will be thrown but the type will not be inferred. If the placeholder already has a type hint, that type will be kept regardless of any casts.

See docs/RFCS/20160203_typing.md for more details on placeholder typing (in particular section "First pass: placeholder annotations").

The typeHints slice contains the client-provided hints and is populated with any newly assigned types. It is assumed to be pre-sized to the number of placeholders in the statement and is populated accordingly.

TODO(nvanbenschoten): Can this visitor and map be preallocated (like normalizeVisitor)?

func ResolveExisting

ResolveExisting performs name resolution for an object name when the target object is expected to exist already. It does not mutate the input name. It additionally returns the resolved prefix qualification for the object. For example, if the unresolved name was "a.b" and the name was resolved to "a.public.b", the prefix "a.public" is returned.

func ResolveTarget

func ResolveTarget(
	ctx context.Context,
	u *UnresolvedObjectName,
	r ObjectNameTargetResolver,
	curDb string,
	searchPath sessiondata.SearchPath,
) (found bool, namePrefix ObjectNamePrefix, scMeta SchemaMeta, err error)

ResolveTarget performs name resolution for an object name when the target object is not expected to exist already. It does not mutate the input name. It additionally returns the resolved prefix qualification for the object. For example, if the unresolved name was "a.b" and the name was resolved to "a.public.b", the prefix "a.public" is returned.

func ResolveType

func ResolveType(
	ctx context.Context, ref ResolvableTypeReference, resolver TypeReferenceResolver,
) (*types.T, error)

ResolveType converts a ResolvableTypeReference into a *types.T.

func Serialize

func Serialize(n NodeFormatter) string

Serialize pretty prints a node to a string using FmtSerializable; it is appropriate when we store expressions into strings that are stored on disk and may be later parsed back into expressions.

func SerializeForDisplay

func SerializeForDisplay(n NodeFormatter) string

SerializeForDisplay pretty prints a node to a string using FmtParsable. It is appropriate when printing expressions that are visible to end users.

func SizeOfDecimal

func SizeOfDecimal(d apd.Decimal) uintptr

SizeOfDecimal returns the size in bytes of an apd.Decimal.

func StmtDebugString

func StmtDebugString(stmt Statement) string

StmtDebugString generates multi-line debug strings in Go format for the expressions that are part of the given statement.

func TimeFamilyPrecisionToRoundDuration

func TimeFamilyPrecisionToRoundDuration(precision int32) time.Duration

TimeFamilyPrecisionToRoundDuration takes in a type's precision, and returns the duration to use to pass into time.Truncate to truncate to that duration. Panics if the precision is not supported.

func WalkExprConst

func WalkExprConst(v Visitor, expr Expr)

WalkExprConst is a variant of WalkExpr for visitors that do not modify the expression.

func WindowModeName

func WindowModeName(mode WindowFrameMode) string

WindowModeName returns the name of the window frame mode.

Types

type AggType

type AggType int

AggType specifies the type of aggregation.

const (

	// GeneralAgg is used for general-purpose aggregate functions.
	// array_agg(col1 ORDER BY col2)
	GeneralAgg AggType
	// OrderedSetAgg is used for ordered-set aggregate functions.
	// percentile_disc(fraction) WITHIN GROUP (ORDER BY col1)
	OrderedSetAgg
)

FuncExpr.AggType

type AggregateSignature added in v0.4.0

type AggregateSignature struct {
	All         bool
	Args        RoutineArgs
	OrderByArgs RoutineArgs
}

AggregateSignature represents an aggregate_signature clause.

func (*AggregateSignature) Format added in v0.4.0

func (node *AggregateSignature) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AggregateToDrop added in v0.5.0

type AggregateToDrop struct {
	Name   *UnresolvedObjectName
	AggSig *AggregateSignature
}

type AliasClause

type AliasClause struct {
	Alias Name
	Cols  NameList
}

AliasClause represents an alias, optionally with a column list: "AS name" or "AS name(col1, col2)".

func (*AliasClause) Format

func (a *AliasClause) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AliasedTableExpr

type AliasedTableExpr struct {
	Expr       TableExpr
	IndexFlags *IndexFlags
	Ordinality bool
	Lateral    bool
	As         AliasClause
}

AliasedTableExpr represents a table expression coupled with an optional alias.

func (*AliasedTableExpr) Format

func (node *AliasedTableExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AliasedTableExpr) String

func (node *AliasedTableExpr) String() string

type AllColumnsSelector

type AllColumnsSelector struct {
	// TableName corresponds to the table prefix, before the star.
	TableName *UnresolvedObjectName
}

AllColumnsSelector corresponds to a selection of all columns in a table when used in a SELECT clause. (e.g. `table.*`).

func (*AllColumnsSelector) Format

func (a *AllColumnsSelector) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AllColumnsSelector) NormalizeVarName

func (a *AllColumnsSelector) NormalizeVarName() (VarName, error)

NormalizeVarName implements the VarName interface.

func (*AllColumnsSelector) Resolve

func (a *AllColumnsSelector) Resolve(
	ctx context.Context, r ColumnItemResolver,
) (srcName *TableName, srcMeta ColumnSourceMeta, err error)

Resolve performs name resolution for a qualified star using a resolver.

func (*AllColumnsSelector) ResolvedType

func (*AllColumnsSelector) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*AllColumnsSelector) String

func (a *AllColumnsSelector) String() string

func (*AllColumnsSelector) TypeCheck

func (expr *AllColumnsSelector) TypeCheck(
	_ context.Context, _ *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*AllColumnsSelector) Variable

func (a *AllColumnsSelector) Variable()

Variable implements the VariableExpr interface. Although, the AllColumnsSelector ought to be replaced to an IndexedVar before the points the VariableExpr interface is used.

func (*AllColumnsSelector) Walk

func (expr *AllColumnsSelector) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type AllTablesSelector

type AllTablesSelector struct {
	ObjectNamePrefix
}

AllTablesSelector corresponds to a selection of all tables in a database, e.g. when used with GRANT.

func (*AllTablesSelector) Format

func (at *AllTablesSelector) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AllTablesSelector) NormalizeTablePattern

func (at *AllTablesSelector) NormalizeTablePattern() (TablePattern, error)

NormalizeTablePattern implements the TablePattern interface.

func (*AllTablesSelector) String

func (at *AllTablesSelector) String() string

type AlterAggregate added in v0.4.0

type AlterAggregate struct {
	Name   *UnresolvedObjectName
	AggSig *AggregateSignature
	Rename Name
	Owner  string
	Schema string
}

AlterAggregate represents a ALTER AGGREGATE statement.

func (*AlterAggregate) Format added in v0.4.0

func (node *AlterAggregate) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterAggregate) StatementTag added in v0.4.0

func (*AlterAggregate) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterAggregate) StatementType added in v0.4.0

func (*AlterAggregate) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterAggregate) String added in v0.4.0

func (n *AlterAggregate) String() string

type AlterAttributeAction added in v0.5.0

type AlterAttributeAction struct {
	Action       string
	ColName      Name
	IfExists     bool
	TypeName     ResolvableTypeReference
	Collate      string
	DropBehavior DropBehavior
}

AlterAttributeAction represents ADD/DROP/ALTER ATTRIBUTE action.

type AlterColComputed added in v0.5.0

type AlterColComputed struct {
	ByDefault bool
	Options   SequenceOptions
	IsRestart bool
	Restart   Expr
}

type AlterCollation added in v0.4.0

type AlterCollation struct {
	Name           Name
	RefreshVersion bool
	Rename         Name
	Owner          string
	Schema         string
}

AlterCollation represents a ALTER COLLATION statement.

func (*AlterCollation) Format added in v0.4.0

func (node *AlterCollation) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterCollation) StatementTag added in v0.4.0

func (*AlterCollation) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterCollation) StatementType added in v0.4.0

func (*AlterCollation) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterCollation) String added in v0.4.0

func (n *AlterCollation) String() string

type AlterConversion added in v0.4.0

type AlterConversion struct {
	Name           Name
	RefreshVersion bool
	Rename         Name
	Owner          string
	Schema         string
}

AlterConversion represents a ALTER COLLATION statement.

func (*AlterConversion) Format added in v0.4.0

func (node *AlterConversion) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterConversion) StatementTag added in v0.4.0

func (*AlterConversion) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterConversion) StatementType added in v0.4.0

func (*AlterConversion) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterConversion) String added in v0.4.0

func (n *AlterConversion) String() string

type AlterDatabase added in v0.4.0

type AlterDatabase struct {
	Name    Name
	Options []DatabaseOption
	// Rename is handled by RenameDatabase
	Owner                   string
	Tablespace              string
	RefreshCollationVersion bool
	SetVar                  *SetVar
	ResetVar                string
	ResetAll                bool
}

AlterDatabase represents a ALTER DATABASE statement.

func (*AlterDatabase) Format added in v0.4.0

func (node *AlterDatabase) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterDatabase) StatementTag added in v0.4.0

func (*AlterDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterDatabase) StatementType added in v0.4.0

func (*AlterDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterDatabase) String added in v0.4.0

func (n *AlterDatabase) String() string

type AlterDatabaseOption added in v0.4.0

type AlterDatabaseOption string
const (
	OptAllowConnections AlterDatabaseOption = "ALLOW_CONNECTIONS"
	OptConnectionLimit  AlterDatabaseOption = "CONNECTION LIMIT"
	OptIsTemplate       AlterDatabaseOption = "IS_TEMPLATE"
)

Names of options on ALTER DATABASE.

type AlterDefaultPrivileges added in v0.4.0

type AlterDefaultPrivileges struct {
	ForRole      bool
	TargetRoles  []string
	Privileges   privilege.List
	Target       TargetList
	Grantees     []string
	GrantOption  bool
	DropBehavior DropBehavior
	Grant        bool
}

AlterDefaultPrivileges represents a ALTER DEFAULT PRIVILEGES statement.

func (*AlterDefaultPrivileges) Format added in v0.4.0

func (node *AlterDefaultPrivileges) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterDefaultPrivileges) StatementTag added in v0.4.0

func (*AlterDefaultPrivileges) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterDefaultPrivileges) StatementType added in v0.4.0

func (*AlterDefaultPrivileges) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterDefaultPrivileges) String added in v0.4.0

func (n *AlterDefaultPrivileges) String() string

type AlterDomain added in v0.5.0

type AlterDomain struct {
	Name *UnresolvedObjectName
	Cmd  AlterDomainCmd
}

AlterDomain represents a ALTER DOMAIN statement.

func (*AlterDomain) Format added in v0.5.0

func (node *AlterDomain) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterDomain) StatementTag added in v0.5.0

func (*AlterDomain) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterDomain) StatementType added in v0.5.0

func (*AlterDomain) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterDomain) String added in v0.5.0

func (n *AlterDomain) String() string

type AlterDomainCmd added in v0.5.0

type AlterDomainCmd interface {
	NodeFormatter
	// contains filtered or unexported methods
}

AlterDomainCmd represents a domain modification operation.

type AlterDomainConstraint added in v0.5.0

type AlterDomainConstraint struct {
	Action         AlterDomainConstraintAction
	Constraint     DomainConstraint
	NotValid       bool
	IfExists       bool
	ConstraintName Name
	DropBehavior   DropBehavior
	NewName        Name
}

AlterDomainConstraint represents an ALTER DOMAIN {ADD|DROP|RENAME|VALIDATE} CONSTRAINT command.

func (*AlterDomainConstraint) Format added in v0.5.0

func (node *AlterDomainConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterDomainConstraintAction added in v0.5.0

type AlterDomainConstraintAction int

AlterDomainConstraintAction represents the action for constraint clause for ALTER DOMAIN command.

const (
	AlterDomainAddConstraint AlterDomainConstraintAction = iota
	AlterDomainDropConstraint
	AlterDomainRenameConstraint
	AlterDomainValidateConstraint
)

type AlterDomainOwner added in v0.5.0

type AlterDomainOwner struct {
	Owner string
}

AlterDomainOwner represents an ALTER DOMAIN OWNER TO command.

func (*AlterDomainOwner) Format added in v0.5.0

func (node *AlterDomainOwner) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterDomainRename added in v0.5.0

type AlterDomainRename struct {
	NewName string
}

AlterDomainRename represents an ALTER DOMAIN RENAME TO command.

func (*AlterDomainRename) Format added in v0.5.0

func (node *AlterDomainRename) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterDomainSetDrop added in v0.5.0

type AlterDomainSetDrop struct {
	IsSet   bool
	Default Expr
	NotNull bool
}

AlterDomainSetDrop represents an ALTER DOMAIN {SET|DROP} {DEFAULT|NOT NULL} command.

func (*AlterDomainSetDrop) Format added in v0.5.0

func (node *AlterDomainSetDrop) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterDomainSetSchema added in v0.5.0

type AlterDomainSetSchema struct {
	Schema string
}

AlterDomainSetSchema represents an ALTER DOMAIN SET SCHEMA command.

func (*AlterDomainSetSchema) Format added in v0.5.0

func (node *AlterDomainSetSchema) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterFunction added in v0.5.0

type AlterFunction struct {
	Name      *UnresolvedObjectName
	Args      RoutineArgs
	Options   []RoutineOption
	Restrict  bool
	Rename    *UnresolvedObjectName
	Owner     string
	Schema    string
	No        bool
	Extension string
}

AlterFunction represents a ALTER FUNCTION statement.

func (*AlterFunction) Format added in v0.5.0

func (node *AlterFunction) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterFunction) StatementTag added in v0.5.0

func (*AlterFunction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterFunction) StatementType added in v0.5.0

func (*AlterFunction) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterFunction) String added in v0.5.0

func (n *AlterFunction) String() string

type AlterIndex

type AlterIndex struct {
	IfExists bool
	Index    TableIndexName
	Cmd      AlterIndexCmd
}

AlterIndex represents an ALTER INDEX statement.

func (*AlterIndex) Format

func (node *AlterIndex) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterIndex) StatementTag

func (*AlterIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterIndex) StatementType

func (*AlterIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterIndex) String

func (n *AlterIndex) String() string

type AlterIndexAllInTablespace added in v0.5.0

type AlterIndexAllInTablespace struct {
	Name       Name
	OwnedBy    []string
	Tablespace string
	NoWait     bool
}

AlterIndexAllInTablespace represents an ALTER INDEX ALL IN TABLESPACE statement.

func (*AlterIndexAllInTablespace) Format added in v0.5.0

func (node *AlterIndexAllInTablespace) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterIndexAllInTablespace) StatementTag added in v0.5.0

func (*AlterIndexAllInTablespace) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterIndexAllInTablespace) StatementType added in v0.5.0

func (*AlterIndexAllInTablespace) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterIndexAllInTablespace) String added in v0.5.0

func (n *AlterIndexAllInTablespace) String() string

type AlterIndexAttachPartition added in v0.5.0

type AlterIndexAttachPartition struct {
	Index UnrestrictedName
}

AlterIndexAttachPartition represents an ALTER INDEX ... ATTACH PARTITION statement.

func (*AlterIndexAttachPartition) Format added in v0.5.0

func (node *AlterIndexAttachPartition) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterIndexCmd

type AlterIndexCmd interface {
	NodeFormatter
	// contains filtered or unexported methods
}

AlterIndexCmd represents an index modification operation.

type AlterIndexExtension added in v0.5.0

type AlterIndexExtension struct {
	No        bool
	Extension string
}

AlterIndexExtension represents an ALTER INDEX ... [NO] DEPENDS ON EXTENSION statement.

func (*AlterIndexExtension) Format added in v0.5.0

func (node *AlterIndexExtension) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterIndexSetStatistics added in v0.5.0

type AlterIndexSetStatistics struct {
	ColumnIdx Expr
	Stats     Expr
}

AlterIndexSetStatistics represents an ALTER INDEX ... SET TABLESPACE command.

func (*AlterIndexSetStatistics) Format added in v0.5.0

func (node *AlterIndexSetStatistics) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterIndexSetStorage added in v0.5.0

type AlterIndexSetStorage struct {
	Params  StorageParams
	IsReset bool
}

AlterIndexSetStorage represents an ALTER INDEX ... SET TABLESPACE command.

func (*AlterIndexSetStorage) Format added in v0.5.0

func (node *AlterIndexSetStorage) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterIndexSetTablespace added in v0.5.0

type AlterIndexSetTablespace struct {
	Tablespace string
}

AlterIndexSetTablespace represents an ALTER INDEX ... SET TABLESPACE command.

func (*AlterIndexSetTablespace) Format added in v0.5.0

func (node *AlterIndexSetTablespace) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterLanguage added in v0.5.0

type AlterLanguage struct {
	Name       Name
	Procedural bool
	NewName    Name
	Owner      string
}

AlterLanguage represents a ALTER LANGUAGE statement.

func (*AlterLanguage) Format added in v0.5.0

func (node *AlterLanguage) Format(ctx *FmtCtx)

func (*AlterLanguage) StatementTag added in v0.5.0

func (*AlterLanguage) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterLanguage) StatementType added in v0.5.0

func (*AlterLanguage) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterLanguage) String added in v0.5.0

func (n *AlterLanguage) String() string

type AlterMaterializedView added in v0.5.0

type AlterMaterializedView struct {
	Name      *UnresolvedObjectName
	IfExists  bool
	Cmds      AlterTableCmds
	No        bool
	Extension string
}

AlterMaterializedView represents an ALTER MATERIALIZED VIEW statement.

func (*AlterMaterializedView) Format added in v0.5.0

func (node *AlterMaterializedView) Format(ctx *FmtCtx)

func (*AlterMaterializedView) StatementTag added in v0.5.0

func (*AlterMaterializedView) StatementTag() string

StatementTag implements the Statement interface.

func (*AlterMaterializedView) StatementType added in v0.5.0

func (*AlterMaterializedView) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterMaterializedView) String added in v0.5.0

func (n *AlterMaterializedView) String() string

type AlterProcedure added in v0.5.0

type AlterProcedure struct {
	Name      *UnresolvedObjectName
	Args      RoutineArgs
	Options   []RoutineOption
	Restrict  bool
	Rename    *UnresolvedObjectName
	Owner     string
	Schema    string
	No        bool
	Extension string
}

AlterProcedure represents a ALTER PROCEDURE statement.

func (*AlterProcedure) Format added in v0.5.0

func (node *AlterProcedure) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterProcedure) StatementTag added in v0.5.0

func (*AlterProcedure) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterProcedure) StatementType added in v0.5.0

func (*AlterProcedure) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterProcedure) String added in v0.5.0

func (n *AlterProcedure) String() string

type AlterRole

type AlterRole struct {
	Name      Expr
	IfExists  bool
	IsRole    bool
	KVOptions KVOptions
}

AlterRole represents an ALTER ROLE statement.

func (*AlterRole) Format

func (node *AlterRole) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterRole) StatementTag

func (*AlterRole) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterRole) StatementType

func (*AlterRole) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterRole) String

func (n *AlterRole) String() string

type AlterSchema

type AlterSchema struct {
	Schema string
	Cmd    AlterSchemaCmd
}

AlterSchema represents an ALTER SCHEMA statement.

func (*AlterSchema) Format

func (node *AlterSchema) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterSchema) StatementTag

func (*AlterSchema) StatementTag() string

StatementTag implements the Statement interface.

func (*AlterSchema) StatementType

func (*AlterSchema) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterSchema) String

func (n *AlterSchema) String() string

type AlterSchemaCmd

type AlterSchemaCmd interface {
	NodeFormatter
	// contains filtered or unexported methods
}

AlterSchemaCmd represents a schema modification operation.

type AlterSchemaOwner

type AlterSchemaOwner struct {
	Owner string
}

AlterSchemaOwner represents an ALTER SCHEMA RENAME command.

func (*AlterSchemaOwner) Format

func (node *AlterSchemaOwner) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterSchemaRename

type AlterSchemaRename struct {
	NewName string
}

AlterSchemaRename represents an ALTER SCHEMA RENAME command.

func (*AlterSchemaRename) Format

func (node *AlterSchemaRename) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterSequence

type AlterSequence struct {
	IfExists bool
	Name     *UnresolvedObjectName
	Options  SequenceOptions
	SetLog   bool
	Logged   bool
	Owner    string
}

AlterSequence represents an ALTER SEQUENCE statement, except in the case of ALTER SEQUENCE <seqName> RENAME TO <newSeqName>, which is represented by a RenameTable node.

func (*AlterSequence) Format

func (node *AlterSequence) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterSequence) StatementTag

func (*AlterSequence) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterSequence) StatementType

func (*AlterSequence) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterSequence) String

func (n *AlterSequence) String() string

type AlterTable

type AlterTable struct {
	IfExists bool
	Table    *UnresolvedObjectName
	Cmds     AlterTableCmds
}

AlterTable represents an ALTER TABLE statement.

func (*AlterTable) Format

func (node *AlterTable) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTable) HoistAddColumnConstraints

func (node *AlterTable) HoistAddColumnConstraints()

HoistAddColumnConstraints converts column constraints in ADD COLUMN commands, stored in node.Cmds, into top-level commands to add those constraints. Currently, this only applies to checks. For example, the ADD COLUMN in

ALTER TABLE t ADD COLUMN a INT CHECK (a < 1)

is transformed into two commands, as in

ALTER TABLE t ADD COLUMN a INT, ADD CONSTRAINT check_a CHECK (a < 1)

(with an auto-generated name).

Note that some SQL databases require that a constraint attached to a column to refer only to the column it is attached to. We follow Postgres' behavior, however, in omitting this restriction by blindly hoisting all column constraints. For example, the following statement is accepted in CockroachDB and Postgres, but not necessarily other SQL databases:

ALTER TABLE t ADD COLUMN a INT CHECK (a < b)

func (*AlterTable) StatementTag

func (*AlterTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterTable) StatementType

func (*AlterTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterTable) String

func (n *AlterTable) String() string

type AlterTableAddColumn

type AlterTableAddColumn struct {
	IfNotExists bool
	ColumnDef   *ColumnTableDef
}

AlterTableAddColumn represents an ADD COLUMN command.

func (*AlterTableAddColumn) Format

func (node *AlterTableAddColumn) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableAddConstraint

type AlterTableAddConstraint struct {
	ConstraintDef      ConstraintTableDef
	ValidationBehavior ValidationBehavior
}

AlterTableAddConstraint represents an ADD CONSTRAINT command.

func (*AlterTableAddConstraint) Format

func (node *AlterTableAddConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableAllInTablespace added in v0.5.0

type AlterTableAllInTablespace struct {
	Name       Name
	OwnedBy    []string
	Tablespace string
	NoWait     bool

	IsMaterialized bool
}

AlterTableAllInTablespace represents an ALTER { TABLE | MATERIALIZED VIEW } ALL IN TABLESPACE ... statement.

func (*AlterTableAllInTablespace) Format added in v0.5.0

func (node *AlterTableAllInTablespace) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableAllInTablespace) StatementTag added in v0.5.0

func (*AlterTableAllInTablespace) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterTableAllInTablespace) StatementType added in v0.5.0

func (*AlterTableAllInTablespace) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterTableAllInTablespace) String added in v0.5.0

func (n *AlterTableAllInTablespace) String() string

type AlterTableAlterColumnType

type AlterTableAlterColumnType struct {
	Collation string
	Column    Name
	ToType    ResolvableTypeReference
	Using     Expr
}

AlterTableAlterColumnType represents an ALTER TABLE ALTER COLUMN TYPE command.

func (*AlterTableAlterColumnType) Format

func (node *AlterTableAlterColumnType) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableAlterColumnType) GetColumn

func (node *AlterTableAlterColumnType) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

type AlterTableAlterConstraint added in v0.5.0

type AlterTableAlterConstraint struct {
	Constraint Name
	Deferrable DeferrableMode
	Initially  InitiallyMode
}

AlterTableAlterConstraint represents an ALTER CONSTRAINT command.

func (*AlterTableAlterConstraint) Format added in v0.5.0

func (node *AlterTableAlterConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableCluster added in v0.5.0

type AlterTableCluster struct {
	OnIndex Name
	Without bool
}

AlterTableCluster represents an ALTER TABLE { CLUSTER ON ... | WITHOUT CLUSTER } command.

func (*AlterTableCluster) Format added in v0.5.0

func (node *AlterTableCluster) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableCmd

type AlterTableCmd interface {
	NodeFormatter
	// contains filtered or unexported methods
}

AlterTableCmd represents a table modification operation.

type AlterTableCmds

type AlterTableCmds []AlterTableCmd

AlterTableCmds represents a list of table alterations.

func (*AlterTableCmds) Format

func (node *AlterTableCmds) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableColSetStorage added in v0.5.0

type AlterTableColSetStorage struct {
	Column Name
	Type   StorageType
}

AlterTableColSetStorage represents an ALTER COLUMN SET STORAGE command to remove the computed-ness from a column.

func (*AlterTableColSetStorage) Format added in v0.5.0

func (node *AlterTableColSetStorage) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableColSetStorage) GetColumn added in v0.5.0

func (node *AlterTableColSetStorage) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

type AlterTableComputed added in v0.5.0

type AlterTableComputed struct {
	Column  Name
	Defs    []AlterColComputed
	IsAdd   bool
	AddDefs ColumnQualification
}

AlterTableComputed represents an ALTER TABLE ALTER COLUMN SET GENERATED command.

func (*AlterTableComputed) Format added in v0.5.0

func (node *AlterTableComputed) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableComputed) GetColumn added in v0.5.0

func (node *AlterTableComputed) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

type AlterTableConstraintUsingIndex added in v0.5.0

type AlterTableConstraintUsingIndex struct {
	Constraint Name
	IsUnique   bool
	Index      Name
	Deferrable DeferrableMode
	Initially  InitiallyMode
}

AlterTableConstraintUsingIndex represents an ALTER TABLE ADD table_constraint USING INDEX command.

func (*AlterTableConstraintUsingIndex) Format added in v0.5.0

func (node *AlterTableConstraintUsingIndex) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableDropColumn

type AlterTableDropColumn struct {
	IfExists     bool
	Column       Name
	DropBehavior DropBehavior
}

AlterTableDropColumn represents a DROP COLUMN command.

func (*AlterTableDropColumn) Format

func (node *AlterTableDropColumn) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableDropConstraint

type AlterTableDropConstraint struct {
	IfExists     bool
	Constraint   Name
	DropBehavior DropBehavior
}

AlterTableDropConstraint represents a DROP CONSTRAINT command.

func (*AlterTableDropConstraint) Format

func (node *AlterTableDropConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableDropExprIden added in v0.5.0

type AlterTableDropExprIden struct {
	Column     Name
	IsIdentity bool
	IfExists   bool
}

AlterTableDropExprIden represents an ALTER COLUMN DROP EXPRESSION | IDENTITY command to remove the computed-ness from a column.

func (*AlterTableDropExprIden) Format added in v0.5.0

func (node *AlterTableDropExprIden) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableDropExprIden) GetColumn added in v0.5.0

func (node *AlterTableDropExprIden) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

type AlterTableDropNotNull

type AlterTableDropNotNull struct {
	Column Name
}

AlterTableDropNotNull represents an ALTER COLUMN DROP NOT NULL command.

func (*AlterTableDropNotNull) Format

func (node *AlterTableDropNotNull) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableDropNotNull) GetColumn

func (node *AlterTableDropNotNull) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

type AlterTableInherit added in v0.5.0

type AlterTableInherit struct {
	Inherit bool
	Table   TableName
}

AlterTableInherit represents an ALTER TABLE { INHERIT | NO INHERIT } ... command.

func (*AlterTableInherit) Format added in v0.5.0

func (node *AlterTableInherit) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableOfType added in v0.5.0

type AlterTableOfType struct {
	Type  ResolvableTypeReference
	NotOf bool
}

AlterTableOfType represents an ALTER TABLE { OF type_name | NOT OF } command.

func (*AlterTableOfType) Format added in v0.5.0

func (node *AlterTableOfType) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableOwner

type AlterTableOwner struct {
	Owner string
}

AlterTableOwner represents an ALTER TABLE OWNER TO command.

func (*AlterTableOwner) Format

func (node *AlterTableOwner) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTablePartition added in v0.5.0

type AlterTablePartition struct {
	Name       *UnresolvedObjectName
	IfExists   bool
	Partition  Name
	Spec       PartitionBoundSpec
	IsDetach   bool
	DetachType DetachPartition
}

AlterTablePartition represents an ALTER TABLE { ATTACH | DETACH } PARTITION ... command.

func (*AlterTablePartition) Format added in v0.5.0

func (node *AlterTablePartition) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTablePartition) StatementTag added in v0.5.0

func (*AlterTablePartition) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterTablePartition) StatementType added in v0.5.0

func (*AlterTablePartition) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterTablePartition) String added in v0.5.0

func (n *AlterTablePartition) String() string

type AlterTableRenameColumn

type AlterTableRenameColumn struct {
	Column  Name
	NewName Name
}

AlterTableRenameColumn represents an ALTER TABLE RENAME [COLUMN] command.

func (*AlterTableRenameColumn) Format

func (node *AlterTableRenameColumn) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableRenameConstraint

type AlterTableRenameConstraint struct {
	Constraint Name
	NewName    Name
}

AlterTableRenameConstraint represents an ALTER TABLE RENAME CONSTRAINT command.

func (*AlterTableRenameConstraint) Format

func (node *AlterTableRenameConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableReplicaIdentity added in v0.5.0

type AlterTableReplicaIdentity struct {
	Type  ReplicaIdentity
	Index Name
}

AlterTableReplicaIdentity represents an ALTER TABLE REPLICA IDENTITY command.

func (*AlterTableReplicaIdentity) Format added in v0.5.0

func (node *AlterTableReplicaIdentity) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableRowLevelSecurity added in v0.5.0

type AlterTableRowLevelSecurity struct {
	Type RowLevelSecurity
}

AlterTableRowLevelSecurity represents an ALTER TABLE ... ROW LEVEL SECURITY command.

func (*AlterTableRowLevelSecurity) Format added in v0.5.0

func (node *AlterTableRowLevelSecurity) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableRule added in v0.5.0

type AlterTableRule struct {
	Disable   bool
	Rule      string
	IsReplica bool
	IsAlways  bool
}

AlterTableRule represents an ALTER TABLE {DISABLE|ENABLE} RULE command.

func (*AlterTableRule) Format added in v0.5.0

func (node *AlterTableRule) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableSetAccessMethod added in v0.5.0

type AlterTableSetAccessMethod struct {
	Method string
}

AlterTableSetAccessMethod represents an ALTER TABLE SET ACCESS METHOD ... command.

func (*AlterTableSetAccessMethod) Format added in v0.5.0

func (node *AlterTableSetAccessMethod) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableSetAttribution added in v0.5.0

type AlterTableSetAttribution struct {
	Column Name
	Reset  bool
	Params StorageParams
}

AlterTableSetAttribution represents an ALTER COLUMN SET | RESET ATTRIBUTION command to remove the computed-ness from a column.

func (*AlterTableSetAttribution) Format added in v0.5.0

func (node *AlterTableSetAttribution) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableSetAttribution) GetColumn added in v0.5.0

func (node *AlterTableSetAttribution) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

type AlterTableSetCompression added in v0.5.0

type AlterTableSetCompression struct {
	Column      Name
	Compression string
}

AlterTableSetCompression represents an ALTER COLUMN SET COMPRESSION command to remove the computed-ness from a column.

func (*AlterTableSetCompression) Format added in v0.5.0

func (node *AlterTableSetCompression) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableSetCompression) GetColumn added in v0.5.0

func (node *AlterTableSetCompression) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

type AlterTableSetDefault

type AlterTableSetDefault struct {
	Column  Name
	Default Expr
}

AlterTableSetDefault represents an ALTER COLUMN SET DEFAULT or DROP DEFAULT command.

func (*AlterTableSetDefault) Format

func (node *AlterTableSetDefault) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableSetDefault) GetColumn

func (node *AlterTableSetDefault) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

type AlterTableSetLog added in v0.5.0

type AlterTableSetLog struct {
	Logged bool
}

AlterTableSetLog represents an ALTER TABLE SET { LOGGED | UNLOGGED }command.

func (*AlterTableSetLog) Format added in v0.5.0

func (node *AlterTableSetLog) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableSetNotNull

type AlterTableSetNotNull struct {
	Column Name
}

AlterTableSetNotNull represents an ALTER COLUMN SET NOT NULL command.

func (*AlterTableSetNotNull) Format

func (node *AlterTableSetNotNull) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableSetNotNull) GetColumn

func (node *AlterTableSetNotNull) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

type AlterTableSetSchema

type AlterTableSetSchema struct {
	Name     *UnresolvedObjectName
	Schema   string
	IfExists bool

	IsMaterialized bool
	IsSequence     bool
}

AlterTableSetSchema represents an ALTER TABLE SET SCHEMA statement.

func (*AlterTableSetSchema) Format

func (node *AlterTableSetSchema) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableSetSchema) StatementTag

func (*AlterTableSetSchema) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterTableSetSchema) StatementType

func (*AlterTableSetSchema) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterTableSetSchema) String

func (n *AlterTableSetSchema) String() string

type AlterTableSetStatistics added in v0.5.0

type AlterTableSetStatistics struct {
	Column Name
	Num    Expr
}

AlterTableSetStatistics represents an ALTER COLUMN SET STATISTICS command to remove the computed-ness from a column.

func (*AlterTableSetStatistics) Format added in v0.5.0

func (node *AlterTableSetStatistics) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterTableSetStatistics) GetColumn added in v0.5.0

func (node *AlterTableSetStatistics) GetColumn() Name

GetColumn implements the ColumnMutationCmd interface.

type AlterTableSetStorage added in v0.5.0

type AlterTableSetStorage struct {
	Params  StorageParams
	IsReset bool
}

AlterTableSetStorage represents an ALTER TABLE { SET | RESET } ( ... ) command.

func (*AlterTableSetStorage) Format added in v0.5.0

func (node *AlterTableSetStorage) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableSetTablespace added in v0.5.0

type AlterTableSetTablespace struct {
	Tablespace string
}

AlterTableSetTablespace represents an ALTER TABLE SET TABLESPACE ... command.

func (*AlterTableSetTablespace) Format added in v0.5.0

func (node *AlterTableSetTablespace) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableTrigger added in v0.5.0

type AlterTableTrigger struct {
	Disable   bool
	Trigger   string
	IsReplica bool
	IsAlways  bool
}

AlterTableTrigger represents an ALTER TABLE {DISABLE|ENABLE} TRIGGER command.

func (*AlterTableTrigger) Format added in v0.5.0

func (node *AlterTableTrigger) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTableValidateConstraint

type AlterTableValidateConstraint struct {
	Constraint Name
}

AlterTableValidateConstraint represents a VALIDATE CONSTRAINT command.

func (*AlterTableValidateConstraint) Format

func (node *AlterTableValidateConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTrigger added in v0.5.0

type AlterTrigger struct {
	Name      Name
	OnTable   TableName
	NewName   Name
	No        bool
	Extension string
}

AlterTrigger represents a ALTER TRIGGER statement.

func (*AlterTrigger) Format added in v0.5.0

func (node *AlterTrigger) Format(ctx *FmtCtx)

func (*AlterTrigger) StatementTag added in v0.5.0

func (*AlterTrigger) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*AlterTrigger) StatementType added in v0.5.0

func (*AlterTrigger) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterTrigger) String added in v0.5.0

func (n *AlterTrigger) String() string

type AlterType

type AlterType struct {
	Type *UnresolvedObjectName
	Cmd  AlterTypeCmd
}

AlterType represents an ALTER TYPE statement.

func (*AlterType) Format

func (node *AlterType) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AlterType) StatementTag

func (*AlterType) StatementTag() string

StatementTag implements the Statement interface.

func (*AlterType) StatementType

func (*AlterType) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterType) String

func (n *AlterType) String() string

type AlterTypeAddValue

type AlterTypeAddValue struct {
	NewVal      string
	IfNotExists bool
	Placement   *AlterTypeAddValuePlacement
}

AlterTypeAddValue represents an ALTER TYPE ADD VALUE command.

func (*AlterTypeAddValue) Format

func (node *AlterTypeAddValue) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTypeAddValuePlacement

type AlterTypeAddValuePlacement struct {
	Before      bool
	ExistingVal string
}

AlterTypeAddValuePlacement represents the placement clause for an ALTER TYPE ADD VALUE command ([BEFORE | AFTER] value).

type AlterTypeAlterAttribute added in v0.5.0

type AlterTypeAlterAttribute struct {
	Actions []AlterAttributeAction
}

AlterTypeAlterAttribute represents an ALTER TYPE {ADD|DROP|ALTER} ATTRIBUTE command.

func (*AlterTypeAlterAttribute) Format added in v0.5.0

func (node *AlterTypeAlterAttribute) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTypeCmd

type AlterTypeCmd interface {
	NodeFormatter
	// contains filtered or unexported methods
}

AlterTypeCmd represents a type modification operation.

type AlterTypeOwner

type AlterTypeOwner struct {
	Owner string
}

AlterTypeOwner represents an ALTER TYPE OWNER TO command.

func (*AlterTypeOwner) Format

func (node *AlterTypeOwner) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTypeRename

type AlterTypeRename struct {
	NewName string
}

AlterTypeRename represents an ALTER TYPE RENAME command.

func (*AlterTypeRename) Format

func (node *AlterTypeRename) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTypeRenameAttribute added in v0.5.0

type AlterTypeRenameAttribute struct {
	ColName      Name
	NewColName   Name
	DropBehavior DropBehavior
}

AlterTypeRenameAttribute represents an ALTER TYPE RENAME ATTRIBUTE command.

func (*AlterTypeRenameAttribute) Format added in v0.5.0

func (node *AlterTypeRenameAttribute) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTypeRenameValue

type AlterTypeRenameValue struct {
	OldVal string
	NewVal string
}

AlterTypeRenameValue represents an ALTER TYPE RENAME VALUE command.

func (*AlterTypeRenameValue) Format

func (node *AlterTypeRenameValue) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTypeSetProperty added in v0.5.0

type AlterTypeSetProperty struct {
	Properties BaseTypeOptions
}

AlterTypeSetProperty represents an ALTER TYPE SET <properties> command.

func (*AlterTypeSetProperty) Format added in v0.5.0

func (node *AlterTypeSetProperty) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterTypeSetSchema

type AlterTypeSetSchema struct {
	Schema string
}

AlterTypeSetSchema represents an ALTER TYPE SET SCHEMA command.

func (*AlterTypeSetSchema) Format

func (node *AlterTypeSetSchema) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterView added in v0.5.0

type AlterView struct {
	Name     *UnresolvedObjectName
	IfExists bool
	Cmd      AlterViewCmd
}

AlterView represents an ALTER VIEW statement.

func (*AlterView) Format added in v0.5.0

func (node *AlterView) Format(ctx *FmtCtx)

func (*AlterView) StatementTag added in v0.5.0

func (*AlterView) StatementTag() string

StatementTag implements the Statement interface.

func (*AlterView) StatementType added in v0.5.0

func (*AlterView) StatementType() StatementType

StatementType implements the Statement interface.

func (*AlterView) String added in v0.5.0

func (n *AlterView) String() string

type AlterViewCmd added in v0.5.0

type AlterViewCmd interface {
	NodeFormatter
	// contains filtered or unexported methods
}

AlterViewCmd represents a view modification operation.

type AlterViewOwnerTo added in v0.5.0

type AlterViewOwnerTo struct {
	Owner string
}

AlterViewOwnerTo represents an ALTER VIEW OWNER TO command.

func (*AlterViewOwnerTo) Format added in v0.5.0

func (node *AlterViewOwnerTo) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterViewRenameColumn added in v0.5.0

type AlterViewRenameColumn struct {
	Column  Name
	NewName Name
}

AlterViewRenameColumn represents an ALTER VIEW RENAME [COLUMN] command.

func (*AlterViewRenameColumn) Format added in v0.5.0

func (node *AlterViewRenameColumn) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterViewRenameTo added in v0.5.0

type AlterViewRenameTo struct {
	Rename *UnresolvedObjectName
}

AlterViewRenameTo represents an ALTER VIEW ... RENAME TO command.

func (*AlterViewRenameTo) Format added in v0.5.0

func (node *AlterViewRenameTo) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterViewSetDefault added in v0.5.0

type AlterViewSetDefault struct {
	Column  Name
	Default Expr
}

AlterViewSetDefault represents an ALTER VIEW ALTER COLUMN SET DEFAULT or DROP DEFAULT command.

func (*AlterViewSetDefault) Format added in v0.5.0

func (node *AlterViewSetDefault) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterViewSetOption added in v0.5.0

type AlterViewSetOption struct {
	Reset  bool
	Params ViewOptions
}

AlterViewSetOption represents an ALTER VIEW SET | RESET ... command.

func (*AlterViewSetOption) Format added in v0.5.0

func (node *AlterViewSetOption) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type AlterViewSetSchema added in v0.5.0

type AlterViewSetSchema struct {
	Schema string
}

AlterViewSetSchema represents an ALTER VIEW ... SET SCHEMA command.

func (*AlterViewSetSchema) Format added in v0.5.0

func (node *AlterViewSetSchema) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type Analyze

type Analyze struct {
	Table TableExpr
}

Analyze represents an ANALYZE statement.

func (*Analyze) Format

func (node *Analyze) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Analyze) StatementTag

func (*Analyze) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Analyze) StatementType

func (*Analyze) StatementType() StatementType

StatementType implements the Statement interface.

func (*Analyze) String

func (n *Analyze) String() string

type AndExpr

type AndExpr struct {
	Left, Right Expr
	// contains filtered or unexported fields
}

AndExpr represents an AND expression.

func NewTypedAndExpr

func NewTypedAndExpr(left, right TypedExpr) *AndExpr

NewTypedAndExpr returns a new AndExpr that is verified to be well-typed.

func (*AndExpr) Format

func (node *AndExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (AndExpr) HasResolvedType added in v0.6.0

func (ta AndExpr) HasResolvedType() bool

func (AndExpr) ResolvedType

func (ta AndExpr) ResolvedType() *types.T

func (*AndExpr) String

func (node *AndExpr) String() string

func (*AndExpr) TypeCheck

func (expr *AndExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*AndExpr) TypedLeft

func (node *AndExpr) TypedLeft() TypedExpr

TypedLeft returns the AndExpr's left expression as a TypedExpr.

func (*AndExpr) TypedRight

func (node *AndExpr) TypedRight() TypedExpr

TypedRight returns the AndExpr's right expression as a TypedExpr.

func (*AndExpr) Walk

func (expr *AndExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type AnnotateTypeExpr

type AnnotateTypeExpr struct {
	Expr Expr
	Type ResolvableTypeReference

	SyntaxMode annotateSyntaxMode
}

AnnotateTypeExpr represents a ANNOTATE_TYPE(expr, type) expression.

func (*AnnotateTypeExpr) Format

func (node *AnnotateTypeExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*AnnotateTypeExpr) String

func (node *AnnotateTypeExpr) String() string

func (*AnnotateTypeExpr) TypeCheck

func (expr *AnnotateTypeExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*AnnotateTypeExpr) TypedInnerExpr

func (node *AnnotateTypeExpr) TypedInnerExpr() TypedExpr

TypedInnerExpr returns the AnnotateTypeExpr's inner expression as a TypedExpr.

func (*AnnotateTypeExpr) Walk

func (expr *AnnotateTypeExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type AnnotatedNode

type AnnotatedNode struct {
	AnnIdx AnnotationIdx
}

AnnotatedNode is embedded in AST nodes that have an annotation.

func (AnnotatedNode) GetAnnotation

func (n AnnotatedNode) GetAnnotation(ann *Annotations) interface{}

GetAnnotation retrieves the annotation associated with this node.

func (AnnotatedNode) SetAnnotation

func (n AnnotatedNode) SetAnnotation(ann *Annotations, annotation interface{})

SetAnnotation sets the annotation associated with this node.

type AnnotationIdx

type AnnotationIdx int32

AnnotationIdx is the 1-based index of an annotation. AST nodes that can be annotated store such an index (unique within that AST).

const NoAnnotation AnnotationIdx = 0

NoAnnotation is the uninitialized annotation index.

type Annotations

type Annotations []interface{}

Annotations is a container for AST annotations.

func MakeAnnotations

func MakeAnnotations(numAnnotations AnnotationIdx) Annotations

MakeAnnotations allocates an annotations container of the given size.

func (*Annotations) Get

func (a *Annotations) Get(idx AnnotationIdx) interface{}

Get an annotation from the container.

func (*Annotations) Set

func (a *Annotations) Set(idx AnnotationIdx, annotation interface{})

Set an annotation in the container.

type ArgTypes

type ArgTypes []struct {
	Name string
	Typ  *types.T
}

ArgTypes is very similar to ArgTypes except it allows keeping a string name for each argument as well and using those when printing the human-readable signature.

func (ArgTypes) GetAt

func (a ArgTypes) GetAt(i int) *types.T

GetAt is part of the TypeList interface.

func (ArgTypes) Length

func (a ArgTypes) Length() int

Length is part of the TypeList interface.

func (ArgTypes) Match

func (a ArgTypes) Match(types []*types.T) bool

Match is part of the TypeList interface.

func (ArgTypes) MatchAt

func (a ArgTypes) MatchAt(typ *types.T, i int) bool

MatchAt is part of the TypeList interface.

func (ArgTypes) MatchLen

func (a ArgTypes) MatchLen(l int) bool

MatchLen is part of the TypeList interface.

func (ArgTypes) String

func (a ArgTypes) String() string

func (ArgTypes) Types

func (a ArgTypes) Types() []*types.T

Types is part of the TypeList interface.

type Array

type Array struct {
	Exprs Exprs
	// contains filtered or unexported fields
}

Array represents an array constructor.

func NewTypedArray

func NewTypedArray(typedExprs TypedExprs, typ *types.T) *Array

NewTypedArray returns an Array that is well-typed.

func (*Array) Format

func (node *Array) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (Array) HasResolvedType added in v0.6.0

func (ta Array) HasResolvedType() bool

func (Array) ResolvedType

func (ta Array) ResolvedType() *types.T

func (*Array) String

func (node *Array) String() string

func (*Array) TypeCheck

func (expr *Array) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*Array) Walk

func (expr *Array) Walk(v Visitor) Expr

Walk implements the Expr interface.

type ArrayFlatten

type ArrayFlatten struct {
	Subquery Expr
	// contains filtered or unexported fields
}

ArrayFlatten represents a subquery array constructor.

func NewTypedArrayFlattenExpr

func NewTypedArrayFlattenExpr(input Expr) *ArrayFlatten

NewTypedArrayFlattenExpr returns a new ArrayFlattenExpr that is verified to be well-typed.

func (*ArrayFlatten) Format

func (node *ArrayFlatten) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (ArrayFlatten) HasResolvedType added in v0.6.0

func (ta ArrayFlatten) HasResolvedType() bool

func (ArrayFlatten) ResolvedType

func (ta ArrayFlatten) ResolvedType() *types.T

func (*ArrayFlatten) String

func (node *ArrayFlatten) String() string

func (*ArrayFlatten) TypeCheck

func (expr *ArrayFlatten) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*ArrayFlatten) Walk

func (expr *ArrayFlatten) Walk(v Visitor) Expr

Walk implements the Expr interface.

type ArraySubscript

type ArraySubscript struct {
	Begin Expr
	End   Expr
	Slice bool
}

ArraySubscript corresponds to the syntax `<name>[ ... ]`.

func (*ArraySubscript) Format

func (a *ArraySubscript) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type ArraySubscripts

type ArraySubscripts []*ArraySubscript

ArraySubscripts represents a sequence of one or more array subscripts.

func (*ArraySubscripts) Format

func (a *ArraySubscripts) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type ArrayTypeReference

type ArrayTypeReference struct {
	ElementType ResolvableTypeReference
}

ArrayTypeReference represents an array of possibly unknown type references.

func (*ArrayTypeReference) SQLString

func (node *ArrayTypeReference) SQLString() string

SQLString implements the ResolvableTypeReference interface.

type AsOfClause

type AsOfClause struct {
	Expr Expr
}

AsOfClause represents an as of time.

func (*AsOfClause) Format

func (a *AsOfClause) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type Backup

type Backup struct {
	Targets         *TargetList
	To              StringOrPlaceholderOptList
	IncrementalFrom Exprs
	AsOf            AsOfClause
	Options         BackupOptions
	Nested          bool
	AppendToLatest  bool
	// Subdir may be set by the parser when the SQL query is of the form
	// `BACKUP INTO 'subdir' IN...`. Alternatively, if Nested is true but a subdir
	// was not explicitly specified by the user, then this will be set during
	// BACKUP planning once the destination has been resolved.
	Subdir Expr
}

Backup represents a BACKUP statement.

func (Backup) Coverage

func (node Backup) Coverage() DescriptorCoverage

Coverage return the coverage (all vs requested).

func (*Backup) Format

func (node *Backup) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Backup) StatementTag

func (*Backup) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Backup) StatementType

func (*Backup) StatementType() StatementType

StatementType implements the Statement interface.

func (*Backup) String

func (n *Backup) String() string

type BackupDetails

type BackupDetails int

BackupDetails represents the type of details to display for a SHOW BACKUP statement.

const (
	// BackupDefaultDetails identifies a bare SHOW BACKUP statement.
	BackupDefaultDetails BackupDetails = iota
	// BackupRangeDetails identifies a SHOW BACKUP RANGES statement.
	BackupRangeDetails
	// BackupFileDetails identifies a SHOW BACKUP FILES statement.
	BackupFileDetails
)

type BackupOptions

type BackupOptions struct {
	CaptureRevisionHistory bool
	EncryptionPassphrase   Expr
	Detached               bool
	EncryptionKMSURI       StringOrPlaceholderOptList
}

BackupOptions describes options for the BACKUP execution.

func (*BackupOptions) CombineWith

func (o *BackupOptions) CombineWith(other *BackupOptions) error

CombineWith merges other backup options into this backup options struct. An error is returned if the same option merged multiple times.

func (*BackupOptions) Format

func (o *BackupOptions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface

func (BackupOptions) IsDefault

func (o BackupOptions) IsDefault() bool

IsDefault returns true if this backup options struct has default value.

type BaseType added in v0.5.0

type BaseType struct {
	Input   string
	Output  string
	Options BaseTypeOptions
}

BaseType represents a `CREATE TYPE <name> ( INPUT = input_function, OUTPUT = output_function, ... )` statement.

func (*BaseType) Format added in v0.5.0

func (node *BaseType) Format(ctx *FmtCtx)

type BaseTypeOption added in v0.5.0

type BaseTypeOption struct {
	Option         BaseTypeOptionType
	StrVal         string
	BoolVal        bool
	InternalLength int64
	Default        Expr
	TypeVal        ResolvableTypeReference
}

type BaseTypeOptionType added in v0.5.0

type BaseTypeOptionType int
const (
	BaseTypeReceive BaseTypeOptionType = iota
	BaseTypeSend
	BaseTypeTypModIn
	BaseTypeTypeModOut
	BaseTypeAnalyze
	BaseTypeSubscript
	BaseTypeInternalLength
	BaseTypePassedByValue
	BaseTypeAlignment
	BaseTypeStorage
	BaseTypeLikeType
	BaseTypeCategory
	BaseTypePreferred
	BaseTypeDefault
	BaseTypeElement
	BaseTypeDelimiter
	BaseTypeCollatable
)

type BaseTypeOptions added in v0.5.0

type BaseTypeOptions []BaseTypeOption

func (*BaseTypeOptions) Format added in v0.5.0

func (node *BaseTypeOptions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type BeginEndBlock added in v0.4.0

type BeginEndBlock struct {
	Statements []Statement
}

BeginEndBlock represents a BEGIN ATOMIC ... END block with one or more statements nested within

func (*BeginEndBlock) Format added in v0.4.0

func (node *BeginEndBlock) Format(ctx *FmtCtx)

func (*BeginEndBlock) StatementTag added in v0.4.0

func (*BeginEndBlock) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*BeginEndBlock) StatementType added in v0.4.0

func (*BeginEndBlock) StatementType() StatementType

StatementType implements the Statement interface.

func (*BeginEndBlock) String added in v0.4.0

func (n *BeginEndBlock) String() string

type BeginTransaction

type BeginTransaction struct {
	Modes TransactionModes
}

BeginTransaction represents a BEGIN statement

func (*BeginTransaction) Format

func (node *BeginTransaction) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*BeginTransaction) StatementTag

func (*BeginTransaction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*BeginTransaction) StatementType

func (*BeginTransaction) StatementType() StatementType

StatementType implements the Statement interface.

func (*BeginTransaction) String

func (n *BeginTransaction) String() string

type BinOp

type BinOp struct {
	LeftType     *types.T
	RightType    *types.T
	ReturnType   *types.T
	NullableArgs bool
	Volatility   Volatility
	// contains filtered or unexported fields
}

BinOp is a binary operator.

type BinaryExpr

type BinaryExpr struct {
	Operator    BinaryOperator
	Left, Right Expr

	Fn *BinOp
	// contains filtered or unexported fields
}

BinaryExpr represents a binary value expression.

func NewTypedBinaryExpr

func NewTypedBinaryExpr(op BinaryOperator, left, right TypedExpr, typ *types.T) *BinaryExpr

NewTypedBinaryExpr returns a new BinaryExpr that is well-typed.

func (*BinaryExpr) Format

func (node *BinaryExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (BinaryExpr) HasResolvedType added in v0.6.0

func (ta BinaryExpr) HasResolvedType() bool

func (*BinaryExpr) ResolvedBinOp

func (node *BinaryExpr) ResolvedBinOp() *BinOp

ResolvedBinOp returns the resolved binary op overload; can only be called after Resolve (which happens during TypeCheck).

func (BinaryExpr) ResolvedType

func (ta BinaryExpr) ResolvedType() *types.T

func (*BinaryExpr) String

func (node *BinaryExpr) String() string

func (*BinaryExpr) TypeCheck

func (expr *BinaryExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*BinaryExpr) TypedLeft

func (node *BinaryExpr) TypedLeft() TypedExpr

TypedLeft returns the BinaryExpr's left expression as a TypedExpr.

func (*BinaryExpr) TypedRight

func (node *BinaryExpr) TypedRight() TypedExpr

TypedRight returns the BinaryExpr's right expression as a TypedExpr.

func (*BinaryExpr) Walk

func (expr *BinaryExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type BinaryOperator

type BinaryOperator int

BinaryOperator represents a binary operator.

const (
	Bitand BinaryOperator = iota
	Bitor
	Bitxor
	Plus
	Minus
	Mult
	Div
	FloorDiv
	Mod
	Pow
	Concat
	LShift
	RShift
	JSONFetchVal
	JSONFetchText
	JSONFetchValPath
	JSONFetchTextPath

	NumBinaryOperators
)

BinaryExpr.Operator

func (BinaryOperator) String

func (i BinaryOperator) String() string

type CCLOnlyStatement

type CCLOnlyStatement interface {
	// contains filtered or unexported methods
}

CCLOnlyStatement is a marker interface for statements that require a CCL binary for successful planning or execution. It is used to enhance error messages when attempting to use these statements in non-CCL binaries.

type CTE

type CTE struct {
	Name AliasClause
	Mtr  MaterializeClause
	Stmt Statement
}

CTE represents a common table expression inside of a WITH clause.

type Call

type Call struct {
	Procedure *FuncExpr
}

Call represents a CALL statement.

func (*Call) Format

func (c *Call) Format(ctx *FmtCtx)

Format implements the interface Statement.

func (*Call) StatementTag

func (c *Call) StatementTag() string

StatementTag implements the interface Statement.

func (*Call) StatementType

func (c *Call) StatementType() StatementType

StatementType implements the interface Statement.

func (*Call) String

func (c *Call) String() string

String implements the interface Statement.

type CancelQueries

type CancelQueries struct {
	Queries  *Select
	IfExists bool
}

CancelQueries represents a CANCEL QUERIES statement.

func (*CancelQueries) Format

func (node *CancelQueries) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CancelQueries) StatementTag

func (*CancelQueries) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CancelQueries) StatementType

func (*CancelQueries) StatementType() StatementType

StatementType implements the Statement interface.

func (*CancelQueries) String

func (n *CancelQueries) String() string

type CancelSessions

type CancelSessions struct {
	Sessions *Select
	IfExists bool
}

CancelSessions represents a CANCEL SESSIONS statement.

func (*CancelSessions) Format

func (node *CancelSessions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CancelSessions) StatementTag

func (*CancelSessions) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CancelSessions) StatementType

func (*CancelSessions) StatementType() StatementType

StatementType implements the Statement interface.

func (*CancelSessions) String

func (n *CancelSessions) String() string

type CannedOptPlan

type CannedOptPlan struct {
	Plan string
}

CannedOptPlan is used as the AST for a PREPARE .. AS OPT PLAN statement. This is a testing facility that allows execution (and benchmarking) of specific plans. See exprgen package for more information on the syntax.

func (*CannedOptPlan) Format

func (node *CannedOptPlan) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CannedOptPlan) StatementTag

func (*CannedOptPlan) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CannedOptPlan) StatementType

func (*CannedOptPlan) StatementType() StatementType

StatementType implements the Statement interface.

func (*CannedOptPlan) String

func (n *CannedOptPlan) String() string

type CaseExpr

type CaseExpr struct {
	Expr  Expr
	Whens []*When
	Else  Expr
	// contains filtered or unexported fields
}

CaseExpr represents a CASE expression.

func NewTypedCaseExpr

func NewTypedCaseExpr(
	expr TypedExpr, whens []*When, elseStmt TypedExpr, typ *types.T,
) (*CaseExpr, error)

NewTypedCaseExpr returns a new CaseExpr that is verified to be well-typed.

func (*CaseExpr) Format

func (node *CaseExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (CaseExpr) HasResolvedType added in v0.6.0

func (ta CaseExpr) HasResolvedType() bool

func (CaseExpr) ResolvedType

func (ta CaseExpr) ResolvedType() *types.T

func (*CaseExpr) String

func (node *CaseExpr) String() string

func (*CaseExpr) TypeCheck

func (expr *CaseExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*CaseExpr) Walk

func (expr *CaseExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type CastExpr

type CastExpr struct {
	Expr Expr
	Type ResolvableTypeReference

	SyntaxMode castSyntaxMode
	// contains filtered or unexported fields
}

CastExpr represents a CAST(expr AS type) expression.

func NewTypedCastExpr

func NewTypedCastExpr(expr TypedExpr, typ *types.T) *CastExpr

NewTypedCastExpr returns a new CastExpr that is verified to be well-typed.

func (*CastExpr) Format

func (node *CastExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (CastExpr) HasResolvedType added in v0.6.0

func (ta CastExpr) HasResolvedType() bool

func (CastExpr) ResolvedType

func (ta CastExpr) ResolvedType() *types.T

func (*CastExpr) String

func (node *CastExpr) String() string

func (*CastExpr) TypeCheck

func (expr *CastExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, _ *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*CastExpr) Walk

func (expr *CastExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type CheckConstraintTableDef

type CheckConstraintTableDef struct {
	Name      Name
	Expr      Expr
	NoInherit bool
}

CheckConstraintTableDef represents a check constraint within a CREATE TABLE statement.

func (*CheckConstraintTableDef) Format

func (node *CheckConstraintTableDef) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CheckConstraintTableDef) SetName

func (node *CheckConstraintTableDef) SetName(name Name)

SetName implements the ConstraintTableDef interface.

type ClientNoticeSender

type ClientNoticeSender interface {
	// SendClientNotice sends a notice out-of-band to the client.
	SendClientNotice(ctx context.Context, notice error)
}

ClientNoticeSender is a limited interface to send notices to the client.

TODO(knz): as of this writing, the implementations of this interface only work on the gateway node (i.e. not from distributed processors).

type CmpOp

type CmpOp struct {
	LeftType  *types.T
	RightType *types.T

	// If NullableArgs is false, the operator returns NULL
	// whenever either argument is NULL.
	NullableArgs bool

	Volatility Volatility
	// contains filtered or unexported fields
}

CmpOp is a comparison operator.

type CoalesceExpr

type CoalesceExpr struct {
	Name  string
	Exprs Exprs
	// contains filtered or unexported fields
}

CoalesceExpr represents a COALESCE or IFNULL expression.

func NewTypedCoalesceExpr

func NewTypedCoalesceExpr(typedExprs TypedExprs, typ *types.T) *CoalesceExpr

NewTypedCoalesceExpr returns a CoalesceExpr that is well-typed.

func (*CoalesceExpr) Format

func (node *CoalesceExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (CoalesceExpr) HasResolvedType added in v0.6.0

func (ta CoalesceExpr) HasResolvedType() bool

func (CoalesceExpr) ResolvedType

func (ta CoalesceExpr) ResolvedType() *types.T

func (*CoalesceExpr) String

func (node *CoalesceExpr) String() string

func (*CoalesceExpr) TypeCheck

func (expr *CoalesceExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*CoalesceExpr) TypedExprAt

func (node *CoalesceExpr) TypedExprAt(idx int) TypedExpr

TypedExprAt returns the expression at the specified index as a TypedExpr.

func (*CoalesceExpr) Walk

func (expr *CoalesceExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type CollateExpr

type CollateExpr struct {
	Expr   Expr
	Locale string
	// contains filtered or unexported fields
}

CollateExpr represents an (expr COLLATE locale) expression.

func NewTypedCollateExpr

func NewTypedCollateExpr(expr TypedExpr, locale string) *CollateExpr

NewTypedCollateExpr returns a new CollateExpr that is verified to be well-typed.

func (*CollateExpr) Format

func (node *CollateExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (CollateExpr) HasResolvedType added in v0.6.0

func (ta CollateExpr) HasResolvedType() bool

func (CollateExpr) ResolvedType

func (ta CollateExpr) ResolvedType() *types.T

func (*CollateExpr) String

func (node *CollateExpr) String() string

func (*CollateExpr) TypeCheck

func (expr *CollateExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*CollateExpr) Walk

func (expr *CollateExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type ColumnAccessExpr

type ColumnAccessExpr struct {
	Expr Expr

	// ByIndex, if set, indicates that the access is using a numeric
	// column reference and ColIndex below is already set.
	ByIndex bool

	// ColName is the name of the column to access. Empty if ByIndex is
	// set.
	ColName string

	// ColIndex indicates the index of the column in the tuple. This is
	// either:
	// - set during type checking based on the label in ColName if
	//   ByIndex is false,
	// - or checked for validity during type checking if ByIndex is true.
	// The first column in the tuple is at index 0. The input
	// syntax (E).@N populates N-1 in this field.
	ColIndex int
	// contains filtered or unexported fields
}

ColumnAccessExpr represents (E).x expressions. Specifically, it allows accessing the column(s) from a Set Returning Function.

func NewTypedColumnAccessExpr

func NewTypedColumnAccessExpr(expr TypedExpr, colName string, colIdx int) *ColumnAccessExpr

NewTypedColumnAccessExpr creates a pre-typed ColumnAccessExpr. A by-index ColumnAccessExpr can be specified by passing an empty string as colName.

func (*ColumnAccessExpr) Format

func (node *ColumnAccessExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (ColumnAccessExpr) HasResolvedType added in v0.6.0

func (ta ColumnAccessExpr) HasResolvedType() bool

func (ColumnAccessExpr) ResolvedType

func (ta ColumnAccessExpr) ResolvedType() *types.T

func (*ColumnAccessExpr) String

func (node *ColumnAccessExpr) String() string

func (*ColumnAccessExpr) TypeCheck

func (expr *ColumnAccessExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*ColumnAccessExpr) Walk

func (expr *ColumnAccessExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type ColumnCheckConstraint

type ColumnCheckConstraint struct {
	Expr      Expr
	NoInherit bool
}

ColumnCheckConstraint represents either a check on a column.

type ColumnComputedDef

type ColumnComputedDef struct {
	Expr      Expr
	ByDefault bool
	Options   SequenceOptions
}

ColumnComputedDef represents the description of a computed column (GENERATED ... clause).

type ColumnDefault

type ColumnDefault struct {
	Expr Expr
}

ColumnDefault represents a DEFAULT clause for a column.

type ColumnFKConstraint

type ColumnFKConstraint struct {
	Table   TableName
	Col     Name // empty-string means use PK
	Actions ReferenceActions
	Match   CompositeKeyMatchMethod
}

ColumnFKConstraint represents a Foreign Key constaint on a column (REFERENCES ... clause).

type ColumnID

type ColumnID uint32

ColumnID is a custom type for ColumnDescriptor IDs.

func (ColumnID) SafeValue

func (ColumnID) SafeValue()

SafeValue implements the redact.SafeValue interface.

type ColumnItem

type ColumnItem struct {
	// TableName holds the table prefix, if the name refers to a column. It is
	// optional.
	//
	// This uses UnresolvedObjectName because we need to preserve the
	// information about which parts were initially specified in the SQL
	// text. ColumnItems are intermediate data structures anyway, that
	// still need to undergo name resolution.
	TableName *UnresolvedObjectName
	// ColumnName names the designated column.
	ColumnName Name
}

ColumnItem corresponds to the name of a column in an expression.

func MakeColumnItem

func MakeColumnItem(tn *TableName, colName Name) ColumnItem

MakeColumnItem constructs a column item from an already valid TableName. This can be used for e.g. pretty-printing.

func NewColumnItem

func NewColumnItem(tn *TableName, colName Name) *ColumnItem

NewColumnItem constructs a column item from an already valid TableName. This can be used for e.g. pretty-printing.

func (*ColumnItem) Column

func (c *ColumnItem) Column() string

Column retrieves the unqualified column name.

func (*ColumnItem) Format

func (c *ColumnItem) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface. If this is updated, then dummyColumnItem.Format should be updated as well.

func (*ColumnItem) NormalizeVarName

func (c *ColumnItem) NormalizeVarName() (VarName, error)

NormalizeVarName implements the VarName interface.

func (*ColumnItem) Resolve

Resolve performs name resolution for a column item using a resolver.

func (*ColumnItem) ResolvedType

func (c *ColumnItem) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*ColumnItem) String

func (c *ColumnItem) String() string

func (*ColumnItem) TypeCheck

func (expr *ColumnItem) TypeCheck(
	_ context.Context, _ *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface. This function has a valid implementation only for testing within this package. During query execution, ColumnItems are replaced to IndexedVars prior to type checking.

func (*ColumnItem) Variable

func (c *ColumnItem) Variable()

Variable implements the VariableExpr interface.

Note that in common uses, ColumnItem ought to be replaced to an IndexedVar prior to evaluation.

func (*ColumnItem) Walk

func (expr *ColumnItem) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type ColumnItemResolver

type ColumnItemResolver interface {
	// FindSourceMatchingName searches for a data source with name tn.
	//
	// This must error out with "ambiguous table name" if there is more
	// than one data source matching tn. The srcMeta is subsequently
	// passed to Resolve() if resolution succeeds. The prefix will not be
	// modified.
	FindSourceMatchingName(ctx context.Context, tn TableName) (res NumResolutionResults, prefix *TableName, srcMeta ColumnSourceMeta, err error)

	// FindSourceProvidingColumn searches for a data source providing
	// a column with the name given.
	//
	// This must error out with "ambiguous column name" if there is more
	// than one data source matching tn, "column not found" if there is
	// none. The srcMeta and colHints are subsequently passed to
	// Resolve() if resolution succeeds. The prefix will not be
	// modified.
	FindSourceProvidingColumn(ctx context.Context, col Name) (prefix *TableName, srcMeta ColumnSourceMeta, colHint int, err error)

	// Resolve() is called if resolution succeeds.
	Resolve(ctx context.Context, prefix *TableName, srcMeta ColumnSourceMeta, colHint int, col Name) (ColumnResolutionResult, error)
}

ColumnItemResolver is the helper interface to resolve column items.

type ColumnMutationCmd

type ColumnMutationCmd interface {
	AlterTableCmd
	GetColumn() Name
}

ColumnMutationCmd is the subset of AlterTableCmds that modify an existing column.

type ColumnQualification

type ColumnQualification interface {
	// contains filtered or unexported methods
}

ColumnQualification represents a constraint on a column.

type ColumnResolutionResult

type ColumnResolutionResult interface {
	// ColumnResolutionResult is the interface anchor.
	ColumnResolutionResult()
}

ColumnResolutionResult is an opaque reference returned by ColumnItemResolver.Resolve().

type ColumnSourceMeta

type ColumnSourceMeta interface {
	// ColumnSourcMeta is the interface anchor.
	ColumnSourceMeta()
}

ColumnSourceMeta is an opaque reference passed through column item resolution.

type ColumnTableDef

type ColumnTableDef struct {
	Name        Name
	Type        ResolvableTypeReference
	Compression string
	Collation   string
	IsSerial    bool
	Nullable    struct {
		Nullability    Nullability
		ConstraintName Name
	}
	// only UNIQUE, PRIMARY KEY, EXCLUDE, and REFERENCES (foreign key) constraints accept this clause
	PrimaryKey struct {
		IsPrimaryKey bool
	}
	Unique               bool
	UniqueConstraintName Name
	UniqueDeferrable     DeferrableMode
	UniqueInitially      InitiallyMode
	DefaultExpr          struct {
		Expr           Expr
		ConstraintName Name
	}
	CheckExprs []ColumnTableDefCheckExpr
	References struct {
		Table          *TableName
		Col            Name
		ConstraintName Name
		Actions        ReferenceActions
		Match          CompositeKeyMatchMethod
		Deferrable     DeferrableMode
		Initially      InitiallyMode
	}
	Computed struct {
		Computed  bool
		ByDefault bool
		Expr      Expr
		Options   SequenceOptions
	}
}

ColumnTableDef represents a column definition within a CREATE TABLE statement.

func NewColumnTableDef

func NewColumnTableDef(
	name Name,
	typRef ResolvableTypeReference,
	compression string,
	collation string,
	qualifications []NamedColumnQualification,
) (*ColumnTableDef, error)

NewColumnTableDef constructs a column definition for a CreateTable statement.

func (*ColumnTableDef) Format

func (node *ColumnTableDef) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ColumnTableDef) HasDefaultExpr

func (node *ColumnTableDef) HasDefaultExpr() bool

HasDefaultExpr returns if the ColumnTableDef has a default expression.

func (*ColumnTableDef) HasFKConstraint

func (node *ColumnTableDef) HasFKConstraint() bool

HasFKConstraint returns if the ColumnTableDef has a foreign key constraint.

func (*ColumnTableDef) IsComputed

func (node *ColumnTableDef) IsComputed() bool

IsComputed returns if the ColumnTableDef is a computed column.

func (*ColumnTableDef) String

func (node *ColumnTableDef) String() string

String implements the fmt.Stringer interface.

type ColumnTableDefCheckExpr

type ColumnTableDefCheckExpr struct {
	Expr           Expr
	ConstraintName Name
	NoInherit      bool
}

ColumnTableDefCheckExpr represents a check constraint on a column definition within a CREATE TABLE statement.

type Comment added in v0.6.0

type Comment struct {
	Object  CommentObject
	Comment *string
}

Comment represents a COMMENT statement.

func (*Comment) Format added in v0.6.0

func (node *Comment) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Comment) StatementTag added in v0.6.0

func (*Comment) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Comment) StatementType added in v0.6.0

func (*Comment) StatementType() StatementType

StatementType implements the Statement interface.

func (*Comment) String added in v0.6.0

func (n *Comment) String() string

type CommentObject added in v0.6.0

type CommentObject interface {
	NodeFormatter
	// contains filtered or unexported methods
}

CommentObject represents an object type definition for COMMENT ON command.

type CommentOnAccessMethod added in v0.6.0

type CommentOnAccessMethod struct {
	Name *UnresolvedObjectName
}

CommentOnAccessMethod represents COMMENT ON ACCESS METHOD command.

func (*CommentOnAccessMethod) Format added in v0.6.0

func (node *CommentOnAccessMethod) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnAggregate added in v0.6.0

type CommentOnAggregate struct {
	Name   *UnresolvedObjectName
	AggSig *AggregateSignature
}

CommentOnAggregate represents COMMENT ON AGGREGATE command.

func (*CommentOnAggregate) Format added in v0.6.0

func (node *CommentOnAggregate) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnCast added in v0.6.0

type CommentOnCast struct {
	Source ResolvableTypeReference
	Target ResolvableTypeReference
}

CommentOnCast represents COMMENT ON CAST command.

func (*CommentOnCast) Format added in v0.6.0

func (node *CommentOnCast) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnCollation added in v0.6.0

type CommentOnCollation struct {
	Name string
}

CommentOnCollation represents COMMENT ON COLLATION command.

func (*CommentOnCollation) Format added in v0.6.0

func (node *CommentOnCollation) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnColumn

type CommentOnColumn struct {
	*ColumnItem
}

CommentOnColumn represents COMMENT ON COLUMN command.

func (*CommentOnColumn) Format

func (node *CommentOnColumn) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnConstraintOnDomain added in v0.6.0

type CommentOnConstraintOnDomain struct {
	Constraint Name
	Domain     *UnresolvedObjectName
}

CommentOnConstraintOnDomain represents COMMENT ON CONSTRAINT ON DOMAIN command.

func (*CommentOnConstraintOnDomain) Format added in v0.6.0

func (node *CommentOnConstraintOnDomain) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnConstraintOnTable added in v0.6.0

type CommentOnConstraintOnTable struct {
	Constraint Name
	Table      *UnresolvedObjectName
}

CommentOnConstraintOnTable represents COMMENT ON CONSTRAINT ON table command.

func (*CommentOnConstraintOnTable) Format added in v0.6.0

func (node *CommentOnConstraintOnTable) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnConversion added in v0.6.0

type CommentOnConversion struct {
	Name Name
}

CommentOnConversion represents COMMENT ON CONVERSION command.

func (*CommentOnConversion) Format added in v0.6.0

func (node *CommentOnConversion) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnDatabase

type CommentOnDatabase struct {
	Name Name
}

CommentOnDatabase represents COMMENT ON DATABASE command.

func (*CommentOnDatabase) Format

func (node *CommentOnDatabase) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnDomain added in v0.6.0

type CommentOnDomain struct {
	Name *UnresolvedObjectName
}

CommentOnDomain represents COMMENT ON DOMAIN command.

func (*CommentOnDomain) Format added in v0.6.0

func (node *CommentOnDomain) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnEventTrigger added in v0.6.0

type CommentOnEventTrigger struct {
	Name Name
}

CommentOnEventTrigger represents COMMENT ON EVENT TRIGGER command.

func (*CommentOnEventTrigger) Format added in v0.6.0

func (node *CommentOnEventTrigger) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnExtension added in v0.4.0

type CommentOnExtension struct {
	Name Name
}

CommentOnExtension represents COMMENT ON EXTENSION command.

func (*CommentOnExtension) Format added in v0.4.0

func (node *CommentOnExtension) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnForeignDataWrapper added in v0.6.0

type CommentOnForeignDataWrapper struct {
	Name Name
}

CommentOnForeignDataWrapper represents COMMENT ON FOREIGN DATA WRAPPER command.

func (*CommentOnForeignDataWrapper) Format added in v0.6.0

func (node *CommentOnForeignDataWrapper) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnForeignTable added in v0.6.0

type CommentOnForeignTable struct {
	Name Name
}

CommentOnForeignTable represents COMMENT ON FOREIGN TABLE command.

func (*CommentOnForeignTable) Format added in v0.6.0

func (node *CommentOnForeignTable) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnFunction added in v0.6.0

type CommentOnFunction struct {
	Name *UnresolvedObjectName
	Args RoutineArgs
}

CommentOnFunction represents COMMENT ON FUNCTION command.

func (*CommentOnFunction) Format added in v0.6.0

func (node *CommentOnFunction) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnIndex

type CommentOnIndex struct {
	Index TableIndexName
}

CommentOnIndex represents COMMENT ON INDEX command.

func (*CommentOnIndex) Format

func (node *CommentOnIndex) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnLanguage added in v0.6.0

type CommentOnLanguage struct {
	Name       Name
	Procedural bool
}

CommentOnLanguage represents COMMENT ON LANGUAGE command.

func (*CommentOnLanguage) Format added in v0.6.0

func (node *CommentOnLanguage) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnLargeObject added in v0.6.0

type CommentOnLargeObject struct {
	Oid Expr
}

CommentOnLargeObject represents COMMENT ON LARGE OBJECT command.

func (*CommentOnLargeObject) Format added in v0.6.0

func (node *CommentOnLargeObject) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnMaterializedView added in v0.6.0

type CommentOnMaterializedView struct {
	Name *UnresolvedObjectName
}

CommentOnMaterializedView represents COMMENT ON MATERIALIZED VIEW command.

func (*CommentOnMaterializedView) Format added in v0.6.0

func (node *CommentOnMaterializedView) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnOperator added in v0.6.0

type CommentOnOperator struct {
	Op    Operator
	Left  ResolvableTypeReference
	Right ResolvableTypeReference
}

CommentOnOperator represents COMMENT ON OPERATOR command.

func (*CommentOnOperator) Format added in v0.6.0

func (node *CommentOnOperator) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnOperatorClass added in v0.6.0

type CommentOnOperatorClass struct {
	Name      Name
	IdxMethod string
}

CommentOnOperatorClass represents COMMENT ON OPERATOR CLASS command.

func (*CommentOnOperatorClass) Format added in v0.6.0

func (node *CommentOnOperatorClass) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnOperatorFamily added in v0.6.0

type CommentOnOperatorFamily struct {
	Name      Name
	IdxMethod string
}

CommentOnOperatorFamily represents COMMENT ON FAMILY command.

func (*CommentOnOperatorFamily) Format added in v0.6.0

func (node *CommentOnOperatorFamily) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnPolicy added in v0.6.0

type CommentOnPolicy struct {
	Policy Name
	Table  *UnresolvedObjectName
}

CommentOnPolicy represents COMMENT ON POLICY command.

func (*CommentOnPolicy) Format added in v0.6.0

func (node *CommentOnPolicy) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnProcedure added in v0.6.0

type CommentOnProcedure struct {
	Name *UnresolvedObjectName
	Args RoutineArgs
}

CommentOnProcedure represents COMMENT ON PROCEDURE command.

func (*CommentOnProcedure) Format added in v0.6.0

func (node *CommentOnProcedure) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnPublication added in v0.6.0

type CommentOnPublication struct {
	Name Name
}

CommentOnPublication represents COMMENT ON PUBLICATION command.

func (*CommentOnPublication) Format added in v0.6.0

func (node *CommentOnPublication) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnRole added in v0.6.0

type CommentOnRole struct {
	Name string
}

CommentOnRole represents COMMENT ON ROLE command.

func (*CommentOnRole) Format added in v0.6.0

func (node *CommentOnRole) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnRoutine added in v0.6.0

type CommentOnRoutine struct {
	Name *UnresolvedObjectName
	Args RoutineArgs
}

CommentOnRoutine represents COMMENT ON ROUTINE command.

func (*CommentOnRoutine) Format added in v0.6.0

func (node *CommentOnRoutine) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnRule added in v0.6.0

type CommentOnRule struct {
	Rule  Name
	Table *UnresolvedObjectName
}

CommentOnRule represents COMMENT ON RULE command.

func (*CommentOnRule) Format added in v0.6.0

func (node *CommentOnRule) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnSchema added in v0.6.0

type CommentOnSchema struct {
	Name string
}

CommentOnSchema represents COMMENT ON SCHEMA command.

func (*CommentOnSchema) Format added in v0.6.0

func (node *CommentOnSchema) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnSequence added in v0.6.0

type CommentOnSequence struct {
	Name *UnresolvedObjectName
}

CommentOnSequence represents COMMENT ON SEQUENCE command.

func (*CommentOnSequence) Format added in v0.6.0

func (node *CommentOnSequence) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnServer added in v0.6.0

type CommentOnServer struct {
	Name Name
}

CommentOnServer represents COMMENT ON SERVER command.

func (*CommentOnServer) Format added in v0.6.0

func (node *CommentOnServer) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnStatistics added in v0.6.0

type CommentOnStatistics struct {
	Name Name
}

CommentOnStatistics represents COMMENT ON STATISTICS command.

func (*CommentOnStatistics) Format added in v0.6.0

func (node *CommentOnStatistics) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnSubscription added in v0.6.0

type CommentOnSubscription struct {
	Name Name
}

CommentOnSubscription represents COMMENT ON SUBSCRIPTION command.

func (*CommentOnSubscription) Format added in v0.6.0

func (node *CommentOnSubscription) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnTable

type CommentOnTable struct {
	Name *UnresolvedObjectName
}

CommentOnTable represents COMMENT ON TABLE command.

func (*CommentOnTable) Format

func (node *CommentOnTable) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnTablespace added in v0.6.0

type CommentOnTablespace struct {
	Name Name
}

CommentOnTablespace represents COMMENT ON TABLESPACE command.

func (*CommentOnTablespace) Format added in v0.6.0

func (node *CommentOnTablespace) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnTextSearchConfiguration added in v0.6.0

type CommentOnTextSearchConfiguration struct {
	Name Name
}

CommentOnTextSearchConfiguration represents COMMENT ON TEXT SEARCH CONFIGURATION command.

func (*CommentOnTextSearchConfiguration) Format added in v0.6.0

func (node *CommentOnTextSearchConfiguration) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnTextSearchDictionary added in v0.6.0

type CommentOnTextSearchDictionary struct {
	Name Name
}

CommentOnTextSearchDictionary represents COMMENT ON TEXT SEARCH DICTIONARY command.

func (*CommentOnTextSearchDictionary) Format added in v0.6.0

func (node *CommentOnTextSearchDictionary) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnTextSearchParser added in v0.6.0

type CommentOnTextSearchParser struct {
	Name Name
}

CommentOnTextSearchParser represents COMMENT ON TEXT SEARCH PARSER command.

func (*CommentOnTextSearchParser) Format added in v0.6.0

func (node *CommentOnTextSearchParser) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnTextSearchTemplate added in v0.6.0

type CommentOnTextSearchTemplate struct {
	Name Name
}

CommentOnTextSearchTemplate represents COMMENT ON TEXT SEARCH TEMPLATE command.

func (*CommentOnTextSearchTemplate) Format added in v0.6.0

func (node *CommentOnTextSearchTemplate) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnTransformFor added in v0.6.0

type CommentOnTransformFor struct {
	Type     ResolvableTypeReference
	Language Name
}

CommentOnTransformFor represents COMMENT ON TRANSFORM FOR command.

func (*CommentOnTransformFor) Format added in v0.6.0

func (node *CommentOnTransformFor) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnTrigger added in v0.6.0

type CommentOnTrigger struct {
	Trigger Name
	Table   *UnresolvedObjectName
}

CommentOnTrigger represents COMMENT ON TRIGGER command.

func (*CommentOnTrigger) Format added in v0.6.0

func (node *CommentOnTrigger) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnType added in v0.6.0

type CommentOnType struct {
	Name *UnresolvedObjectName
}

CommentOnType represents COMMENT ON TYPE command.

func (*CommentOnType) Format added in v0.6.0

func (node *CommentOnType) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommentOnView added in v0.6.0

type CommentOnView struct {
	Name *UnresolvedObjectName
}

CommentOnView represents COMMENT ON VIEW command.

func (*CommentOnView) Format added in v0.6.0

func (node *CommentOnView) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CommitTransaction

type CommitTransaction struct{}

CommitTransaction represents a COMMIT statement.

func (*CommitTransaction) Format

func (node *CommitTransaction) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CommitTransaction) StatementTag

func (*CommitTransaction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CommitTransaction) StatementType

func (*CommitTransaction) StatementType() StatementType

StatementType implements the Statement interface.

func (*CommitTransaction) String

func (n *CommitTransaction) String() string

type CommonLookupFlags

type CommonLookupFlags struct {
	// if required is set, lookup will return an error if the item is not found.
	Required bool
	// RequireMutable specifies whether to return a mutable descriptor.
	RequireMutable bool
	// if AvoidCached is set, lookup will avoid the cache (if any).
	AvoidCached bool
	// IncludeOffline specifies if offline descriptors should be visible.
	IncludeOffline bool
	// IncludeOffline specifies if dropped descriptors should be visible.
	IncludeDropped bool
}

CommonLookupFlags is the common set of flags for the various accessor interfaces.

type ComparisonExpr

type ComparisonExpr struct {
	Operator    ComparisonOperator
	SubOperator ComparisonOperator // used for array operators (when Operator is Any, Some, or All)
	Left, Right Expr

	Fn *CmpOp
	// contains filtered or unexported fields
}

ComparisonExpr represents a two-value comparison expression.

func NewTypedComparisonExpr

func NewTypedComparisonExpr(op ComparisonOperator, left, right TypedExpr) *ComparisonExpr

NewTypedComparisonExpr returns a new ComparisonExpr that is verified to be well-typed.

func NewTypedComparisonExprWithSubOp

func NewTypedComparisonExprWithSubOp(
	op, subOp ComparisonOperator, left, right TypedExpr,
) *ComparisonExpr

NewTypedComparisonExprWithSubOp returns a new ComparisonExpr that is verified to be well-typed.

func (*ComparisonExpr) Format

func (node *ComparisonExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (ComparisonExpr) HasResolvedType added in v0.6.0

func (ta ComparisonExpr) HasResolvedType() bool

func (ComparisonExpr) ResolvedType

func (ta ComparisonExpr) ResolvedType() *types.T

func (*ComparisonExpr) String

func (node *ComparisonExpr) String() string

func (*ComparisonExpr) TypeCheck

func (expr *ComparisonExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*ComparisonExpr) TypedLeft

func (node *ComparisonExpr) TypedLeft() TypedExpr

TypedLeft returns the ComparisonExpr's left expression as a TypedExpr.

func (*ComparisonExpr) TypedRight

func (node *ComparisonExpr) TypedRight() TypedExpr

TypedRight returns the ComparisonExpr's right expression as a TypedExpr.

func (*ComparisonExpr) Walk

func (expr *ComparisonExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type ComparisonOperator

type ComparisonOperator int

ComparisonOperator represents a binary operator.

const (
	EQ ComparisonOperator = iota
	LT
	GT
	LE
	GE
	NE
	In
	NotIn
	Like
	NotLike
	ILike
	NotILike
	SimilarTo
	NotSimilarTo
	RegMatch
	NotRegMatch
	RegIMatch
	NotRegIMatch
	TextSearchMatch
	IsDistinctFrom
	IsNotDistinctFrom
	Contains
	ContainedBy
	JSONExists
	JSONSomeExists
	JSONAllExists
	Overlaps

	// The following operators will always be used with an associated SubOperator.
	// If Go had algebraic data types they would be defined in a self-contained
	// manner like:
	//
	// Any(ComparisonOperator)
	// Some(ComparisonOperator)
	// ...
	//
	// where the internal ComparisonOperator qualifies the behavior of the primary
	// operator. Instead, a secondary ComparisonOperator is optionally included in
	// ComparisonExpr for the cases where these operators are the primary op.
	//
	// ComparisonOperator.HasSubOperator returns true for ops in this group.
	Any
	Some
	All

	NumComparisonOperators
)

ComparisonExpr.Operator

func (ComparisonOperator) HasSubOperator

func (i ComparisonOperator) HasSubOperator() bool

HasSubOperator returns if the ComparisonOperator is used with a sub-operator.

func (ComparisonOperator) Inverse

Inverse returns the inverse of this comparison operator if it exists. The second return value is true if it exists, and false otherwise.

func (ComparisonOperator) String

func (i ComparisonOperator) String() string

type CompositeDatum

type CompositeDatum interface {
	Datum
	// IsComposite returns true if this datum is not round-tripable in a key
	// encoding.
	IsComposite() bool
}

CompositeDatum is a Datum that may require composite encoding in indexes. Any Datum implementing this interface must also add itself to colinfo.HasCompositeKeyEncoding.

type CompositeKeyMatchMethod

type CompositeKeyMatchMethod int

CompositeKeyMatchMethod is the algorithm use when matching composite keys. See https://github.com/cockroachdb/cockroach/issues/20305 or https://www.postgresql.org/docs/11/sql-createtable.html for details on the different composite foreign key matching methods.

const (
	MatchSimple CompositeKeyMatchMethod = iota
	MatchFull
	MatchPartial // Note: PARTIAL not actually supported at this point.
)

The values for CompositeKeyMatchMethod.

func (CompositeKeyMatchMethod) String

func (c CompositeKeyMatchMethod) String() string

type CompositeType added in v0.5.0

type CompositeType struct {
	Types []CompositeTypeElem
}

CompositeType represents a `CREATE TYPE <name> AS ( <type>, ... )` statement.

func (*CompositeType) Format added in v0.5.0

func (node *CompositeType) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CompositeTypeElem added in v0.5.0

type CompositeTypeElem struct {
	AttrName string
	Type     ResolvableTypeReference
	// below fields are optional
	Collate string
}

type Constant

type Constant interface {
	Expr
	// AvailableTypes returns the ordered set of types that the Constant is able to
	// be resolved into. The order of the type slice provides a notion of precedence,
	// with the first element in the ordering being the Constant's "natural type".
	AvailableTypes() []*types.T
	// DesirableTypes returns the ordered set of types that the constant would
	// prefer to be resolved into. As in AvailableTypes, the order of the returned
	// type slice provides a notion of precedence, with the first element in the
	// ordering being the Constant's "natural type." The function is meant to be
	// differentiated from AvailableTypes in that it will exclude certain types
	// that are possible, but not desirable.
	//
	// An example of this is a floating point numeric constant without a value
	// past the decimal point. It is possible to resolve this constant as a
	// decimal, but it is not desirable.
	DesirableTypes() []*types.T
	// ResolveAsType resolves the Constant as the specified type, or returns an
	// error if the Constant could not be resolved as that type. The method should
	// only be passed a type returned from AvailableTypes and should never be
	// called more than once for a given Constant.
	//
	// The returned expression is either a Datum or a CastExpr wrapping a Datum;
	// the latter is necessary for cases where the result would depend on the
	// context (like the timezone or the current time).
	ResolveAsType(context.Context, *SemaContext, *types.T) (TypedExpr, error)
}

Constant is an constant literal expression which may be resolved to more than one type.

type ConstraintTableDef

type ConstraintTableDef interface {
	TableDef

	// SetName replaces the name of the definition in-place. Used in the parser.
	SetName(name Name)
	// contains filtered or unexported methods
}

ConstraintTableDef represents a table constraint definition within a CREATE TABLE statement.

type ControlJobs

type ControlJobs struct {
	Jobs    *Select
	Command JobCommand
}

ControlJobs represents a PAUSE/RESUME/CANCEL JOBS statement.

func (*ControlJobs) Format

func (n *ControlJobs) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ControlJobs) StatementTag

func (n *ControlJobs) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ControlJobs) StatementType

func (*ControlJobs) StatementType() StatementType

StatementType implements the Statement interface.

func (*ControlJobs) String

func (n *ControlJobs) String() string

type ControlJobsForSchedules

type ControlJobsForSchedules struct {
	Schedules *Select
	Command   JobCommand
}

ControlJobsForSchedules represents PAUSE/RESUME/CANCEL clause which applies job command to the jobs matching specified schedule(s).

func (*ControlJobsForSchedules) Format

func (n *ControlJobsForSchedules) Format(ctx *FmtCtx)

Format implements NodeFormatter interface

func (*ControlJobsForSchedules) StatementTag

func (n *ControlJobsForSchedules) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ControlJobsForSchedules) StatementType

func (*ControlJobsForSchedules) StatementType() StatementType

StatementType implements the Statement interface.

func (*ControlJobsForSchedules) String

func (n *ControlJobsForSchedules) String() string

type ControlSchedules

type ControlSchedules struct {
	Schedules *Select
	Command   ScheduleCommand
}

ControlSchedules represents PAUSE/RESUME SCHEDULE statement.

func (*ControlSchedules) Format

func (n *ControlSchedules) Format(ctx *FmtCtx)

Format implements NodeFormatter interface

func (*ControlSchedules) StatementTag

func (n *ControlSchedules) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ControlSchedules) StatementType

func (*ControlSchedules) StatementType() StatementType

StatementType implements the Statement interface.

func (*ControlSchedules) String

func (n *ControlSchedules) String() string

type CopyFormat

type CopyFormat int

CopyFormat identifies a COPY data format.

const (
	CopyFormatText CopyFormat = iota
	CopyFormatBinary
)

Valid values for CopyFormat.

type CopyFrom

type CopyFrom struct {
	Table   TableName
	Columns NameList
	Stdin   bool
	Options CopyOptions
}

CopyFrom represents a COPY FROM statement.

func (*CopyFrom) Format

func (node *CopyFrom) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CopyFrom) StatementTag

func (*CopyFrom) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CopyFrom) StatementType

func (*CopyFrom) StatementType() StatementType

StatementType implements the Statement interface.

func (*CopyFrom) String

func (n *CopyFrom) String() string

type CopyOptions

type CopyOptions struct {
	Destination Expr
	CopyFormat  CopyFormat
}

CopyOptions describes options for COPY execution.

func (*CopyOptions) CombineWith

func (o *CopyOptions) CombineWith(other *CopyOptions) error

CombineWith merges other options into this struct. An error is returned if the same option merged multiple times.

func (*CopyOptions) Format

func (o *CopyOptions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface

func (CopyOptions) IsDefault

func (o CopyOptions) IsDefault() bool

IsDefault returns true if this struct has default value.

type CreateAggOption added in v0.5.0

type CreateAggOption struct {
	Option CreateOptionType
	// IntVal is used for SSpace and MSSpace
	IntVal Expr
	// CondVal is used for InitCond and MInitCond
	CondVal Expr
	// BoolVal is used for FinalFuncExtra and MFinalFuncExtra
	BoolVal bool
	// StrVal is used for FinalFunc, CombineFunc, SerialFunc,
	// DeserialFunc, MSFunc, MInvFunc and MFinalFunc
	StrVal string
	// FinalFuncModify is used for FinalFuncModify and MFinalFuncModify
	FinalFuncModify FinalFuncModifyType
	// TypeVal is used for MSType
	TypeVal  ResolvableTypeReference
	Parallel Parallel
	SortOp   Operator
}

func (*CreateAggOption) Format added in v0.5.0

func (node *CreateAggOption) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CreateAggOptions added in v0.5.0

type CreateAggOptions []CreateAggOption

func (*CreateAggOptions) Format added in v0.5.0

func (node *CreateAggOptions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CreateAggregate added in v0.5.0

type CreateAggregate struct {
	Name        *UnresolvedObjectName
	Replace     bool
	Args        RoutineArgs
	SFunc       string
	SType       ResolvableTypeReference
	AggOptions  CreateAggOptions
	OrderByArgs RoutineArgs
	BaseType    ResolvableTypeReference
}

CreateAggregate represents a CREATE AGGREGATE statement.

func (*CreateAggregate) Format added in v0.5.0

func (node *CreateAggregate) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateAggregate) StatementTag added in v0.5.0

func (*CreateAggregate) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateAggregate) StatementType added in v0.5.0

func (*CreateAggregate) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateAggregate) String added in v0.5.0

func (n *CreateAggregate) String() string

type CreateChangefeed

type CreateChangefeed struct {
	Targets TargetList
	SinkURI Expr
	Options KVOptions
}

CreateChangefeed represents a CREATE CHANGEFEED statement.

func (*CreateChangefeed) Format

func (node *CreateChangefeed) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateChangefeed) StatementTag

func (n *CreateChangefeed) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateChangefeed) StatementType

func (*CreateChangefeed) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateChangefeed) String

func (n *CreateChangefeed) String() string

type CreateDatabase

type CreateDatabase struct {
	IfNotExists      bool
	Name             Name
	Owner            string
	Template         string
	Encoding         string
	Strategy         string
	Locale           string
	Collate          string
	CType            string
	IcuLocale        string
	IcuRules         string
	LocaleProvider   string
	CollationVersion string
	Tablespace       string
	AllowConnections Expr // default is true
	ConnectionLimit  Expr // default is -1
	IsTemplate       Expr // default is false
	Oid              Expr
}

CreateDatabase represents a CREATE DATABASE statement.

func (*CreateDatabase) Format

func (node *CreateDatabase) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateDatabase) StatementTag

func (*CreateDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateDatabase) StatementType

func (*CreateDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateDatabase) String

func (n *CreateDatabase) String() string

type CreateDomain added in v0.5.0

type CreateDomain struct {
	TypeName    *UnresolvedObjectName
	DataType    ResolvableTypeReference
	Collate     string
	Default     Expr
	Constraints DomainConstraints
}

CreateDomain represents a CREATE DOMAIN statement.

func (*CreateDomain) Format added in v0.5.0

func (node *CreateDomain) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateDomain) StatementTag added in v0.5.0

func (*CreateDomain) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateDomain) StatementType added in v0.5.0

func (*CreateDomain) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateDomain) String added in v0.5.0

func (n *CreateDomain) String() string

type CreateExtension added in v0.4.0

type CreateExtension struct {
	Name        Name
	IfNotExists bool
	Schema      string
	Version     string
	Cascade     bool
}

CreateExtension represents a CREATE EXTENSION statement.

func (*CreateExtension) Format added in v0.4.0

func (node *CreateExtension) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateExtension) StatementTag added in v0.4.0

func (*CreateExtension) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateExtension) StatementType added in v0.4.0

func (*CreateExtension) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateExtension) String added in v0.4.0

func (n *CreateExtension) String() string

type CreateFunction added in v0.4.0

type CreateFunction struct {
	Name    *UnresolvedObjectName
	Replace bool
	Args    RoutineArgs
	SetOf   bool
	RetType []SimpleColumnDef
	Options []RoutineOption
}

CreateFunction represents a CREATE FUNCTION statement.

func (*CreateFunction) Format added in v0.4.0

func (node *CreateFunction) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateFunction) StatementTag added in v0.4.0

func (*CreateFunction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateFunction) StatementType added in v0.4.0

func (*CreateFunction) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateFunction) String added in v0.4.0

func (n *CreateFunction) String() string

type CreateIndex

type CreateIndex struct {
	Name          Name
	Table         TableName
	Unique        bool
	Concurrently  bool
	IfNotExists   bool
	Only          bool
	Using         string
	Columns       IndexElemList
	NullsDistinct bool
	IndexParams   IndexParams
	Predicate     Expr
}

CreateIndex represents a CREATE INDEX statement.

func (*CreateIndex) Format

func (node *CreateIndex) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateIndex) StatementTag

func (*CreateIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateIndex) StatementType

func (*CreateIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateIndex) String

func (n *CreateIndex) String() string

type CreateLanguage added in v0.5.0

type CreateLanguage struct {
	Name       Name
	Replace    bool
	Trusted    bool
	Procedural bool
	Handler    *LanguageHandler
}

CreateLanguage represents a CREATE LANGUAGE statement.

func (*CreateLanguage) Format added in v0.5.0

func (node *CreateLanguage) Format(ctx *FmtCtx)

func (*CreateLanguage) StatementTag added in v0.5.0

func (*CreateLanguage) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateLanguage) StatementType added in v0.5.0

func (*CreateLanguage) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateLanguage) String added in v0.5.0

func (n *CreateLanguage) String() string

type CreateMaterializedView added in v0.5.0

type CreateMaterializedView struct {
	Name        TableName
	ColumnNames NameList
	IfNotExists bool
	Using       string
	Params      StorageParams
	Tablespace  Name
	AsSource    *Select
	CheckOption ViewCheckOption
	WithNoData  bool
}

CreateMaterializedView represents a CREATE MATERIALIZED VIEW statement.

func (*CreateMaterializedView) Format added in v0.5.0

func (node *CreateMaterializedView) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateMaterializedView) StatementTag added in v0.5.0

func (*CreateMaterializedView) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateMaterializedView) StatementType added in v0.5.0

func (*CreateMaterializedView) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateMaterializedView) String added in v0.5.0

func (n *CreateMaterializedView) String() string

type CreateOptionType added in v0.5.0

type CreateOptionType int
const (
	AggOptTypeSSpace CreateOptionType = iota
	AggOptTypeFinalFunc
	AggOptTypeFinalFuncExtra
	AggOptTypeFinalFuncModify
	AggOptTypeCombineFunc
	AggOptTypeSerialFunc
	AggOptTypeDeserialFunc
	AggOptTypeInitCond
	AggOptTypeMSFunc
	AggOptTypeMInvFunc
	AggOptTypeMSType
	AggOptTypeMSSpace
	AggOptTypeMFinalFunc
	AggOptTypeMFinalFuncExtra
	AggOptTypeMFinalFuncModify
	AggOptTypeMInitCond
	AggOptTypeSortOp
	AggOptTypeParallel
	AggOptTypeHypothetical
)

type CreateProcedure added in v0.5.0

type CreateProcedure struct {
	Name    *UnresolvedObjectName
	Replace bool
	Args    RoutineArgs
	Options []RoutineOption
}

CreateProcedure represents a CREATE PROCEDURE statement.

func (*CreateProcedure) Format added in v0.5.0

func (node *CreateProcedure) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateProcedure) StatementTag added in v0.5.0

func (*CreateProcedure) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateProcedure) StatementType added in v0.5.0

func (*CreateProcedure) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateProcedure) String added in v0.5.0

func (n *CreateProcedure) String() string

type CreateRole

type CreateRole struct {
	Name        Expr
	IfNotExists bool
	IsRole      bool
	KVOptions   KVOptions
}

CreateRole represents a CREATE ROLE statement.

func (*CreateRole) Format

func (node *CreateRole) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateRole) StatementTag

func (*CreateRole) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateRole) StatementType

func (*CreateRole) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateRole) String

func (n *CreateRole) String() string

type CreateSchema

type CreateSchema struct {
	IfNotExists    bool
	Schema         string
	AuthRole       string
	SchemaElements []Statement
}

CreateSchema represents a CREATE SCHEMA statement.

func (*CreateSchema) Format

func (node *CreateSchema) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateSchema) StatementTag

func (n *CreateSchema) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateSchema) StatementType

func (n *CreateSchema) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateSchema) String

func (n *CreateSchema) String() string

type CreateSequence

type CreateSequence struct {
	IfNotExists bool
	Name        TableName
	Persistence Persistence
	Options     SequenceOptions
}

CreateSequence represents a CREATE SEQUENCE statement.

func (*CreateSequence) Format

func (node *CreateSequence) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateSequence) StatementTag

func (*CreateSequence) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateSequence) StatementType

func (*CreateSequence) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateSequence) String

func (n *CreateSequence) String() string

type CreateStats

type CreateStats struct {
	Name        Name
	ColumnNames NameList
	Table       TableExpr
	Options     CreateStatsOptions
}

CreateStats represents a CREATE STATISTICS statement.

func (*CreateStats) Format

func (node *CreateStats) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateStats) StatementTag

func (*CreateStats) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateStats) StatementType

func (*CreateStats) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateStats) String

func (n *CreateStats) String() string

type CreateStatsOptions

type CreateStatsOptions struct {
	// Throttling enables throttling and indicates the fraction of time we are
	// idling (between 0 and 1).
	Throttling float64

	// AsOf performs a historical read at the given timestamp.
	// Note that the timestamp will be moved up during the operation if it gets
	// too old (in order to avoid problems with TTL expiration).
	AsOf AsOfClause
}

CreateStatsOptions contains options for CREATE STATISTICS.

func (*CreateStatsOptions) CombineWith

func (o *CreateStatsOptions) CombineWith(other *CreateStatsOptions) error

CombineWith combines two options, erroring out if the two options contain incompatible settings.

func (*CreateStatsOptions) Empty

func (o *CreateStatsOptions) Empty() bool

Empty returns true if no options were provided.

func (*CreateStatsOptions) Format

func (o *CreateStatsOptions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type CreateTable

type CreateTable struct {
	IfNotExists   bool
	Table         TableName
	Inherits      TableNames
	PartitionBy   *PartitionBy
	Persistence   Persistence
	StorageParams StorageParams
	OnCommit      CreateTableOnCommitSetting
	Using         string
	Tablespace    Name
	// In CREATE...AS queries, Defs represents a list of ColumnTableDefs, one for
	// each column, and a ConstraintTableDef for each constraint on a subset of
	// these columns.
	Defs       TableDefs
	AsSource   *Select
	WithNoData bool
	// Used for `CREATE TABLE ... OF type_name ...` statements.
	OfType *UnresolvedObjectName
	// Used for `CREATE TABLE ... PARTITION OF type_name ...` statements.
	PartitionOf        TableName
	PartitionBoundSpec PartitionBoundSpec
}

CreateTable represents a CREATE TABLE statement.

func (*CreateTable) As

func (node *CreateTable) As() bool

As returns true if this table represents a CREATE TABLE ... AS statement, false otherwise.

func (*CreateTable) AsHasUserSpecifiedPrimaryKey

func (node *CreateTable) AsHasUserSpecifiedPrimaryKey() bool

AsHasUserSpecifiedPrimaryKey returns true if a CREATE TABLE ... AS statement has a PRIMARY KEY constraint specified.

func (*CreateTable) Format

func (node *CreateTable) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateTable) FormatBody

func (node *CreateTable) FormatBody(ctx *FmtCtx)

FormatBody formats the "body" of the create table definition - everything but the CREATE TABLE tableName part.

func (*CreateTable) HoistConstraints

func (node *CreateTable) HoistConstraints()

HoistConstraints finds column check and foreign key constraints defined inline with their columns and makes them table-level constraints, stored in n.Defs. For example, the foreign key constraint in

CREATE TABLE foo (a INT REFERENCES bar(a))

gets pulled into a top-level constraint like:

CREATE TABLE foo (a INT, FOREIGN KEY (a) REFERENCES bar(a))

Similarly, the CHECK constraint in

CREATE TABLE foo (a INT CHECK (a < 1), b INT)

gets pulled into a top-level constraint like:

CREATE TABLE foo (a INT, b INT, CHECK (a < 1))

Note that some SQL databases require that a constraint attached to a column to refer only to the column it is attached to. We follow Postgres' behavior, however, in omitting this restriction by blindly hoisting all column constraints. For example, the following table definition is accepted in CockroachDB and Postgres, but not necessarily other SQL databases:

CREATE TABLE foo (a INT CHECK (a < b), b INT)

Unique constraints are not hoisted.

func (*CreateTable) StatementTag

func (n *CreateTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateTable) StatementType

func (n *CreateTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateTable) String

func (n *CreateTable) String() string

type CreateTableOnCommitSetting

type CreateTableOnCommitSetting uint32

CreateTableOnCommitSetting represents the CREATE TABLE ... ON COMMIT <action> parameters.

const (
	// CreateTableOnCommitUnset indicates that ON COMMIT was unset.
	CreateTableOnCommitUnset CreateTableOnCommitSetting = iota
	// CreateTableOnCommitPreserveRows indicates that ON COMMIT PRESERVE ROWS was set.
	CreateTableOnCommitPreserveRows
	// CreateTableOnCommitDeleteRows indicates that ON COMMIT DELETE ROWS was set.
	CreateTableOnCommitDeleteRows
	// CreateTableOnCommitDrop indicates that ON COMMIT DROP was set.
	CreateTableOnCommitDrop
)

type CreateTrigger added in v0.5.0

type CreateTrigger struct {
	Replace    bool
	Constraint bool
	Name       Name
	Time       TriggerTime
	Events     TriggerEvents
	OnTable    TableName
	RefTable   Name
	Deferrable TriggerDeferrableMode
	Relations  TriggerRelations
	ForEachRow bool
	When       Expr
	FuncName   *UnresolvedObjectName
	Args       NameList
}

CreateTrigger represents a CREATE TRIGGER statement.

func (*CreateTrigger) Format added in v0.5.0

func (node *CreateTrigger) Format(ctx *FmtCtx)

func (*CreateTrigger) StatementTag added in v0.5.0

func (*CreateTrigger) StatementTag() string

StatementTag implements the Statement interface.

func (*CreateTrigger) StatementType added in v0.5.0

func (*CreateTrigger) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateTrigger) String added in v0.5.0

func (n *CreateTrigger) String() string

type CreateType

type CreateType struct {
	TypeName  *UnresolvedObjectName
	Variety   CreateTypeVariety
	Composite CompositeType
	Enum      EnumType
	Range     RangeType
	Base      BaseType
}

CreateType represents a CREATE TYPE statement.

func (*CreateType) Format

func (node *CreateType) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateType) StatementTag

func (*CreateType) StatementTag() string

StatementTag implements the Statement interface.

func (*CreateType) StatementType

func (*CreateType) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateType) String

func (n *CreateType) String() string

type CreateTypeVariety

type CreateTypeVariety int

CreateTypeVariety represents a particular variety of user defined types.

const (

	// Composite represents a composite user defined type.
	Composite CreateTypeVariety
	// Enum represents an ENUM user defined type.
	Enum
	// Range represents a RANGE user defined type.
	Range
	// Base represents a base user defined type.
	Base
	// Shell represents a shell user defined type. Represents a `CREATE TYPE name` statement.
	Shell
	// Domain represents a DOMAIN user defined type.
	Domain
)

func (CreateTypeVariety) String

func (i CreateTypeVariety) String() string

type CreateView

type CreateView struct {
	Name        TableName
	Persistence Persistence
	Replace     bool
	IsRecursive bool
	ColumnNames NameList
	Options     ViewOptions
	AsSource    *Select
	CheckOption ViewCheckOption
}

CreateView represents a CREATE VIEW statement.

func (*CreateView) Format

func (node *CreateView) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*CreateView) StatementTag

func (*CreateView) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*CreateView) StatementType

func (*CreateView) StatementType() StatementType

StatementType implements the Statement interface.

func (*CreateView) String

func (n *CreateView) String() string

type DArray

type DArray struct {
	ParamTyp *types.T
	Array    Datums
	// HasNulls is set to true if any of the datums within the array are null.
	// This is used in the binary array serialization format.
	HasNulls bool
	// HasNonNulls is set to true if any of the datums within the are non-null.
	// This is used in expression serialization (FmtParsable).
	HasNonNulls bool
	// contains filtered or unexported fields
}

DArray is the array Datum. Any Datum inserted into a DArray are treated as text during serialization.

func AsDArray

func AsDArray(e Expr) (*DArray, bool)

AsDArray attempts to retrieve a *DArray from an Expr, returning a *DArray and a flag signifying whether the assertion was successful. The function should be used instead of direct type assertions wherever a *DArray wrapped by a *DOidWrapper is possible.

func MustBeDArray

func MustBeDArray(e Expr) *DArray

MustBeDArray attempts to retrieve a *DArray from an Expr, panicking if the assertion fails.

func NewDArray

func NewDArray(paramTyp *types.T) *DArray

NewDArray returns a DArray containing elements of the specified type.

func ParseDArrayFromString

func ParseDArrayFromString(
	ctx ParseTimeContext, s string, t *types.T,
) (_ *DArray, dependsOnContext bool, _ error)

ParseDArrayFromString parses the string-form of constructing arrays, handling cases such as `'{1,2,3}'::INT[]`. The input type t is the type of the parameter of the array to parse.

The dependsOnContext return value indicates if we had to consult the ParseTimeContext (either for the time or the local timezone).

func (*DArray) AmbiguousFormat

func (d *DArray) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DArray) Append

func (d *DArray) Append(v Datum) error

Append appends a Datum to the array, whose parameterized type must be consistent with the type of the Datum.

func (*DArray) FirstIndex

func (d *DArray) FirstIndex() int

FirstIndex returns the first index of the array. 1 for normal SQL arrays, which are 1-indexed, and 0 for the special Postgers vector types which are 0-indexed.

func (*DArray) Format

func (d *DArray) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DArray) IsComposite

func (d *DArray) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DArray) Len

func (d *DArray) Len() int

Len returns the length of the Datum array.

func (*DArray) ResolvedType

func (d *DArray) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DArray) Size

func (d *DArray) Size() uintptr

Size implements the Datum interface.

func (*DArray) String

func (node *DArray) String() string

func (*DArray) TypeCheck

func (d *DArray) TypeCheck(_ context.Context, _ *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DArray) Validate

func (d *DArray) Validate() error

Validate checks that the given array is valid, for example, that it's not too big.

func (*DArray) Walk

func (expr *DArray) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DBitArray

type DBitArray struct {
	utils.BitArray
}

DBitArray is the BIT/VARBIT Datum.

func NewDBitArrayFromInt

func NewDBitArrayFromInt(i int64, width uint) (*DBitArray, error)

NewDBitArrayFromInt creates a bit array from the specified integer at the specified width. If the width is zero, only positive integers can be converted. If the width is nonzero, the value is truncated to that width. Negative values are encoded using two's complement.

func ParseDBitArray

func ParseDBitArray(s string) (*DBitArray, error)

ParseDBitArray parses a string representation of binary digits.

func (*DBitArray) AmbiguousFormat

func (*DBitArray) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DBitArray) AsDInt

func (d *DBitArray) AsDInt(n uint) *DInt

AsDInt computes the integer value of the given bit array. The value is assumed to be encoded using two's complement. The result is truncated to the given integer number of bits, if specified. The given width must be 64 or smaller. The results are undefined if n is greater than 64.

func (*DBitArray) Format

func (d *DBitArray) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DBitArray) ResolvedType

func (*DBitArray) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DBitArray) Size

func (d *DBitArray) Size() uintptr

Size implements the Datum interface.

func (*DBitArray) String

func (node *DBitArray) String() string

func (*DBitArray) TypeCheck

func (d *DBitArray) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DBitArray) Walk

func (expr *DBitArray) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DBool

type DBool bool

DBool is the boolean Datum.

func MakeDBool

func MakeDBool(d DBool) *DBool

MakeDBool converts its argument to a *DBool, returning either DBoolTrue or DBoolFalse.

func ParseDBool

func ParseDBool(s string) (*DBool, error)

ParseDBool parses and returns the *DBool Datum value represented by the provided string, or an error if parsing is unsuccessful. See https://github.com/postgres/postgres/blob/90627cf98a8e7d0531789391fd798c9bfcc3bc1a/src/backend/utils/adt/bool.c#L36

func (*DBool) AmbiguousFormat

func (*DBool) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DBool) Format

func (d *DBool) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DBool) ResolvedType

func (*DBool) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DBool) Size

func (d *DBool) Size() uintptr

Size implements the Datum interface.

func (*DBool) String

func (node *DBool) String() string

func (*DBool) TypeCheck

func (d *DBool) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DBool) Walk

func (expr *DBool) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DBox2D

type DBox2D struct {
	geo.CartesianBoundingBox
}

DBox2D is the Datum representation of the Box2D type.

func NewDBox2D

func NewDBox2D(b geo.CartesianBoundingBox) *DBox2D

NewDBox2D returns a new Box2D Datum.

func ParseDBox2D

func ParseDBox2D(str string) (*DBox2D, error)

ParseDBox2D attempts to pass `str` as a Box2D type.

func (*DBox2D) AmbiguousFormat

func (*DBox2D) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DBox2D) Format

func (d *DBox2D) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DBox2D) ResolvedType

func (*DBox2D) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DBox2D) Size

func (d *DBox2D) Size() uintptr

Size implements the Datum interface.

func (*DBox2D) String

func (node *DBox2D) String() string

func (*DBox2D) TypeCheck

func (d *DBox2D) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DBox2D) Walk

func (expr *DBox2D) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DBytes

type DBytes string

DBytes is the bytes Datum. The underlying type is a string because we want the immutability, but this may contain arbitrary bytes.

func NewDBytes

func NewDBytes(d DBytes) *DBytes

NewDBytes is a helper routine to create a *DBytes initialized from its argument.

func ParseDByte

func ParseDByte(s string) (*DBytes, error)

ParseDByte parses a string representation of hex encoded binary data. It supports both the hex format, with "\x" followed by a string of hexadecimal digits (the "\x" prefix occurs just once at the beginning), and the escaped format, which supports "\\" and octal escapes.

func (*DBytes) AmbiguousFormat

func (*DBytes) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DBytes) Format

func (d *DBytes) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DBytes) ResolvedType

func (*DBytes) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DBytes) Size

func (d *DBytes) Size() uintptr

Size implements the Datum interface.

func (*DBytes) String

func (node *DBytes) String() string

func (*DBytes) TypeCheck

func (d *DBytes) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DBytes) Walk

func (expr *DBytes) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DCollatedString

type DCollatedString struct {
	Contents string
	Locale   string
	// Key is the collation key.
	Key []byte
}

DCollatedString is the Datum for strings with a locale. The struct members are intended to be immutable.

func (*DCollatedString) AmbiguousFormat

func (*DCollatedString) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DCollatedString) Format

func (d *DCollatedString) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DCollatedString) IsComposite

func (d *DCollatedString) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DCollatedString) ResolvedType

func (d *DCollatedString) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DCollatedString) Size

func (d *DCollatedString) Size() uintptr

Size implements the Datum interface.

func (*DCollatedString) String

func (node *DCollatedString) String() string

func (*DCollatedString) TypeCheck

func (d *DCollatedString) TypeCheck(
	_ context.Context, _ *SemaContext, _ *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DCollatedString) Walk

func (expr *DCollatedString) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DDate

type DDate struct {
	pgdate.Date
}

DDate is the date Datum represented as the number of days after the Unix epoch.

func NewDDate

func NewDDate(d pgdate.Date) *DDate

NewDDate is a helper routine to create a *DDate initialized from its argument.

func ParseDDate

func ParseDDate(ctx ParseTimeContext, s string) (_ *DDate, dependsOnContext bool, _ error)

ParseDDate parses and returns the *DDate Datum value represented by the provided string in the provided location, or an error if parsing is unsuccessful.

The dependsOnContext return value indicates if we had to consult the ParseTimeContext (either for the time or the local timezone).

func (*DDate) AmbiguousFormat

func (*DDate) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DDate) Format

func (d *DDate) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DDate) ResolvedType

func (*DDate) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DDate) Size

func (d *DDate) Size() uintptr

Size implements the Datum interface.

func (*DDate) String

func (node *DDate) String() string

func (*DDate) TypeCheck

func (d *DDate) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DDate) Walk

func (expr *DDate) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DDecimal

type DDecimal struct {
	apd.Decimal
}

DDecimal is the decimal Datum.

func ParseDDecimal

func ParseDDecimal(s string) (*DDecimal, error)

ParseDDecimal parses and returns the *DDecimal Datum value represented by the provided string, or an error if parsing is unsuccessful.

func (*DDecimal) AmbiguousFormat

func (*DDecimal) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DDecimal) Format

func (d *DDecimal) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DDecimal) IsComposite

func (d *DDecimal) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DDecimal) ResolvedType

func (*DDecimal) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DDecimal) SetString

func (d *DDecimal) SetString(s string) error

SetString sets d to s. Any non-standard NaN values are converted to a normal NaN. Any negative zero is converted to positive.

func (*DDecimal) Size

func (d *DDecimal) Size() uintptr

Size implements the Datum interface.

func (*DDecimal) String

func (node *DDecimal) String() string

func (*DDecimal) TypeCheck

func (d *DDecimal) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DDecimal) Walk

func (expr *DDecimal) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DEnum

type DEnum struct {
	// EnumType is the hydrated type of this enum.
	EnumTyp *types.T
	// PhysicalRep is a slice containing the encodable and ordered physical
	// representation of this datum. It is used for comparisons and encoding.
	PhysicalRep []byte
	// LogicalRep is a string containing the user visible value of the enum.
	LogicalRep string
}

DEnum represents an ENUM value.

func MakeDEnumFromLogicalRepresentation

func MakeDEnumFromLogicalRepresentation(typ *types.T, rep string) (*DEnum, error)

MakeDEnumFromLogicalRepresentation creates a DEnum of the input type and input logical representation. It returns an error if the input logical representation is invalid.

func MakeDEnumFromPhysicalRepresentation

func MakeDEnumFromPhysicalRepresentation(typ *types.T, rep []byte) (*DEnum, error)

MakeDEnumFromPhysicalRepresentation creates a DEnum of the input type and the input physical representation.

func (*DEnum) AmbiguousFormat

func (d *DEnum) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DEnum) Format

func (d *DEnum) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DEnum) MaxWriteable

func (d *DEnum) MaxWriteable() (Datum, bool)

MaxWriteable returns the largest member of the enum that is writeable.

func (*DEnum) MinWriteable

func (d *DEnum) MinWriteable() (Datum, bool)

MinWriteable returns the smallest member of the enum that is writeable.

func (*DEnum) ResolvedType

func (d *DEnum) ResolvedType() *types.T

ResolvedType implements the Datum interface.

func (*DEnum) Size

func (d *DEnum) Size() uintptr

Size implements the Datum interface.

func (*DEnum) String

func (d *DEnum) String() string

func (*DEnum) TypeCheck

func (d *DEnum) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DEnum) Walk

func (expr *DEnum) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DFloat

type DFloat float64

DFloat is the float Datum.

func NewDFloat

func NewDFloat(d DFloat) *DFloat

NewDFloat is a helper routine to create a *DFloat initialized from its argument.

func ParseDFloat

func ParseDFloat(s string) (*DFloat, error)

ParseDFloat parses and returns the *DFloat Datum value represented by the provided string, or an error if parsing is unsuccessful.

func (*DFloat) AmbiguousFormat

func (*DFloat) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DFloat) Format

func (d *DFloat) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DFloat) IsComposite

func (d *DFloat) IsComposite() bool

IsComposite implements the CompositeDatum interface.

func (*DFloat) ResolvedType

func (*DFloat) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DFloat) Size

func (d *DFloat) Size() uintptr

Size implements the Datum interface.

func (*DFloat) String

func (node *DFloat) String() string

func (*DFloat) TypeCheck

func (d *DFloat) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DFloat) Walk

func (expr *DFloat) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DGeography

type DGeography struct {
	geo.Geography
}

DGeography is the Geometry Datum.

func NewDGeography

func NewDGeography(g geo.Geography) *DGeography

NewDGeography returns a new Geography Datum.

func ParseDGeography

func ParseDGeography(str string) (*DGeography, error)

ParseDGeography attempts to pass `str` as a Geography type.

func (*DGeography) AmbiguousFormat

func (*DGeography) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DGeography) Format

func (d *DGeography) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DGeography) ResolvedType

func (*DGeography) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DGeography) Size

func (d *DGeography) Size() uintptr

Size implements the Datum interface.

func (*DGeography) String

func (node *DGeography) String() string

func (*DGeography) TypeCheck

func (d *DGeography) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DGeography) Walk

func (expr *DGeography) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DGeometry

type DGeometry struct {
	geo.Geometry
}

DGeometry is the Geometry Datum.

func NewDGeometry

func NewDGeometry(g geo.Geometry) *DGeometry

NewDGeometry returns a new Geometry Datum.

func ParseDGeometry

func ParseDGeometry(str string) (*DGeometry, error)

ParseDGeometry attempts to pass `str` as a Geometry type.

func (*DGeometry) AmbiguousFormat

func (*DGeometry) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DGeometry) Format

func (d *DGeometry) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DGeometry) ResolvedType

func (*DGeometry) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DGeometry) Size

func (d *DGeometry) Size() uintptr

Size implements the Datum interface.

func (*DGeometry) String

func (node *DGeometry) String() string

func (*DGeometry) TypeCheck

func (d *DGeometry) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DGeometry) Walk

func (expr *DGeometry) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DIPAddr

type DIPAddr struct {
	ipaddr.IPAddr
}

DIPAddr is the IPAddr Datum.

func ParseDIPAddrFromINetString

func ParseDIPAddrFromINetString(s string) (*DIPAddr, error)

ParseDIPAddrFromINetString parses and returns the *DIPAddr Datum value represented by the provided input INet string, or an error.

func (*DIPAddr) AmbiguousFormat

func (*DIPAddr) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DIPAddr) Format

func (d *DIPAddr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DIPAddr) ResolvedType

func (*DIPAddr) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DIPAddr) Size

func (d *DIPAddr) Size() uintptr

Size implements the Datum interface.

func (*DIPAddr) String

func (node *DIPAddr) String() string

func (*DIPAddr) TypeCheck

func (d *DIPAddr) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DIPAddr) Walk

func (expr *DIPAddr) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DInt

type DInt int64

DInt is the int Datum.

func NewDInt

func NewDInt(d DInt) *DInt

NewDInt is a helper routine to create a *DInt initialized from its argument.

func ParseDInt

func ParseDInt(s string) (*DInt, error)

ParseDInt parses and returns the *DInt Datum value represented by the provided string, or an error if parsing is unsuccessful.

func (*DInt) AmbiguousFormat

func (*DInt) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DInt) Format

func (d *DInt) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DInt) ResolvedType

func (*DInt) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DInt) Size

func (d *DInt) Size() uintptr

Size implements the Datum interface.

func (*DInt) String

func (node *DInt) String() string

func (*DInt) TypeCheck

func (d *DInt) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DInt) Walk

func (expr *DInt) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DInterval

type DInterval struct {
	duration.Duration
}

DInterval is the interval Datum.

func ParseDInterval

func ParseDInterval(s string) (*DInterval, error)

ParseDInterval parses and returns the *DInterval Datum value represented by the provided string, or an error if parsing is unsuccessful.

func ParseDIntervalWithTypeMetadata

func ParseDIntervalWithTypeMetadata(s string, itm types.IntervalTypeMetadata) (*DInterval, error)

ParseDIntervalWithTypeMetadata is like ParseDInterval, but it also takes a types.IntervalTypeMetadata that both specifies the units for unitless, numeric intervals and also specifies the precision of the interval.

func (*DInterval) AmbiguousFormat

func (*DInterval) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DInterval) Format

func (d *DInterval) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DInterval) ResolvedType

func (*DInterval) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DInterval) Size

func (d *DInterval) Size() uintptr

Size implements the Datum interface.

func (*DInterval) String

func (node *DInterval) String() string

func (*DInterval) TypeCheck

func (d *DInterval) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DInterval) ValueAsString

func (d *DInterval) ValueAsString() string

ValueAsString returns the interval as a string (e.g. "1h2m").

func (*DInterval) Walk

func (expr *DInterval) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DJSON

type DJSON struct{ json.JSON }

DJSON is the JSON Datum.

func NewDJSON

func NewDJSON(j json.JSON) *DJSON

NewDJSON is a helper routine to create a DJSON initialized from its argument.

func (*DJSON) AmbiguousFormat

func (*DJSON) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DJSON) Format

func (d *DJSON) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DJSON) ResolvedType

func (*DJSON) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DJSON) Size

func (d *DJSON) Size() uintptr

Size implements the Datum interface. TODO(justin): is this a frequently-called method? Should we be caching the computed size?

func (*DJSON) String

func (node *DJSON) String() string

func (*DJSON) TypeCheck

func (d *DJSON) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DJSON) Walk

func (expr *DJSON) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DOid

type DOid struct {
	// A DOid embeds a DInt, the underlying integer OID for this OID datum.
	DInt
	// contains filtered or unexported fields
}

DOid is the Postgres OID datum. It can represent either an OID type or any of the reg* types, such as regproc or regclass.

func MakeDOid

func MakeDOid(d DInt) DOid

MakeDOid is a helper routine to create a DOid initialized from a DInt.

func NewDOid

func NewDOid(d DInt) *DOid

NewDOid is a helper routine to create a *DOid initialized from a DInt.

func (*DOid) AmbiguousFormat

func (*DOid) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DOid) AsRegProc

func (d *DOid) AsRegProc(name string) *DOid

AsRegProc changes the input DOid into a regproc with the given name and returns it.

func (*DOid) Format

func (d *DOid) Format(ctx *FmtCtx)

Format implements the Datum interface.

func (*DOid) ResolvedType

func (d *DOid) ResolvedType() *types.T

ResolvedType implements the Datum interface.

func (*DOid) Size

func (d *DOid) Size() uintptr

Size implements the Datum interface.

func (*DOid) String

func (node *DOid) String() string

func (*DOid) TypeCheck

func (d *DOid) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DOid) Walk

func (expr *DOid) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DOidWrapper

type DOidWrapper struct {
	Wrapped Datum
	Oid     oid.Oid
}

DOidWrapper is a Datum implementation which is a wrapper around a Datum, allowing custom Oid values to be attached to the Datum and its types.T. The reason the Datum type was introduced was to permit the introduction of Datum types with new Object IDs while maintaining identical behavior to current Datum types. Specifically, it obviates the need to define a new tree.Datum type for each possible Oid value.

Instead, DOidWrapper allows a standard Datum to be wrapped with a new Oid. This approach provides two major advantages:

  • performance of the existing Datum types are not affected because they do not need to have custom oid.Oids added to their structure.
  • the introduction of new Datum aliases is straightforward and does not require additions to typing rules or type-dependent evaluation behavior.

Types that currently benefit from DOidWrapper are: - DName => DOidWrapper(*DString, oid.T_name)

func (*DOidWrapper) AmbiguousFormat

func (d *DOidWrapper) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DOidWrapper) Format

func (d *DOidWrapper) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DOidWrapper) ResolvedType

func (d *DOidWrapper) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DOidWrapper) Size

func (d *DOidWrapper) Size() uintptr

Size implements the Datum interface.

func (*DOidWrapper) String

func (node *DOidWrapper) String() string

func (*DOidWrapper) TypeCheck

func (d *DOidWrapper) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DOidWrapper) Walk

func (expr *DOidWrapper) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DString

type DString string

DString is the string Datum.

func NewDString

func NewDString(d string) *DString

NewDString is a helper routine to create a *DString initialized from its argument.

func (*DString) AmbiguousFormat

func (*DString) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DString) Format

func (d *DString) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DString) ResolvedType

func (*DString) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DString) Size

func (d *DString) Size() uintptr

Size implements the Datum interface.

func (*DString) String

func (node *DString) String() string

func (*DString) TypeCheck

func (d *DString) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DString) Walk

func (expr *DString) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DTime

type DTime timeofday.TimeOfDay

DTime is the time Datum.

func MakeDTime

func MakeDTime(t timeofday.TimeOfDay) *DTime

MakeDTime creates a DTime from a TimeOfDay.

func ParseDTime

func ParseDTime(
	ctx ParseTimeContext, s string, precision time.Duration,
) (_ *DTime, dependsOnContext bool, _ error)

ParseDTime parses and returns the *DTime Datum value represented by the provided string, or an error if parsing is unsuccessful.

The dependsOnContext return value indicates if we had to consult the ParseTimeContext (either for the time or the local timezone).

func (*DTime) AmbiguousFormat

func (*DTime) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTime) Format

func (d *DTime) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DTime) ResolvedType

func (*DTime) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DTime) Round

func (d *DTime) Round(precision time.Duration) *DTime

Round returns a new DTime to the specified precision.

func (*DTime) Size

func (d *DTime) Size() uintptr

Size implements the Datum interface.

func (*DTime) String

func (node *DTime) String() string

func (*DTime) TypeCheck

func (d *DTime) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DTime) Walk

func (expr *DTime) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DTimeTZ

type DTimeTZ struct {
	timetz.TimeTZ
}

DTimeTZ is the time with time zone Datum.

func NewDTimeTZ

func NewDTimeTZ(t timetz.TimeTZ) *DTimeTZ

NewDTimeTZ creates a DTimeTZ from a timetz.TimeTZ.

func NewDTimeTZFromOffset

func NewDTimeTZFromOffset(t timeofday.TimeOfDay, offsetSecs int32) *DTimeTZ

NewDTimeTZFromOffset creates a DTimeTZ from a TimeOfDay and offset.

func ParseDTimeTZ

func ParseDTimeTZ(
	ctx ParseTimeContext, s string, precision time.Duration,
) (_ *DTimeTZ, dependsOnContext bool, _ error)

ParseDTimeTZ parses and returns the *DTime Datum value represented by the provided string, or an error if parsing is unsuccessful.

The dependsOnContext return value indicates if we had to consult the ParseTimeContext (either for the time or the local timezone).

func (*DTimeTZ) AmbiguousFormat

func (*DTimeTZ) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTimeTZ) Format

func (d *DTimeTZ) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DTimeTZ) ResolvedType

func (*DTimeTZ) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DTimeTZ) Round

func (d *DTimeTZ) Round(precision time.Duration) *DTimeTZ

Round returns a new DTimeTZ to the specified precision.

func (*DTimeTZ) Size

func (d *DTimeTZ) Size() uintptr

Size implements the Datum interface.

func (*DTimeTZ) String

func (node *DTimeTZ) String() string

func (*DTimeTZ) TypeCheck

func (d *DTimeTZ) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DTimeTZ) Walk

func (expr *DTimeTZ) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DTimestamp

type DTimestamp struct {
	// Time always has UTC location.
	time.Time
}

DTimestamp is the timestamp Datum.

func MakeDTimestamp

func MakeDTimestamp(t time.Time, precision time.Duration) (*DTimestamp, error)

MakeDTimestamp creates a DTimestamp with specified precision.

func MustMakeDTimestamp

func MustMakeDTimestamp(t time.Time, precision time.Duration) *DTimestamp

MustMakeDTimestamp wraps MakeDTimestamp but panics if there is an error. This is intended for testing applications only.

func ParseDTimestamp

func ParseDTimestamp(
	ctx ParseTimeContext, s string, precision time.Duration,
) (_ *DTimestamp, dependsOnContext bool, _ error)

ParseDTimestamp parses and returns the *DTimestamp Datum value represented by the provided string in UTC, or an error if parsing is unsuccessful.

The dependsOnContext return value indicates if we had to consult the ParseTimeContext (either for the time or the local timezone).

func (*DTimestamp) AmbiguousFormat

func (*DTimestamp) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTimestamp) Format

func (d *DTimestamp) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DTimestamp) ResolvedType

func (*DTimestamp) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DTimestamp) Round

func (d *DTimestamp) Round(precision time.Duration) (*DTimestamp, error)

Round returns a new DTimestamp to the specified precision.

func (*DTimestamp) Size

func (d *DTimestamp) Size() uintptr

Size implements the Datum interface.

func (*DTimestamp) String

func (node *DTimestamp) String() string

func (*DTimestamp) TypeCheck

func (d *DTimestamp) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DTimestamp) Walk

func (expr *DTimestamp) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DTimestampTZ

type DTimestampTZ struct {
	time.Time
}

DTimestampTZ is the timestamp Datum that is rendered with session offset.

func MakeDTimestampTZ

func MakeDTimestampTZ(t time.Time, precision time.Duration) (*DTimestampTZ, error)

MakeDTimestampTZ creates a DTimestampTZ with specified precision.

func MustMakeDTimestampTZ

func MustMakeDTimestampTZ(t time.Time, precision time.Duration) *DTimestampTZ

MustMakeDTimestampTZ wraps MakeDTimestampTZ but panics if there is an error. This is intended for testing applications only.

func ParseDTimestampTZ

func ParseDTimestampTZ(
	ctx ParseTimeContext, s string, precision time.Duration,
) (_ *DTimestampTZ, dependsOnContext bool, _ error)

ParseDTimestampTZ parses and returns the *DTimestampTZ Datum value represented by the provided string in the provided location, or an error if parsing is unsuccessful.

The dependsOnContext return value indicates if we had to consult the ParseTimeContext (either for the time or the local timezone).

func (*DTimestampTZ) AmbiguousFormat

func (*DTimestampTZ) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTimestampTZ) Format

func (d *DTimestampTZ) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DTimestampTZ) ResolvedType

func (*DTimestampTZ) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DTimestampTZ) Round

func (d *DTimestampTZ) Round(precision time.Duration) (*DTimestampTZ, error)

Round returns a new DTimestampTZ to the specified precision.

func (*DTimestampTZ) Size

func (d *DTimestampTZ) Size() uintptr

Size implements the Datum interface.

func (*DTimestampTZ) String

func (node *DTimestampTZ) String() string

func (*DTimestampTZ) TypeCheck

func (d *DTimestampTZ) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DTimestampTZ) Walk

func (expr *DTimestampTZ) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DTuple

type DTuple struct {
	D Datums
	// contains filtered or unexported fields
}

DTuple is the tuple Datum.

func (*DTuple) AmbiguousFormat

func (*DTuple) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DTuple) AssertSorted

func (d *DTuple) AssertSorted()

AssertSorted asserts that the DTuple is sorted.

func (*DTuple) ContainsNull

func (d *DTuple) ContainsNull() bool

ContainsNull returns true if the tuple contains NULL, possibly nested inside other tuples. For example, all the following tuples contain NULL:

(1, 2, NULL)
((1, 1), (2, NULL))
(((1, 1), (2, 2)), ((3, 3), (4, NULL)))

func (*DTuple) Format

func (d *DTuple) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DTuple) ResolvedType

func (d *DTuple) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DTuple) SetSorted

func (d *DTuple) SetSorted() *DTuple

SetSorted sets the sorted flag on the DTuple. This should be used when a DTuple is known to be sorted based on the datums added to it.

func (*DTuple) Size

func (d *DTuple) Size() uintptr

Size implements the Datum interface.

func (*DTuple) Sorted

func (d *DTuple) Sorted() bool

Sorted returns true if the tuple is known to be sorted (and contains no NULLs).

func (*DTuple) String

func (node *DTuple) String() string

func (*DTuple) TypeCheck

func (d *DTuple) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DTuple) Walk

func (expr *DTuple) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DUuid

type DUuid struct {
	uuid.UUID
}

DUuid is the UUID Datum.

func NewDUuid

func NewDUuid(d DUuid) *DUuid

NewDUuid is a helper routine to create a *DUuid initialized from its argument.

func ParseDUuidFromBytes

func ParseDUuidFromBytes(b []byte) (*DUuid, error)

ParseDUuidFromBytes parses and returns the *DUuid Datum value represented by the provided input bytes, or an error.

func ParseDUuidFromString

func ParseDUuidFromString(s string) (*DUuid, error)

ParseDUuidFromString parses and returns the *DUuid Datum value represented by the provided input string, or an error.

func (*DUuid) AmbiguousFormat

func (*DUuid) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*DUuid) Format

func (d *DUuid) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DUuid) ResolvedType

func (*DUuid) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*DUuid) Size

func (d *DUuid) Size() uintptr

Size implements the Datum interface.

func (*DUuid) String

func (node *DUuid) String() string

func (*DUuid) TypeCheck

func (d *DUuid) TypeCheck(_ context.Context, _ *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (*DUuid) Walk

func (expr *DUuid) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DatabaseListFlags

type DatabaseListFlags struct {
	CommonLookupFlags
	// ExplicitPrefix, when set, will cause the returned table names to
	// have an explicit schema and catalog part.
	ExplicitPrefix bool
}

DatabaseListFlags is the flag struct suitable for GetObjectNames().

type DatabaseLookupFlags

type DatabaseLookupFlags = CommonLookupFlags

DatabaseLookupFlags is the flag struct suitable for GetDatabaseDesc().

type DatabaseOption added in v0.4.0

type DatabaseOption struct {
	Opt AlterDatabaseOption
	Val Expr
}

DatabaseOption represents a ALTER DATABASE option.

type Datum

type Datum interface {
	TypedExpr

	// AmbiguousFormat indicates whether the result of formatting this Datum can
	// be interpreted into more than one type. Used with
	// fmtFlags.disambiguateDatumTypes.
	AmbiguousFormat() bool

	// Size returns a lower bound on the total size of the receiver in bytes,
	// including memory that is pointed at (even if shared between Datum
	// instances) but excluding allocation overhead.
	//
	// It holds for every Datum d that d.Size().
	Size() uintptr
}

Datum represents a SQL value.

func NewDNameFromDString

func NewDNameFromDString(d *DString) Datum

NewDNameFromDString is a helper routine to create a *DName (implemented as a *DOidWrapper) initialized from an existing *DString.

func ParseAndRequireString

func ParseAndRequireString(
	t *types.T, s string, ctx ParseTimeContext,
) (d Datum, dependsOnContext bool, err error)

ParseAndRequireString parses s as type t for simple types. Arrays and collated strings are not handled.

The dependsOnContext return value indicates if we had to consult the ParseTimeContext (either for the time or the local timezone).

func ParseDJSON

func ParseDJSON(s string) (Datum, error)

ParseDJSON takes a string of JSON and returns a DJSON value.

func SampleDatum

func SampleDatum(t *types.T) Datum

SampleDatum is intended to be a more lightweight version of RandDatum for when you just need one consistent example of a datum.

func UnwrapDatum

func UnwrapDatum(d Datum) Datum

UnwrapDatum returns the base Datum type for a provided datum, stripping an *DOidWrapper if present. This is useful for cases like type switches, where type aliases should be ignored.

type Datums

type Datums []Datum

Datums is a slice of Datum values.

func (*Datums) Format

func (d *Datums) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (Datums) Len

func (d Datums) Len() int

Len returns the number of Datum values.

func (*Datums) String

func (node *Datums) String() string

type Deallocate

type Deallocate struct {
	Name Name // empty for ALL
}

Deallocate represents a DEALLOCATE statement.

func (*Deallocate) Format

func (node *Deallocate) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Deallocate) StatementTag

func (n *Deallocate) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Deallocate) StatementType

func (*Deallocate) StatementType() StatementType

StatementType implements the Statement interface.

func (*Deallocate) String

func (n *Deallocate) String() string

type DefaultVal

type DefaultVal struct{}

DefaultVal represents the DEFAULT expression.

func (DefaultVal) Format

func (node DefaultVal) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (DefaultVal) ResolvedType

func (DefaultVal) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (DefaultVal) String

func (node DefaultVal) String() string

func (DefaultVal) TypeCheck

func (expr DefaultVal) TypeCheck(
	_ context.Context, _ *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (DefaultVal) Walk

func (expr DefaultVal) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type DeferrableMode

type DeferrableMode int

DeferrableMode holds the deferrable mode for a transaction.

const (
	UnspecifiedDeferrableMode DeferrableMode = iota
	Deferrable
	NotDeferrable
)

DeferrableMode values.

func (DeferrableMode) String

func (d DeferrableMode) String() string

type Delete

type Delete struct {
	With      *With
	Table     TableExpr
	Where     *Where
	OrderBy   OrderBy
	Limit     *Limit
	Returning ReturningClause
}

Delete represents a DELETE statement.

func (*Delete) Format

func (node *Delete) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Delete) StatementTag

func (*Delete) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Delete) StatementType

func (n *Delete) StatementType() StatementType

StatementType implements the Statement interface.

func (*Delete) String

func (n *Delete) String() string

type DescriptorCoverage

type DescriptorCoverage int32

DescriptorCoverage specifies whether or not a subset of descriptors were requested or if all the descriptors were requested, so all the descriptors are covered in a given backup.

const (
	// RequestedDescriptors table coverage means that the backup is not
	// guaranteed to have all of the cluster data. This can be accomplished by
	// backing up a specific subset of tables/databases. Note that even if all
	// of the tables and databases have been included in the backup manually, a
	// backup is not said to have complete table coverage unless it was created
	// by a `BACKUP TO` command.
	RequestedDescriptors DescriptorCoverage = iota
	// AllDescriptors table coverage means that backup is guaranteed to have all the
	// relevant data in the cluster. These can only be created by running a
	// full cluster backup with `BACKUP TO`.
	AllDescriptors
)

type DesiredObjectKind

type DesiredObjectKind int

DesiredObjectKind represents what kind of object is desired in a name resolution attempt.

const (
	// TableObject is used when a table-like object is desired from resolution.
	TableObject DesiredObjectKind = iota
	// TypeObject is used when a type-like object is desired from resolution.
	TypeObject
)

type DetachPartition added in v0.5.0

type DetachPartition int
const (
	DetachPartitionNone DetachPartition = iota
	DetachPartitionConcurrently
	DetachPartitionFinalize
)

type Direction

type Direction int8

Direction for ordering results.

const (
	DefaultDirection Direction = iota
	Ascending
	Descending
)

Direction values.

func (Direction) String

func (d Direction) String() string

type Discard

type Discard struct {
	Mode DiscardMode
}

Discard represents a DISCARD statement.

func (*Discard) Format

func (node *Discard) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Discard) StatementTag

func (*Discard) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Discard) StatementType

func (*Discard) StatementType() StatementType

StatementType implements the Statement interface.

func (*Discard) String

func (node *Discard) String() string

String implements the Statement interface.

type DiscardMode

type DiscardMode int

DiscardMode is an enum of the various discard modes.

const (
	// DiscardModeAll represents a DISCARD ALL statement.
	DiscardModeAll DiscardMode = iota
)

type DistinctOn

type DistinctOn []Expr

DistinctOn represents a DISTINCT ON clause.

func (*DistinctOn) Format

func (node *DistinctOn) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type DomainConstraint added in v0.5.0

type DomainConstraint struct {
	Constraint Name
	NotNull    bool
	Check      Expr
}

DomainConstraint represents the {NOT NULL|NULL|CHECK} constraint clauses for CREATE DOMAIN command.

func (*DomainConstraint) Format added in v0.5.0

func (node *DomainConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type DomainConstraints added in v0.5.0

type DomainConstraints []DomainConstraint

func (*DomainConstraints) Format added in v0.5.0

func (node *DomainConstraints) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type DropAggregate added in v0.5.0

type DropAggregate struct {
	Aggregates   []AggregateToDrop
	IfExists     bool
	DropBehavior DropBehavior
}

DropAggregate represents a DROP AGGREGATE statement.

func (*DropAggregate) Format added in v0.5.0

func (node *DropAggregate) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropAggregate) StatementTag added in v0.5.0

func (*DropAggregate) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropAggregate) StatementType added in v0.5.0

func (*DropAggregate) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropAggregate) String added in v0.5.0

func (n *DropAggregate) String() string

type DropBehavior

type DropBehavior int

DropBehavior represents options for dropping schema elements.

const (
	DropDefault DropBehavior = iota
	DropRestrict
	DropCascade
)

DropBehavior values.

func (DropBehavior) String

func (d DropBehavior) String() string

type DropDatabase

type DropDatabase struct {
	Name     Name
	IfExists bool
	Force    bool
}

DropDatabase represents a DROP DATABASE statement.

func (*DropDatabase) Format

func (node *DropDatabase) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropDatabase) StatementTag

func (*DropDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropDatabase) StatementType

func (*DropDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropDatabase) String

func (n *DropDatabase) String() string

type DropDomain added in v0.5.0

type DropDomain struct {
	Names        NameList
	IfExists     bool
	DropBehavior DropBehavior
}

DropDomain represents a DROP DOMAIN statement.

func (*DropDomain) Format added in v0.5.0

func (node *DropDomain) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropDomain) StatementTag added in v0.5.0

func (*DropDomain) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropDomain) StatementType added in v0.5.0

func (*DropDomain) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropDomain) String added in v0.5.0

func (n *DropDomain) String() string

type DropExtension added in v0.4.0

type DropExtension struct {
	Names        NameList
	IfExists     bool
	DropBehavior DropBehavior
}

DropExtension represents a DROP EXTENSION statement.

func (*DropExtension) Format added in v0.4.0

func (node *DropExtension) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropExtension) StatementTag added in v0.4.0

func (*DropExtension) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropExtension) StatementType added in v0.4.0

func (*DropExtension) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropExtension) String added in v0.4.0

func (n *DropExtension) String() string

type DropFunction added in v0.4.0

type DropFunction struct {
	Functions    []RoutineWithArgs
	IfExists     bool
	DropBehavior DropBehavior
}

DropFunction represents a DROP FUNCTION statement.

func (*DropFunction) Format added in v0.4.0

func (node *DropFunction) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropFunction) StatementTag added in v0.4.0

func (*DropFunction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropFunction) StatementType added in v0.4.0

func (*DropFunction) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropFunction) String added in v0.4.0

func (n *DropFunction) String() string

type DropIndex

type DropIndex struct {
	IndexList    TableIndexNames
	IfExists     bool
	DropBehavior DropBehavior
	Concurrently bool
}

DropIndex represents a DROP INDEX statement.

func (*DropIndex) Format

func (node *DropIndex) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropIndex) StatementTag

func (*DropIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropIndex) StatementType

func (*DropIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropIndex) String

func (n *DropIndex) String() string

type DropLanguage added in v0.5.0

type DropLanguage struct {
	Name         Name
	Procedural   bool
	IfExists     bool
	DropBehavior DropBehavior
}

DropLanguage represents a DROP LANGUAGE statement.

func (*DropLanguage) Format added in v0.5.0

func (node *DropLanguage) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropLanguage) StatementTag added in v0.5.0

func (*DropLanguage) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropLanguage) StatementType added in v0.5.0

func (*DropLanguage) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropLanguage) String added in v0.5.0

func (n *DropLanguage) String() string

type DropProcedure added in v0.5.0

type DropProcedure struct {
	Procedures   []RoutineWithArgs
	IfExists     bool
	DropBehavior DropBehavior
}

DropProcedure represents a DROP PROCEDURE statement.

func (*DropProcedure) Format added in v0.5.0

func (node *DropProcedure) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropProcedure) StatementTag added in v0.5.0

func (*DropProcedure) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropProcedure) StatementType added in v0.5.0

func (*DropProcedure) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropProcedure) String added in v0.5.0

func (n *DropProcedure) String() string

type DropRole

type DropRole struct {
	Names    Exprs
	IsRole   bool
	IfExists bool
}

DropRole represents a DROP ROLE statement

func (*DropRole) Format

func (node *DropRole) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropRole) StatementTag

func (*DropRole) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropRole) StatementType

func (*DropRole) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropRole) String

func (n *DropRole) String() string

type DropSchema

type DropSchema struct {
	Names        []string
	IfExists     bool
	DropBehavior DropBehavior
}

DropSchema represents a DROP SCHEMA command.

func (*DropSchema) Format

func (node *DropSchema) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropSchema) StatementTag

func (*DropSchema) StatementTag() string

StatementTag implements the Statement interface.

func (*DropSchema) StatementType

func (*DropSchema) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropSchema) String

func (n *DropSchema) String() string

type DropSequence

type DropSequence struct {
	Names        TableNames
	IfExists     bool
	DropBehavior DropBehavior
}

DropSequence represents a DROP SEQUENCE statement.

func (*DropSequence) Format

func (node *DropSequence) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropSequence) StatementTag

func (*DropSequence) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropSequence) StatementType

func (*DropSequence) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropSequence) String

func (n *DropSequence) String() string

type DropTable

type DropTable struct {
	Names        TableNames
	IfExists     bool
	DropBehavior DropBehavior
}

DropTable represents a DROP TABLE statement.

func (*DropTable) Format

func (node *DropTable) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropTable) StatementTag

func (*DropTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropTable) StatementType

func (*DropTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropTable) String

func (n *DropTable) String() string

type DropTrigger added in v0.5.0

type DropTrigger struct {
	Name         Name
	IfExists     bool
	OnTable      TableName
	DropBehavior DropBehavior
}

DropTrigger represents a DROP TRIGGER statement.

func (*DropTrigger) Format added in v0.5.0

func (node *DropTrigger) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropTrigger) StatementTag added in v0.5.0

func (*DropTrigger) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropTrigger) StatementType added in v0.5.0

func (*DropTrigger) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropTrigger) String added in v0.5.0

func (n *DropTrigger) String() string

type DropType

type DropType struct {
	Names        []*UnresolvedObjectName
	IfExists     bool
	DropBehavior DropBehavior
}

DropType represents a DROP TYPE command.

func (*DropType) Format

func (node *DropType) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropType) StatementTag

func (*DropType) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropType) StatementType

func (*DropType) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropType) String

func (n *DropType) String() string

type DropView

type DropView struct {
	Names          TableNames
	IfExists       bool
	DropBehavior   DropBehavior
	IsMaterialized bool
}

DropView represents a DROP VIEW statement.

func (*DropView) Format

func (node *DropView) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*DropView) StatementTag

func (*DropView) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*DropView) StatementType

func (*DropView) StatementType() StatementType

StatementType implements the Statement interface.

func (*DropView) String

func (n *DropView) String() string

type EnumType added in v0.5.0

type EnumType struct {
	Labels []string
}

EnumType represents a `CREATE TYPE <name> AS ENUM ( 'label', ... )` statement.

func (*EnumType) Format added in v0.5.0

func (node *EnumType) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type EvalContextTestingKnobs

type EvalContextTestingKnobs struct {
	// AssertFuncExprReturnTypes indicates whether FuncExpr evaluations
	// should assert that the returned Datum matches the expected
	// ReturnType of the function.
	AssertFuncExprReturnTypes bool
	// AssertUnaryExprReturnTypes indicates whether UnaryExpr evaluations
	// should assert that the returned Datum matches the expected
	// ReturnType of the function.
	AssertUnaryExprReturnTypes bool
	// AssertBinaryExprReturnTypes indicates whether BinaryExpr
	// evaluations should assert that the returned Datum matches the
	// expected ReturnType of the function.
	AssertBinaryExprReturnTypes bool
	// DisableOptimizerRuleProbability is the probability that any given
	// transformation rule in the optimizer is disabled.
	DisableOptimizerRuleProbability float64
	// OptimizerCostPerturbation is used to randomly perturb the estimated
	// cost of each expression in the query tree for the purpose of creating
	// alternate query plans in the optimizer.
	OptimizerCostPerturbation float64
}

EvalContextTestingKnobs contains test knobs.

type EvalDatabase

type EvalDatabase interface {
	// ParseQualifiedTableName parses a SQL string of the form
	// `[ database_name . ] [ schema_name . ] table_name`.
	// NB: this is deprecated! Use parser.ParseQualifiedTableName when possible.
	ParseQualifiedTableName(sql string) (*TableName, error)

	// ResolveTableName expands the given table name and
	// makes it point to a valid object.
	// If the database name is not given, it uses the search path to find it, and
	// sets it on the returned TableName.
	// It returns the ID of the resolved table, and an error if the table doesn't exist.
	ResolveTableName(ctx context.Context, tn *TableName) (ID, error)

	// LookupSchema looks up the schema with the given name in the given
	// database.
	LookupSchema(ctx context.Context, dbName, scName string) (found bool, scMeta SchemaMeta, err error)
}

EvalDatabase consists of functions that reference the session database and is to be used from EvalContext.

type EvalPlanner

type EvalPlanner interface {
	EvalDatabase
	TypeReferenceResolver
	// ParseType parses a column type.
	ParseType(sql string) (*types.T, error)

	// EvalSubquery returns the Datum for the given subquery node.
	EvalSubquery(expr *Subquery) (Datum, error)
}

EvalPlanner is a limited planner that can be used from EvalContext.

type EvalSessionAccessor

type EvalSessionAccessor interface {
	// SetConfig sets a session variable to a new value.
	//
	// This interface only supports strings as this is sufficient for
	// pg_catalog.set_config().
	SetSessionVar(ctx context.Context, settingName, newValue string) error

	// GetSessionVar retrieves the current value of a session variable.
	GetSessionVar(ctx context.Context, settingName string, missingOk bool) (bool, string, error)

	// HasAdminRole returns true iff the current session user has the admin role.
	HasAdminRole(ctx context.Context) (bool, error)

	// HasAdminRole returns nil iff the current session user has the specified
	// role option.
	HasRoleOption(ctx context.Context, roleOption roleoption.Option) (bool, error)
}

EvalSessionAccessor is a limited interface to access session variables.

type ExcludeConstraintTableDef added in v0.5.0

type ExcludeConstraintTableDef struct {
	IndexTableDef
	Using     string
	Predicate Expr
}

ExcludeConstraintTableDef represents a FOREIGN KEY constraint in the AST.

func (*ExcludeConstraintTableDef) Format added in v0.5.0

func (node *ExcludeConstraintTableDef) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ExcludeConstraintTableDef) SetName added in v0.5.0

func (node *ExcludeConstraintTableDef) SetName(name Name)

SetName implements the ConstraintTableDef interface.

type ExcludeElement added in v0.5.0

type ExcludeElement struct {
	Elem IndexElem
	With Operator
}

type Execute

type Execute struct {
	Name   Name
	Params Exprs
	// DiscardRows is set when we want to throw away all the rows rather than
	// returning for client (used for testing and benchmarking).
	DiscardRows bool
}

Execute represents an EXECUTE statement.

func (*Execute) Format

func (node *Execute) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Execute) StatementTag

func (*Execute) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Execute) StatementType

func (*Execute) StatementType() StatementType

StatementType implements the Statement interface.

func (*Execute) String

func (n *Execute) String() string

type Explain

type Explain struct {
	ExplainOptions

	// Statement is the statement being EXPLAINed.
	Statement Statement
}

Explain represents an EXPLAIN statement.

func (*Explain) Format

func (node *Explain) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Explain) StatementTag

func (*Explain) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Explain) StatementType

func (*Explain) StatementType() StatementType

StatementType implements the Statement interface.

func (*Explain) String

func (n *Explain) String() string

type ExplainAnalyzeDebug

type ExplainAnalyzeDebug struct {
	Statement Statement
}

ExplainAnalyzeDebug represents an EXPLAIN ANALYZE (DEBUG) statement. It is a different node type than Explain to allow easier special treatment in the SQL layer.

func (*ExplainAnalyzeDebug) Format

func (node *ExplainAnalyzeDebug) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ExplainAnalyzeDebug) StatementTag

func (*ExplainAnalyzeDebug) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ExplainAnalyzeDebug) StatementType

func (*ExplainAnalyzeDebug) StatementType() StatementType

StatementType implements the Statement interface.

func (*ExplainAnalyzeDebug) String

func (n *ExplainAnalyzeDebug) String() string

type ExplainFlag

type ExplainFlag uint8

ExplainFlag is a modifier in an EXPLAIN statement (like VERBOSE).

const (
	ExplainFlagVerbose ExplainFlag = 1 + iota
	ExplainFlagTypes
	ExplainFlagAnalyze
	ExplainFlagEnv
	ExplainFlagCatalog
	ExplainFlagDebug
)

Explain flags.

func (ExplainFlag) String

func (f ExplainFlag) String() string

type ExplainMode

type ExplainMode uint8

ExplainMode indicates the mode of the explain. Currently there are two modes: PLAN (the default) and DISTSQL.

const (
	// ExplainPlan shows information about the planNode tree for a query.
	ExplainPlan ExplainMode = 1 + iota

	// ExplainDistSQL shows the physical distsql plan for a query and whether a
	// query would be run in "auto" DISTSQL mode. See sql/explain_distsql.go for
	// details. If the ANALYZE option is included, the plan is also executed and
	// execution statistics are collected and shown in the diagram.
	ExplainDistSQL

	// ExplainOpt shows the optimized relational expression (from the cost-based
	// optimizer).
	ExplainOpt

	// ExplainVec shows the physical vectorized plan for a query and whether a
	// query would be run in "auto" vectorized mode.
	ExplainVec
)

func (ExplainMode) String

func (m ExplainMode) String() string

type ExplainOptions

type ExplainOptions struct {
	Mode  ExplainMode
	Flags [numExplainFlags + 1]bool
}

ExplainOptions contains information about the options passed to an EXPLAIN statement.

type Export

type Export struct {
	Query      *Select
	FileFormat string
	File       Expr
	Options    KVOptions
}

Export represents a EXPORT statement.

func (*Export) Format

func (node *Export) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Export) StatementTag

func (*Export) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Export) StatementType

func (*Export) StatementType() StatementType

StatementType implements the Statement interface.

func (*Export) String

func (n *Export) String() string

type Expr

type Expr interface {
	fmt.Stringer
	NodeFormatter
	// Walk recursively walks all children using WalkExpr. If any children are changed, it returns a
	// copy of this node updated to point to the new children. Otherwise the receiver is returned.
	// For childless (leaf) Exprs, its implementation is empty.
	Walk(Visitor) Expr
	// TypeCheck transforms the Expr into a well-typed TypedExpr, which further permits
	// evaluation and type introspection, or an error if the expression cannot be well-typed.
	// When type checking is complete, if no error was reported, the expression and all
	// sub-expressions will be guaranteed to be well-typed, meaning that the method effectively
	// maps the Expr tree into a TypedExpr tree.
	//
	// The semaCtx parameter defines the context in which to perform type checking.
	// The desired parameter hints the desired type that the method's caller wants from
	// the resulting TypedExpr. It is not valid to call TypeCheck with a nil desired
	// type. Instead, call it with wildcard type types.Any if no specific type is
	// desired. This restriction is also true of most methods and functions related
	// to type checking.
	TypeCheck(ctx context.Context, semaCtx *SemaContext, desired *types.T) (TypedExpr, error)
}

Expr represents an expression.

func SimpleVisit

func SimpleVisit(expr Expr, preFn SimpleVisitFn) (Expr, error)

SimpleVisit is a convenience wrapper for visitors that only have VisitPre code and don't return any results except an error. The given function is called in VisitPre for every node. The visitor stops as soon as an error is returned.

func StripMemoizedFuncs

func StripMemoizedFuncs(expr Expr) Expr

StripMemoizedFuncs strips memoized function references from expression trees. This is necessary to permit equality checks using reflect.DeepEqual. Used in testing.

func StripParens

func StripParens(expr Expr) Expr

StripParens strips any parentheses surrounding an expression and returns the inner expression. For instance:

 1   -> 1
(1)  -> 1

((1)) -> 1

func WalkExpr

func WalkExpr(v Visitor, expr Expr) (newExpr Expr, changed bool)

WalkExpr traverses the nodes in an expression.

NOTE: Do not count on the walkStmt/WalkExpr machinery to visit all expressions contained in a query. Only a sub-set of all expressions are found by walkStmt and subsequently traversed. See the comment below on walkStmt for details.

type Exprs

type Exprs []Expr

Exprs represents a list of value expressions. It's not a valid expression because it's not parenthesized.

func (*Exprs) Format

func (node *Exprs) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Exprs) String

func (node *Exprs) String() string

type FinalFuncModifyType added in v0.5.0

type FinalFuncModifyType string
const (
	FinalFuncModifyReadOnly  FinalFuncModifyType = "READ_ONLY"
	FinalFuncModifyShareable FinalFuncModifyType = "SHAREABLE"
	FinalFuncModifyReadWrite FinalFuncModifyType = "READ_WRITE"
)

type FmtCtx

type FmtCtx struct {
	bytes.Buffer
	// contains filtered or unexported fields
}

FmtCtx is suitable for passing to Format() methods. It also exposes the underlying bytes.Buffer interface for convenience.

FmtCtx cannot be copied by value.

func NewFmtCtx

func NewFmtCtx(f FmtFlags) *FmtCtx

NewFmtCtx creates a FmtCtx; only flags that don't require Annotations can be used.

func NewFmtCtxEx

func NewFmtCtxEx(f FmtFlags, ann *Annotations) *FmtCtx

NewFmtCtxEx creates a FmtCtx.

func (*FmtCtx) Close

func (ctx *FmtCtx) Close()

Close releases a FmtCtx for reuse. Closing a FmtCtx is not required, but is recommended for performance-sensitive paths.

func (*FmtCtx) CloseAndGetString

func (ctx *FmtCtx) CloseAndGetString() string

CloseAndGetString combines Close() and String().

func (*FmtCtx) FormatName

func (ctx *FmtCtx) FormatName(s string)

FormatName formats a string as a name.

Note: prefer FormatNameP below when the string is already on the heap.

func (*FmtCtx) FormatNameP

func (ctx *FmtCtx) FormatNameP(s *string)

FormatNameP formats a string reference as a name.

func (*FmtCtx) FormatNode

func (ctx *FmtCtx) FormatNode(n NodeFormatter)

FormatNode recurses into a node for pretty-printing. Flag-driven special cases can hook into this.

func (*FmtCtx) FormatTypeReference

func (ctx *FmtCtx) FormatTypeReference(ref ResolvableTypeReference)

FormatTypeReference formats a ResolvableTypeReference.

func (*FmtCtx) HasFlags

func (ctx *FmtCtx) HasFlags(f FmtFlags) bool

HasFlags returns true iff the given flags are set in the formatter context.

func (*FmtCtx) Printf

func (ctx *FmtCtx) Printf(f string, args ...interface{})

Printf calls fmt.Fprintf on the linked bytes.Buffer. It is provided for convenience, to avoid having to call fmt.Fprintf(&ctx.Buffer, ...).

Note: DO NOT USE THIS TO INTERPOLATE %s ON NodeFormatter OBJECTS. This would call the String() method on them and would fail to reuse the same bytes buffer (and waste allocations). Instead use ctx.FormatNode().

func (*FmtCtx) SetIndexedTypeFormat

func (ctx *FmtCtx) SetIndexedTypeFormat(fn func(*FmtCtx, *OIDTypeReference))

SetIndexedTypeFormat modifies FmtCtx to customize the printing of IDTypeReferences using the provided function.

func (*FmtCtx) SetIndexedVarFormat

func (ctx *FmtCtx) SetIndexedVarFormat(fn func(ctx *FmtCtx, idx int))

SetIndexedVarFormat modifies FmtCtx to customize the printing of IndexedVars using the provided function.

func (*FmtCtx) SetPlaceholderFormat

func (ctx *FmtCtx) SetPlaceholderFormat(placeholderFn func(_ *FmtCtx, _ *Placeholder))

SetPlaceholderFormat modifies FmtCtx to customize the printing of StarDatums using the provided function.

func (*FmtCtx) SetReformatTableNames

func (ctx *FmtCtx) SetReformatTableNames(tableNameFmt func(*FmtCtx, *TableName))

SetReformatTableNames modifies FmtCtx to to substitute the printing of table names using the provided function.

func (*FmtCtx) WithFlags

func (ctx *FmtCtx) WithFlags(flags FmtFlags, fn func())

WithFlags changes the flags in the FmtCtx, runs the given function, then restores the old flags.

func (*FmtCtx) WithReformatTableNames

func (ctx *FmtCtx) WithReformatTableNames(tableNameFmt func(*FmtCtx, *TableName), fn func())

WithReformatTableNames modifies FmtCtx to to substitute the printing of table names using the provided function, calls fn, then restores the original table formatting.

type FmtFlags

type FmtFlags int

FmtFlags carries options for the pretty-printer.

func (FmtFlags) EncodeFlags

func (f FmtFlags) EncodeFlags() lex.EncodeFlags

EncodeFlags returns the subset of the flags that are also lex encode flags.

func (FmtFlags) HasAnyFlags

func (f FmtFlags) HasAnyFlags(subset FmtFlags) bool

HasAnyFlags tests whether any of the given flags are all set.

func (FmtFlags) HasFlags

func (f FmtFlags) HasFlags(subset FmtFlags) bool

HasFlags tests whether the given flags are all set.

type ForeignKeyConstraintTableDef

type ForeignKeyConstraintTableDef struct {
	Name     Name
	FromCols NameList
	Table    TableName
	ToCols   NameList
	Actions  ReferenceActions
	Match    CompositeKeyMatchMethod
}

ForeignKeyConstraintTableDef represents a FOREIGN KEY constraint in the AST.

func (*ForeignKeyConstraintTableDef) Format

func (node *ForeignKeyConstraintTableDef) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ForeignKeyConstraintTableDef) SetName

func (node *ForeignKeyConstraintTableDef) SetName(name Name)

SetName implements the ConstraintTableDef interface.

type From

type From struct {
	Tables TableExprs
	AsOf   AsOfClause
}

From represents a FROM clause.

func (*From) Format

func (node *From) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type FullBackupClause

type FullBackupClause struct {
	AlwaysFull bool
	Recurrence Expr
}

FullBackupClause describes the frequency of full backups.

type FuncExpr

type FuncExpr struct {
	Func  ResolvableFunctionReference
	Type  funcType
	Exprs Exprs
	// Filter is used for filters on aggregates: SUM(k) FILTER (WHERE k > 0)
	Filter    Expr
	WindowDef *WindowDef

	// AggType is used to specify the type of aggregation.
	AggType AggType
	// OrderBy is used for aggregations which specify an order. This same field
	// is used for any type of aggregation.
	OrderBy OrderBy
	// contains filtered or unexported fields
}

FuncExpr represents a function call.

func NewTypedFuncExpr

func NewTypedFuncExpr(
	ref ResolvableFunctionReference,
	aggQualifier funcType,
	exprs TypedExprs,
	filter TypedExpr,
	windowDef *WindowDef,
	typ *types.T,
	props *FunctionProperties,
	overload *Overload,
) *FuncExpr

NewTypedFuncExpr returns a FuncExpr that is already well-typed and resolved.

func (*FuncExpr) CanHandleNulls

func (node *FuncExpr) CanHandleNulls() bool

CanHandleNulls returns whether or not the function can handle null arguments.

func (*FuncExpr) Format

func (node *FuncExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (FuncExpr) HasResolvedType added in v0.6.0

func (ta FuncExpr) HasResolvedType() bool

func (*FuncExpr) IsDistSQLBlocklist

func (node *FuncExpr) IsDistSQLBlocklist() bool

IsDistSQLBlocklist returns whether the function is not supported by DistSQL.

func (*FuncExpr) IsWindowFunctionApplication

func (node *FuncExpr) IsWindowFunctionApplication() bool

IsWindowFunctionApplication returns true iff the function is being applied as a window function.

func (*FuncExpr) ResolvedOverload

func (node *FuncExpr) ResolvedOverload() *Overload

ResolvedOverload returns the builtin definition; can only be called after Resolve (which happens during TypeCheck).

func (FuncExpr) ResolvedType

func (ta FuncExpr) ResolvedType() *types.T

func (*FuncExpr) String

func (node *FuncExpr) String() string

func (*FuncExpr) TypeCheck

func (expr *FuncExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*FuncExpr) Walk

func (expr *FuncExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type FunctionClass

type FunctionClass int

FunctionClass specifies the class of the builtin function.

const (
	// NormalClass is a standard builtin function.
	NormalClass FunctionClass = iota
	// AggregateClass is a builtin aggregate function.
	AggregateClass
	// WindowClass is a builtin window function.
	WindowClass
	// GeneratorClass is a builtin generator function.
	GeneratorClass
	// SQLClass is a builtin function that executes a SQL statement as a side
	// effect of the function call.
	//
	// For example, AddGeometryColumn is a SQLClass function that executes an
	// ALTER TABLE ... ADD COLUMN statement to add a geometry column to an
	// existing table. It returns metadata about the column added.
	//
	// All builtin functions of this class should include a definition for
	// Overload.SQLFn, which returns the SQL statement to be executed. They
	// should also include a definition for Overload.Fn, which is executed
	// like a NormalClass function and returns a Datum.
	SQLClass
)

type FunctionDefinition

type FunctionDefinition struct {
	// Name is the short name of the function.
	Name string

	// Definition is the set of overloads for this function name.
	// We use []overloadImpl here although all the uses of this struct
	// could actually write a []Overload, because we want to share
	// the code with typeCheckOverloadedExprs().
	Definition []overloadImpl

	// FunctionProperties are the properties common to all overloads.
	FunctionProperties
}

FunctionDefinition implements a reference to the (possibly several) overloads for a built-in function.

func NewFunctionDefinition

func NewFunctionDefinition(
	name string, props *FunctionProperties, def []Overload,
) *FunctionDefinition

NewFunctionDefinition allocates a function definition corresponding to the given built-in definition.

func (*FunctionDefinition) Format

func (fd *FunctionDefinition) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*FunctionDefinition) String

func (fd *FunctionDefinition) String() string

type FunctionOption added in v0.5.0

type FunctionOption int8
const (
	OptionLanguage FunctionOption = 1 + iota
	OptionTransform
	OptionWindow
	OptionVolatility
	OptionLeakProof
	OptionNullInput
	OptionSecurity
	OptionParallel
	OptionCost
	OptionRows
	OptionSupport
	OptionSet
	OptionAs1
	OptionAs2
	OptionSqlBody
	OptionReset // For ALTER { FUNCTION | PROCEDURE } use only
)

type FunctionProperties

type FunctionProperties struct {
	// UnsupportedWithIssue, if non-zero indicates the built-in is not
	// really supported; the name is a placeholder. Value -1 just says
	// "not supported" without an issue to link; values > 0 provide an
	// issue number to link.
	UnsupportedWithIssue int

	// Undocumented, when set to true, indicates that the built-in function is
	// hidden from documentation. This is currently used to hide experimental
	// functionality as it is being developed.
	Undocumented bool

	// Private, when set to true, indicates the built-in function is not
	// available for use by user queries. This is currently used by some
	// aggregates due to issue #10495. Private functions are implicitly
	// considered undocumented.
	Private bool

	// NullableArgs is set to true when a function's definition can
	// handle NULL arguments. When set, the function will be given the
	// chance to see NULL arguments. When not, the function will
	// evaluate directly to NULL in the presence of any NULL arguments.
	//
	// NOTE: when set, a function should be prepared for any of its arguments to
	// be NULL and should act accordingly.
	NullableArgs bool

	// DistsqlBlocklist is set to true when a function depends on
	// members of the EvalContext that are not marshaled by DistSQL
	// (e.g. planner). Currently used for DistSQL to determine if
	// expressions can be evaluated on a different node without sending
	// over the EvalContext.
	//
	// TODO(andrei): Get rid of the planner from the EvalContext and then we can
	// get rid of this blocklist.
	DistsqlBlocklist bool

	// Class is the kind of built-in function (normal/aggregate/window/etc.)
	Class FunctionClass

	// Category is used to generate documentation strings.
	Category string

	// AvailableOnPublicSchema indicates whether the function can be resolved
	// if it is found on the public schema.
	AvailableOnPublicSchema bool

	// ReturnLabels can be used to override the return column name of a
	// function in a FROM clause.
	// This satisfies a Postgres quirk where some json functions have
	// different return labels when used in SELECT or FROM clause.
	ReturnLabels []string

	// AmbiguousReturnType is true if the builtin's return type can't be
	// determined without extra context. This is used for formatting builtins
	// with the FmtParsable directive.
	AmbiguousReturnType bool

	// HasSequenceArguments is true if the builtin function takes in a sequence
	// name (string) and can be used in a scalar expression.
	// TODO(richardjcai): When implicit casting is supported, these builtins
	// should take RegClass as the arg type for the sequence name instead of
	// string, we will add a dependency on all RegClass types used in a view.
	HasSequenceArguments bool
}

FunctionProperties defines the properties of the built-in functions that are common across all overloads.

func (*FunctionProperties) ShouldDocument

func (fp *FunctionProperties) ShouldDocument() bool

ShouldDocument returns whether the built-in function should be included in external-facing documentation.

type FunctionReference

type FunctionReference interface {
	fmt.Stringer
	NodeFormatter
	// contains filtered or unexported methods
}

FunctionReference is the common interface to UnresolvedName and QualifiedFunctionName.

type Grant

type Grant struct {
	Privileges      privilege.List
	Targets         TargetList
	Grantees        []string
	WithGrantOption bool
	GrantedBy       string

	// only used for table target with column names defined
	PrivsWithCols []PrivForCols
}

Grant represents a GRANT statement.

func (*Grant) Format

func (node *Grant) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Grant) StatementTag

func (*Grant) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Grant) StatementType

func (*Grant) StatementType() StatementType

StatementType implements the Statement interface.

func (*Grant) String

func (n *Grant) String() string

type GrantRole

type GrantRole struct {
	Roles      NameList
	Members    []string
	WithOption string
	GrantedBy  string
}

GrantRole represents a GRANT <role> statement.

func (*GrantRole) Format

func (node *GrantRole) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*GrantRole) StatementTag

func (*GrantRole) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*GrantRole) StatementType

func (*GrantRole) StatementType() StatementType

StatementType implements the Statement interface.

func (*GrantRole) String

func (n *GrantRole) String() string

type GroupBy

type GroupBy []Expr

GroupBy represents a GROUP BY clause.

func (*GroupBy) Format

func (node *GroupBy) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type HiddenFromShowQueries

type HiddenFromShowQueries interface {
	// contains filtered or unexported methods
}

HiddenFromShowQueries is a pseudo-interface to be implemented by statements that should not show up in SHOW QUERIES (and are hence not cancellable using CANCEL QUERIES either). Usually implemented by statements that spawn jobs.

type HomogeneousType

type HomogeneousType struct{}

HomogeneousType is a TypeList implementation that accepts any arguments, as long as all are the same type or NULL. The homogeneous constraint is enforced in typeCheckOverloadedExprs.

func (HomogeneousType) GetAt

func (HomogeneousType) GetAt(i int) *types.T

GetAt is part of the TypeList interface.

func (HomogeneousType) Length

func (HomogeneousType) Length() int

Length is part of the TypeList interface.

func (HomogeneousType) Match

func (HomogeneousType) Match(types []*types.T) bool

Match is part of the TypeList interface.

func (HomogeneousType) MatchAt

func (HomogeneousType) MatchAt(typ *types.T, i int) bool

MatchAt is part of the TypeList interface.

func (HomogeneousType) MatchLen

func (HomogeneousType) MatchLen(l int) bool

MatchLen is part of the TypeList interface.

func (HomogeneousType) String

func (HomogeneousType) String() string

func (HomogeneousType) Types

func (HomogeneousType) Types() []*types.T

Types is part of the TypeList interface.

type ID

type ID uint32

ID is a custom type for {Database,Table}Descriptor IDs.

func (ID) SafeValue

func (ID) SafeValue()

SafeValue implements the redact.SafeValue interface.

type IfErrExpr

type IfErrExpr struct {
	Cond    Expr
	Else    Expr
	ErrCode Expr
	// contains filtered or unexported fields
}

IfErrExpr represents an IFERROR expression.

func NewTypedIfErrExpr

func NewTypedIfErrExpr(cond, orElse, errCode TypedExpr) *IfErrExpr

NewTypedIfErrExpr returns a new IfErrExpr that is verified to be well-typed.

func (*IfErrExpr) Format

func (node *IfErrExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (IfErrExpr) HasResolvedType added in v0.6.0

func (ta IfErrExpr) HasResolvedType() bool

func (IfErrExpr) ResolvedType

func (ta IfErrExpr) ResolvedType() *types.T

func (*IfErrExpr) String

func (node *IfErrExpr) String() string

func (*IfErrExpr) TypeCheck

func (expr *IfErrExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*IfErrExpr) Walk

func (expr *IfErrExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type IfExpr

type IfExpr struct {
	Cond Expr
	True Expr
	Else Expr
	// contains filtered or unexported fields
}

IfExpr represents an IF expression.

func (*IfExpr) Format

func (node *IfExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (IfExpr) HasResolvedType added in v0.6.0

func (ta IfExpr) HasResolvedType() bool

func (IfExpr) ResolvedType

func (ta IfExpr) ResolvedType() *types.T

func (*IfExpr) String

func (node *IfExpr) String() string

func (*IfExpr) TypeCheck

func (expr *IfExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*IfExpr) TypedCondExpr

func (node *IfExpr) TypedCondExpr() TypedExpr

TypedCondExpr returns the IfExpr's Cond expression as a TypedExpr.

func (*IfExpr) TypedElseExpr

func (node *IfExpr) TypedElseExpr() TypedExpr

TypedElseExpr returns the IfExpr's Else expression as a TypedExpr.

func (*IfExpr) TypedTrueExpr

func (node *IfExpr) TypedTrueExpr() TypedExpr

TypedTrueExpr returns the IfExpr's True expression as a TypedExpr.

func (*IfExpr) Walk

func (expr *IfExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type Import

type Import struct {
	Table      *TableName
	Into       bool
	IntoCols   NameList
	CreateFile Expr
	CreateDefs TableDefs
	FileFormat string
	Files      Exprs
	Bundle     bool
	Options    KVOptions
}

Import represents a IMPORT statement.

func (*Import) Format

func (node *Import) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Import) StatementTag

func (*Import) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Import) StatementType

func (n *Import) StatementType() StatementType

StatementType implements the Statement interface.

func (*Import) String

func (n *Import) String() string

type IndexElem

type IndexElem struct {
	Column     Name
	Expr       Expr // in parentheses or function name
	Collation  string
	OpClass    *IndexElemOpClass
	Direction  Direction
	NullsOrder NullsOrder
	// only used for EXCLUDE clause
	ExcludeOp Operator
}

IndexElem represents a column with a direction in a CREATE INDEX statement.

func (*IndexElem) Format

func (node *IndexElem) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type IndexElemList

type IndexElemList []IndexElem

IndexElemList is list of IndexElem.

func (*IndexElemList) Format

func (l *IndexElemList) Format(ctx *FmtCtx)

Format pretty-prints the contained names separated by commas. Format implements the NodeFormatter interface.

type IndexElemOpClass added in v0.4.0

type IndexElemOpClass struct {
	Name    string
	Options []IndexElemOpClassOption
}

type IndexElemOpClassOption added in v0.4.0

type IndexElemOpClassOption struct {
	Param string
	Val   Expr
}

func (*IndexElemOpClassOption) Format added in v0.4.0

func (node *IndexElemOpClassOption) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type IndexFlags

type IndexFlags struct {
	Index   UnrestrictedName
	IndexID IndexID
	// Direction of the scan, if provided. Can only be set if
	// one of Index or IndexID is set.
	Direction Direction
	// NoIndexJoin cannot be specified together with an index.
	NoIndexJoin bool
	// IgnoreForeignKeys disables optimizations based on outbound foreign key
	// references from this table. This is useful in particular for scrub queries
	// used to verify the consistency of foreign key relations.
	IgnoreForeignKeys bool
}

IndexFlags represents "@<index_name|index_id>" or "@{param[,param]}" where param is one of:

  • FORCE_INDEX=<index_name|index_id>
  • ASC / DESC
  • NO_INDEX_JOIN
  • IGNORE_FOREIGN_KEYS

It is used optionally after a table name in SELECT statements.

func (*IndexFlags) Check

func (ih *IndexFlags) Check() error

Check verifies if the flags are valid:

  • ascending/descending is not specified without an index;
  • no_index_join isn't specified with an index.

func (*IndexFlags) CombineWith

func (ih *IndexFlags) CombineWith(other *IndexFlags) error

CombineWith combines two IndexFlags structures, returning an error if they conflict with one another.

func (*IndexFlags) ForceIndex

func (ih *IndexFlags) ForceIndex() bool

ForceIndex returns true if a forced index was specified, either using a name or an IndexID.

func (*IndexFlags) Format

func (ih *IndexFlags) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type IndexID

type IndexID uint32

IndexID is a custom type for IndexDescriptor IDs.

type IndexParams added in v0.5.0

type IndexParams struct {
	IncludeColumns IndexElemList // names only
	StorageParams  StorageParams
	Tablespace     Name
}

IndexParams is sub-clause used in UNIQUE, PRIMARY KEY, and EXCLUDE constraints.

func (*IndexParams) Format added in v0.5.0

func (node *IndexParams) Format(ctx *FmtCtx)

type IndexTableDef

type IndexTableDef struct {
	Name        Name
	Columns     IndexElemList
	IndexParams IndexParams
}

IndexTableDef represents an index definition within a CREATE TABLE statement.

func (*IndexTableDef) Format

func (node *IndexTableDef) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type IndexedVar

type IndexedVar struct {
	Idx  int
	Used bool
	// contains filtered or unexported fields
}

IndexedVar is a VariableExpr that can be used as a leaf in expressions; it represents a dynamic value. It defers calls to TypeCheck, Eval, String to an IndexedVarContainer.

func NewOrdinalReference

func NewOrdinalReference(r int) *IndexedVar

NewOrdinalReference is a helper routine to create a standalone IndexedVar with the given index value. This needs to undergo BindIfUnbound() below before it can be fully used.

func NewTypedOrdinalReference

func NewTypedOrdinalReference(r int, typ *types.T) *IndexedVar

NewTypedOrdinalReference returns a new IndexedVar with the given index value that is verified to be well-typed.

func (*IndexedVar) Format

func (v *IndexedVar) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (IndexedVar) HasResolvedType added in v0.6.0

func (ta IndexedVar) HasResolvedType() bool

func (*IndexedVar) ResolvedType

func (v *IndexedVar) ResolvedType() *types.T

ResolvedType is part of the TypedExpr interface.

func (*IndexedVar) String

func (node *IndexedVar) String() string

func (*IndexedVar) TypeCheck

func (v *IndexedVar) TypeCheck(
	_ context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck is part of the Expr interface.

func (*IndexedVar) Variable

func (*IndexedVar) Variable()

Variable is a dummy function part of the VariableExpr interface.

func (*IndexedVar) Walk

func (v *IndexedVar) Walk(_ Visitor) Expr

Walk is part of the Expr interface.

type IndexedVarContainer

type IndexedVarContainer interface {
	IndexedVarResolvedType(idx int) *types.T
	// IndexedVarNodeFormatter returns a NodeFormatter; if an object that
	// wishes to implement this interface has lost the textual name that an
	// IndexedVar originates from, this function can return nil (and the
	// ordinal syntax "@1, @2, .." will be used).
	IndexedVarNodeFormatter(idx int) NodeFormatter
}

IndexedVarContainer provides the implementation of TypeCheck, Eval, and String for IndexedVars.

type IndexedVarHelper

type IndexedVarHelper struct {
	// contains filtered or unexported fields
}

IndexedVarHelper wraps an IndexedVarContainer (an interface) and creates IndexedVars bound to that container.

It also keeps track of which indexes from the container are used by expressions.

func MakeIndexedVarHelper

func MakeIndexedVarHelper(container IndexedVarContainer, numVars int) IndexedVarHelper

MakeIndexedVarHelper initializes an IndexedVarHelper structure.

func MakeTypesOnlyIndexedVarHelper

func MakeTypesOnlyIndexedVarHelper(types []*types.T) IndexedVarHelper

MakeTypesOnlyIndexedVarHelper creates an IndexedVarHelper which provides the given types for indexed vars. It does not support evaluation, unless Rebind is used with another container which supports evaluation.

func (*IndexedVarHelper) AppendSlot

func (h *IndexedVarHelper) AppendSlot() int

AppendSlot expands the capacity of this IndexedVarHelper by one and returns the index of the new slot.

func (*IndexedVarHelper) BindIfUnbound

func (h *IndexedVarHelper) BindIfUnbound(ivar *IndexedVar) (*IndexedVar, error)

BindIfUnbound ensures the IndexedVar is attached to this helper's container. - for freshly created IndexedVars (with a nil container) this will bind in-place. - for already bound IndexedVar, bound to this container, this will return the same ivar unchanged. - for ordinal references (with an explicit unboundContainer) this will return a new var. - for already bound IndexedVars, bound to another container, this will error out.

func (*IndexedVarHelper) Container

func (h *IndexedVarHelper) Container() IndexedVarContainer

Container returns the container associated with the helper.

func (*IndexedVarHelper) GetIndexedVars

func (h *IndexedVarHelper) GetIndexedVars() []IndexedVar

GetIndexedVars returns the indexed var array of this helper. IndexedVars to the caller; unused vars are guaranteed to have a false Used field.

func (*IndexedVarHelper) IndexedVar

func (h *IndexedVarHelper) IndexedVar(idx int) *IndexedVar

IndexedVar returns an IndexedVar for the given index. The index must be valid.

func (*IndexedVarHelper) IndexedVarUsed

func (h *IndexedVarHelper) IndexedVarUsed(idx int) bool

IndexedVarUsed returns true if IndexedVar() was called for the given index. The index must be valid.

func (*IndexedVarHelper) IndexedVarWithType

func (h *IndexedVarHelper) IndexedVarWithType(idx int, typ *types.T) *IndexedVar

IndexedVarWithType returns an IndexedVar for the given index, with the given type. The index must be valid. This should be used in the case where an indexed var is being added before its container has a corresponding entry for it.

func (*IndexedVarHelper) NumVars

func (h *IndexedVarHelper) NumVars() int

NumVars returns the number of variables the IndexedVarHelper was initialized for.

func (*IndexedVarHelper) Rebind

func (h *IndexedVarHelper) Rebind(expr TypedExpr) TypedExpr

Rebind collects all the IndexedVars in the given expression and re-binds them to this helper.

func (*IndexedVarHelper) VisitPost

func (*IndexedVarHelper) VisitPost(expr Expr) Expr

VisitPost implements the Visitor interface.

func (*IndexedVarHelper) VisitPre

func (h *IndexedVarHelper) VisitPre(expr Expr) (recurse bool, newExpr Expr)

VisitPre implements the Visitor interface.

type IndirectionExpr

type IndirectionExpr struct {
	Expr        Expr
	Indirection ArraySubscripts
	// contains filtered or unexported fields
}

IndirectionExpr represents a subscript expression.

func NewTypedIndirectionExpr

func NewTypedIndirectionExpr(expr, index TypedExpr, typ *types.T) *IndirectionExpr

NewTypedIndirectionExpr returns a new IndirectionExpr that is verified to be well-typed.

func (*IndirectionExpr) Format

func (node *IndirectionExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (IndirectionExpr) HasResolvedType added in v0.6.0

func (ta IndirectionExpr) HasResolvedType() bool

func (IndirectionExpr) ResolvedType

func (ta IndirectionExpr) ResolvedType() *types.T

func (*IndirectionExpr) String

func (node *IndirectionExpr) String() string

func (*IndirectionExpr) TypeCheck

func (expr *IndirectionExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*IndirectionExpr) Walk

func (expr *IndirectionExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type InitiallyMode added in v0.5.0

type InitiallyMode int
const (
	UnspecifiedInitiallyMode InitiallyMode = iota
	InitiallyDeferred
	InitiallyImmediate
)

InitiallyMode values.

type Insert

type Insert struct {
	With       *With
	Table      TableExpr
	Columns    NameList
	Rows       *Select
	OnConflict *OnConflict
	Returning  ReturningClause
}

Insert represents an INSERT statement.

func (*Insert) DefaultValues

func (node *Insert) DefaultValues() bool

DefaultValues returns true iff only default values are being inserted.

func (*Insert) Format

func (node *Insert) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Insert) StatementTag

func (*Insert) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Insert) StatementType

func (n *Insert) StatementType() StatementType

StatementType implements the Statement interface.

func (*Insert) String

func (n *Insert) String() string

type IsNotNullExpr

type IsNotNullExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

IsNotNullExpr represents an IS NOT NULL expression. This is equivalent to IS DISTINCT FROM NULL, except when the input is a tuple.

func NewTypedIsNotNullExpr

func NewTypedIsNotNullExpr(expr TypedExpr) *IsNotNullExpr

NewTypedIsNotNullExpr returns a new IsNotNullExpr that is verified to be well-typed.

func (*IsNotNullExpr) Format

func (node *IsNotNullExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (IsNotNullExpr) HasResolvedType added in v0.6.0

func (ta IsNotNullExpr) HasResolvedType() bool

func (IsNotNullExpr) ResolvedType

func (ta IsNotNullExpr) ResolvedType() *types.T

func (*IsNotNullExpr) String

func (node *IsNotNullExpr) String() string

func (*IsNotNullExpr) TypeCheck

func (expr *IsNotNullExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*IsNotNullExpr) TypedInnerExpr

func (node *IsNotNullExpr) TypedInnerExpr() TypedExpr

TypedInnerExpr returns the IsNotNullExpr's inner expression as a TypedExpr.

func (*IsNotNullExpr) Walk

func (expr *IsNotNullExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type IsNullExpr

type IsNullExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

IsNullExpr represents an IS NULL expression. This is equivalent to IS NOT DISTINCT FROM NULL, except when the input is a tuple.

func NewTypedIsNullExpr

func NewTypedIsNullExpr(expr TypedExpr) *IsNullExpr

NewTypedIsNullExpr returns a new IsNullExpr that is verified to be well-typed.

func (*IsNullExpr) Format

func (node *IsNullExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (IsNullExpr) HasResolvedType added in v0.6.0

func (ta IsNullExpr) HasResolvedType() bool

func (IsNullExpr) ResolvedType

func (ta IsNullExpr) ResolvedType() *types.T

func (*IsNullExpr) String

func (node *IsNullExpr) String() string

func (*IsNullExpr) TypeCheck

func (expr *IsNullExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*IsNullExpr) TypedInnerExpr

func (node *IsNullExpr) TypedInnerExpr() TypedExpr

TypedInnerExpr returns the IsNullExpr's inner expression as a TypedExpr.

func (*IsNullExpr) Walk

func (expr *IsNullExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type IsOfTypeExpr

type IsOfTypeExpr struct {
	Not   bool
	Expr  Expr
	Types []ResolvableTypeReference
	// contains filtered or unexported fields
}

IsOfTypeExpr represents an IS {,NOT} OF (type_list) expression.

func (*IsOfTypeExpr) Format

func (node *IsOfTypeExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (IsOfTypeExpr) HasResolvedType added in v0.6.0

func (ta IsOfTypeExpr) HasResolvedType() bool

func (IsOfTypeExpr) ResolvedType

func (ta IsOfTypeExpr) ResolvedType() *types.T

func (*IsOfTypeExpr) ResolvedTypes

func (node *IsOfTypeExpr) ResolvedTypes() []*types.T

ResolvedTypes returns a slice of resolved types corresponding to the Types slice of unresolved types. It may only be accessed after typechecking.

func (*IsOfTypeExpr) String

func (node *IsOfTypeExpr) String() string

func (*IsOfTypeExpr) TypeCheck

func (expr *IsOfTypeExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*IsOfTypeExpr) Walk

func (expr *IsOfTypeExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type IsolationLevel

type IsolationLevel int

IsolationLevel holds the isolation level for a transaction.

const (
	UnspecifiedIsolation IsolationLevel = iota
	SerializableIsolation
)

IsolationLevel values

func (IsolationLevel) String

func (i IsolationLevel) String() string

type JobCommand

type JobCommand int

JobCommand determines which type of action to effect on the selected job(s).

const (
	PauseJob JobCommand = iota
	CancelJob
	ResumeJob
)

JobCommand values

type JoinCond

type JoinCond interface {
	NodeFormatter
	// contains filtered or unexported methods
}

JoinCond represents a join condition.

type JoinTableExpr

type JoinTableExpr struct {
	JoinType string
	Left     TableExpr
	Right    TableExpr
	Cond     JoinCond
	Hint     string
}

JoinTableExpr represents a TableExpr that's a JOIN operation.

func (*JoinTableExpr) Format

func (node *JoinTableExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*JoinTableExpr) String

func (node *JoinTableExpr) String() string

type KVOption

type KVOption struct {
	Key   Name
	Value Expr
}

KVOption is a key-value option.

type KVOptions

type KVOptions []KVOption

KVOptions is a list of KVOptions.

func (*KVOptions) Format

func (o *KVOptions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (KVOptions) ToRoleOptions

func (o KVOptions) ToRoleOptions(
	typeAsStringOrNull func(e Expr, op string) (func() (bool, string, error), error), op string,
) (roleoption.List, error)

ToRoleOptions converts KVOptions to a roleoption.List using typeAsString to convert exprs to strings.

type LanguageHandler added in v0.5.0

type LanguageHandler struct {
	Handler   *UnresolvedObjectName
	Inline    *UnresolvedObjectName
	Validator *UnresolvedObjectName
}

func (*LanguageHandler) Format added in v0.5.0

func (h *LanguageHandler) Format(ctx *FmtCtx)

type LikeTableDef

type LikeTableDef struct {
	Name    TableName
	Options []LikeTableOption
}

LikeTableDef represents a LIKE table declaration on a CREATE TABLE statement.

func (*LikeTableDef) Format

func (def *LikeTableDef) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type LikeTableOpt

type LikeTableOpt int

LikeTableOpt represents one of the types of things that can be included or excluded in a LIKE table declaration. It's a bitmap, where each of the Opt values is a single enabled bit in the map.

const (
	LikeTableOptConstraints LikeTableOpt = 1 << iota
	LikeTableOptDefaults
	LikeTableOptGenerated
	LikeTableOptIndexes
)

The values for LikeTableOpt.

func (LikeTableOpt) Has

func (o LikeTableOpt) Has(other LikeTableOpt) bool

Has returns true if the receiver has the other options bits set.

func (LikeTableOpt) String

func (o LikeTableOpt) String() string

type LikeTableOption

type LikeTableOption struct {
	Excluded bool
	Opt      LikeTableOpt
}

LikeTableOption represents an individual INCLUDING / EXCLUDING statement on a LIKE table declaration.

func (LikeTableOption) Format

func (l LikeTableOption) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type Limit

type Limit struct {
	Offset, Count Expr
	LimitAll      bool
}

Limit represents a LIMIT clause.

func (*Limit) Format

func (node *Limit) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type LockingClause

type LockingClause []*LockingItem

LockingClause represents a locking clause, like FOR UPDATE.

func (*LockingClause) Format

func (node *LockingClause) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type LockingItem

type LockingItem struct {
	Strength   LockingStrength
	Targets    TableNames
	WaitPolicy LockingWaitPolicy
}

LockingItem represents a single locking item in a locking clause.

NOTE: if this struct changes, HashLockingItem and IsLockingItemEqual in opt/memo/interner.go will need to be updated accordingly.

func (*LockingItem) Format

func (f *LockingItem) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type LockingStrength

type LockingStrength byte

LockingStrength represents the possible row-level lock modes for a SELECT statement.

const (
	// ForNone represents the default - no for statement at all.
	// LockingItem AST nodes are never created with this strength.
	ForNone LockingStrength = iota
	// ForKeyShare represents FOR KEY SHARE.
	ForKeyShare
	// ForShare represents FOR SHARE.
	ForShare
	// ForNoKeyUpdate represents FOR NO KEY UPDATE.
	ForNoKeyUpdate
	// ForUpdate represents FOR UPDATE.
	ForUpdate
)

The ordering of the variants is important, because the highest numerical value takes precedence when row-level locking is specified multiple ways.

func (LockingStrength) Format

func (s LockingStrength) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (LockingStrength) Max

Max returns the maximum of the two locking strengths.

func (LockingStrength) String

func (s LockingStrength) String() string

type LockingWaitPolicy

type LockingWaitPolicy byte

LockingWaitPolicy represents the possible policies for handling conflicting locks held by other active transactions when attempting to lock rows due to FOR UPDATE/SHARE clauses (i.e. it represents the NOWAIT and SKIP LOCKED options).

const (
	// LockWaitBlock represents the default - wait for the lock to become
	// available.
	LockWaitBlock LockingWaitPolicy = iota
	// LockWaitSkip represents SKIP LOCKED - skip rows that can't be locked.
	LockWaitSkip
	// LockWaitError represents NOWAIT - raise an error if a row cannot be
	// locked.
	LockWaitError
)

The ordering of the variants is important, because the highest numerical value takes precedence when row-level locking is specified multiple ways.

func (LockingWaitPolicy) Format

func (p LockingWaitPolicy) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (LockingWaitPolicy) Max

Max returns the maximum of the two locking wait policies.

func (LockingWaitPolicy) String

func (p LockingWaitPolicy) String() string

type MaterializeClause

type MaterializeClause struct {
	// Set controls whether to use the Materialize bool instead of the default.
	Set bool

	// Materialize overrides the default materialization behavior.
	Materialize bool
}

MaterializeClause represents a materialize clause inside of a WITH clause.

type MultipleResultsError

type MultipleResultsError struct {
	SQL string // the query that produced this error
}

MultipleResultsError is returned by QueryRow when more than one result is encountered.

func (*MultipleResultsError) Error

func (e *MultipleResultsError) Error() string

type Name

type Name string

A Name is an SQL identifier.

In general, a Name is the result of parsing a name nonterminal, which is used in the grammar where reserved keywords cannot be distinguished from identifiers. A Name that matches a reserved keyword must thus be quoted when formatted. (Names also need quoting for a variety of other reasons; see isBareIdentifier.)

For historical reasons, some Names are instead the result of parsing `unrestricted_name` nonterminals. See UnrestrictedName for details.

func (*Name) Format

func (n *Name) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (Name) Normalize

func (n Name) Normalize() string

Normalize normalizes to lowercase and Unicode Normalization Form C (NFC).

func (*Name) String

func (node *Name) String() string

type NameList

type NameList []Name

A NameList is a list of identifiers.

func (*NameList) Format

func (l *NameList) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*NameList) String

func (list *NameList) String() string

func (NameList) ToStrings

func (l NameList) ToStrings() []string

ToStrings converts the name list to an array of regular strings.

type NameParts

type NameParts = [4]string

NameParts is the array of strings that composes the path in an UnresolvedName.

type NameResolutionResult

type NameResolutionResult interface {
	// NameResolutionResult is the interface anchor.
	NameResolutionResult()
}

NameResolutionResult is an opaque reference returned by LookupObject().

type NamedColumnQualification

type NamedColumnQualification struct {
	Name          Name
	Qualification ColumnQualification
	Collation     string
	Deferrable    DeferrableMode
	Initially     InitiallyMode
}

NamedColumnQualification wraps a NamedColumnQualification with a name.

type NaturalJoinCond

type NaturalJoinCond struct{}

NaturalJoinCond represents a NATURAL join condition

func (NaturalJoinCond) Format

func (NaturalJoinCond) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type NoReturningClause

type NoReturningClause struct{}

NoReturningClause represents the absence of a RETURNING clause.

func (*NoReturningClause) Format

func (*NoReturningClause) Format(_ *FmtCtx)

Format implements the NodeFormatter interface.

type NodeFormatter

type NodeFormatter interface {
	// Format performs pretty-printing towards a bytes buffer. The flags member
	// of ctx influences the results. Most callers should use FormatNode instead.
	Format(ctx *FmtCtx)
}

NodeFormatter is implemented by nodes that can be pretty-printed.

type NotExpr

type NotExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

NotExpr represents a NOT expression.

func NewTypedNotExpr

func NewTypedNotExpr(expr TypedExpr) *NotExpr

NewTypedNotExpr returns a new NotExpr that is verified to be well-typed.

func (*NotExpr) Format

func (node *NotExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (NotExpr) HasResolvedType added in v0.6.0

func (ta NotExpr) HasResolvedType() bool

func (NotExpr) ResolvedType

func (ta NotExpr) ResolvedType() *types.T

func (*NotExpr) String

func (node *NotExpr) String() string

func (*NotExpr) TypeCheck

func (expr *NotExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*NotExpr) TypedInnerExpr

func (node *NotExpr) TypedInnerExpr() TypedExpr

TypedInnerExpr returns the NotExpr's inner expression as a TypedExpr.

func (*NotExpr) Walk

func (expr *NotExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type NotNullConstraint

type NotNullConstraint struct{}

NotNullConstraint represents NOT NULL on a column.

type NullConstraint

type NullConstraint struct{}

NullConstraint represents NULL on a column.

type NullIfExpr

type NullIfExpr struct {
	Expr1 Expr
	Expr2 Expr
	// contains filtered or unexported fields
}

NullIfExpr represents a NULLIF expression.

func (*NullIfExpr) Format

func (node *NullIfExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (NullIfExpr) HasResolvedType added in v0.6.0

func (ta NullIfExpr) HasResolvedType() bool

func (NullIfExpr) ResolvedType

func (ta NullIfExpr) ResolvedType() *types.T

func (*NullIfExpr) String

func (node *NullIfExpr) String() string

func (*NullIfExpr) TypeCheck

func (expr *NullIfExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*NullIfExpr) Walk

func (expr *NullIfExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type NullInput added in v0.4.0

type NullInput string
const (
	CalledOnNullInput      NullInput = "called on null input" // default
	ReturnsNullOnNullInput NullInput = "returns null on null input"
	StrictNullInput        NullInput = "strict"
)

type NullLiteral added in v0.2.0

type NullLiteral struct{}

func (NullLiteral) AmbiguousFormat added in v0.2.0

func (NullLiteral) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (NullLiteral) Format added in v0.2.0

func (NullLiteral) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (NullLiteral) ResolvedType added in v0.2.0

func (NullLiteral) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (NullLiteral) Size added in v0.2.0

func (d NullLiteral) Size() uintptr

Size implements the Datum interface.

func (NullLiteral) String added in v0.2.0

func (d NullLiteral) String() string

func (NullLiteral) TypeCheck added in v0.2.0

func (d NullLiteral) TypeCheck(_ context.Context, _ *SemaContext, desired *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface. It is implemented as an idempotent identity function for Datum.

func (NullLiteral) Walk added in v0.2.0

func (d NullLiteral) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type Nullability

type Nullability int

Nullability represents either NULL, NOT NULL or an unspecified value (silent NULL).

const (
	NotNull Nullability = iota
	Null
	SilentNull
)

The values for NullType.

type NullsOrder

type NullsOrder int8

NullsOrder for specifying ordering of NULLs.

const (
	DefaultNullsOrder NullsOrder = iota
	NullsFirst
	NullsLast
)

Null order values.

func (NullsOrder) String

func (n NullsOrder) String() string

type NumResolutionResults

type NumResolutionResults int

NumResolutionResults represents the number of results in the lookup of data sources matching a given prefix.

const (
	// NoResults for when there is no result.
	NoResults NumResolutionResults = iota
	// ExactlyOne indicates just one source matching the requested name.
	ExactlyOne
	// MoreThanOne signals an ambiguous match.
	MoreThanOne
)

type NumVal

type NumVal struct {
	// contains filtered or unexported fields
}

NumVal represents a constant numeric value.

func NewNumVal

func NewNumVal(value constant.Value, origString string, negative bool) *NumVal

NewNumVal constructs a new NumVal instance. This is used during parsing and in tests.

func (*NumVal) AsConstantInt

func (expr *NumVal) AsConstantInt() (constant.Value, bool)

AsConstantInt returns the value as an constant.Int if possible, along with a flag indicating whether the conversion was possible. The result contains the proper sign as per expr.negative.

func (*NumVal) AsConstantValue

func (expr *NumVal) AsConstantValue() constant.Value

AsConstantValue returns the value as a constant numerical value, with the proper sign as given by expr.negative.

func (*NumVal) AsInt32

func (expr *NumVal) AsInt32() (int32, error)

AsInt32 returns the value as 32-bit integer if possible, or returns an error if not possible. The method will set expr.resInt to the value of this int32 if it is successful, avoiding the need to call the method again.

func (*NumVal) AsInt64

func (expr *NumVal) AsInt64() (int64, error)

AsInt64 returns the value as a 64-bit integer if possible, or returns an error if not possible. The method will set expr.resInt to the value of this int64 if it is successful, avoiding the need to call the method again.

func (*NumVal) AvailableTypes

func (expr *NumVal) AvailableTypes() []*types.T

AvailableTypes implements the Constant interface.

func (*NumVal) DesirableTypes

func (expr *NumVal) DesirableTypes() []*types.T

DesirableTypes implements the Constant interface.

func (*NumVal) ExactString

func (expr *NumVal) ExactString() string

ExactString implements the constant.Value interface. Does not include the negative sign.

func (*NumVal) Format

func (expr *NumVal) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*NumVal) FormattedString added in v0.2.0

func (expr *NumVal) FormattedString() string

FormattedString returns a string that includes the negative sign.

func (*NumVal) Kind

func (expr *NumVal) Kind() constant.Kind

Kind implements the constant.Value interface.

func (*NumVal) Negate

func (expr *NumVal) Negate()

Negate sets the negative field to the opposite of its current value. The parser calls this to simplify unary negation expressions.

func (*NumVal) OrigString

func (expr *NumVal) OrigString() string

OrigString returns the origString field. Does not include the negative sign.

func (*NumVal) ResolveAsType

func (expr *NumVal) ResolveAsType(
	ctx context.Context, semaCtx *SemaContext, typ *types.T,
) (TypedExpr, error)

ResolveAsType implements the Constant interface.

func (*NumVal) SetNegative

func (expr *NumVal) SetNegative()

SetNegative sets the negative field to true. The parser calls this when it identifies a negative constant.

func (*NumVal) ShouldBeInt64

func (expr *NumVal) ShouldBeInt64() bool

ShouldBeInt64 checks if the value naturally is an int64:

1   = yes
1.0 = no
1.1 = no
123...overflow...456 = no

func (*NumVal) String

func (node *NumVal) String() string

func (*NumVal) TypeCheck

func (expr *NumVal) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*NumVal) Walk

func (expr *NumVal) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type OIDTypeReference

type OIDTypeReference struct {
	OID oid.Oid
}

OIDTypeReference is a reference to a type directly by its stable ID.

func (*OIDTypeReference) SQLString

func (node *OIDTypeReference) SQLString() string

SQLString implements the ResolvableTypeReference interface.

type ObjectLookupFlags

type ObjectLookupFlags struct {
	CommonLookupFlags
	AllowWithoutPrimaryKey bool
	// Control what type of object is being requested.
	DesiredObjectKind DesiredObjectKind
	// Control what kind of table object is being requested. This field is
	// only respected when DesiredObjectKind is TableObject.
	DesiredTableDescKind RequiredTableKind
}

ObjectLookupFlags is the flag struct suitable for GetObjectDesc().

func ObjectLookupFlagsWithRequired

func ObjectLookupFlagsWithRequired() ObjectLookupFlags

ObjectLookupFlagsWithRequired returns a default ObjectLookupFlags object with just the Required flag true. This is a common configuration of the flags.

func ObjectLookupFlagsWithRequiredTableKind

func ObjectLookupFlagsWithRequiredTableKind(kind RequiredTableKind) ObjectLookupFlags

ObjectLookupFlagsWithRequiredTableKind returns an ObjectLookupFlags with Required set to true, and the DesiredTableDescKind set to the input kind.

type ObjectName

type ObjectName interface {
	NodeFormatter
	Object() string
	Schema() string
	Catalog() string
	FQString() string
	// contains filtered or unexported methods
}

ObjectName is a common interface for qualified object names.

func NewQualifiedObjectName

func NewQualifiedObjectName(catalog, schema, object string, kind DesiredObjectKind) ObjectName

NewQualifiedObjectName returns an ObjectName of the corresponding kind. It is used mainly for constructing appropriate error messages depending on what kind of object was requested.

type ObjectNameExistingResolver

type ObjectNameExistingResolver interface {
	LookupObject(ctx context.Context, flags ObjectLookupFlags, dbName, scName, obName string) (
		found bool, objMeta NameResolutionResult, err error,
	)
}

ObjectNameExistingResolver is the helper interface to resolve table names when the object is expected to exist already. The boolean passed is used to specify if a MutableTableDescriptor is to be returned in the result.

type ObjectNamePrefix

type ObjectNamePrefix struct {
	CatalogName Name
	SchemaName  Name

	// ExplicitCatalog is true iff the catalog was explicitly specified
	// or it needs to be rendered during pretty-printing.
	ExplicitCatalog bool
	// ExplicitSchema is true iff the schema was explicitly specified
	// or it needs to be rendered during pretty-printing.
	ExplicitSchema bool
}

ObjectNamePrefix corresponds to the path prefix of an object name.

func (*ObjectNamePrefix) Catalog

func (tp *ObjectNamePrefix) Catalog() string

Catalog retrieves the unqualified catalog name.

func (*ObjectNamePrefix) Format

func (tp *ObjectNamePrefix) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ObjectNamePrefix) Resolve

func (tp *ObjectNamePrefix) Resolve(
	ctx context.Context, r ObjectNameTargetResolver, curDb string, searchPath sessiondata.SearchPath,
) (found bool, scMeta SchemaMeta, err error)

Resolve is used for table prefixes. This is adequate for table patterns with stars, e.g. AllTablesSelector.

func (*ObjectNamePrefix) Schema

func (tp *ObjectNamePrefix) Schema() string

Schema retrieves the unqualified schema name.

func (*ObjectNamePrefix) String

func (tp *ObjectNamePrefix) String() string

type ObjectNameTargetResolver

type ObjectNameTargetResolver interface {
	LookupSchema(ctx context.Context, dbName, scName string) (found bool, scMeta SchemaMeta, err error)
}

ObjectNameTargetResolver is the helper interface to resolve object names when the object is not expected to exist. The planner implements LookupSchema to return an object consisting of the parent database and resolved target schema.

type ObserverStatement

type ObserverStatement interface {
	// contains filtered or unexported methods
}

ObserverStatement is a marker interface for statements which are allowed to run regardless of the current transaction state: statements other than rollback are generally rejected if the session is in a failed transaction state, but it's convenient to allow some statements (e.g. "show syntax; set tracing"). Such statements are not expected to modify the database, the transaction or session state (other than special cases such as enabling/disabling tracing).

These statements short-circuit the regular execution - they don't get planned (there are no corresponding planNodes). The connExecutor recognizes them and handles them.

type OnConflict

type OnConflict struct {
	Columns          NameList
	ArbiterPredicate Expr
	Exprs            UpdateExprs
	Where            *Where
	DoNothing        bool
}

OnConflict represents an `ON CONFLICT (columns) WHERE arbiter DO UPDATE SET exprs WHERE where` clause.

The zero value for OnConflict is used to signal the UPSERT short form, which uses the primary key for as the conflict index and the values being inserted for Exprs.

func (*OnConflict) IsUpsertAlias

func (oc *OnConflict) IsUpsertAlias() bool

IsUpsertAlias returns true if the UPSERT syntactic sugar was used.

type OnJoinCond

type OnJoinCond struct {
	Expr Expr
}

OnJoinCond represents an ON join condition.

func (*OnJoinCond) Format

func (node *OnJoinCond) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type Operator

type Operator interface {
	// contains filtered or unexported methods
}

Operator is used to identify Operators; used in sql.y.

type OrExpr

type OrExpr struct {
	Left, Right Expr
	// contains filtered or unexported fields
}

OrExpr represents an OR expression.

func NewTypedOrExpr

func NewTypedOrExpr(left, right TypedExpr) *OrExpr

NewTypedOrExpr returns a new OrExpr that is verified to be well-typed.

func (*OrExpr) Format

func (node *OrExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (OrExpr) HasResolvedType added in v0.6.0

func (ta OrExpr) HasResolvedType() bool

func (OrExpr) ResolvedType

func (ta OrExpr) ResolvedType() *types.T

func (*OrExpr) String

func (node *OrExpr) String() string

func (*OrExpr) TypeCheck

func (expr *OrExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*OrExpr) TypedLeft

func (node *OrExpr) TypedLeft() TypedExpr

TypedLeft returns the OrExpr's left expression as a TypedExpr.

func (*OrExpr) TypedRight

func (node *OrExpr) TypedRight() TypedExpr

TypedRight returns the OrExpr's right expression as a TypedExpr.

func (*OrExpr) Walk

func (expr *OrExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type Order

type Order struct {
	OrderType  OrderType
	Expr       Expr
	Direction  Direction
	NullsOrder NullsOrder
	// Table/Index replaces Expr when OrderType = OrderByIndex.
	Table TableName
	// If Index is empty, then the order should use the primary key.
	Index UnrestrictedName
}

Order represents an ordering expression.

func (*Order) Equal

func (node *Order) Equal(other *Order) bool

Equal checks if the node ordering is equivalent to other.

func (*Order) Format

func (node *Order) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type OrderBy

type OrderBy []*Order

OrderBy represents an ORDER BY clause.

func (*OrderBy) Format

func (node *OrderBy) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type OrderType

type OrderType int

OrderType indicates which type of expression is used in ORDER BY.

const (
	// OrderByColumn is the regular "by expression/column" ORDER BY specification.
	OrderByColumn OrderType = iota
	// OrderByIndex enables the user to specify a given index' columns implicitly.
	OrderByIndex
)

type Overload

type Overload struct {
	Types      TypeList
	ReturnType ReturnTyper
	Volatility Volatility

	// PreferredOverload determines overload resolution as follows.
	// When multiple overloads are eligible based on types even after all of of
	// the heuristics to pick one have been used, if one of the overloads is a
	// Overload with the `PreferredOverload` flag set to true it can be selected
	// rather than returning a no-such-method error.
	// This should generally be avoided -- avoiding introducing ambiguous
	// overloads in the first place is a much better solution -- and only done
	// after consultation with @knz @nvanbenschoten.
	PreferredOverload bool

	// Info is a description of the function, which is surfaced on the CockroachDB
	// docs site on the "Functions and Operators" page. Descriptions typically use
	// third-person with the function as an implicit subject (e.g. "Calculates
	// infinity"), but should focus more on ease of understanding so other structures
	// might be more appropriate.
	Info string

	// SpecializedVecBuiltin is used to let the vectorized engine
	// know when an Overload has a specialized vectorized operator.
	SpecializedVecBuiltin SpecializedVectorizedBuiltin

	// IgnoreVolatilityCheck ignores checking the functions overload's
	// volatility against Postgres's volatility at test time.
	// This should be used with caution.
	IgnoreVolatilityCheck bool
}

Overload is one of the overloads of a built-in function. Each FunctionDefinition may contain one or more overloads.

func (Overload) FixedReturnType

func (b Overload) FixedReturnType() *types.T

FixedReturnType returns a fixed type that the function returns, returning Any if the return type is based on the function's arguments.

func (Overload) Signature

func (b Overload) Signature(simplify bool) string

Signature returns a human-readable signature. If simplify is bool, tuple-returning functions with just 1 tuple element unwrap the return type in the signature.

type Parallel added in v0.4.0

type Parallel string
const (
	ParallelUnsafe     Parallel = "unsafe"
	ParallelRestricted Parallel = "restricted"
	ParallelSafe       Parallel = "safe"
)

type ParenExpr

type ParenExpr struct {
	Expr Expr
	// contains filtered or unexported fields
}

ParenExpr represents a parenthesized expression.

func (*ParenExpr) Format

func (node *ParenExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (ParenExpr) HasResolvedType added in v0.6.0

func (ta ParenExpr) HasResolvedType() bool

func (ParenExpr) ResolvedType

func (ta ParenExpr) ResolvedType() *types.T

func (*ParenExpr) String

func (node *ParenExpr) String() string

func (*ParenExpr) TypeCheck

func (expr *ParenExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*ParenExpr) TypedInnerExpr

func (node *ParenExpr) TypedInnerExpr() TypedExpr

TypedInnerExpr returns the ParenExpr's inner expression as a TypedExpr.

func (*ParenExpr) Walk

func (expr *ParenExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type ParenSelect

type ParenSelect struct {
	Select *Select
}

ParenSelect represents a parenthesized SELECT/UNION/VALUES statement.

func (*ParenSelect) Format

func (node *ParenSelect) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ParenSelect) StatementTag

func (*ParenSelect) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ParenSelect) StatementType

func (*ParenSelect) StatementType() StatementType

StatementType implements the Statement interface.

func (*ParenSelect) String

func (n *ParenSelect) String() string

type ParenTableExpr

type ParenTableExpr struct {
	Expr TableExpr
}

ParenTableExpr represents a parenthesized TableExpr.

func (*ParenTableExpr) Format

func (node *ParenTableExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ParenTableExpr) String

func (node *ParenTableExpr) String() string

type ParseTimeContext

type ParseTimeContext interface {
	// GetRelativeParseTime returns the transaction time in the session's
	// timezone (i.e. now()). This is used to calculate relative dates,
	// like "tomorrow", and also provides a default time.Location for
	// parsed times.
	GetRelativeParseTime() time.Time
}

ParseTimeContext provides the information necessary for parsing dates, times, and timestamps. A nil value is generally acceptable and will result in reasonable defaults being applied.

type PartitionBoundSpec added in v0.5.0

type PartitionBoundSpec struct {
	IsDefault bool
	Type      PartitionBoundType
	// NOTE: Values MINVALUE and MAXVALUE for FROM and TO expressions will be in string constant format.
	// From holds also expressions for IN type or a single expression for MODULUS part of WITH type
	From Exprs
	// To holds also a single expression for REMAINDER part of WITH type
	To Exprs
}

func (*PartitionBoundSpec) Format added in v0.5.0

func (node *PartitionBoundSpec) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type PartitionBoundType added in v0.5.0

type PartitionBoundType int
const (
	PartitionBoundIn PartitionBoundType = iota
	PartitionBoundFromTo
	PartitionBoundWith
)

The values for PartitionBoundType.

type PartitionBy

type PartitionBy struct {
	// Exactly one of List or Range or Hash is required to be non-empty.
	Type  PartitionByType
	Elems IndexElemList
}

PartitionBy represents an PARTITION BY definition within a CREATE/ALTER TABLE/INDEX statement.

func (*PartitionBy) Format

func (node *PartitionBy) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type PartitionByType

type PartitionByType string

PartitionByType is an enum of each type of partitioning (LIST/RANGE).

const (
	// PartitionByList indicates a PARTITION BY LIST clause.
	PartitionByList PartitionByType = "LIST"
	// PartitionByRange indicates a PARTITION BY RANGE clause.
	PartitionByRange PartitionByType = "RANGE"
	// PartitionByHash indicates a PARTITION BY HASH clause.
	PartitionByHash PartitionByType = "HASH"
)

type PartitionMaxVal

type PartitionMaxVal struct{}

PartitionMaxVal represents the MAXVALUE expression.

func (PartitionMaxVal) Format

func (node PartitionMaxVal) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (PartitionMaxVal) String

func (node PartitionMaxVal) String() string

func (PartitionMaxVal) TypeCheck

func (expr PartitionMaxVal) TypeCheck(
	_ context.Context, _ *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (PartitionMaxVal) Walk

func (expr PartitionMaxVal) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type PartitionMinVal

type PartitionMinVal struct{}

PartitionMinVal represents the MINVALUE expression.

func (PartitionMinVal) Format

func (node PartitionMinVal) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (PartitionMinVal) String

func (node PartitionMinVal) String() string

func (PartitionMinVal) TypeCheck

func (expr PartitionMinVal) TypeCheck(
	_ context.Context, _ *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (PartitionMinVal) Walk

func (expr PartitionMinVal) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type Persistence

type Persistence int

Persistence defines the persistence strategy for a given table.

const (
	// PersistencePermanent indicates a permanent table.
	PersistencePermanent Persistence = iota
	// PersistenceTemporary indicates a temporary table.
	PersistenceTemporary
	// PersistenceUnlogged indicates an unlogged table.
	// Note this state is not persisted on disk and is used at parse time only.
	PersistenceUnlogged
)

func (Persistence) IsTemporary

func (p Persistence) IsTemporary() bool

IsTemporary returns whether the Persistence value is Temporary.

func (Persistence) IsUnlogged

func (p Persistence) IsUnlogged() bool

IsUnlogged returns whether the Persistence value is Unlogged.

type Placeholder

type Placeholder struct {
	Idx PlaceholderIdx
	// contains filtered or unexported fields
}

Placeholder represents a named placeholder.

func NewPlaceholder

func NewPlaceholder(name string) (*Placeholder, error)

NewPlaceholder allocates a Placeholder.

func (*Placeholder) AmbiguousFormat

func (d *Placeholder) AmbiguousFormat() bool

AmbiguousFormat implements the Datum interface.

func (*Placeholder) Format

func (node *Placeholder) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (Placeholder) HasResolvedType added in v0.6.0

func (ta Placeholder) HasResolvedType() bool

func (*Placeholder) ResolvedType

func (node *Placeholder) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*Placeholder) Size

func (d *Placeholder) Size() uintptr

Size implements the Datum interface.

func (*Placeholder) String

func (node *Placeholder) String() string

func (*Placeholder) TypeCheck

func (expr *Placeholder) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*Placeholder) Walk

func (expr *Placeholder) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type PlaceholderIdx

type PlaceholderIdx uint16

PlaceholderIdx is the 0-based index of a placeholder. Placeholder "$1" has PlaceholderIdx=0.

func (PlaceholderIdx) String

func (idx PlaceholderIdx) String() string

String returns the index as a placeholder string representation ($1, $2 etc).

type PlaceholderInfo

type PlaceholderInfo struct {
	PlaceholderTypesInfo

	Values QueryArguments
}

PlaceholderInfo defines the interface to SQL placeholders.

func (*PlaceholderInfo) Assign

func (p *PlaceholderInfo) Assign(src *PlaceholderInfo, numPlaceholders int) error

Assign resets the PlaceholderInfo to the contents of src. If src is nil, a new structure is initialized.

func (*PlaceholderInfo) Init

func (p *PlaceholderInfo) Init(numPlaceholders int, typeHints PlaceholderTypes) error

Init initializes a PlaceholderInfo structure appropriate for the given number of placeholders, and with the given (optional) type hints.

func (*PlaceholderInfo) IsUnresolvedPlaceholder

func (p *PlaceholderInfo) IsUnresolvedPlaceholder(expr Expr) bool

IsUnresolvedPlaceholder returns whether expr is an unresolved placeholder. In other words, it returns whether the provided expression is a placeholder expression or a placeholder expression within nested parentheses, and if so, whether the placeholder's type remains unset in the PlaceholderInfo.

func (*PlaceholderInfo) Value

func (p *PlaceholderInfo) Value(idx PlaceholderIdx) (TypedExpr, bool)

Value returns the known value of a placeholder. Returns false in the 2nd value if the placeholder does not have a value.

type PlaceholderTypes

type PlaceholderTypes []*types.T

PlaceholderTypes stores placeholder types (or type hints), one per PlaceholderIdx. The slice is always pre-allocated to the number of placeholders in the statement. Entries that don't yet have a type are nil.

func (PlaceholderTypes) AssertAllSet

func (pt PlaceholderTypes) AssertAllSet() error

AssertAllSet verifies that all types have been set and returns an error otherwise.

func (PlaceholderTypes) Equals

func (pt PlaceholderTypes) Equals(other PlaceholderTypes) bool

Equals returns true if two PlaceholderTypes contain the same types.

type PlaceholderTypesInfo

type PlaceholderTypesInfo struct {
	// TypeHints contains the initially set type hints for each placeholder if
	// present. It is not changed during query type checking.
	TypeHints PlaceholderTypes
	// Types contains the final types set for each placeholder after type
	// checking.
	Types PlaceholderTypes
}

PlaceholderTypesInfo encapsulates typing information for placeholders.

func (*PlaceholderTypesInfo) SetType

func (p *PlaceholderTypesInfo) SetType(idx PlaceholderIdx, typ *types.T) error

SetType assigns a known type to a placeholder. Reports an error if another type was previously assigned.

func (*PlaceholderTypesInfo) Type

func (p *PlaceholderTypesInfo) Type(idx PlaceholderIdx) (_ *types.T, ok bool)

Type returns the known type of a placeholder. If there is no known type yet but there is a type hint, returns the type hint.

func (*PlaceholderTypesInfo) ValueType

func (p *PlaceholderTypesInfo) ValueType(idx PlaceholderIdx) (_ *types.T, ok bool)

ValueType returns the type of the value that must be supplied for a placeholder. This is the type hint given by the client if there is one, or the placeholder type if there isn't one. This can differ from Type(idx) when a client hint is overridden (see Placeholder.Eval).

type Prepare

type Prepare struct {
	Name      Name
	Types     []ResolvableTypeReference
	Statement Statement
}

Prepare represents a PREPARE statement.

func (*Prepare) Format

func (node *Prepare) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Prepare) StatementTag

func (*Prepare) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Prepare) StatementType

func (*Prepare) StatementType() StatementType

StatementType implements the Statement interface.

func (*Prepare) String

func (n *Prepare) String() string

type PrettyAlignMode

type PrettyAlignMode int

PrettyAlignMode directs which alignment mode to use.

TODO(knz/mjibson): this variety of options currently exists so as to enable comparisons and gauging individual preferences. We should aim to remove some or all of these options in the future.

type PrettyCfg

type PrettyCfg struct {
	// LineWidth is the desired maximum line width.
	LineWidth int
	// TabWidth is the amount of spaces to use for tabs when UseTabs is
	// false.
	TabWidth int
	// Align, when set to another value than PrettyNoAlign, uses
	// alignment for some constructs as a first choice. If not set or if
	// the line width is insufficient, nesting is used instead.
	Align PrettyAlignMode
	// UseTabs indicates whether to use tab chars to signal indentation.
	UseTabs bool
	// Simplify, when set, removes extraneous parentheses.
	Simplify bool
	// Case, if set, transforms case-insensitive strings (like SQL keywords).
	Case func(string) string
	// JSONFmt, when set, pretty-prints strings that are asserted or cast
	// to JSON.
	JSONFmt bool
}

PrettyCfg holds configuration for pretty printing statements.

func DefaultPrettyCfg

func DefaultPrettyCfg() PrettyCfg

DefaultPrettyCfg returns a PrettyCfg with the default configuration.

func (*PrettyCfg) Doc

func (p *PrettyCfg) Doc(f NodeFormatter) pretty.Doc

Doc converts f (generally a Statement) to a pretty.Doc. If f does not have a native conversion, its .Format representation is used as a simple Text Doc.

func (*PrettyCfg) Pretty

func (p *PrettyCfg) Pretty(stmt NodeFormatter) string

Pretty pretty prints stmt with specified options.

type PrivForCols added in v0.4.0

type PrivForCols struct {
	Privilege privilege.Kind
	ColNames  NameList
}

PrivForCols is only used for table target with column names defined

type QueryArguments

type QueryArguments []TypedExpr

QueryArguments stores query arguments, one per PlaceholderIdx.

A nil value represents a NULL argument.

func (QueryArguments) String

func (qa QueryArguments) String() string

type RangeCond

type RangeCond struct {
	Not       bool
	Symmetric bool
	Left      Expr
	From, To  Expr
	// contains filtered or unexported fields
}

RangeCond represents a BETWEEN [SYMMETRIC] or a NOT BETWEEN [SYMMETRIC] expression.

func (*RangeCond) Format

func (node *RangeCond) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (RangeCond) HasResolvedType added in v0.6.0

func (ta RangeCond) HasResolvedType() bool

func (RangeCond) ResolvedType

func (ta RangeCond) ResolvedType() *types.T

func (*RangeCond) String

func (node *RangeCond) String() string

func (*RangeCond) TypeCheck

func (expr *RangeCond) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*RangeCond) TypedFrom

func (node *RangeCond) TypedFrom() TypedExpr

TypedFrom returns the RangeCond's from expression as a TypedExpr.

func (*RangeCond) TypedLeftFrom

func (node *RangeCond) TypedLeftFrom() TypedExpr

TypedLeftFrom returns the RangeCond's left expression as a TypedExpr, in the context of a comparison with TypedFrom().

func (*RangeCond) TypedLeftTo

func (node *RangeCond) TypedLeftTo() TypedExpr

TypedLeftTo returns the RangeCond's left expression as a TypedExpr, in the context of a comparison with TypedTo().

func (*RangeCond) TypedTo

func (node *RangeCond) TypedTo() TypedExpr

TypedTo returns the RangeCond's to expression as a TypedExpr.

func (*RangeCond) Walk

func (expr *RangeCond) Walk(v Visitor) Expr

Walk implements the Expr interface.

type RangeType added in v0.5.0

type RangeType struct {
	Subtype ResolvableTypeReference
	Options []RangeTypeOption
}

RangeType represents a `CREATE TYPE <name> AS RANGE ( <subtype>, ... )` statement.

func (*RangeType) Format added in v0.5.0

func (node *RangeType) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type RangeTypeOption added in v0.5.0

type RangeTypeOption struct {
	Option     RangeTypeOptionType
	StrVal     string
	MRTypeName *UnresolvedObjectName
}

type RangeTypeOptionType added in v0.5.0

type RangeTypeOptionType int
const (
	RangeTypeSubtypeOpClass RangeTypeOptionType = iota
	RangeTypeCollation
	RangeTypeCanonical
	RangeTypeSubtypeDiff
	RangeTypeMultiRangeTypeName
)

type ReadWriteMode

type ReadWriteMode int

ReadWriteMode holds the read write mode for a transaction.

const (
	UnspecifiedReadWriteMode ReadWriteMode = iota
	ReadOnly
	ReadWrite
)

ReadWriteMode values

func (ReadWriteMode) String

func (ro ReadWriteMode) String() string

type RefAction added in v0.5.0

type RefAction struct {
	Action  ReferenceAction
	Columns NameList // used for SET NULL or SET DEFAULT
}

func (*RefAction) Format added in v0.5.0

func (node *RefAction) Format(ctx *FmtCtx)

type ReferenceAction

type ReferenceAction int

ReferenceAction is the method used to maintain referential integrity through foreign keys.

const (
	NoAction ReferenceAction = iota
	Restrict
	SetNull
	SetDefault
	Cascade
)

The values for ReferenceAction.

func (ReferenceAction) String

func (ra ReferenceAction) String() string

type ReferenceActions

type ReferenceActions struct {
	Delete RefAction
	Update RefAction
}

ReferenceActions contains the actions specified to maintain referential integrity through foreign keys for different operations.

func (*ReferenceActions) Format

func (node *ReferenceActions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type RefreshDataOption

type RefreshDataOption int

RefreshDataOption corresponds to arguments for the REFRESH MATERIALIZED VIEW statement.

const (
	// RefreshDataDefault refers to no option provided to the REFRESH MATERIALIZED
	// VIEW statement.
	RefreshDataDefault RefreshDataOption = iota
	// RefreshDataWithData refers to the WITH DATA option provided to the REFRESH
	// MATERIALIZED VIEW statement.
	RefreshDataWithData
	// RefreshDataClear refers to the WITH NO DATA option provided to the REFRESH
	// MATERIALIZED VIEW statement.
	RefreshDataClear
)

type RefreshMaterializedView

type RefreshMaterializedView struct {
	Name              *UnresolvedObjectName
	Concurrently      bool
	RefreshDataOption RefreshDataOption
}

RefreshMaterializedView represents a REFRESH MATERIALIZED VIEW statement.

func (*RefreshMaterializedView) Format

func (node *RefreshMaterializedView) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*RefreshMaterializedView) StatementTag

func (*RefreshMaterializedView) StatementTag() string

StatementTag implements the Statement interface.

func (*RefreshMaterializedView) StatementType

func (*RefreshMaterializedView) StatementType() StatementType

StatementType implements the Statement interface.

func (*RefreshMaterializedView) String

func (n *RefreshMaterializedView) String() string

type ReleaseSavepoint

type ReleaseSavepoint struct {
	Savepoint Name
}

ReleaseSavepoint represents a RELEASE SAVEPOINT <name> statement.

func (*ReleaseSavepoint) Format

func (node *ReleaseSavepoint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ReleaseSavepoint) StatementTag

func (*ReleaseSavepoint) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ReleaseSavepoint) StatementType

func (*ReleaseSavepoint) StatementType() StatementType

StatementType implements the Statement interface.

func (*ReleaseSavepoint) String

func (n *ReleaseSavepoint) String() string

type Relocate

type Relocate struct {
	// TODO(a-robinson): It's not great that this can only work on ranges that
	// are part of a currently valid table or index.
	TableOrIndex TableIndexName
	// Each row contains an array with store ids and values for the columns in the
	// PK or index (or a prefix of the columns).
	// See docs/RFCS/sql_split_syntax.md.
	Rows          *Select
	RelocateLease bool
}

Relocate represents an `ALTER TABLE/INDEX .. EXPERIMENTAL_RELOCATE ..` statement.

func (*Relocate) Format

func (node *Relocate) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Relocate) StatementTag

func (n *Relocate) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Relocate) StatementType

func (*Relocate) StatementType() StatementType

StatementType implements the Statement interface.

func (*Relocate) String

func (n *Relocate) String() string

type RenameColumn

type RenameColumn struct {
	Table   TableName
	Name    Name
	NewName Name
	// IfExists refers to the table, not the column.
	IfExists bool
}

RenameColumn represents a RENAME COLUMN statement.

func (*RenameColumn) Format

func (node *RenameColumn) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*RenameColumn) StatementTag

func (*RenameColumn) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RenameColumn) StatementType

func (*RenameColumn) StatementType() StatementType

StatementType implements the Statement interface.

func (*RenameColumn) String

func (n *RenameColumn) String() string

type RenameDatabase

type RenameDatabase struct {
	Name    Name
	NewName Name
}

RenameDatabase represents a RENAME DATABASE statement.

func (*RenameDatabase) Format

func (node *RenameDatabase) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*RenameDatabase) StatementTag

func (*RenameDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RenameDatabase) StatementType

func (*RenameDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*RenameDatabase) String

func (n *RenameDatabase) String() string

type RenameIndex

type RenameIndex struct {
	Index    *TableIndexName
	NewName  UnrestrictedName
	IfExists bool
}

RenameIndex represents a RENAME INDEX statement.

func (*RenameIndex) Format

func (node *RenameIndex) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*RenameIndex) StatementTag

func (*RenameIndex) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RenameIndex) StatementType

func (*RenameIndex) StatementType() StatementType

StatementType implements the Statement interface.

func (*RenameIndex) String

func (n *RenameIndex) String() string

type RenameTable

type RenameTable struct {
	Name           *UnresolvedObjectName
	NewName        *UnresolvedObjectName
	IfExists       bool
	IsMaterialized bool
	IsSequence     bool
}

RenameTable represents a RENAME TABLE or RENAME VIEW or RENAME SEQUENCE statement. Whether the user has asked to rename a view or a sequence is indicated by the IsView and IsSequence fields.

func (*RenameTable) Format

func (node *RenameTable) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*RenameTable) StatementTag

func (n *RenameTable) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RenameTable) StatementType

func (*RenameTable) StatementType() StatementType

StatementType implements the Statement interface.

func (*RenameTable) String

func (n *RenameTable) String() string

type ReparentDatabase

type ReparentDatabase struct {
	Name   Name
	Parent Name
}

ReparentDatabase represents a database reparenting as a schema operation.

func (*ReparentDatabase) Format

func (node *ReparentDatabase) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ReparentDatabase) StatementTag

func (*ReparentDatabase) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ReparentDatabase) StatementType

func (*ReparentDatabase) StatementType() StatementType

StatementType implements the Statement interface.

func (*ReparentDatabase) String

func (n *ReparentDatabase) String() string

type ReplicaIdentity added in v0.5.0

type ReplicaIdentity int
const (
	ReplicaIdentityDefault ReplicaIdentity = iota
	ReplicaIdentityUsingIndex
	ReplicaIdentityFull
	ReplicaIdentityNothing
)

type RequiredTableKind

type RequiredTableKind int

RequiredTableKind controls what kind of TableDescriptor backed object is requested to be resolved.

const (
	ResolveAnyTableKind RequiredTableKind = iota
	ResolveRequireTableDesc
	ResolveRequireViewDesc
	ResolveRequireTableOrViewDesc
	ResolveRequireSequenceDesc
)

RequiredTableKind options have descriptive names.

func (RequiredTableKind) String

func (r RequiredTableKind) String() string

type ResetAll added in v0.5.0

type ResetAll struct{}

func (*ResetAll) Format added in v0.5.0

func (node *ResetAll) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ResetAll) StatementTag added in v0.5.0

func (*ResetAll) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ResetAll) StatementType added in v0.5.0

func (*ResetAll) StatementType() StatementType

StatementType implements the Statement interface.

func (*ResetAll) String added in v0.5.0

func (n *ResetAll) String() string

type ResolvableFunctionReference

type ResolvableFunctionReference struct {
	FunctionReference
}

ResolvableFunctionReference implements the editable reference cell of a FuncExpr. The FunctionRerence is updated by the Normalize() method.

func WrapFunction

func WrapFunction(n string) ResolvableFunctionReference

WrapFunction creates a new ResolvableFunctionReference holding a pre-resolved function. Helper for grammar rules.

func (*ResolvableFunctionReference) Format

func (fn *ResolvableFunctionReference) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ResolvableFunctionReference) Resolve

Resolve checks if the function name is already resolved and resolves it as necessary.

func (*ResolvableFunctionReference) String

func (fn *ResolvableFunctionReference) String() string

type ResolvableTypeReference

type ResolvableTypeReference interface {
	SQLString() string
}

ResolvableTypeReference represents a type that is possibly unknown until type-checking/type name resolution is performed. N.B. ResolvableTypeReferences in expressions must be formatted with FormatTypeReference instead of SQLString.

type Restore

type Restore struct {
	Targets            TargetList
	DescriptorCoverage DescriptorCoverage
	From               []StringOrPlaceholderOptList
	AsOf               AsOfClause
	Options            RestoreOptions
	Subdir             Expr
}

Restore represents a RESTORE statement.

func (*Restore) Format

func (node *Restore) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Restore) StatementTag

func (*Restore) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Restore) StatementType

func (*Restore) StatementType() StatementType

StatementType implements the Statement interface.

func (*Restore) String

func (n *Restore) String() string

type RestoreOptions

type RestoreOptions struct {
	EncryptionPassphrase      Expr
	DecryptionKMSURI          StringOrPlaceholderOptList
	IntoDB                    Expr
	SkipMissingFKs            bool
	SkipMissingSequences      bool
	SkipMissingSequenceOwners bool
	SkipMissingViews          bool
	Detached                  bool
}

RestoreOptions describes options for the RESTORE execution.

func (*RestoreOptions) CombineWith

func (o *RestoreOptions) CombineWith(other *RestoreOptions) error

CombineWith merges other backup options into this backup options struct. An error is returned if the same option merged multiple times.

func (*RestoreOptions) Format

func (o *RestoreOptions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (RestoreOptions) IsDefault

func (o RestoreOptions) IsDefault() bool

IsDefault returns true if this backup options struct has default value.

type Return added in v0.4.0

type Return struct {
	Expr Expr
}

func (*Return) Format added in v0.4.0

func (node *Return) Format(ctx *FmtCtx)

func (*Return) StatementTag added in v0.4.0

func (*Return) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Return) StatementType added in v0.4.0

func (*Return) StatementType() StatementType

StatementType implements the Statement interface.

func (*Return) String added in v0.4.0

func (n *Return) String() string

type ReturnTyper

type ReturnTyper func(args []TypedExpr) *types.T

ReturnTyper defines the type-level function in which a builtin function's return type is determined. ReturnTypers should make sure to return unknownReturnType when necessary.

func ArrayOfFirstNonNullReturnType

func ArrayOfFirstNonNullReturnType() ReturnTyper

ArrayOfFirstNonNullReturnType returns an array type from the first non-null type in the argument list.

func FirstNonNullReturnType

func FirstNonNullReturnType() ReturnTyper

FirstNonNullReturnType returns the type of the first non-null argument, or types.Unknown if all arguments are null. There must be at least one argument, or else FirstNonNullReturnType returns UnknownReturnType. This method is used with HomogeneousType functions, in which all arguments have been checked to have the same type (or be null).

func FixedReturnType

func FixedReturnType(typ *types.T) ReturnTyper

FixedReturnType functions simply return a fixed type, independent of argument types.

func IdentityReturnType

func IdentityReturnType(idx int) ReturnTyper

IdentityReturnType creates a returnType that is a projection of the idx'th argument type.

type ReturningClause

type ReturningClause interface {
	NodeFormatter
	// contains filtered or unexported methods
}

ReturningClause represents the returning clause on a statement.

type ReturningExprs

type ReturningExprs SelectExprs

ReturningExprs represents RETURNING expressions.

func (*ReturningExprs) Format

func (r *ReturningExprs) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type ReturningNothing

type ReturningNothing struct{}

ReturningNothing represents RETURNING NOTHING.

func (*ReturningNothing) Format

func (*ReturningNothing) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type Revoke

type Revoke struct {
	Privileges     privilege.List
	Targets        TargetList
	Grantees       []string
	GrantOptionFor bool
	GrantedBy      string
	DropBehavior   DropBehavior

	// only used for table target with column names defined
	PrivsWithCols []PrivForCols
}

Revoke represents a REVOKE statement. PrivilegeList and TargetList are defined in grant.go

func (*Revoke) Format

func (node *Revoke) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Revoke) StatementTag

func (*Revoke) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Revoke) StatementType

func (*Revoke) StatementType() StatementType

StatementType implements the Statement interface.

func (*Revoke) String

func (n *Revoke) String() string

type RevokeRole

type RevokeRole struct {
	Roles        NameList
	Members      []string
	Option       string
	GrantedBy    string
	DropBehavior DropBehavior
}

RevokeRole represents a REVOKE <role> statement.

func (*RevokeRole) Format

func (node *RevokeRole) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*RevokeRole) StatementTag

func (*RevokeRole) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RevokeRole) StatementType

func (*RevokeRole) StatementType() StatementType

StatementType implements the Statement interface.

func (*RevokeRole) String

func (n *RevokeRole) String() string

type RollbackToSavepoint

type RollbackToSavepoint struct {
	Savepoint Name
}

RollbackToSavepoint represents a ROLLBACK TO SAVEPOINT <name> statement.

func (*RollbackToSavepoint) Format

func (node *RollbackToSavepoint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*RollbackToSavepoint) StatementTag

func (*RollbackToSavepoint) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RollbackToSavepoint) StatementType

func (*RollbackToSavepoint) StatementType() StatementType

StatementType implements the Statement interface.

func (*RollbackToSavepoint) String

func (n *RollbackToSavepoint) String() string

type RollbackTransaction

type RollbackTransaction struct{}

RollbackTransaction represents a ROLLBACK statement.

func (*RollbackTransaction) Format

func (node *RollbackTransaction) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*RollbackTransaction) StatementTag

func (*RollbackTransaction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*RollbackTransaction) StatementType

func (*RollbackTransaction) StatementType() StatementType

StatementType implements the Statement interface.

func (*RollbackTransaction) String

func (n *RollbackTransaction) String() string

type Routine added in v0.4.0

type Routine struct {
	Name Name
	Args RoutineArgs
}

Routine used for { FUNCTION | PROCEDURE | ROUTINE }

type RoutineArg added in v0.4.0

type RoutineArg struct {
	Mode    RoutineArgMode
	Name    Name
	Type    ResolvableTypeReference
	Default Expr
}

RoutineArg represents a routine argument. It can be used by FUNCTIONs and PROCEDUREs.

type RoutineArgMode added in v0.6.0

type RoutineArgMode int8
const (
	RoutineArgModeIn RoutineArgMode = iota
	RoutineArgModeVariadic
	RoutineArgModeOut
	RoutineArgModeInout
)

func (*RoutineArgMode) Format added in v0.6.0

func (node *RoutineArgMode) Format(ctx *FmtCtx)

type RoutineArgs added in v0.4.0

type RoutineArgs []*RoutineArg

func (RoutineArgs) Format added in v0.4.0

func (node RoutineArgs) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type RoutineOption added in v0.4.0

type RoutineOption struct {
	OptionType FunctionOption
	// these members cannot be defined more than once
	Language       string
	TransformTypes []ResolvableTypeReference
	Volatility     Volatility
	IsLeakProof    bool
	NullInput      NullInput
	External       bool
	Definer        bool // true if Definer, false if Invoker
	Parallel       Parallel
	Cost           Expr // positive number
	Rows           Expr // positive number
	Support        string
	SetVar         *SetVar
	Definition     string // It can be an internal function name, the path to an object file, an SQL command, or text in a procedural language.
	ObjFile        string
	LinkSymbol     string
	SqlBody        Statement

	// For ALTER { FUNCTION | PROCEDURE } use only
	ResetParam string
	ResetAll   bool
}

func (RoutineOption) Format added in v0.4.0

func (node RoutineOption) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type RoutineWithArgs added in v0.5.0

type RoutineWithArgs struct {
	Name *UnresolvedObjectName
	Args RoutineArgs
}

RoutineWithArgs represents the routine name and its arguments, if any, for DROP { FUNCTION | PROCEDURE } statement.

func (*RoutineWithArgs) Format added in v0.5.0

func (node *RoutineWithArgs) Format(ctx *FmtCtx)

type RowLevelSecurity added in v0.5.0

type RowLevelSecurity int
const (
	RowLevelSecurityDisable RowLevelSecurity = iota
	RowLevelSecurityEnable
	RowLevelSecurityForce
	RowLevelSecurityNoForce
)

type RowsFromExpr

type RowsFromExpr struct {
	Items Exprs
}

RowsFromExpr represents a ROWS FROM(...) expression.

func (*RowsFromExpr) Format

func (node *RowsFromExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type Savepoint

type Savepoint struct {
	Name Name
}

Savepoint represents a SAVEPOINT <name> statement.

func (*Savepoint) Format

func (node *Savepoint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Savepoint) StatementTag

func (*Savepoint) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Savepoint) StatementType

func (*Savepoint) StatementType() StatementType

StatementType implements the Statement interface.

func (*Savepoint) String

func (n *Savepoint) String() string

type ScalarProperties

type ScalarProperties struct {
	// SeenAggregate is set to true if the expression originally
	// contained an aggregation.
	SeenAggregate bool

	// SeenWindowApplication is set to true if the expression originally
	// contained a window function.
	SeenWindowApplication bool

	// SeenGenerator is set to true if the expression originally
	// contained a SRF.
	SeenGenerator bool

	// InWindowFunc is temporarily set to true while type checking the
	// parameters of a window function in order to reject nested window
	// functions.
	InWindowFunc bool
	// contains filtered or unexported fields
}

ScalarProperties contains the properties of the current scalar expression discovered during semantic analysis. The properties are collected prior to simplification, so some of the properties may not hold anymore by the time semantic analysis completes.

func (*ScalarProperties) Clear

func (sp *ScalarProperties) Clear()

Clear resets the scalar properties to defaults.

type Scatter

type Scatter struct {
	TableOrIndex TableIndexName
	// Optional from and to values for the columns in the PK or index (or a prefix
	// of the columns).
	// See docs/RFCS/sql_split_syntax.md.
	From, To Exprs
}

Scatter represents an `ALTER TABLE/INDEX .. SCATTER ..` statement.

func (*Scatter) Format

func (node *Scatter) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Scatter) StatementTag

func (*Scatter) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Scatter) StatementType

func (*Scatter) StatementType() StatementType

StatementType implements the Statement interface.

func (*Scatter) String

func (n *Scatter) String() string

type ScheduleCommand

type ScheduleCommand int

ScheduleCommand determines which type of action to effect on the selected job(s).

const (
	PauseSchedule ScheduleCommand = iota
	ResumeSchedule
	DropSchedule
)

ScheduleCommand values

func (ScheduleCommand) String

func (c ScheduleCommand) String() string

type ScheduleState

type ScheduleState int

ScheduleState describes what kind of schedules to display

const (
	// SpecifiedSchedules indicates that show schedules should
	// only show subset of schedules.
	SpecifiedSchedules ScheduleState = iota

	// ActiveSchedules indicates that show schedules should
	// only show those schedules that are currently active.
	ActiveSchedules

	// PausedSchedules indicates that show schedules should
	// only show those schedules that are currently paused.
	PausedSchedules
)

func (ScheduleState) Format

func (s ScheduleState) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type ScheduledBackup

type ScheduledBackup struct {
	ScheduleLabel   Expr
	Recurrence      Expr
	FullBackup      *FullBackupClause /* nil implies choose default */
	Targets         *TargetList       /* nil implies tree.AllDescriptors coverage */
	To              StringOrPlaceholderOptList
	BackupOptions   BackupOptions
	ScheduleOptions KVOptions
}

ScheduledBackup represents scheduled backup job.

func (*ScheduledBackup) Format

func (node *ScheduledBackup) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ScheduledBackup) StatementTag

func (*ScheduledBackup) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ScheduledBackup) StatementType

func (*ScheduledBackup) StatementType() StatementType

StatementType implements the Statement interface.

func (*ScheduledBackup) String

func (n *ScheduledBackup) String() string

type ScheduledJobExecutorType

type ScheduledJobExecutorType int

ScheduledJobExecutorType is a type identifying the names of the supported scheduled job executors.

const (
	// InvalidExecutor is a placeholder for an invalid executor type.
	InvalidExecutor ScheduledJobExecutorType = iota

	// ScheduledBackupExecutor is an executor responsible for
	// the execution of the scheduled backups.
	ScheduledBackupExecutor
)

func (ScheduledJobExecutorType) InternalName

func (t ScheduledJobExecutorType) InternalName() string

InternalName returns an internal executor name. This name can be used to filter matching schedules.

func (ScheduledJobExecutorType) UserName

func (t ScheduledJobExecutorType) UserName() string

UserName returns a user friendly executor name.

type SchemaLookupFlags

type SchemaLookupFlags = CommonLookupFlags

SchemaLookupFlags is the flag struct suitable for GetSchema().

type SchemaMeta

type SchemaMeta interface {
	// SchemaMeta is the interface anchor.
	SchemaMeta()
}

SchemaMeta is an opaque reference returned by LookupSchema().

type Scrub

type Scrub struct {
	Typ     ScrubType
	Options ScrubOptions
	// Table is only set during SCRUB TABLE statements.
	Table *UnresolvedObjectName
	// Database is only set during SCRUB DATABASE statements.
	Database Name
	AsOf     AsOfClause
}

Scrub represents a SCRUB statement.

func (*Scrub) Format

func (n *Scrub) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Scrub) StatementTag

func (n *Scrub) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Scrub) StatementType

func (*Scrub) StatementType() StatementType

StatementType implements the Statement interface.

func (*Scrub) String

func (n *Scrub) String() string

type ScrubOption

type ScrubOption interface {
	fmt.Stringer
	NodeFormatter
	// contains filtered or unexported methods
}

ScrubOption represents a scrub option.

type ScrubOptionConstraint

type ScrubOptionConstraint struct {
	ConstraintNames NameList
}

ScrubOptionConstraint represents a CONSTRAINT scrub check.

func (*ScrubOptionConstraint) Format

func (n *ScrubOptionConstraint) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ScrubOptionConstraint) String

func (n *ScrubOptionConstraint) String() string

type ScrubOptionIndex

type ScrubOptionIndex struct {
	IndexNames NameList
}

ScrubOptionIndex represents an INDEX scrub check.

func (*ScrubOptionIndex) Format

func (n *ScrubOptionIndex) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ScrubOptionIndex) String

func (n *ScrubOptionIndex) String() string

type ScrubOptionPhysical

type ScrubOptionPhysical struct{}

ScrubOptionPhysical represents a PHYSICAL scrub check.

func (*ScrubOptionPhysical) Format

func (n *ScrubOptionPhysical) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ScrubOptionPhysical) String

func (n *ScrubOptionPhysical) String() string

type ScrubOptions

type ScrubOptions []ScrubOption

ScrubOptions corresponds to a comma-delimited list of scrub options.

func (*ScrubOptions) Format

func (n *ScrubOptions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ScrubOptions) String

func (n *ScrubOptions) String() string

type ScrubType

type ScrubType int

ScrubType describes the SCRUB statement operation.

type Select

type Select struct {
	With    *With
	Select  SelectStatement
	OrderBy OrderBy
	Limit   *Limit
	Locking LockingClause
}

Select represents a SelectStatement with an ORDER and/or LIMIT.

func (*Select) Format

func (node *Select) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Select) StatementTag

func (*Select) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Select) StatementType

func (*Select) StatementType() StatementType

StatementType implements the Statement interface.

func (*Select) String

func (n *Select) String() string

type SelectClause

type SelectClause struct {
	Distinct    bool
	DistinctOn  DistinctOn
	Exprs       SelectExprs
	From        From
	Where       *Where
	GroupBy     GroupBy
	Having      *Where
	Window      Window
	TableSelect bool
}

SelectClause represents a SELECT statement.

func (*SelectClause) Format

func (node *SelectClause) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*SelectClause) StatementTag

func (*SelectClause) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*SelectClause) StatementType

func (*SelectClause) StatementType() StatementType

StatementType implements the Statement interface.

func (*SelectClause) String

func (n *SelectClause) String() string

type SelectExpr

type SelectExpr struct {
	Expr Expr
	As   UnrestrictedName
}

SelectExpr represents a SELECT expression.

func StarSelectExpr

func StarSelectExpr() SelectExpr

StarSelectExpr is a convenience function that represents an unqualified "*" in a select expression.

func (*SelectExpr) Format

func (node *SelectExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*SelectExpr) NormalizeTopLevelVarName

func (node *SelectExpr) NormalizeTopLevelVarName() error

NormalizeTopLevelVarName preemptively expands any UnresolvedName at the top level of the expression into a VarName. This is meant to catch stars so that sql.checkRenderStar() can see it prior to other expression transformations.

type SelectExprs

type SelectExprs []SelectExpr

SelectExprs represents SELECT expressions.

func (*SelectExprs) Format

func (node *SelectExprs) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type SelectStatement

type SelectStatement interface {
	Statement
	// contains filtered or unexported methods
}

SelectStatement represents any SELECT statement.

type SemaContext

type SemaContext struct {
	// Annotations augments the AST with extra information.
	Annotations Annotations

	// Placeholders relates placeholder names to their type and, later, value.
	Placeholders PlaceholderInfo

	// IVarContainer is used to resolve the types of IndexedVars.
	IVarContainer IndexedVarContainer

	// SearchPath indicates where to search for unqualified function
	// names. The path elements must be normalized via Name.Normalize()
	// already.
	SearchPath sessiondata.SearchPath

	// TypeResolver manages resolving type names into *types.T's.
	TypeResolver TypeReferenceResolver

	// AsOfTimestamp denotes the explicit AS OF SYSTEM TIME timestamp for the
	// query, if any. If the query is not an AS OF SYSTEM TIME query,
	// AsOfTimestamp is nil.
	// TODO(knz): we may want to support table readers at arbitrary
	// timestamps, so that each FROM clause can have its own
	// timestamp. In that case, the timestamp would not be set
	// globally for the entire txn and this field would not be needed.
	AsOfTimestamp *hlc.Timestamp

	Properties SemaProperties
}

SemaContext defines the context in which to perform semantic analysis on an expression syntax tree.

func MakeSemaContext

func MakeSemaContext() SemaContext

MakeSemaContext initializes a simple SemaContext suitable for "lightweight" type checking such as the one performed for default expressions. Note: if queries with placeholders are going to be used, SemaContext.Placeholders.Init must be called separately.

func (*SemaContext) GetTypeResolver

func (sc *SemaContext) GetTypeResolver() TypeReferenceResolver

GetTypeResolver returns the TypeReferenceResolver.

type SemaProperties

type SemaProperties struct {

	// Derived is populated during semantic analysis with properties
	// from the expression being analyzed.  The caller is responsible
	// for re-initializing this when needed.
	Derived ScalarProperties
	// contains filtered or unexported fields
}

SemaProperties is a holder for required and derived properties during semantic analysis. It provides scoping semantics via its Restore() method, see below.

func (*SemaProperties) IsSet

func (s *SemaProperties) IsSet(rejectFlags SemaRejectFlags) bool

IsSet checks if the given rejectFlag is set as a required property.

func (*SemaProperties) Require

func (s *SemaProperties) Require(context string, rejectFlags SemaRejectFlags)

Require resets the derived properties and sets required constraints.

func (*SemaProperties) Restore

func (s *SemaProperties) Restore(orig SemaProperties)

Restore restores a copy of a SemaProperties. Use with: defer semaCtx.Properties.Restore(semaCtx.Properties)

type SemaRejectFlags

type SemaRejectFlags int

SemaRejectFlags contains flags to filter out certain kinds of expressions.

const (
	// RejectAggregates rejects min(), max(), etc.
	RejectAggregates SemaRejectFlags = 1 << iota

	// RejectNestedAggregates rejects any use of aggregates inside the
	// argument list of another function call, which can itself be an aggregate
	// (RejectAggregates notwithstanding).
	RejectNestedAggregates

	// RejectNestedWindows rejects any use of window functions inside the
	// argument list of another window function.
	RejectNestedWindowFunctions

	// RejectWindowApplications rejects "x() over y", etc.
	RejectWindowApplications

	// RejectGenerators rejects any use of SRFs, e.g "generate_series()".
	RejectGenerators

	// RejectNestedGenerators rejects any use of SRFs inside the
	// argument list of another function call, which can itself be a SRF
	// (RejectGenerators notwithstanding).
	// This is used e.g. when processing the calls inside ROWS FROM.
	RejectNestedGenerators

	// RejectStableOperators rejects any stable functions or operators (including
	// casts).
	RejectStableOperators

	// RejectVolatileFunctions rejects any volatile functions.
	RejectVolatileFunctions

	// RejectSubqueries rejects subqueries in scalar contexts.
	RejectSubqueries

	// RejectSpecial is used in common places like the LIMIT clause.
	RejectSpecial = RejectAggregates | RejectGenerators | RejectWindowApplications
)

Valid values for SemaRejectFlags.

type SequenceOperators

type SequenceOperators interface {
	EvalDatabase

	// GetSerialSequenceNameFromColumn returns the sequence name for a given table and column
	// provided it is part of a SERIAL sequence.
	// Returns an empty string if the sequence name does not exist.
	GetSerialSequenceNameFromColumn(ctx context.Context, tableName *TableName, columnName Name) (*TableName, error)

	// IncrementSequence increments the given sequence and returns the result.
	// It returns an error if the given name is not a sequence.
	// The caller must ensure that seqName is fully qualified already.
	IncrementSequence(ctx context.Context, seqName *TableName) (int64, error)

	// GetLatestValueInSessionForSequence returns the value most recently obtained by
	// nextval() for the given sequence in this session.
	GetLatestValueInSessionForSequence(ctx context.Context, seqName *TableName) (int64, error)

	// SetSequenceValue sets the sequence's value.
	// If isCalled is false, the sequence is set such that the next time nextval() is called,
	// `newVal` is returned. Otherwise, the next call to nextval will return
	// `newVal + seqOpts.Increment`.
	SetSequenceValue(ctx context.Context, seqName *TableName, newVal int64, isCalled bool) error
}

SequenceOperators is used for various sql related functions that can be used from EvalContext.

type SequenceOption

type SequenceOption struct {
	Name          string
	IntVal        *int64
	OptionalWord  bool
	ColumnItemVal *ColumnItem
	AsType        ResolvableTypeReference
}

SequenceOption represents an option on a CREATE/ALTER SEQUENCE statement.

type SequenceOptions

type SequenceOptions []SequenceOption

SequenceOptions represents a list of sequence options.

func (*SequenceOptions) Format

func (node *SequenceOptions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type SetConstraints added in v0.5.0

type SetConstraints struct {
	Names    NameList
	All      bool
	Deferred bool
}

SetConstraints represents a SET CONSTRAINTS statement.

func (*SetConstraints) Format added in v0.5.0

func (node *SetConstraints) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*SetConstraints) StatementTag added in v0.5.0

func (*SetConstraints) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*SetConstraints) StatementType added in v0.5.0

func (*SetConstraints) StatementType() StatementType

StatementType implements the Statement interface.

func (*SetConstraints) String added in v0.5.0

func (n *SetConstraints) String() string

type SetRole added in v0.5.0

type SetRole struct {
	IsLocal bool
	Name    string
	None    bool
	Reset   bool
}

SetRole represents a SET ROLE ... and RESET ROLE statements.

func (*SetRole) Format added in v0.5.0

func (node *SetRole) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*SetRole) SetLocalSetStmt added in v0.5.0

func (node *SetRole) SetLocalSetStmt()

func (*SetRole) StatementTag added in v0.5.0

func (*SetRole) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*SetRole) StatementType added in v0.5.0

func (*SetRole) StatementType() StatementType

StatementType implements the Statement interface.

func (*SetRole) String added in v0.5.0

func (n *SetRole) String() string

type SetSessionAuthorization added in v0.5.0

type SetSessionAuthorization struct {
	Username string
	IsLocal  bool
}

SetSessionAuthorization represents a SET SESSION AUTHORIZATION ... statement.

func (*SetSessionAuthorization) Format added in v0.5.0

func (node *SetSessionAuthorization) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*SetSessionAuthorization) SetLocalSetStmt added in v0.5.0

func (node *SetSessionAuthorization) SetLocalSetStmt()

func (*SetSessionAuthorization) StatementTag added in v0.5.0

func (*SetSessionAuthorization) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*SetSessionAuthorization) StatementType added in v0.5.0

func (*SetSessionAuthorization) StatementType() StatementType

StatementType implements the Statement interface.

func (*SetSessionAuthorization) String added in v0.5.0

func (n *SetSessionAuthorization) String() string

type SetSessionCharacteristics

type SetSessionCharacteristics struct {
	Modes TransactionModes
}

SetSessionCharacteristics represents a SET SESSION CHARACTERISTICS AS TRANSACTION statement.

func (*SetSessionCharacteristics) Format

func (node *SetSessionCharacteristics) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*SetSessionCharacteristics) StatementTag

func (*SetSessionCharacteristics) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*SetSessionCharacteristics) StatementType

func (*SetSessionCharacteristics) StatementType() StatementType

StatementType implements the Statement interface.

func (*SetSessionCharacteristics) String

func (n *SetSessionCharacteristics) String() string

type SetStmt added in v0.5.0

type SetStmt interface {
	NodeFormatter
	SetLocalSetStmt()
}

SetStmt represents a set statement that has [ SESSION | LOCAL ] setting option. It is used to set the |node.IsLocal| to true if LOCAL clause is defined.

type SetTransaction

type SetTransaction struct {
	Modes TransactionModes
}

SetTransaction represents a SET TRANSACTION statement.

func (*SetTransaction) Format

func (node *SetTransaction) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*SetTransaction) StatementTag

func (*SetTransaction) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*SetTransaction) StatementType

func (*SetTransaction) StatementType() StatementType

StatementType implements the Statement interface.

func (*SetTransaction) String

func (n *SetTransaction) String() string

type SetVar

type SetVar struct {
	IsLocal bool
	Name    string
	Values  Exprs
	// FromCurrent is used for SET clauses in CREATE statements only.
	FromCurrent bool
}

SetVar represents a SET or RESET <configuration_param> statement.

func (*SetVar) Format

func (node *SetVar) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*SetVar) SetLocalSetStmt added in v0.5.0

func (node *SetVar) SetLocalSetStmt()

func (*SetVar) StatementTag

func (*SetVar) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*SetVar) StatementType

func (*SetVar) StatementType() StatementType

StatementType implements the Statement interface.

func (*SetVar) String

func (n *SetVar) String() string

type ShowBackup

type ShowBackup struct {
	Path                 Expr
	InCollection         Expr
	Details              BackupDetails
	ShouldIncludeSchemas bool
	Options              KVOptions
}

ShowBackup represents a SHOW BACKUP statement.

func (*ShowBackup) Format

func (node *ShowBackup) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowBackup) StatementTag

func (*ShowBackup) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowBackup) StatementType

func (*ShowBackup) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowBackup) String

func (n *ShowBackup) String() string

type ShowColumns

type ShowColumns struct {
	Table       *UnresolvedObjectName
	WithComment bool
}

ShowColumns represents a SHOW COLUMNS statement.

func (*ShowColumns) Format

func (node *ShowColumns) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowColumns) StatementTag

func (*ShowColumns) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowColumns) StatementType

func (*ShowColumns) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowColumns) String

func (n *ShowColumns) String() string

type ShowConstraints

type ShowConstraints struct {
	Table *UnresolvedObjectName
}

ShowConstraints represents a SHOW CONSTRAINTS statement.

func (*ShowConstraints) Format

func (node *ShowConstraints) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowConstraints) StatementTag

func (*ShowConstraints) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowConstraints) StatementType

func (*ShowConstraints) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowConstraints) String

func (n *ShowConstraints) String() string

type ShowCreate

type ShowCreate struct {
	Name *UnresolvedObjectName
}

ShowCreate represents a SHOW CREATE statement.

func (*ShowCreate) Format

func (node *ShowCreate) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowCreate) StatementTag

func (*ShowCreate) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowCreate) StatementType

func (*ShowCreate) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowCreate) String

func (n *ShowCreate) String() string

type ShowDatabaseIndexes

type ShowDatabaseIndexes struct {
	Database    Name
	WithComment bool
}

ShowDatabaseIndexes represents a SHOW INDEXES FROM DATABASE statement.

func (*ShowDatabaseIndexes) Format

func (node *ShowDatabaseIndexes) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowDatabaseIndexes) StatementTag

func (*ShowDatabaseIndexes) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowDatabaseIndexes) StatementType

func (*ShowDatabaseIndexes) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowDatabaseIndexes) String

func (n *ShowDatabaseIndexes) String() string

type ShowDatabases

type ShowDatabases struct {
	WithComment bool
}

ShowDatabases represents a SHOW DATABASES statement.

func (*ShowDatabases) Format

func (node *ShowDatabases) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowDatabases) StatementTag

func (*ShowDatabases) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowDatabases) StatementType

func (*ShowDatabases) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowDatabases) String

func (n *ShowDatabases) String() string

type ShowEnums

type ShowEnums struct{}

ShowEnums represents a SHOW ENUMS statement.

func (*ShowEnums) Format

func (node *ShowEnums) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowEnums) StatementTag

func (*ShowEnums) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowEnums) StatementType

func (*ShowEnums) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowEnums) String

func (n *ShowEnums) String() string

type ShowFingerprints

type ShowFingerprints struct {
	Table *UnresolvedObjectName
}

ShowFingerprints represents a SHOW EXPERIMENTAL_FINGERPRINTS statement.

func (*ShowFingerprints) Format

func (node *ShowFingerprints) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowFingerprints) StatementTag

func (*ShowFingerprints) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowFingerprints) StatementType

func (*ShowFingerprints) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowFingerprints) String

func (n *ShowFingerprints) String() string

type ShowGrants

type ShowGrants struct {
	Targets  *TargetList
	Grantees NameList
}

ShowGrants represents a SHOW GRANTS statement. TargetList is defined in grant.go.

func (*ShowGrants) Format

func (node *ShowGrants) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowGrants) StatementTag

func (*ShowGrants) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowGrants) StatementType

func (*ShowGrants) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowGrants) String

func (n *ShowGrants) String() string

type ShowHistogram

type ShowHistogram struct {
	HistogramID int64
}

ShowHistogram represents a SHOW HISTOGRAM statement.

func (*ShowHistogram) Format

func (node *ShowHistogram) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowHistogram) StatementTag

func (*ShowHistogram) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowHistogram) StatementType

func (*ShowHistogram) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowHistogram) String

func (n *ShowHistogram) String() string

type ShowIndexes

type ShowIndexes struct {
	Table       *UnresolvedObjectName
	WithComment bool
}

ShowIndexes represents a SHOW INDEX statement.

func (*ShowIndexes) Format

func (node *ShowIndexes) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowIndexes) StatementTag

func (*ShowIndexes) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowIndexes) StatementType

func (*ShowIndexes) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowIndexes) String

func (n *ShowIndexes) String() string

type ShowJobs

type ShowJobs struct {
	// If non-nil, a select statement that provides the job ids to be shown.
	Jobs *Select

	// If Automatic is true, show only automatically-generated jobs such
	// as automatic CREATE STATISTICS jobs. If Automatic is false, show
	// only non-automatically-generated jobs.
	Automatic bool

	// Whether to block and wait for completion of all running jobs to be displayed.
	Block bool

	// If non-nil, only display jobs started by the specified
	// schedules.
	Schedules *Select
}

ShowJobs represents a SHOW JOBS statement

func (*ShowJobs) Format

func (node *ShowJobs) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowJobs) StatementTag

func (*ShowJobs) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowJobs) StatementType

func (*ShowJobs) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowJobs) String

func (n *ShowJobs) String() string

type ShowLastQueryStatistics

type ShowLastQueryStatistics struct{}

ShowLastQueryStatistics represents a SHOW LAST QUERY STATS statement.

func (*ShowLastQueryStatistics) Format

func (node *ShowLastQueryStatistics) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowLastQueryStatistics) StatementTag

func (*ShowLastQueryStatistics) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowLastQueryStatistics) StatementType

func (*ShowLastQueryStatistics) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowLastQueryStatistics) String

func (n *ShowLastQueryStatistics) String() string

type ShowPartitions

type ShowPartitions struct {
	IsDB     bool
	Database Name

	IsIndex bool
	Index   TableIndexName

	IsTable bool
	Table   *UnresolvedObjectName
}

ShowPartitions represents a SHOW PARTITIONS statement.

func (*ShowPartitions) Format

func (node *ShowPartitions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowPartitions) StatementTag

func (*ShowPartitions) StatementTag() string

StatementTag returns a short string identifying the type of the statement.

func (*ShowPartitions) StatementType

func (*ShowPartitions) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowPartitions) String

func (n *ShowPartitions) String() string

type ShowQueries

type ShowQueries struct {
	All     bool
	Cluster bool
}

ShowQueries represents a SHOW QUERIES statement.

func (*ShowQueries) Format

func (node *ShowQueries) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowQueries) StatementTag

func (*ShowQueries) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowQueries) StatementType

func (*ShowQueries) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowQueries) String

func (n *ShowQueries) String() string

type ShowRoleGrants

type ShowRoleGrants struct {
	Roles    NameList
	Grantees NameList
}

ShowRoleGrants represents a SHOW GRANTS ON ROLE statement.

func (*ShowRoleGrants) Format

func (node *ShowRoleGrants) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowRoleGrants) StatementTag

func (*ShowRoleGrants) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowRoleGrants) StatementType

func (*ShowRoleGrants) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowRoleGrants) String

func (n *ShowRoleGrants) String() string

type ShowRoles

type ShowRoles struct {
}

ShowRoles represents a SHOW ROLES statement.

func (*ShowRoles) Format

func (node *ShowRoles) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowRoles) StatementTag

func (*ShowRoles) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowRoles) StatementType

func (*ShowRoles) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowRoles) String

func (n *ShowRoles) String() string

type ShowSavepointStatus

type ShowSavepointStatus struct {
}

ShowSavepointStatus represents a SHOW SAVEPOINT STATUS statement.

func (*ShowSavepointStatus) Format

func (node *ShowSavepointStatus) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowSavepointStatus) StatementTag

func (*ShowSavepointStatus) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowSavepointStatus) StatementType

func (*ShowSavepointStatus) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowSavepointStatus) String

func (n *ShowSavepointStatus) String() string

type ShowSchedules

type ShowSchedules struct {
	WhichSchedules ScheduleState
	ExecutorType   ScheduledJobExecutorType
	ScheduleID     Expr
}

ShowSchedules represents a SHOW SCHEDULES statement.

func (*ShowSchedules) Format

func (n *ShowSchedules) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowSchedules) StatementTag

func (*ShowSchedules) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowSchedules) StatementType

func (*ShowSchedules) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowSchedules) String

func (n *ShowSchedules) String() string

type ShowSchemas

type ShowSchemas struct {
	Database Name
}

ShowSchemas represents a SHOW SCHEMAS statement.

func (*ShowSchemas) Format

func (node *ShowSchemas) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowSchemas) StatementTag

func (*ShowSchemas) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowSchemas) StatementType

func (*ShowSchemas) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowSchemas) String

func (n *ShowSchemas) String() string

type ShowSequences

type ShowSequences struct {
	Database Name
}

ShowSequences represents a SHOW SEQUENCES statement.

func (*ShowSequences) Format

func (node *ShowSequences) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowSequences) StatementTag

func (*ShowSequences) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowSequences) StatementType

func (*ShowSequences) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowSequences) String

func (n *ShowSequences) String() string

type ShowSessions

type ShowSessions struct {
	All     bool
	Cluster bool
}

ShowSessions represents a SHOW SESSIONS statement

func (*ShowSessions) Format

func (node *ShowSessions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowSessions) StatementTag

func (*ShowSessions) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowSessions) StatementType

func (*ShowSessions) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowSessions) String

func (n *ShowSessions) String() string

type ShowSyntax

type ShowSyntax struct {
	Statement string
}

ShowSyntax represents a SHOW SYNTAX statement. This the most lightweight thing that can be done on a statement server-side: just report the statement that was entered without any processing. Meant for use for syntax checking on clients, when the client version might differ from the server.

func (*ShowSyntax) Format

func (node *ShowSyntax) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowSyntax) StatementTag

func (*ShowSyntax) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowSyntax) StatementType

func (*ShowSyntax) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowSyntax) String

func (n *ShowSyntax) String() string

type ShowTableStats

type ShowTableStats struct {
	Table     *UnresolvedObjectName
	UsingJSON bool
}

ShowTableStats represents a SHOW STATISTICS FOR TABLE statement.

func (*ShowTableStats) Format

func (node *ShowTableStats) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowTableStats) StatementTag

func (*ShowTableStats) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowTableStats) StatementType

func (*ShowTableStats) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowTableStats) String

func (n *ShowTableStats) String() string

type ShowTables

type ShowTables struct {
	ObjectNamePrefix
	WithComment bool
}

ShowTables represents a SHOW TABLES statement.

func (*ShowTables) Format

func (node *ShowTables) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowTables) StatementTag

func (*ShowTables) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowTables) StatementType

func (*ShowTables) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowTables) String

func (n *ShowTables) String() string

type ShowTraceForSession

type ShowTraceForSession struct {
	TraceType ShowTraceType
	Compact   bool
}

ShowTraceForSession represents a SHOW TRACE FOR SESSION statement.

func (*ShowTraceForSession) Format

func (node *ShowTraceForSession) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowTraceForSession) StatementTag

func (*ShowTraceForSession) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowTraceForSession) StatementType

func (*ShowTraceForSession) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowTraceForSession) String

func (n *ShowTraceForSession) String() string

type ShowTraceType

type ShowTraceType string

ShowTraceType is an enum of SHOW TRACE variants.

const (
	ShowTraceRaw     ShowTraceType = "TRACE"
	ShowTraceKV      ShowTraceType = "KV TRACE"
	ShowTraceReplica ShowTraceType = "EXPERIMENTAL_REPLICA TRACE"
)

A list of the SHOW TRACE variants.

type ShowTransactionStatus

type ShowTransactionStatus struct {
}

ShowTransactionStatus represents a SHOW TRANSACTION STATUS statement.

func (*ShowTransactionStatus) Format

func (node *ShowTransactionStatus) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowTransactionStatus) StatementTag

func (*ShowTransactionStatus) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowTransactionStatus) StatementType

func (*ShowTransactionStatus) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowTransactionStatus) String

func (n *ShowTransactionStatus) String() string

type ShowTransactions

type ShowTransactions struct {
	All     bool
	Cluster bool
}

ShowTransactions represents a SHOW TRANSACTIONS statement

func (*ShowTransactions) Format

func (node *ShowTransactions) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowTransactions) StatementTag

func (*ShowTransactions) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowTransactions) StatementType

func (*ShowTransactions) StatementType() StatementType

StatementType implements the Statement interface

func (*ShowTransactions) String

func (n *ShowTransactions) String() string

type ShowTypes

type ShowTypes struct{}

ShowTypes represents a SHOW TYPES statement.

func (*ShowTypes) Format

func (node *ShowTypes) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowTypes) StatementTag

func (*ShowTypes) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowTypes) StatementType

func (*ShowTypes) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowTypes) String

func (n *ShowTypes) String() string

type ShowUsers

type ShowUsers struct {
}

ShowUsers represents a SHOW USERS statement.

func (*ShowUsers) Format

func (node *ShowUsers) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowUsers) StatementTag

func (*ShowUsers) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowUsers) StatementType

func (*ShowUsers) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowUsers) String

func (n *ShowUsers) String() string

type ShowVar

type ShowVar struct {
	Name string
}

ShowVar represents a SHOW statement.

func (*ShowVar) Format

func (node *ShowVar) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ShowVar) StatementTag

func (*ShowVar) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ShowVar) StatementType

func (*ShowVar) StatementType() StatementType

StatementType implements the Statement interface.

func (*ShowVar) String

func (n *ShowVar) String() string

type SimpleColumnDef added in v0.4.0

type SimpleColumnDef struct {
	Name Name
	Type ResolvableTypeReference
}

type SimpleVisitFn

type SimpleVisitFn func(expr Expr) (recurse bool, newExpr Expr, err error)

SimpleVisitFn is a function that is run for every node in the VisitPre stage; see SimpleVisit.

type SpecializedVectorizedBuiltin

type SpecializedVectorizedBuiltin int

SpecializedVectorizedBuiltin is used to map overloads to the vectorized operator that is specific to that implementation of the builtin function.

const (
	SubstringStringIntInt SpecializedVectorizedBuiltin
)

Keep this list alphabetized so that it is easy to manage.

type Split

type Split struct {
	TableOrIndex TableIndexName
	// Each row contains values for the columns in the PK or index (or a prefix
	// of the columns).
	Rows *Select
	// Splits can last a specified amount of time before becoming eligible for
	// automatic merging.
	ExpireExpr Expr
}

Split represents an `ALTER TABLE/INDEX .. SPLIT AT ..` statement.

func (*Split) Format

func (node *Split) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Split) StatementTag

func (*Split) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Split) StatementType

func (*Split) StatementType() StatementType

StatementType implements the Statement interface.

func (*Split) String

func (n *Split) String() string

type Statement

type Statement interface {
	fmt.Stringer
	NodeFormatter
	StatementType() StatementType
	// StatementTag is a short string identifying the type of statement
	// (usually a single verb). This is different than the Stringer output,
	// which is the actual statement (including args).
	// TODO(dt): Currently tags are always pg-compatible in the future it
	// might make sense to pass a tag format specifier.
	StatementTag() string
}

Statement represents a statement.

func MakeExplain

func MakeExplain(options []string, stmt Statement) (Statement, error)

MakeExplain parses the EXPLAIN option strings and generates an explain statement.

type StatementSource

type StatementSource struct {
	Statement Statement
}

StatementSource encapsulates one of the other statements as a data source.

func (*StatementSource) Format

func (node *StatementSource) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type StatementType

type StatementType int

StatementType is the enumerated type for Statement return styles on the wire.

const (
	// Ack indicates that the statement does not have a meaningful
	// return. Examples include SET, BEGIN, COMMIT.
	Ack StatementType = iota
	// DDL indicates that the statement mutates the database schema.
	//
	// Note: this is the type indicated back to the client; it is not a
	// sufficient test for schema mutation for planning purposes. There
	// are schema-modifying statements (e.g. CREATE TABLE AS) which
	// report RowsAffected to the client, not DDL.
	// Use CanModifySchema() below instead.
	DDL
	// RowsAffected indicates that the statement returns the count of
	// affected rows.
	RowsAffected
	// Rows indicates that the statement returns the affected rows after
	// the statement was applied.
	Rows
	// CopyIn indicates a COPY FROM statement.
	CopyIn
	// Unknown indicates that the statement does not have a known
	// return style at the time of parsing. This is not first in the
	// enumeration because it is more convenient to have Ack as a zero
	// value, and because the use of Unknown should be an explicit choice.
	// The primary example of this statement type is EXECUTE, where the
	// statement type depends on the statement type of the prepared statement
	// being executed.
	Unknown
)

func (StatementType) String

func (i StatementType) String() string

type StorageParam

type StorageParam struct {
	Key   Name
	Value Expr
}

StorageParam is a key-value parameter for table storage.

type StorageParams

type StorageParams []StorageParam

StorageParams is a list of StorageParams.

func (*StorageParams) Format

func (o *StorageParams) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type StorageType added in v0.5.0

type StorageType int
const (
	StoragePlain StorageType = iota
	StorageExternal
	StorageExtended
	StorageMain
)

type StrVal

type StrVal struct {
	// contains filtered or unexported fields
}

StrVal represents a constant string value.

func NewBytesStrVal

func NewBytesStrVal(s string) *StrVal

NewBytesStrVal constructs a StrVal instance suitable as byte array. This is used during parsing when interpreting a token of type BCONST, i.e. using the b'...' or x'...' syntax.

func NewStrVal

func NewStrVal(s string) *StrVal

NewStrVal constructs a StrVal instance. This is used during parsing when interpreting a token of type SCONST, i.e. *not* using the b'...' or x'...' syntax.

func (*StrVal) AvailableTypes

func (expr *StrVal) AvailableTypes() []*types.T

AvailableTypes implements the Constant interface.

To fully take advantage of literal type inference, this method would determine exactly which types are available for a given string. This would entail attempting to parse the literal string as a date, a timestamp, an interval, etc. and having more fine-grained results than StrValAvailAllParsable. However, this is not feasible in practice because of the associated parsing overhead.

Conservative approaches like checking the string's length have been investigated to reduce ambiguity and improve type inference in some cases. When doing so, the length of the string literal was compared against all valid date and timestamp formats to quickly gain limited insight into whether parsing the string as the respective datum types could succeed. The hope was to eliminate impossibilities and constrain the returned type sets as much as possible. Unfortunately, two issues were found with this approach:

  • date and timestamp formats do not always imply a fixed-length valid input. For instance, timestamp formats that take fractional seconds can successfully parse inputs of varied length.
  • the set of date and timestamp formats are not disjoint, which means that ambiguity can not be eliminated when inferring the type of string literals that use these shared formats.

While these limitations still permitted improved type inference in many cases, they resulted in behavior that was ultimately incomplete, resulted in unpredictable levels of inference, and occasionally failed to eliminate ambiguity. Further heuristics could have been applied to improve the accuracy of the inference, like checking that all or some characters were digits, but it would not have circumvented the fundamental issues here. Fully parsing the literal into each type would be the only way to concretely avoid the issue of unpredictable inference behavior.

func (*StrVal) DesirableTypes

func (expr *StrVal) DesirableTypes() []*types.T

DesirableTypes implements the Constant interface.

func (*StrVal) Format

func (expr *StrVal) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*StrVal) RawString

func (expr *StrVal) RawString() string

RawString retrieves the underlying string of the StrVal.

func (*StrVal) ResolveAsType

func (expr *StrVal) ResolveAsType(
	ctx context.Context, semaCtx *SemaContext, typ *types.T,
) (TypedExpr, error)

ResolveAsType implements the Constant interface.

func (*StrVal) String

func (node *StrVal) String() string

func (*StrVal) TypeCheck

func (expr *StrVal) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*StrVal) Walk

func (expr *StrVal) Walk(_ Visitor) Expr

Walk implements the Expr interface.

func (*StrVal) WasScannedAsBytes added in v0.2.0

func (expr *StrVal) WasScannedAsBytes() bool

WasScannedAsBytes returns true iff the input syntax was using b'...' or x'....'

type StringOrPlaceholderOptList

type StringOrPlaceholderOptList []Expr

StringOrPlaceholderOptList is a list of strings or placeholders.

func (*StringOrPlaceholderOptList) Format

func (node *StringOrPlaceholderOptList) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type Subquery

type Subquery struct {
	Select SelectStatement
	Exists bool

	// Idx is a query-unique index for the subquery.
	// Subqueries are 1-indexed to ensure that the default
	// value 0 can be used to detect uninitialized subqueries.
	Idx int
	// contains filtered or unexported fields
}

Subquery represents a subquery.

func (*Subquery) Format

func (node *Subquery) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (Subquery) HasResolvedType added in v0.6.0

func (ta Subquery) HasResolvedType() bool

func (Subquery) ResolvedType

func (ta Subquery) ResolvedType() *types.T

func (*Subquery) SetType

func (node *Subquery) SetType(t *types.T)

SetType forces the type annotation on the Subquery node.

func (*Subquery) String

func (node *Subquery) String() string

func (*Subquery) SubqueryExpr

func (*Subquery) SubqueryExpr()

SubqueryExpr implements the SubqueryExpr interface.

func (*Subquery) TypeCheck

func (expr *Subquery) TypeCheck(_ context.Context, sc *SemaContext, _ *types.T) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*Subquery) Variable

func (*Subquery) Variable()

Variable implements the VariableExpr interface.

func (*Subquery) Walk

func (expr *Subquery) Walk(v Visitor) Expr

Walk implements the Expr interface.

type SubqueryExpr

type SubqueryExpr interface {
	Expr
	SubqueryExpr()
}

SubqueryExpr is an interface used to identify an expression as a subquery. It is implemented by both tree.Subquery and optbuilder.subquery, and is used in TypeCheck.

type TableDef

type TableDef interface {
	NodeFormatter
	// contains filtered or unexported methods
}

TableDef represents a column, index or constraint definition within a CREATE TABLE statement.

type TableDefs

type TableDefs []TableDef

TableDefs represents a list of table definitions.

func ConvertIdxElemsToTblDefsForColumnNameOnly added in v0.5.0

func ConvertIdxElemsToTblDefsForColumnNameOnly(idxElems IndexElemList) TableDefs

ConvertIdxElemsToTblDefsForColumnNameOnly converts given IndexElemList that holds column names only to TableDefs that holds column names only.

func (*TableDefs) Format

func (node *TableDefs) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type TableExpr

type TableExpr interface {
	NodeFormatter
	// contains filtered or unexported methods
}

TableExpr represents a table expression.

func StripTableParens

func StripTableParens(expr TableExpr) TableExpr

StripTableParens strips any parentheses surrounding a selection clause.

type TableExprs

type TableExprs []TableExpr

TableExprs represents a list of table expressions.

func (*TableExprs) Format

func (node *TableExprs) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type TableIndexName

type TableIndexName struct {
	Table TableName
	Index UnrestrictedName
}

TableIndexName refers to a table index. There are a few cases:

  • if both the table name and the index name are set, refers to a specific index in a specific table.

  • if the table name is set and index name is empty, refers to the primary index of that table.

  • if the table name is empty and the index name is set, refers to an index of that name among all tables within a catalog/schema; if there is a duplicate name, that will result in an error. Note that it is possible to specify the schema or catalog without specifying a table name; in this case, Table.ObjectNamePrefix has the fields set but Table.ObjectName is empty.

func (*TableIndexName) Format

func (n *TableIndexName) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*TableIndexName) String

func (n *TableIndexName) String() string

type TableIndexNames

type TableIndexNames []*TableIndexName

TableIndexNames is a list of indexes.

func (*TableIndexNames) Format

func (n *TableIndexNames) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type TableName

type TableName struct {
	// contains filtered or unexported fields
}

TableName corresponds to the name of a table in a FROM clause, INSERT or UPDATE statement, etc.

This is constructed for incoming SQL queries from an UnresolvedObjectName,

Internal uses of this struct should not construct instances of TableName directly, and instead use the NewTableName / MakeTableName functions underneath.

TableName is a public type for objName. It exposes the fields and can be default-constructed but cannot be instantiated with a non-default value; this encourages the use of the constructors below.

func MakeTableName

func MakeTableName(db, tbl Name) TableName

MakeTableName creates a new table name qualified with just a schema.

func MakeTableNameFromPrefix

func MakeTableNameFromPrefix(prefix ObjectNamePrefix, object Name) TableName

MakeTableNameFromPrefix creates a table name from an unqualified name and a resolved prefix.

func MakeTableNameWithSchema

func MakeTableNameWithSchema(db, schema, tbl Name) TableName

MakeTableNameWithSchema creates a new fully qualified table name.

func MakeUnqualifiedTableName

func MakeUnqualifiedTableName(tbl Name) TableName

MakeUnqualifiedTableName creates a new base table name.

func NewTableName

func NewTableName(db, tbl Name) *TableName

NewTableName creates a new table name qualified with a given catalog and the public schema.

func NewUnqualifiedTableName

func NewUnqualifiedTableName(tbl Name) *TableName

NewUnqualifiedTableName creates a new base table name.

func (*TableName) Equals

func (t *TableName) Equals(other *TableName) bool

Equals returns true if the two table names are identical (including the ExplicitSchema/ExplicitCatalog flags).

func (*TableName) FQString

func (t *TableName) FQString() string

FQString renders the table name in full, not omitting the prefix schema and catalog names. Suitable for logging, etc.

func (*TableName) Format

func (t *TableName) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*TableName) NormalizeTablePattern

func (t *TableName) NormalizeTablePattern() (TablePattern, error)

NormalizeTablePattern implements the TablePattern interface.

func (*TableName) Object

func (o *TableName) Object() string

func (*TableName) String

func (t *TableName) String() string

func (*TableName) Table

func (t *TableName) Table() string

Table retrieves the unqualified table name.

func (*TableName) ToUnresolvedObjectName

func (o *TableName) ToUnresolvedObjectName() *UnresolvedObjectName

ToUnresolvedObjectName converts the type name to an unresolved object name. Schema and catalog are included if indicated by the ExplicitSchema and ExplicitCatalog flags.

type TableNames

type TableNames []TableName

TableNames represents a comma separated list (see the Format method) of table names.

func (*TableNames) Format

func (ts *TableNames) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*TableNames) String

func (ts *TableNames) String() string

type TablePattern

type TablePattern interface {
	fmt.Stringer
	NodeFormatter

	// NormalizeTablePattern() guarantees to return a pattern that is
	// not an UnresolvedName. This converts the UnresolvedName to an
	// AllTablesSelector or TableName as necessary.
	NormalizeTablePattern() (TablePattern, error)
}

TablePattern is the common interface to UnresolvedName, TableName and AllTablesSelector.

type TablePatterns

type TablePatterns []TablePattern

TablePatterns implement a comma-separated list of table patterns. Used by e.g. the GRANT statement.

func (*TablePatterns) Format

func (tt *TablePatterns) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type TableRef

type TableRef struct {
	// TableID is the descriptor ID of the requested table.
	TableID int64

	// ColumnIDs is the list of column IDs requested in the table.
	// Note that a nil array here means "unspecified" (all columns)
	// whereas an array of length 0 means "zero columns".
	// Lists of zero columns are not supported and will throw an error.
	Columns []ColumnID

	// As determines the names that can be used in the surrounding query
	// to refer to this source.
	As AliasClause
}

TableRef represents a numeric table reference. (Syntax !NNN in SQL.)

func (*TableRef) Format

func (n *TableRef) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*TableRef) String

func (n *TableRef) String() string

type TargetList

type TargetList struct {
	TargetType privilege.ObjectType
	InSchema   []string // used with ALL only

	Tables           TablePatterns
	TableColumnNames NameList
	Sequences        NameList
	Databases        NameList
	LargeObjects     []Expr
	Routines         []Routine
	Parameters       NameList
	Types            []*UnresolvedObjectName
	// domains, foreign data wrappers, foreign servers, languages,
	// parameters, schemas, tablespaces are using string for name definition
	Names []string

	// ForRoles and Roles are used internally in the parser and not used
	// in the AST. Therefore they do not participate in pretty-printing,
	// etc.
	ForRoles bool
	Roles    NameList
}

TargetList represents a list of targets. Only one field may be non-nil.

func (*TargetList) Format

func (tl *TargetList) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type TenantOperator

type TenantOperator interface {
	// CreateTenant attempts to install a new tenant in the system. It returns
	// an error if the tenant already exists.
	CreateTenant(ctx context.Context, tenantID uint64, tenantInfo []byte) error

	// DestroyTenant attempts to uninstall an existing tenant from the system.
	// It returns an error if the tenant does not exist.
	DestroyTenant(ctx context.Context, tenantID uint64) error
}

TenantOperator is capable of interacting with tenant state, allowing SQL builtin functions to create and destroy tenants. The methods will return errors when run by any tenant other than the system tenant.

type TestingMapTypeResolver

type TestingMapTypeResolver struct {
	// contains filtered or unexported fields
}

TestingMapTypeResolver is a fake type resolver for testing purposes.

func (*TestingMapTypeResolver) ResolveType

func (dtr *TestingMapTypeResolver) ResolveType(
	_ context.Context, name *UnresolvedObjectName,
) (*types.T, error)

ResolveType implements the TypeReferenceResolver interface.

func (*TestingMapTypeResolver) ResolveTypeByOID

func (dtr *TestingMapTypeResolver) ResolveTypeByOID(context.Context, oid.Oid) (*types.T, error)

ResolveTypeByOID implements the TypeReferenceResolver interface.

type TransactionModes

type TransactionModes struct {
	Isolation     IsolationLevel
	UserPriority  UserPriority
	ReadWriteMode ReadWriteMode
	AsOf          AsOfClause
	Deferrable    DeferrableMode
}

TransactionModes holds the transaction modes for a transaction.

func (*TransactionModes) Format

func (node *TransactionModes) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*TransactionModes) Merge

func (node *TransactionModes) Merge(other TransactionModes) error

Merge groups two sets of transaction modes together. Used in the parser.

type TriggerDeferrableMode added in v0.5.0

type TriggerDeferrableMode int
const (
	// TriggerDeferrable is used for { DEFERRABLE [ INITIALLY IMMEDIATE ] }
	TriggerDeferrable TriggerDeferrableMode = iota
	// TriggerNotDeferrable is used as default when not specified and for { NOT DEFERRABLE }
	// Validation cannot be specified as it's always INITIALLY IMMEDIATE for not deferrable constraint.
	TriggerNotDeferrable
	// TriggerInitiallyDeferred is used for { [ DEFERRABLE ] INITIALLY DEFERRED }
	TriggerInitiallyDeferred
)

type TriggerEvent added in v0.5.0

type TriggerEvent struct {
	Type TriggerEventType
	Cols NameList // used only for UPDATE event type
}

type TriggerEventType added in v0.5.0

type TriggerEventType int
const (
	TriggerEventInsert TriggerEventType = iota
	TriggerEventUpdate
	TriggerEventDelete
	TriggerEventTruncate
)

type TriggerEvents added in v0.5.0

type TriggerEvents []TriggerEvent

func (TriggerEvents) Format added in v0.5.0

func (node TriggerEvents) Format(ctx *FmtCtx)

type TriggerRelation added in v0.5.0

type TriggerRelation struct {
	IsOld bool
	Name  string
}

TriggerRelation describes { { OLD | NEW } TABLE [ AS ] transition_relation_name }

type TriggerRelations added in v0.5.0

type TriggerRelations []TriggerRelation

func (TriggerRelations) Format added in v0.5.0

func (t TriggerRelations) Format(ctx *FmtCtx)

type TriggerTime added in v0.5.0

type TriggerTime int
const (
	TriggerTimeBefore TriggerTime = iota
	TriggerTimeAfter
	TriggerTimeInsteadOf
)

type Truncate

type Truncate struct {
	Tables       TableNames
	DropBehavior DropBehavior
}

Truncate represents a TRUNCATE statement.

func (*Truncate) Format

func (node *Truncate) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Truncate) StatementTag

func (*Truncate) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Truncate) StatementType

func (*Truncate) StatementType() StatementType

StatementType implements the Statement interface.

func (*Truncate) String

func (n *Truncate) String() string

type Tuple

type Tuple struct {
	Exprs  Exprs
	Labels []string

	// Row indicates whether `ROW` was used in the input syntax. This is
	// used solely to generate column names automatically, see
	// col_name.go.
	Row bool
	// contains filtered or unexported fields
}

Tuple represents a parenthesized list of expressions.

func NewTypedTuple

func NewTypedTuple(typ *types.T, typedExprs Exprs) *Tuple

NewTypedTuple returns a new Tuple that is verified to be well-typed.

func (*Tuple) Format

func (node *Tuple) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Tuple) ResolvedType

func (node *Tuple) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*Tuple) String

func (node *Tuple) String() string

func (*Tuple) TypeCheck

func (expr *Tuple) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*Tuple) Walk

func (expr *Tuple) Walk(v Visitor) Expr

Walk implements the Expr interface.

type TupleStar

type TupleStar struct {
	Expr Expr
}

TupleStar represents (E).* expressions. It is meant to evaporate during star expansion.

func (*TupleStar) Format

func (node *TupleStar) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*TupleStar) NormalizeVarName

func (node *TupleStar) NormalizeVarName() (VarName, error)

NormalizeVarName implements the VarName interface.

func (*TupleStar) ResolvedType

func (expr *TupleStar) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*TupleStar) String

func (node *TupleStar) String() string

func (*TupleStar) TypeCheck

func (expr *TupleStar) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*TupleStar) Walk

func (expr *TupleStar) Walk(v Visitor) Expr

Walk implements the Expr interface.

type TypeCollectorVisitor

type TypeCollectorVisitor struct {
	OIDs map[oid.Oid]struct{}
}

TypeCollectorVisitor is an expression visitor that collects all explicit OID type references in an expression.

func (*TypeCollectorVisitor) VisitPost

func (v *TypeCollectorVisitor) VisitPost(e Expr) Expr

VisitPost implements the Visitor interface.

func (*TypeCollectorVisitor) VisitPre

func (v *TypeCollectorVisitor) VisitPre(expr Expr) (bool, Expr)

VisitPre implements the Visitor interface.

type TypeList

type TypeList interface {
	// Match checks if all types in the TypeList match the corresponding elements in types.
	Match(types []*types.T) bool
	// MatchAt checks if the parameter type at index i of the TypeList matches type typ.
	// In all implementations, types.Null will match with each parameter type, allowing
	// NULL values to be used as arguments.
	MatchAt(typ *types.T, i int) bool
	// matchLen checks that the TypeList can support l parameters.
	MatchLen(l int) bool
	// getAt returns the type at the given index in the TypeList, or nil if the TypeList
	// cannot have a parameter at index i.
	GetAt(i int) *types.T
	// Length returns the number of types in the list
	Length() int
	// Types returns a realized copy of the list. variadic lists return a list of size one.
	Types() []*types.T
	// String returns a human readable signature
	String() string
}

TypeList is a list of types representing a function parameter list.

type TypeName

type TypeName struct {
	// contains filtered or unexported fields
}

TypeName corresponds to the name of a type in a CREATE TYPE statement, in an expression, or column type etc.

Users of this struct should not construct it directly, and instead use the constructors below.

func MakeNewQualifiedTypeName

func MakeNewQualifiedTypeName(db, schema, typ string) TypeName

MakeNewQualifiedTypeName creates a fully qualified type name.

func MakeUnqualifiedTypeName

func MakeUnqualifiedTypeName(typ Name) TypeName

MakeUnqualifiedTypeName returns a new type name.

func NewUnqualifiedTypeName

func NewUnqualifiedTypeName(typ Name) *TypeName

NewUnqualifiedTypeName returns a new base type name.

func (*TypeName) FQString

func (t *TypeName) FQString() string

FQString renders the type name in full, not omitting the prefix schema and catalog names. Suitable for logging, etc.

func (*TypeName) Format

func (t *TypeName) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*TypeName) Object

func (o *TypeName) Object() string

func (*TypeName) String

func (t *TypeName) String() string

String implements the Stringer interface.

func (*TypeName) ToUnresolvedObjectName

func (o *TypeName) ToUnresolvedObjectName() *UnresolvedObjectName

ToUnresolvedObjectName converts the type name to an unresolved object name. Schema and catalog are included if indicated by the ExplicitSchema and ExplicitCatalog flags.

func (*TypeName) Type

func (t *TypeName) Type() string

Type returns the unqualified name of this TypeName.

type TypeReferenceResolver

type TypeReferenceResolver interface {
	ResolveType(ctx context.Context, name *UnresolvedObjectName) (*types.T, error)
	ResolveTypeByOID(ctx context.Context, oid oid.Oid) (*types.T, error)
}

TypeReferenceResolver is the interface that will provide the ability to actually look up type metadata and transform references into *types.T's. Implementers of TypeReferenceResolver should also implement descpb.TypeDescriptorResolver is sqlbase.TypeDescriptorInterface is the underlying representation of a user defined type.

func MakeTestingMapTypeResolver

func MakeTestingMapTypeResolver(typeMap map[string]*types.T) TypeReferenceResolver

MakeTestingMapTypeResolver creates a TestingMapTypeResolver from a map.

type TypedExpr

type TypedExpr interface {
	Expr
	// ResolvedType provides the type of the TypedExpr, which is the type of Datum
	// that the TypedExpr will return when evaluated.
	ResolvedType() *types.T
}

TypedExpr represents a well-typed expression.

func TypeCheck

func TypeCheck(
	ctx context.Context, expr Expr, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck performs type checking on the provided expression tree, returning the new typed expression tree, which additionally permits evaluation and type introspection globally and on each sub-tree.

While doing so, it will fold numeric constants and bind placeholder names to their inferred types in the provided context. The optional desired parameter can be used to hint the desired type for the root of the resulting typed expression tree. Like with Expr.TypeCheck, it is not valid to provide a nil desired type. Instead, call it with the wildcard type types.Any if no specific type is desired.

func TypeCheckAndRequire

func TypeCheckAndRequire(
	ctx context.Context, expr Expr, semaCtx *SemaContext, required *types.T, op string,
) (TypedExpr, error)

TypeCheckAndRequire performs type checking on the provided expression tree in an identical manner to TypeCheck. It then asserts that the resulting TypedExpr has the provided return type, returning both the typed expression and an error if it does not.

func TypeCheckSameTypedExprs

func TypeCheckSameTypedExprs(
	ctx context.Context, semaCtx *SemaContext, desired *types.T, exprs ...Expr,
) ([]TypedExpr, *types.T, error)

TypeCheckSameTypedExprs type checks a list of expressions, asserting that all resolved TypeExprs have the same type. An optional desired type can be provided, which will hint that type which the expressions should resolve to, if possible.

type TypedExprs

type TypedExprs []TypedExpr

TypedExprs represents a list of well-typed value expressions. It's not a valid expression because it's not parenthesized.

func (*TypedExprs) String

func (node *TypedExprs) String() string

type UnaryExpr

type UnaryExpr struct {
	Operator UnaryOperator
	Expr     Expr
	// contains filtered or unexported fields
}

UnaryExpr represents a unary value expression.

func NewTypedUnaryExpr

func NewTypedUnaryExpr(op UnaryOperator, expr TypedExpr, typ *types.T) *UnaryExpr

NewTypedUnaryExpr returns a new UnaryExpr that is well-typed.

func (*UnaryExpr) Format

func (node *UnaryExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (UnaryExpr) HasResolvedType added in v0.6.0

func (ta UnaryExpr) HasResolvedType() bool

func (UnaryExpr) ResolvedType

func (ta UnaryExpr) ResolvedType() *types.T

func (*UnaryExpr) String

func (node *UnaryExpr) String() string

func (*UnaryExpr) TypeCheck

func (expr *UnaryExpr) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*UnaryExpr) TypedInnerExpr

func (node *UnaryExpr) TypedInnerExpr() TypedExpr

TypedInnerExpr returns the UnaryExpr's inner expression as a TypedExpr.

func (*UnaryExpr) Walk

func (expr *UnaryExpr) Walk(v Visitor) Expr

Walk implements the Expr interface.

type UnaryOp

type UnaryOp struct {
	Typ        *types.T
	ReturnType *types.T
	Volatility Volatility
	// contains filtered or unexported fields
}

UnaryOp is a unary operator.

type UnaryOperator

type UnaryOperator int

UnaryOperator represents a unary operator.

const (
	UnaryMinus UnaryOperator = iota
	UnaryComplement
	UnarySqrt
	UnaryCbrt
	UnaryAbsolute

	NumUnaryOperators
)

UnaryExpr.Operator

func (UnaryOperator) String

func (i UnaryOperator) String() string

type UnionClause

type UnionClause struct {
	Type        UnionType
	Left, Right *Select
	All         bool
}

UnionClause represents a UNION statement.

func (*UnionClause) Format

func (node *UnionClause) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*UnionClause) StatementTag

func (*UnionClause) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*UnionClause) StatementType

func (*UnionClause) StatementType() StatementType

StatementType implements the Statement interface.

func (*UnionClause) String

func (n *UnionClause) String() string

type UnionType

type UnionType int

UnionType represents one of the three set operations in sql.

const (
	UnionOp UnionType = iota
	IntersectOp
	ExceptOp
)

Union.Type

func (UnionType) String

func (i UnionType) String() string

type UniqueConstraint

type UniqueConstraint struct {
	NullsDistinct bool
	IndexParams   IndexParams
	IsPrimary     bool
}

UniqueConstraint represents UNIQUE and PRIMARY KEY on a column.

type UniqueConstraintTableDef

type UniqueConstraintTableDef struct {
	IndexTableDef
	NullsNotDistinct bool
	PrimaryKey       bool
}

UniqueConstraintTableDef represents a unique constraint within a CREATE TABLE statement.

func (*UniqueConstraintTableDef) Format

func (node *UniqueConstraintTableDef) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*UniqueConstraintTableDef) SetName

func (node *UniqueConstraintTableDef) SetName(name Name)

SetName implements the TableDef interface.

type UnqualifiedStar

type UnqualifiedStar struct{}

UnqualifiedStar corresponds to a standalone '*' in a scalar expression.

func (UnqualifiedStar) Format

func (UnqualifiedStar) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (UnqualifiedStar) NormalizeVarName

func (u UnqualifiedStar) NormalizeVarName() (VarName, error)

NormalizeVarName implements the VarName interface.

func (UnqualifiedStar) ResolvedType

func (UnqualifiedStar) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (UnqualifiedStar) String

func (u UnqualifiedStar) String() string

func (UnqualifiedStar) TypeCheck

func (expr UnqualifiedStar) TypeCheck(
	_ context.Context, _ *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (UnqualifiedStar) Variable

func (UnqualifiedStar) Variable()

Variable implements the VariableExpr interface.

func (UnqualifiedStar) Walk

func (expr UnqualifiedStar) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type UnresolvedName

type UnresolvedName struct {
	// NumParts indicates the number of name parts specified, including
	// the star. Always 1 or greater.
	NumParts int

	// Star indicates the name ends with a star.
	// In that case, Parts below is empty in the first position.
	Star bool

	// Parts are the name components, in reverse order.
	// There are at most 4: column, table, schema, catalog/db.
	//
	// Note: NameParts has a fixed size so that we avoid a heap
	// allocation for the slice every time we construct an
	// UnresolvedName. It does imply however that Parts does not have
	// a meaningful "length"; its actual length (the number of parts
	// specified) is populated in NumParts above.
	Parts NameParts
}

UnresolvedName corresponds to an unresolved qualified name.

func MakeUnresolvedName

func MakeUnresolvedName(args ...string) UnresolvedName

MakeUnresolvedName constructs an UnresolvedName from some strings.

func NewUnresolvedName

func NewUnresolvedName(args ...string) *UnresolvedName

NewUnresolvedName constructs an UnresolvedName from some strings.

func (*UnresolvedName) Format

func (u *UnresolvedName) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*UnresolvedName) NormalizeTablePattern

func (n *UnresolvedName) NormalizeTablePattern() (TablePattern, error)

NormalizeTablePattern resolves an UnresolvedName to either a TableName or AllTablesSelector.

func (*UnresolvedName) NormalizeVarName

func (n *UnresolvedName) NormalizeVarName() (VarName, error)

NormalizeVarName implements the VarName interface.

func (*UnresolvedName) ResolveFunction

func (n *UnresolvedName) ResolveFunction(
	searchPath sessiondata.SearchPath,
) (*FunctionDefinition, error)

ResolveFunction transforms an UnresolvedName to a FunctionDefinition.

Function resolution currently takes a "short path" using the assumption that there are no stored functions in the database. That is, only functions in the (virtual) global namespace and virtual schemas can be used. This in turn implies that the current database does not matter and no resolver is needed.

TODO(whoever): this needs to be revisited when there can be stored functions. When that is the case, function names must be first normalized to e.g. TableName (or whatever an object name will be called by then) and then undergo regular name resolution via ResolveExisting(). When that happens, the following function can be removed.

func (*UnresolvedName) ResolvedType

func (*UnresolvedName) ResolvedType() *types.T

ResolvedType implements the TypedExpr interface.

func (*UnresolvedName) String

func (u *UnresolvedName) String() string

func (*UnresolvedName) ToUnresolvedObjectName

func (u *UnresolvedName) ToUnresolvedObjectName(idx AnnotationIdx) (*UnresolvedObjectName, error)

ToUnresolvedObjectName converts an UnresolvedName to an UnresolvedObjectName.

func (*UnresolvedName) TypeCheck

func (expr *UnresolvedName) TypeCheck(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
) (TypedExpr, error)

TypeCheck implements the Expr interface.

func (*UnresolvedName) Variable

func (*UnresolvedName) Variable()

Variable implements the VariableExpr interface. Although, the UnresolvedName ought to be replaced to an IndexedVar before the points the VariableExpr interface is used.

func (*UnresolvedName) Walk

func (expr *UnresolvedName) Walk(_ Visitor) Expr

Walk implements the Expr interface.

type UnresolvedObjectName

type UnresolvedObjectName struct {
	// NumParts indicates the number of name parts specified; always 1 or greater.
	NumParts int

	// Parts are the name components, in reverse order.
	// There are at most 3: object name, schema, catalog/db.
	//
	// Note: Parts has a fixed size so that we avoid a heap allocation for the
	// slice every time we construct an UnresolvedObjectName. It does imply
	// however that Parts does not have a meaningful "length"; its actual length
	// (the number of parts specified) is populated in NumParts above.
	Parts [3]string

	// UnresolvedObjectName can be annotated with a *tree.TableName.
	AnnotatedNode
}

UnresolvedObjectName is an unresolved qualified name for a database object (table, view, etc). It is like UnresolvedName but more restrictive. It should only be constructed via NewUnresolvedObjectName.

func NewUnresolvedObjectName

func NewUnresolvedObjectName(
	numParts int, parts [3]string, annotationIdx AnnotationIdx,
) (*UnresolvedObjectName, error)

NewUnresolvedObjectName creates an unresolved object name, verifying that it is well-formed.

func (*UnresolvedObjectName) Catalog

func (u *UnresolvedObjectName) Catalog() string

Catalog returns the catalog of the object.

func (*UnresolvedObjectName) Format

func (u *UnresolvedObjectName) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*UnresolvedObjectName) HasExplicitCatalog

func (u *UnresolvedObjectName) HasExplicitCatalog() bool

HasExplicitCatalog returns whether a catalog is specified on the object.

func (*UnresolvedObjectName) HasExplicitSchema

func (u *UnresolvedObjectName) HasExplicitSchema() bool

HasExplicitSchema returns whether a schema is specified on the object.

func (*UnresolvedObjectName) Object

func (u *UnresolvedObjectName) Object() string

Object returns the unqualified object name.

func (*UnresolvedObjectName) Resolved

func (u *UnresolvedObjectName) Resolved(ann *Annotations) ObjectName

Resolved returns the resolved name in the annotation for this node (or nil if there isn't one).

func (*UnresolvedObjectName) SQLString

func (name *UnresolvedObjectName) SQLString() string

SQLString implements the ResolvableTypeReference interface.

func (*UnresolvedObjectName) Schema

func (u *UnresolvedObjectName) Schema() string

Schema returns the schema of the object.

func (*UnresolvedObjectName) String

func (u *UnresolvedObjectName) String() string

func (*UnresolvedObjectName) ToTableName

func (u *UnresolvedObjectName) ToTableName() TableName

ToTableName converts the unresolved name to a table name.

TODO(radu): the schema and catalog names might not be in the right places; we would only figure that out during name resolution. This method is temporary, while we change all the code paths to only use TableName after resolution.

func (*UnresolvedObjectName) ToUnresolvedName

func (u *UnresolvedObjectName) ToUnresolvedName() *UnresolvedName

ToUnresolvedName converts the unresolved object name to the more general unresolved name.

type UnrestrictedName

type UnrestrictedName string

An UnrestrictedName is a Name that does not need to be escaped when it matches a reserved keyword.

In general, an UnrestrictedName is the result of parsing an unrestricted_name nonterminal, which is used in the grammar where reserved keywords can be unambiguously interpreted as identifiers. When formatted, an UnrestrictedName that matches a reserved keyword thus does not need to be quoted.

For historical reasons, some unrestricted_name nonterminals are instead parsed as Names. The only user-visible impact of this is that we are too aggressive about quoting names in certain positions. New grammar rules should prefer to parse unrestricted_name nonterminals into UnrestrictedNames.

func (*UnrestrictedName) Format

func (u *UnrestrictedName) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*UnrestrictedName) String

func (node *UnrestrictedName) String() string

type Unsplit

type Unsplit struct {
	TableOrIndex TableIndexName
	// Each row contains values for the columns in the PK or index (or a prefix
	// of the columns).
	Rows *Select
	All  bool
}

Unsplit represents an `ALTER TABLE/INDEX .. UNSPLIT AT ..` statement.

func (*Unsplit) Format

func (node *Unsplit) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Unsplit) StatementTag

func (*Unsplit) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Unsplit) StatementType

func (*Unsplit) StatementType() StatementType

StatementType implements the Statement interface.

func (*Unsplit) String

func (n *Unsplit) String() string

type Update

type Update struct {
	With      *With
	Table     TableExpr
	Exprs     UpdateExprs
	From      TableExprs
	Where     *Where
	OrderBy   OrderBy
	Limit     *Limit
	Returning ReturningClause
}

Update represents an UPDATE statement.

func (*Update) Format

func (node *Update) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*Update) StatementTag

func (*Update) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*Update) StatementType

func (n *Update) StatementType() StatementType

StatementType implements the Statement interface.

func (*Update) String

func (n *Update) String() string

type UpdateExpr

type UpdateExpr struct {
	Tuple bool
	Names NameList
	Expr  Expr
}

UpdateExpr represents an update expression.

func (*UpdateExpr) Format

func (node *UpdateExpr) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type UpdateExprs

type UpdateExprs []*UpdateExpr

UpdateExprs represents a list of update expressions.

func (*UpdateExprs) Format

func (node *UpdateExprs) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type UserPriority

type UserPriority int

UserPriority holds the user priority for a transaction.

const (
	UnspecifiedUserPriority UserPriority = iota
	Low
	Normal
	High
)

UserPriority values

func UserPriorityFromString

func UserPriorityFromString(val string) (_ UserPriority, ok bool)

UserPriorityFromString converts a string into a UserPriority.

func (UserPriority) String

func (up UserPriority) String() string

type UsingJoinCond

type UsingJoinCond struct {
	Cols NameList
}

UsingJoinCond represents a USING join condition.

func (*UsingJoinCond) Format

func (node *UsingJoinCond) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type ValidationBehavior

type ValidationBehavior int

ValidationBehavior specifies whether or not a constraint is validated.

const (
	// ValidationDefault is the default validation behavior (immediate).
	ValidationDefault ValidationBehavior = iota
	// ValidationSkip skips validation of any existing data.
	ValidationSkip
)

type ValuesClause

type ValuesClause struct {
	Rows []Exprs
}

ValuesClause represents a VALUES clause.

func (*ValuesClause) Format

func (node *ValuesClause) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*ValuesClause) StatementTag

func (*ValuesClause) StatementTag() string

StatementTag returns a short string identifying the type of statement.

func (*ValuesClause) StatementType

func (*ValuesClause) StatementType() StatementType

StatementType implements the Statement interface.

func (*ValuesClause) String

func (n *ValuesClause) String() string

type VarName

type VarName interface {
	TypedExpr

	// NormalizeVarName() guarantees to return a variable name
	// that is not an UnresolvedName. This converts the UnresolvedName
	// to an AllColumnsSelector or ColumnItem as necessary.
	NormalizeVarName() (VarName, error)
}

VarName occurs inside scalar expressions.

Immediately after parsing, the following types can occur:

  • UnqualifiedStar: a naked star as argument to a function, e.g. count(*), or at the top level of a SELECT clause. See also uses of StarExpr() and StarSelectExpr() in the grammar.

- UnresolvedName: other names of the form `a.b....e` or `a.b...e.*`.

Consumers of variable names do not like UnresolvedNames and instead expect either AllColumnsSelector or ColumnItem. Use NormalizeVarName() for this.

After a ColumnItem is available, it should be further resolved, for this the Resolve() method should be used; see name_resolution.go.

func StarExpr

func StarExpr() VarName

StarExpr is a convenience function that represents an unqualified "*".

type VariableExpr

type VariableExpr interface {
	Expr
	Variable()
}

VariableExpr is an Expr that may change per row. It is used to signal the evaluation/simplification machinery that the underlying Expr is not constant.

type VariadicType

type VariadicType struct {
	FixedTypes []*types.T
	VarType    *types.T
}

VariadicType is a TypeList implementation which accepts a fixed number of arguments at the beginning and an arbitrary number of homogenous arguments at the end.

func (VariadicType) GetAt

func (v VariadicType) GetAt(i int) *types.T

GetAt is part of the TypeList interface.

func (VariadicType) Length

func (v VariadicType) Length() int

Length is part of the TypeList interface.

func (VariadicType) Match

func (v VariadicType) Match(types []*types.T) bool

Match is part of the TypeList interface.

func (VariadicType) MatchAt

func (v VariadicType) MatchAt(typ *types.T, i int) bool

MatchAt is part of the TypeList interface.

func (VariadicType) MatchLen

func (v VariadicType) MatchLen(l int) bool

MatchLen is part of the TypeList interface.

func (VariadicType) String

func (v VariadicType) String() string

func (VariadicType) Types

func (v VariadicType) Types() []*types.T

Types is part of the TypeList interface.

type ViewCheckOption added in v0.5.0

type ViewCheckOption int
const (
	ViewCheckOptionUnspecified ViewCheckOption = iota
	ViewCheckOptionCascaded
	ViewCheckOptionLocal
)

type ViewOption added in v0.5.0

type ViewOption struct {
	Name string
	Val  Expr
}

type ViewOptions added in v0.5.0

type ViewOptions []ViewOption

func (ViewOptions) Format added in v0.5.0

func (node ViewOptions) Format(ctx *FmtCtx)

type Visitor

type Visitor interface {
	// VisitPre is called for each node before recursing into that subtree. Upon return, if recurse
	// is false, the visit will not recurse into the subtree (and VisitPost will not be called for
	// this node).
	//
	// The returned Expr replaces the visited expression and can be used for rewriting expressions.
	// The function should NOT modify nodes in-place; it should make copies of nodes. The Walk
	// infrastructure will automatically make copies of parents as needed.
	VisitPre(expr Expr) (recurse bool, newExpr Expr)

	// VisitPost is called for each node after recursing into the subtree. The returned Expr
	// replaces the visited expression and can be used for rewriting expressions.
	//
	// The returned Expr replaces the visited expression and can be used for rewriting expressions.
	// The function should NOT modify nodes in-place; it should make and return copies of nodes. The
	// Walk infrastructure will automatically make copies of parents as needed.
	VisitPost(expr Expr) (newNode Expr)
}

Visitor defines methods that are called for nodes during an expression or statement walk.

type Volatility

type Volatility int8

Volatility 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 (
	// VolatilityLeakProof 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 leak-proof.
	//
	// 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: VolatilityLeakProof is strictly stronger than VolatilityImmutable. In
	// principle it could be possible to have leak-proof stable or volatile
	// functions (perhaps now()); but this is not useful in practice as very few
	// operators are marked leak-proof.
	// Examples: integer comparison.
	VolatilityLeakProof Volatility = 1 + iota
	// VolatilityImmutable 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.
	VolatilityImmutable
	// VolatilityStable 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.
	VolatilityStable
	// VolatilityVolatile means that the operator can do anything, including
	// modifying database state.
	// Examples: random, crdb_internal.force_error, nextval.
	VolatilityVolatile
)

func VolatilityFromPostgres

func VolatilityFromPostgres(provolatile string, proleakproof bool) (Volatility, error)

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

func (Volatility) String

func (v Volatility) String() string

String returns the byte representation of Volatility as a string.

func (Volatility) ToPostgres

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

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

type When

type When struct {
	Cond Expr
	Val  Expr
}

When represents a WHEN sub-expression.

func (*When) Format

func (node *When) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type Where

type Where struct {
	Type string
	Expr Expr
}

Where represents a WHERE or HAVING clause.

func NewWhere

func NewWhere(typ string, expr Expr) *Where

NewWhere creates a WHERE or HAVING clause out of an Expr. If the expression is nil, it returns nil.

func (*Where) Format

func (node *Where) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type Window

type Window []*WindowDef

Window represents a WINDOW clause.

func (*Window) Format

func (node *Window) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type WindowDef

type WindowDef struct {
	Name       Name
	RefName    Name
	Partitions Exprs
	OrderBy    OrderBy
	Frame      *WindowFrame
}

WindowDef represents a single window definition expression.

func OverrideWindowDef

func OverrideWindowDef(base *WindowDef, override WindowDef) (WindowDef, error)

OverrideWindowDef implements the logic to have a base window definition which then gets augmented by a different window definition.

func (*WindowDef) Format

func (node *WindowDef) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type WindowFrame

type WindowFrame struct {
	Mode      WindowFrameMode      // the mode of framing being used
	Bounds    WindowFrameBounds    // the bounds of the frame
	Exclusion WindowFrameExclusion // optional frame exclusion
}

WindowFrame represents static state of window frame over which calculations are made.

func (*WindowFrame) Format

func (node *WindowFrame) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type WindowFrameBound

type WindowFrameBound struct {
	BoundType  WindowFrameBoundType
	OffsetExpr Expr
}

WindowFrameBound specifies the offset and the type of boundary.

func (*WindowFrameBound) Format

func (node *WindowFrameBound) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

func (*WindowFrameBound) HasOffset

func (node *WindowFrameBound) HasOffset() bool

HasOffset returns whether node contains an offset.

type WindowFrameBoundType

type WindowFrameBoundType int

WindowFrameBoundType indicates which type of boundary is used.

const (
	// UnboundedPreceding represents UNBOUNDED PRECEDING type of boundary.
	UnboundedPreceding WindowFrameBoundType = iota
	// OffsetPreceding represents 'value' PRECEDING type of boundary.
	OffsetPreceding
	// CurrentRow represents CURRENT ROW type of boundary.
	CurrentRow
	// OffsetFollowing represents 'value' FOLLOWING type of boundary.
	OffsetFollowing
	// UnboundedFollowing represents UNBOUNDED FOLLOWING type of boundary.
	UnboundedFollowing
)

func (WindowFrameBoundType) IsOffset

func (ft WindowFrameBoundType) IsOffset() bool

IsOffset returns true if the WindowFrameBoundType is an offset.

type WindowFrameBounds

type WindowFrameBounds struct {
	StartBound *WindowFrameBound
	EndBound   *WindowFrameBound
}

WindowFrameBounds specifies boundaries of the window frame. The row at StartBound is included whereas the row at EndBound is not.

func (*WindowFrameBounds) HasOffset

func (node *WindowFrameBounds) HasOffset() bool

HasOffset returns whether node contains an offset in either of the bounds.

type WindowFrameExclusion

type WindowFrameExclusion int

WindowFrameExclusion indicates which mode of exclusion is used.

const (
	// NoExclusion represents an omitted frame exclusion clause.
	NoExclusion WindowFrameExclusion = iota
	// ExcludeCurrentRow represents EXCLUDE CURRENT ROW mode of frame exclusion.
	ExcludeCurrentRow
	// ExcludeGroup represents EXCLUDE GROUP mode of frame exclusion.
	ExcludeGroup
	// ExcludeTies represents EXCLUDE TIES mode of frame exclusion.
	ExcludeTies
)

func (WindowFrameExclusion) Format

func (node WindowFrameExclusion) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

type WindowFrameMode

type WindowFrameMode int

WindowFrameMode indicates which mode of framing is used.

const (
	// RANGE is the mode of specifying frame in terms of logical range (e.g. 100 units cheaper).
	RANGE WindowFrameMode = iota
	// ROWS is the mode of specifying frame in terms of physical offsets (e.g. 1 row before etc).
	ROWS
	// GROUPS is the mode of specifying frame in terms of peer groups.
	GROUPS
)

type With

type With struct {
	Recursive bool
	CTEList   []*CTE
}

With represents a WITH statement.

func (*With) Format

func (node *With) Format(ctx *FmtCtx)

Format implements the NodeFormatter interface.

Source Files

Jump to

Keyboard shortcuts

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