Struct mz_adapter::session::vars::SessionVars
source · pub struct SessionVars {Show 25 fields
application_name: SessionVar<str>,
build_info: &'static BuildInfo,
client_encoding: ServerVar<str>,
client_min_messages: SessionVar<ClientSeverity>,
cluster: SessionVar<str>,
cluster_replica: SessionVar<Option<String>>,
database: SessionVar<str>,
date_style: &'static ServerVar<Vec<String>>,
extra_float_digits: SessionVar<i32>,
failpoints: ServerVar<str>,
integer_datetimes: ServerVar<bool>,
interval_style: ServerVar<str>,
search_path: SessionVar<Vec<Ident>>,
server_version: ServerVar<str>,
server_version_num: ServerVar<i32>,
sql_safe_updates: SessionVar<bool>,
standard_conforming_strings: ServerVar<bool>,
statement_timeout: SessionVar<Duration>,
idle_in_transaction_session_timeout: SessionVar<Duration>,
timezone: SessionVar<TimeZone>,
transaction_isolation: SessionVar<IsolationLevel>,
real_time_recency: SessionVar<bool>,
emit_timestamp_notice: SessionVar<bool>,
emit_trace_id_notice: SessionVar<bool>,
is_superuser: SessionVar<bool>,
}
Expand description
Session variables.
Materialize roughly follows the PostgreSQL configuration model, which works
as follows. There is a global set of named configuration parameters, like
DateStyle
and client_encoding
. These parameters can be set in several
places: in an on-disk configuration file (in Postgres, named
postgresql.conf), in command line arguments when the server is started, or
at runtime via the ALTER SYSTEM
or SET
statements. Parameters that are
set in a session take precedence over database defaults, which in turn take
precedence over command line arguments, which in turn take precedence over
settings in the on-disk configuration. Note that changing the value of
parameters obeys transaction semantics: if a transaction fails to commit,
any parameters that were changed in that transaction (i.e., via SET
)
will be rolled back to their previous value.
The Materialize configuration hierarchy at the moment is much simpler. Global defaults are hardcoded into the binary, and a select few parameters can be overridden per session. A select few parameters can be overridden on disk.
The set of variables that can be overridden per session and the set of variables that can be overridden on disk are currently disjoint. The infrastructure has been designed with an eye towards merging these two sets and supporting additional layers to the hierarchy, however, should the need arise.
The configuration parameters that exist are driven by compatibility with PostgreSQL drivers that expect them, not because they are particularly important.
Fields§
§application_name: SessionVar<str>
§build_info: &'static BuildInfo
§client_encoding: ServerVar<str>
§client_min_messages: SessionVar<ClientSeverity>
§cluster: SessionVar<str>
§cluster_replica: SessionVar<Option<String>>
§database: SessionVar<str>
§date_style: &'static ServerVar<Vec<String>>
§extra_float_digits: SessionVar<i32>
§failpoints: ServerVar<str>
§integer_datetimes: ServerVar<bool>
§interval_style: ServerVar<str>
§search_path: SessionVar<Vec<Ident>>
§server_version: ServerVar<str>
§server_version_num: ServerVar<i32>
§sql_safe_updates: SessionVar<bool>
§standard_conforming_strings: ServerVar<bool>
§statement_timeout: SessionVar<Duration>
§idle_in_transaction_session_timeout: SessionVar<Duration>
§timezone: SessionVar<TimeZone>
§transaction_isolation: SessionVar<IsolationLevel>
§real_time_recency: SessionVar<bool>
§emit_timestamp_notice: SessionVar<bool>
§emit_trace_id_notice: SessionVar<bool>
§is_superuser: SessionVar<bool>
Implementations§
source§impl SessionVars
impl SessionVars
sourcepub fn new(build_info: &'static BuildInfo) -> SessionVars
pub fn new(build_info: &'static BuildInfo) -> SessionVars
Creates a new SessionVars
.
sourcepub fn iter(&self) -> impl Iterator<Item = &dyn Var>
pub fn iter(&self) -> impl Iterator<Item = &dyn Var>
Returns an iterator over the configuration parameters and their current values for this session.
sourcepub fn notify_set(&self) -> impl Iterator<Item = &dyn Var>
pub fn notify_set(&self) -> impl Iterator<Item = &dyn Var>
Returns an iterator over configuration parameters (and their current values for this session) that are expected to be sent to the client when a new connection is established or when their value changes.
sourcepub fn get(&self, name: &str) -> Result<&dyn Var, AdapterError>
pub fn get(&self, name: &str) -> Result<&dyn Var, AdapterError>
Returns a Var
representing the configuration parameter with the
specified name.
Configuration parameters are matched case insensitively. If no such
configuration parameter exists, get
returns an error.
Note that if name
is known at compile time, you should instead use the
named accessor to access the variable with its true Rust type. For
example, self.get("sql_safe_updates").value()
returns the string
"true"
or "false"
, while self.sql_safe_updates()
returns a bool.
sourcepub fn set(
&mut self,
name: &str,
input: VarInput<'_>,
local: bool
) -> Result<(), AdapterError>
pub fn set(
&mut self,
name: &str,
input: VarInput<'_>,
local: bool
) -> Result<(), AdapterError>
Sets the configuration parameter named name
to the value represented
by value
.
The new value may be either committed or rolled back by the next call to
SessionVars::end_transaction
. If local
is true, the new value is always
discarded by the next call to SessionVars::end_transaction
, even if the
transaction is marked to commit.
Like with SessionVars::get
, configuration parameters are matched case
insensitively. If value
is not valid, as determined by the underlying
configuration parameter, or if the named configuration parameter does
not exist, an error is returned.
sourcepub fn reset(&mut self, name: &str, local: bool) -> Result<(), AdapterError>
pub fn reset(&mut self, name: &str, local: bool) -> Result<(), AdapterError>
Sets the configuration parameter named name
to its default value.
The new value may be either committed or rolled back by the next call to
SessionVars::end_transaction
. If local
is true, the new value is always
discarded by the next call to SessionVars::end_transaction
, even if the
transaction is marked to commit.
Like with SessionVars::get
, configuration parameters are matched case
insensitively. If the named configuration parameter does not exist, an
error is returned.
sourcepub fn end_transaction(&mut self, action: EndTransactionAction)
pub fn end_transaction(&mut self, action: EndTransactionAction)
Commits or rolls back configuration parameter updates made via
SessionVars::set
since the last call to end_transaction
.
sourcepub fn application_name(&self) -> &str
pub fn application_name(&self) -> &str
Returns the value of the application_name
configuration parameter.
sourcepub fn build_info(&self) -> &'static BuildInfo
pub fn build_info(&self) -> &'static BuildInfo
Returns the build info.
sourcepub fn client_encoding(&self) -> &'static str
pub fn client_encoding(&self) -> &'static str
Returns the value of the client_encoding
configuration parameter.
sourcepub fn client_min_messages(&self) -> &ClientSeverity
pub fn client_min_messages(&self) -> &ClientSeverity
Returns the value of the client_min_messages
configuration parameter.
sourcepub fn cluster_replica(&self) -> Option<&str>
pub fn cluster_replica(&self) -> Option<&str>
Returns the value of the cluster_replica
configuration parameter.
sourcepub fn date_style(&self) -> &[String]
pub fn date_style(&self) -> &[String]
Returns the value of the DateStyle
configuration parameter.
sourcepub fn extra_float_digits(&self) -> i32
pub fn extra_float_digits(&self) -> i32
Returns the value of the extra_float_digits
configuration parameter.
sourcepub fn integer_datetimes(&self) -> bool
pub fn integer_datetimes(&self) -> bool
Returns the value of the integer_datetimes
configuration parameter.
sourcepub fn intervalstyle(&self) -> &'static str
pub fn intervalstyle(&self) -> &'static str
Returns the value of the intervalstyle
configuration parameter.
sourcepub fn mz_version(&self) -> String
pub fn mz_version(&self) -> String
Returns the value of the mz_version
configuration parameter.
sourcepub fn search_path(&self) -> &[Ident]
pub fn search_path(&self) -> &[Ident]
Returns the value of the search_path
configuration parameter.
sourcepub fn server_version(&self) -> &'static str
pub fn server_version(&self) -> &'static str
Returns the value of the server_version
configuration parameter.
sourcepub fn server_version_num(&self) -> i32
pub fn server_version_num(&self) -> i32
Returns the value of the server_version_num
configuration parameter.
sourcepub fn sql_safe_updates(&self) -> bool
pub fn sql_safe_updates(&self) -> bool
Returns the value of the sql_safe_updates
configuration parameter.
sourcepub fn standard_conforming_strings(&self) -> bool
pub fn standard_conforming_strings(&self) -> bool
Returns the value of the standard_conforming_strings
configuration
parameter.
sourcepub fn statement_timeout(&self) -> &Duration
pub fn statement_timeout(&self) -> &Duration
Returns the value of the statement_timeout
configuration parameter.
sourcepub fn idle_in_transaction_session_timeout(&self) -> &Duration
pub fn idle_in_transaction_session_timeout(&self) -> &Duration
Returns the value of the idle_in_transaction_session_timeout
configuration parameter.
sourcepub fn transaction_isolation(&self) -> &IsolationLevel
pub fn transaction_isolation(&self) -> &IsolationLevel
Returns the value of the transaction_isolation
configuration
parameter.
sourcepub fn real_time_recency(&self) -> bool
pub fn real_time_recency(&self) -> bool
Returns the value of real_time_recency
configuration parameter.
sourcepub fn emit_timestamp_notice(&self) -> bool
pub fn emit_timestamp_notice(&self) -> bool
Returns the value of emit_timestamp_notice
configuration parameter.
sourcepub fn emit_trace_id_notice(&self) -> bool
pub fn emit_trace_id_notice(&self) -> bool
Returns the value of emit_trace_id_notice
configuration parameter.
sourcepub fn is_superuser(&self) -> bool
pub fn is_superuser(&self) -> bool
Returns the value of is_superuser
configuration parameter.
pub(crate) fn set_cluster(&mut self, cluster: String)
pub(crate) fn set_superuser(&mut self, is_superuser: bool)
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for SessionVars
impl Send for SessionVars
impl Sync for SessionVars
impl Unpin for SessionVars
impl UnwindSafe for SessionVars
Blanket Implementations§
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.