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 CRDBInternalSchemaName = "crdb_internal"

CRDBInternalSchemaName is the name of the crdb_internal system schema.

const InformationSchemaName = "information_schema"

InformationSchemaName is the name of the information_schema system schema.

const PgCatalogName = "pg_catalog"

PgCatalogName is the name of the pg_catalog system schema.

const PgExtensionSchemaName = "pg_extension"

PgExtensionSchemaName is the alias for schemas which are usually "public" in postgres when installing an extension, but must be stored as a separate schema in CRDB.

const PgSchemaPrefix = "pg_"

PgSchemaPrefix is a prefix for Postgres system schemas. Users cannot create schemas with this prefix.

const PgTempSchemaName = "pg_temp"

PgTempSchemaName is the alias for temporary schemas across sessions.

const PublicSchemaName = "public"

PublicSchemaName is the name of the pg_catalog system schema.

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 lex.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) 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 ExperimentalDistSQLPlanningMode Uses

type ExperimentalDistSQLPlanningMode int64

ExperimentalDistSQLPlanningMode controls if and when the opt-driven DistSQL planning is used to create physical plans.

const (
    // ExperimentalDistSQLPlanningOff means that we always use the old path of
    // going from opt.Expr to planNodes and then to processor specs.
    ExperimentalDistSQLPlanningOff ExperimentalDistSQLPlanningMode = iota
    // ExperimentalDistSQLPlanningOn means that we will attempt to use the new
    // path for performing DistSQL planning in the optimizer, and if that
    // doesn't succeed for some reason, we will fallback to the old path.
    ExperimentalDistSQLPlanningOn
    // ExperimentalDistSQLPlanningAlways means that we will only use the new path,
    // and if it fails for any reason, the query will fail as well.
    ExperimentalDistSQLPlanningAlways
)

func ExperimentalDistSQLPlanningModeFromString Uses

func ExperimentalDistSQLPlanningModeFromString(val string) (ExperimentalDistSQLPlanningMode, bool)

ExperimentalDistSQLPlanningModeFromString converts a string into a ExperimentalDistSQLPlanningMode. False is returned if the conversion was unsuccessful.

func (ExperimentalDistSQLPlanningMode) String Uses

func (m ExperimentalDistSQLPlanningMode) 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) GetTemporarySchemaName Uses

func (s SearchPath) GetTemporarySchemaName() string

GetTemporarySchemaName returns the temporary schema specific to the current session.

func (SearchPath) Iter Uses

func (s SearchPath) Iter() SearchPathIter

Iter returns an iterator through the search path. We must include the implicit pg_catalog and temporary schema at the beginning of the search path, unless they have been explicitly set later by the user. We also include pg_extension in the path, as this normally be used in place of the public schema. This should be read before "public" is read. "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." "Likewise, the current session's temporary-table schema, pg_temp_nnn, is always searched if it exists. It can be explicitly listed in the path by using the alias pg_temp. If it is not listed in the path then it is searched first (even before pg_catalog)." - https://www.postgresql.org/docs/9.1/static/runtime-config-client.html

func (SearchPath) IterWithoutImplicitPGSchemas Uses

func (s SearchPath) IterWithoutImplicitPGSchemas() SearchPathIter

IterWithoutImplicitPGSchemas is the same as Iter, but does not include the implicit pg_temp and pg_catalog.

func (SearchPath) MaybeResolveTemporarySchema Uses

func (s SearchPath) MaybeResolveTemporarySchema(schemaName string) (string, error)

MaybeResolveTemporarySchema returns the session specific temporary schema for the pg_temp alias (only if a temporary schema exists). It acts as a pass through for all other schema names.

func (SearchPath) String Uses

func (s SearchPath) String() string

func (SearchPath) UpdatePaths Uses

func (s SearchPath) UpdatePaths(paths []string) SearchPath

UpdatePaths returns a new immutable SearchPath struct with the paths supplied and the same tempSchemaName as before.

func (SearchPath) WithTemporarySchemaName Uses

func (s SearchPath) WithTemporarySchemaName(tempSchemaName string) SearchPath

WithTemporarySchemaName returns a new immutable SearchPath struct with the tempSchemaName supplied and the same paths as before. This should be called every time a session creates a temporary schema for the first time.

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. The tempSchemaName in the iterator is only set if the session has created a temporary schema.

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
    // DefaultTxnPriority indicates the default priority of newly created
    // transactions.
    // NOTE: we'd prefer to use tree.UserPriority here, but doing so would
    // introduce a package dependency cycle.
    DefaultTxnPriority int
    // 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
    // EnumsEnabled indicates whether use of ENUM types are allowed.
    EnumsEnabled bool
    // UserDefinedSchemasEnabled indicates whether use of user defined schemas
    // are allowed.
    UserDefinedSchemasEnabled bool
    // ExperimentalDistSQLPlanningMode indicates whether the experimental
    // DistSQL planning driven by the optimizer is enabled.
    ExperimentalDistSQLPlanningMode ExperimentalDistSQLPlanningMode
    // PartiallyDistributedPlansDisabled indicates whether the partially
    // distributed plans produced by distSQLSpecExecFactory are disabled. It
    // should be set to 'true' only in tests that verify that the old and the
    // new factories return exactly the same physical plans.
    // TODO(yuzefovich): remove it when deleting old sql.execFactory.
    PartiallyDistributedPlansDisabled bool
    // OptimizerFKCascadesLimit is the maximum number of cascading operations that
    // are run for a single query.
    OptimizerFKCascadesLimit int
    // OptimizerUseHistograms indicates whether we should use histograms for
    // cardinality estimation in the optimizer.
    OptimizerUseHistograms bool
    // OptimizerUseMultiColStats indicates whether we should use multi-column
    // statistics for cardinality estimation in the optimizer.
    OptimizerUseMultiColStats bool
    // PartialIndexes indicates whether creation of partial indexes are allowed.
    // TODO(mgartner): remove this once partial indexes are fully supported.
    PartialIndexes 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
    // IdleInSessionTimeout is the duration a session is permitted to idle before
    // the session is canceled. If set to 0, there is no timeout.
    IdleInSessionTimeout 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
    // RequireExplicitPrimaryKeys indicates whether CREATE TABLE statements should
    // error out if no primary key is provided.
    RequireExplicitPrimaryKeys bool
    // 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
    // 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
    // TempTablesEnabled indicates whether temporary tables can be created or not.
    TempTablesEnabled bool
    // HashShardedIndexesEnabled indicates whether hash sharded indexes can be created.
    HashShardedIndexesEnabled bool
    // ImplicitSelectForUpdate is true if FOR UPDATE locking may be used during
    // the row-fetch phase of mutation statements.
    ImplicitSelectForUpdate bool
    // InsertFastPath is true if the fast path for insert (with VALUES input) may
    // be used.
    InsertFastPath bool
    // InterleavedJoins is true if interleaved joins may be used.
    InterleavedJoins bool
    // NoticeDisplaySeverity indicates the level of Severity to send notices for the given
    // session.
    NoticeDisplaySeverity pgnotice.DisplaySeverity
    // AlterColumnTypeGeneralEnabled is true if ALTER TABLE ... ALTER COLUMN ...
    // TYPE x may be used for general conversions requiring online schema change/
    AlterColumnTypeGeneralEnabled bool

    // SynchronousCommit is a dummy setting for the synchronous_commit var.
    SynchronousCommit bool
    // EnableSeqScan is a dummy setting for the enable_seqscan var.
    EnableSeqScan bool
}

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. WARNING: When adding a VectorizeExecMode, note that nodes at previous versions might interpret the integer value differently. To avoid this, only append to the list or bump the minimum required distsql version (maybe also take advantage of that to reorder the list as you see fit).

const (
    // VectorizeOff means that columnar execution is disabled.
    VectorizeOff VectorizeExecMode = iota
    // Vectorize201Auto 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. If any part of a query is not
    // supported by the vectorized execution engine, the whole query will fall
    // back to row execution.
    // This is the default setting in 20.1.
    Vectorize201Auto
    // VectorizeOn means that any supported queries will be run using the
    // columnar execution.
    VectorizeOn
    // 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 9 packages (graph) and is imported by 74 packages. Updated 2020-08-05. Refresh now. Tools for package owners.