Skip to main content

Policy

Struct Policy 

Source
pub struct Policy {
Show 13 fields pub parse: ParseLimits, pub confirmed: bool, pub dry_run: bool, pub count_only: bool, pub read_only: bool, pub require_where: bool, pub require_unique_key: bool, pub max_affected: u64, pub max_rows: usize, pub row_count_mode: RowCountMode, pub delimiter: String, pub timeout: Duration, pub max_input_bytes: usize,
}
Expand description

Every ceiling and every guard one invocation runs under.

Not one of these values is written into the code that uses it. A ceiling compiled into a call site cannot be changed by whoever owns the host, so all of them arrive here from the settings layer or from a flag.

Fields§

§parse: ParseLimits

The bounds the statement parser runs inside.

§confirmed: bool

Whether the caller confirmed a destructive operation.

§dry_run: bool

Whether the caller asked to see the effect without causing it.

§count_only: bool

Whether the caller asked for a count instead of the rows themselves.

Carried here rather than only in the output layer because a count is a question about a READING, and asking it of a change is a contradiction the call can be refused for before anything is opened. FR-037 publishes that refusal and gives it the usage number.

§read_only: bool

Whether every change is refused before the connection is opened.

§require_where: bool

Whether a change without a restriction is refused.

§require_unique_key: bool

Whether a change against a table with no unique key is refused.

When this is off the absence is reported on the auxiliary channel and the change proceeds, because the absence makes a repeat unsafe without making this change wrong.

§max_affected: u64

Ceiling on rows one change may affect.

§max_rows: usize

Ceiling on rows one read may return.

§row_count_mode: RowCountMode

What a change count means.

§delimiter: String

The separator between statements inside a file.

§timeout: Duration

Ceiling for one operation.

§max_input_bytes: usize

Ceiling on what one invocation will READ before judging any of it.

Distinct from parse.max_statement_bytes, which bounds how large a single statement may be. This bounds how much reaches memory at all: the entry points used to take a whole file or the whole standard input in with read_to_string and measure statements afterwards, so the cost was paid before any ceiling existed to refuse it.

Implementations§

Source§

impl Policy

Source

pub fn new( parse: ParseLimits, max_affected: u64, max_rows: usize, row_count_mode: RowCountMode, delimiter: String, timeout: Duration, ) -> Self

Builds a policy from explicit values.

There is no constructor without arguments on purpose: a policy assembled from nothing would carry ceilings this module invented.

Source

pub fn admit_read_only(&self, what: &str) -> Result<()>

Whether this policy refuses changes outright.

§Why this is separate from the rest of admitting a change

It is the one part of the decision that needs nothing but the statement, so it is the one part that can be made before a connection is opened — which FR-071 requires and the field’s own documentation already claimed. Confirmation is not like that in practice: the same call that changes the server also carries the mark, and refusing early on that would move a second guard without being asked to.

§Errors

Returns a validation failure when this invocation refuses every change.

Source

pub fn admit_change(&self, what: &str) -> Result<()>

Whether a change may be attempted at all under this policy.

§Errors

Returns a validation failure when changes are refused outright, or when the caller did not confirm a destructive operation.

Source

pub fn admit_simulation(&self, what: &str) -> Result<()>

Whether a command that cannot simulate may run under a simulation.

§Why this is a second question and not part of the one above

admit_change admits a simulation, because the command that APPLIES a change honours it and returns before anything is sent. Two others ask the same guard and then execute regardless: a stored routine cannot be called halfway, and the measured plan is measured BY running the statement.

While the confirmation was demanded of every change, those two were held back by a mark they never needed. Relaxing it for simulations handed them a way through, and --dry-run alone began reaching the server — measured on query call, which answered with the server’s own condition for a routine that does not exist, which only an attempted call produces.

So the commands that cannot simulate say so. Refusing is the honest answer: the alternative is serving a real effect under the name of a preview.

§Errors

Returns a validation failure when this invocation is a simulation.

Trait Implementations§

Source§

impl Clone for Policy

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Policy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more