Documentation
¶
Index ¶
- Constants
- type BytesEncodeFormat
- type DataConversionConfig
- type DistSQLExecMode
- type SearchPath
- func (s SearchPath) Equals(other *SearchPath) bool
- func (s SearchPath) GetPathArray() []string
- func (s SearchPath) GetTemporarySchemaName() string
- func (s SearchPath) Iter() SearchPathIter
- func (s SearchPath) IterWithoutImplicitPGSchemas() SearchPathIter
- func (s SearchPath) MaybeResolveTemporarySchema(schemaName string) (string, error)
- func (s SearchPath) String() string
- func (s SearchPath) UpdatePaths(paths []string) SearchPath
- func (s SearchPath) WithTemporarySchemaName(tempSchemaName string) SearchPath
- type SearchPathIter
- type SequenceState
- func (ss *SequenceState) Export() (map[uint32]int64, uint32)
- func (ss *SequenceState) GetLastValue() (int64, error)
- func (ss *SequenceState) GetLastValueByID(seqID uint32) (int64, bool)
- func (ss *SequenceState) RecordValue(seqID uint32, val int64)
- func (ss *SequenceState) SetLastSequenceIncremented(seqID uint32)
- type SerialNormalizationMode
- type SessionData
- type VectorizeExecMode
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.
const PgTempSchemaName = "pg_temp"
PgTempSchemaName is the alias for temporary schemas across sessions.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BytesEncodeFormat ¶
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 ¶
func BytesEncodeFormatFromString(val string) (_ BytesEncodeFormat, ok bool)
BytesEncodeFormatFromString converts a string into a BytesEncodeFormat.
func (BytesEncodeFormat) String ¶
func (f BytesEncodeFormat) String() string
type DataConversionConfig ¶
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 ¶
func (c *DataConversionConfig) Equals(other *DataConversionConfig) bool
Equals returns true if the two DataConversionConfigs are identical.
func (*DataConversionConfig) GetFloatPrec ¶
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 ¶
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 ¶
func DistSQLExecModeFromString(val string) (_ DistSQLExecMode, ok bool)
DistSQLExecModeFromString converts a string into a DistSQLExecMode
func (DistSQLExecMode) String ¶
func (m DistSQLExecMode) String() string
type SearchPath ¶
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 ¶
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 ¶
func (s SearchPath) Equals(other *SearchPath) bool
Equals returns true if two SearchPaths are the same.
func (SearchPath) GetPathArray ¶
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 ¶
func (s SearchPath) GetTemporarySchemaName() string
GetTemporarySchemaName returns the temporary schema specific to the current session.
func (SearchPath) Iter ¶
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. "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 ¶
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 ¶
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 ¶
func (s SearchPath) String() string
func (SearchPath) UpdatePaths ¶
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 ¶
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 ¶
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 ¶
func (iter *SearchPathIter) Next() (path string, ok bool)
Next returns the next search path, or false if there are no remaining paths.
type SequenceState ¶
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 ¶
func NewSequenceState() *SequenceState
NewSequenceState creates a SequenceState.
func (*SequenceState) Export ¶
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 ¶
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 ¶
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 ¶
func (ss *SequenceState) RecordValue(seqID uint32, val int64)
RecordValue records the latest manipulation of a sequence done by a session.
func (*SequenceState) SetLastSequenceIncremented ¶
func (ss *SequenceState) SetLastSequenceIncremented(seqID uint32)
SetLastSequenceIncremented sets the id of the last incremented sequence. Usually this id is set through RecordValue().
type SerialNormalizationMode ¶
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 ¶
func SerialNormalizationModeFromString(val string) (_ SerialNormalizationMode, ok bool)
SerialNormalizationModeFromString converts a string into a SerialNormalizationMode
func (SerialNormalizationMode) String ¶
func (m SerialNormalizationMode) String() string
type SessionData ¶
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 // 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 // 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 }
SessionData contains session parameters. They are all user-configurable. A SQL Session changes fields in SessionData through sql.sessionDataMutator.
type VectorizeExecMode ¶
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 // 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. If any part of a query is not // supported by the vectorized execution engine, the whole query will fall // back to row execution. VectorizeAuto // 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 ¶
func VectorizeExecModeFromString(val string) (VectorizeExecMode, bool)
VectorizeExecModeFromString converts a string into a VectorizeExecMode. False is returned if the conversion was unsuccessful.
func (VectorizeExecMode) String ¶
func (m VectorizeExecMode) String() string