Documentation ¶
Index ¶
- Variables
- func MarshalNonLocal(sd *SessionData, proto *sessiondatapb.SessionData)
- type InternalExecutorOverride
- type LocalUnmigratableSessionData
- type SearchPath
- func (s SearchPath) Contains(target string) bool
- 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) SQLIdentifiers() string
- func (s SearchPath) String() string
- func (s SearchPath) UpdatePaths(paths []string) SearchPath
- func (s SearchPath) WithTemporarySchemaName(tempSchemaName string) SearchPath
- func (s SearchPath) WithUserSchemaName(userSchemaName 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 SessionData
- func (s *SessionData) Clone() *SessionData
- func (s *SessionData) GetDateStyle() pgdate.DateStyle
- func (s *SessionData) GetIntervalStyle() duration.IntervalStyle
- func (s *SessionData) GetLocation() *time.Location
- func (s *SessionData) GetTemporarySchemaIDForDB(dbID uint32) (uint32, bool)
- func (s *SessionData) IsTemporarySchemaID(schemaID uint32) bool
- func (s *SessionData) MaybeGetDatabaseForTemporarySchemaID(schemaID uint32) (uint32, bool)
- type Stack
- func (s *Stack) Base() *SessionData
- func (s *Stack) Clone() *Stack
- func (s *Stack) Elems() []*SessionData
- func (s *Stack) Pop() error
- func (s *Stack) PopAll()
- func (s *Stack) PopN(n int) error
- func (s *Stack) Push(elem *SessionData)
- func (s *Stack) PushTopClone()
- func (s *Stack) Replace(repl *Stack)
- func (s *Stack) Top() *SessionData
Constants ¶
This section is empty.
Variables ¶
var EmptySearchPath = SearchPath{}
EmptySearchPath is a SearchPath with no schema names in it.
var NoSessionDataOverride = InternalExecutorOverride{}
NoSessionDataOverride is the empty InternalExecutorOverride which does not override any session data.
Functions ¶
func MarshalNonLocal ¶
func MarshalNonLocal(sd *SessionData, proto *sessiondatapb.SessionData)
MarshalNonLocal serializes all non-local parameters from SessionData struct that don't have native protobuf support into proto.
Types ¶
type InternalExecutorOverride ¶
type InternalExecutorOverride struct { // User represents the user that the query will run under. //User security.SQLUsername // Database represents the default database for the query. Database string // ApplicationName represents the application that the query runs under. ApplicationName string // SearchPath represents the namespaces to search in. SearchPath *SearchPath // DatabaseIDToTempSchemaID represents the mapping for temp schemas used which // allows temporary schema resolution by ID. DatabaseIDToTempSchemaID map[uint32]uint32 }
InternalExecutorOverride is used by the InternalExecutor interface to allow control over some of the session data.
type LocalUnmigratableSessionData ¶
type LocalUnmigratableSessionData struct { // RemoteAddr is used to generate logging events. // RemoteAddr will acceptably change between session migrations. RemoteAddr net.Addr // DatabaseIDToTempSchemaID stores the temp schema ID for every // database that has created a temporary schema. The mapping is from // descpb.ID -> descpb.ID, but cannot be stored as such due to package // dependencies. Temporary tables are not supported in session migrations. DatabaseIDToTempSchemaID map[uint32]uint32 }
LocalUnmigratableSessionData contains session parameters that cannot be propagated to remote nodes and cannot be migrated to another session.
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) Contains ¶
func (s SearchPath) Contains(target string) bool
Contains returns true iff the SearchPath contains the given string.
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, or an empty string if the current session has not yet created a temporary schema.
Note that even after the current session has created a temporary schema, a schema with that name may not exist in the session's current database.
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. 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 ¶
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) SQLIdentifiers ¶
func (s SearchPath) SQLIdentifiers() string
SQLIdentifiers returns quotes for string starting with special characters.
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 and userSchemaName 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.
func (SearchPath) WithUserSchemaName ¶
func (s SearchPath) WithUserSchemaName(userSchemaName string) SearchPath
WithUserSchemaName returns a new immutable SearchPath struct with the userSchemaName populated and the same values for all other fields as before.
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. If there are no values in latestValues, the returned map will be nil. 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 SessionData ¶
type SessionData struct { // SessionData contains session parameters that are easily serializable and // are required to be propagated to the remote nodes for the correct // execution of DistSQL flows. sessiondatapb.SessionData // LocalOnlySessionData contains session parameters that don't need to be // propagated to the remote nodes. sessiondatapb.LocalOnlySessionData // LocalUnmigratableSessionData contains session parameters that cannot // be propagated to remote nodes and cannot be migrated to another // session. LocalUnmigratableSessionData // All session parameters below must be propagated to the remote nodes but // are not easily serializable. They require custom serialization // (MarshalNonLocal) and deserialization (UnmarshalNonLocal). // // Location indicates the current time zone. Location *time.Location // SearchPath is a list of namespaces to search builtins in. SearchPath SearchPath // SequenceState gives access to the SQL sequences that have been // manipulated by the session. SequenceState *SequenceState }
SessionData contains session parameters. They are all user-configurable. A SQL Session changes fields in SessionData through sql.sessionDataMutator.
func UnmarshalNonLocal ¶
func UnmarshalNonLocal(proto sessiondatapb.SessionData) (*SessionData, error)
UnmarshalNonLocal returns a new SessionData based on the serialized representation. Note that only non-local session parameters are populated.
func (*SessionData) Clone ¶
func (s *SessionData) Clone() *SessionData
Clone returns a clone of SessionData.
func (*SessionData) GetDateStyle ¶
func (s *SessionData) GetDateStyle() pgdate.DateStyle
GetDateStyle returns the session date style.
func (*SessionData) GetIntervalStyle ¶
func (s *SessionData) GetIntervalStyle() duration.IntervalStyle
GetIntervalStyle returns the session interval style.
func (*SessionData) GetLocation ¶
func (s *SessionData) GetLocation() *time.Location
GetLocation returns the session timezone.
func (*SessionData) GetTemporarySchemaIDForDB ¶
func (s *SessionData) GetTemporarySchemaIDForDB(dbID uint32) (uint32, bool)
GetTemporarySchemaIDForDB returns the schemaID for the temporary schema if one exists for the DB. The second return value communicates the existence of the temp schema for that DB.
func (*SessionData) IsTemporarySchemaID ¶
func (s *SessionData) IsTemporarySchemaID(schemaID uint32) bool
IsTemporarySchemaID returns true if the given ID refers to any of the temp schemas created by the session.
func (*SessionData) MaybeGetDatabaseForTemporarySchemaID ¶
func (s *SessionData) MaybeGetDatabaseForTemporarySchemaID(schemaID uint32) (uint32, bool)
MaybeGetDatabaseForTemporarySchemaID returns the corresponding database and true if the schemaID refers to any of the temp schemas created by this session.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack represents a stack of SessionData objects. This is used to support transaction-scoped variables, where SET LOCAL only affects the top of the stack. There is always guaranteed to be one element in the stack.
func (*Stack) Base ¶
func (s *Stack) Base() *SessionData
Base returns the bottom element of the stack. This is a non-racy structure, as the bottom element is always constant.
func (*Stack) Elems ¶
func (s *Stack) Elems() []*SessionData
Elems returns all elements in the Stack.
func (*Stack) PopAll ¶
func (s *Stack) PopAll()
PopAll removes all except the base SessionData element from the stack.
func (*Stack) Push ¶
func (s *Stack) Push(elem *SessionData)
Push pushes a SessionData element to the stack.
func (*Stack) PushTopClone ¶
func (s *Stack) PushTopClone()
PushTopClone pushes a copy of the top element to the stack.