cockroach: github.com/cockroachdb/cockroach/pkg/sql/sessiondata Index | Files

package sessiondata

import "github.com/cockroachdb/cockroach/pkg/sql/sessiondata"

Index

Package Files

search_path.go sequence_state.go session_data.go

Constants

const DefaultDatabaseName = "defaultdb"

DefaultDatabaseName is the name ofthe default CockroachDB database used for connections without a current db set.

const PgCatalogName = "pg_catalog"

PgCatalogName is the name of the pg_catalog system schema.

const PgDatabaseName = "postgres"

PgDatabaseName is the name of the default postgres system database.

type BytesEncodeFormat Uses

type BytesEncodeFormat int

BytesEncodeFormat controls which format to use for BYTES->STRING conversions.

const (
    // BytesEncodeHex uses the hex format: e'abc\n'::BYTES::STRING -> '\x61626312'.
    // This is the default, for compatibility with PostgreSQL.
    BytesEncodeHex BytesEncodeFormat = iota
    // BytesEncodeEscape uses the escaped format: e'abc\n'::BYTES::STRING -> 'abc\012'.
    BytesEncodeEscape
    // BytesEncodeBase64 uses base64 encoding.
    BytesEncodeBase64
)

func BytesEncodeFormatFromString Uses

func BytesEncodeFormatFromString(val string) (_ BytesEncodeFormat, ok bool)

BytesEncodeFormatFromString converts a string into a BytesEncodeFormat.

func (BytesEncodeFormat) String Uses

func (f BytesEncodeFormat) String() string

type DataConversionConfig Uses

type DataConversionConfig struct {
    // Location indicates the current time zone.
    Location *time.Location

    // BytesEncodeFormat indicates how to encode byte arrays when converting
    // to string.
    BytesEncodeFormat BytesEncodeFormat

    // ExtraFloatDigits indicates the number of digits beyond the
    // standard number to use for float conversions.
    // This must be set to a value between -15 and 3, inclusive.
    ExtraFloatDigits int
}

DataConversionConfig contains the parameters that influence the conversion between SQL data types and strings/byte arrays.

func (*DataConversionConfig) Equals Uses

func (c *DataConversionConfig) Equals(other *DataConversionConfig) bool

Equals returns true if the two DataConversionConfigs are identical.

func (*DataConversionConfig) GetFloatPrec Uses

func (c *DataConversionConfig) GetFloatPrec() int

GetFloatPrec computes a precision suitable for a call to strconv.FormatFloat() or for use with '%.*g' in a printf-like function.

type DistSQLExecMode Uses

type DistSQLExecMode int64

DistSQLExecMode controls if and when the Executor distributes queries. Since 2.1, we run everything through the DistSQL infrastructure, and these settings control whether to use a distributed plan, or use a plan that only involves local DistSQL processors.

const (
    // DistSQLOff means that we never distribute queries.
    DistSQLOff DistSQLExecMode = iota
    // DistSQLAuto means that we automatically decide on a case-by-case basis if
    // we distribute queries.
    DistSQLAuto
    // DistSQLOn means that we distribute queries that are supported.
    DistSQLOn
    // DistSQLAlways means that we only distribute; unsupported queries fail.
    DistSQLAlways
)

func DistSQLExecModeFromString Uses

func DistSQLExecModeFromString(val string) (_ DistSQLExecMode, ok bool)

DistSQLExecModeFromString converts a string into a DistSQLExecMode

func (DistSQLExecMode) String Uses

func (m DistSQLExecMode) String() string

type SearchPath Uses

type SearchPath struct {
    // contains filtered or unexported fields
}

SearchPath represents a list of namespaces to search builtins in. The names must be normalized (as per Name.Normalize) already.

func MakeSearchPath Uses

func MakeSearchPath(paths []string) SearchPath

MakeSearchPath returns a new immutable SearchPath struct. The paths slice must not be modified after hand-off to MakeSearchPath.

func (SearchPath) Equals Uses

func (s SearchPath) Equals(other *SearchPath) bool

Equals returns true if two SearchPaths are the same.

func (SearchPath) GetPathArray Uses

func (s SearchPath) GetPathArray() []string

GetPathArray returns the underlying path array of this SearchPath. The resultant slice is not to be modified.

func (SearchPath) Iter Uses

func (s SearchPath) Iter() SearchPathIter

Iter returns an iterator through the search path. We must include the implicit pg_catalog at the beginning of the search path, unless it has been explicitly set later by the user. "The system catalog schema, pg_catalog, is always searched, whether it is mentioned in the path or not. If it is mentioned in the path then it will be searched in the specified order. If pg_catalog is not in the path then it will be searched before searching any of the path items." - https://www.postgresql.org/docs/9.1/static/runtime-config-client.html

func (SearchPath) IterWithoutImplicitPGCatalog Uses

func (s SearchPath) IterWithoutImplicitPGCatalog() SearchPathIter

IterWithoutImplicitPGCatalog is the same as Iter, but does not include the implicit pg_catalog.

func (SearchPath) String Uses

func (s SearchPath) String() string

type SearchPathIter Uses

type SearchPathIter struct {
    // contains filtered or unexported fields
}

SearchPathIter enables iteration over the search paths without triggering an allocation. Use one of the SearchPath.Iter methods to get an instance of the iterator, and then repeatedly call the Next method in order to iterate over each search path.

func (*SearchPathIter) Next Uses

func (iter *SearchPathIter) Next() (path string, ok bool)

Next returns the next search path, or false if there are no remaining paths.

type SequenceState Uses

type SequenceState struct {
    // contains filtered or unexported fields
}

SequenceState stores session-scoped state used by sequence builtins.

All public methods of SequenceState are thread-safe, as the structure is meant to be shared by statements executing in parallel on a session.

func NewSequenceState Uses

func NewSequenceState() *SequenceState

NewSequenceState creates a SequenceState.

func (*SequenceState) Export Uses

func (ss *SequenceState) Export() (map[uint32]int64, uint32)

Export returns a copy of the SequenceState's state - the latestValues and lastSequenceIncremented. lastSequenceIncremented is only defined if latestValues is non-empty.

func (*SequenceState) GetLastValue Uses

func (ss *SequenceState) GetLastValue() (int64, error)

GetLastValue returns the value most recently obtained by nextval() for the last sequence for which RecordLatestVal() was called.

func (*SequenceState) GetLastValueByID Uses

func (ss *SequenceState) GetLastValueByID(seqID uint32) (int64, bool)

GetLastValueByID returns the value most recently obtained by nextval() for the given sequence in this session. The bool retval is false if RecordLatestVal() was never called on the requested sequence.

func (*SequenceState) RecordValue Uses

func (ss *SequenceState) RecordValue(seqID uint32, val int64)

RecordValue records the latest manipulation of a sequence done by a session.

func (*SequenceState) SetLastSequenceIncremented Uses

func (ss *SequenceState) SetLastSequenceIncremented(seqID uint32)

SetLastSequenceIncremented sets the id of the last incremented sequence. Usually this id is set through RecordValue().

type SerialNormalizationMode Uses

type SerialNormalizationMode int64

SerialNormalizationMode controls if and when the Executor uses DistSQL.

const (
    // SerialUsesRowID means use INT NOT NULL DEFAULT unique_rowid().
    SerialUsesRowID SerialNormalizationMode = iota
    // SerialUsesVirtualSequences means create a virtual sequence and
    // use INT NOT NULL DEFAULT nextval(...).
    SerialUsesVirtualSequences
    // SerialUsesSQLSequences means create a regular SQL sequence and
    // use INT NOT NULL DEFAULT nextval(...).
    SerialUsesSQLSequences
)

func SerialNormalizationModeFromString Uses

func SerialNormalizationModeFromString(val string) (_ SerialNormalizationMode, ok bool)

SerialNormalizationModeFromString converts a string into a SerialNormalizationMode

func (SerialNormalizationMode) String Uses

func (m SerialNormalizationMode) String() string

type SessionData Uses

type SessionData struct {
    // ApplicationName is the name of the application running the
    // current session. This can be used for logging and per-application
    // statistics.
    ApplicationName string
    // Database indicates the "current" database for the purpose of
    // resolving names. See searchAndQualifyDatabase() for details.
    Database string
    // DefaultReadOnly indicates the default read-only status of newly created
    // transactions.
    DefaultReadOnly bool
    // DistSQLMode indicates whether to run queries using the distributed
    // execution engine.
    DistSQLMode DistSQLExecMode
    // ForceSplitAt indicates whether checks to prevent incorrect usage of ALTER
    // TABLE ... SPLIT AT should be skipped.
    ForceSplitAt bool
    // OptimizerFKs indicates whether we should use the new paths to plan foreign
    // key checks in the optimizer.
    OptimizerFKs bool
    // SerialNormalizationMode indicates how to handle the SERIAL pseudo-type.
    SerialNormalizationMode SerialNormalizationMode
    // SearchPath is a list of namespaces to search builtins in.
    SearchPath SearchPath
    // StmtTimeout is the duration a query is permitted to run before it is
    // canceled by the session. If set to 0, there is no timeout.
    StmtTimeout time.Duration
    // User is the name of the user logged into the session.
    User string
    // SafeUpdates causes errors when the client
    // sends syntax that may have unwanted side effects.
    SafeUpdates bool
    // RemoteAddr is used to generate logging events.
    RemoteAddr net.Addr
    // ZigzagJoinEnabled indicates whether the optimizer should try and plan a
    // zigzag join.
    ZigzagJoinEnabled bool
    // ReorderJoinsLimit indicates the number of joins at which the optimizer should
    // stop attempting to reorder.
    ReorderJoinsLimit int
    // SequenceState gives access to the SQL sequences that have been manipulated
    // by the session.
    SequenceState *SequenceState
    // DataConversion gives access to the data conversion configuration.
    DataConversion DataConversionConfig
    // DurationAdditionMode enables math compatibility options to be enabled.
    // TODO(bob): Remove this once the 2.2 release branch is cut.
    DurationAdditionMode duration.AdditionMode
    // VectorizeMode indicates which kinds of queries to use vectorized execution
    // engine for.
    VectorizeMode VectorizeExecMode
    // VectorizeRowCountThreshold indicates the row count above which the
    // vectorized execution engine will be used if possible.
    VectorizeRowCountThreshold uint64
    // ForceSavepointRestart overrides the default SAVEPOINT behavior
    // for compatibility with certain ORMs. When this flag is set,
    // the savepoint name will no longer be compared against the magic
    // identifier `cockroach_restart` in order use a restartable
    // transaction.
    ForceSavepointRestart bool
    // DefaultIntSize specifies the size in bits or bytes (preferred)
    // of how a "naked" INT type should be parsed.
    DefaultIntSize int
    // ResultsBufferSize specifies the size at which the pgwire results buffer
    // will self-flush.
    ResultsBufferSize int64
    // AllowPrepareAsOptPlan must be set to allow use of
    //   PREPARE name AS OPT PLAN '...'
    AllowPrepareAsOptPlan bool
    // SaveTablesPrefix indicates that a table should be created with the
    // given prefix for the output of each subexpression in a query. If
    // SaveTablesPrefix is empty, no tables are created.
    SaveTablesPrefix string
}

SessionData contains session parameters. They are all user-configurable. A SQL Session changes fields in SessionData through sql.sessionDataMutator.

type VectorizeExecMode Uses

type VectorizeExecMode int64

VectorizeExecMode controls if an when the Executor executes queries using the columnar execution engine.

const (
    // VectorizeOff means that columnar execution is disabled.
    VectorizeOff VectorizeExecMode = iota
    // VectorizeAuto means that that any supported queries that use only
    // streaming operators (i.e. those that do not require any buffering) will be
    // run using the columnar execution.
    VectorizeAuto
    // VectorizeExperimentalOn means that any supported queries will be run using
    // the columnar execution on.
    VectorizeExperimentalOn
    // VectorizeExperimentalAlways means that we attempt to vectorize all
    // queries; unsupported queries will fail. Mostly used for testing.
    VectorizeExperimentalAlways
)

func VectorizeExecModeFromString Uses

func VectorizeExecModeFromString(val string) (VectorizeExecMode, bool)

VectorizeExecModeFromString converts a string into a VectorizeExecMode. False is returned if the conversion was unsuccessful.

func (VectorizeExecMode) String Uses

func (m VectorizeExecMode) String() string

Package sessiondata imports 8 packages (graph) and is imported by 32 packages. Updated 2019-09-11. Refresh now. Tools for package owners.