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: ParseLimitsThe bounds the statement parser runs inside.
confirmed: boolWhether the caller confirmed a destructive operation.
dry_run: boolWhether the caller asked to see the effect without causing it.
count_only: boolWhether 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: boolWhether every change is refused before the connection is opened.
require_where: boolWhether a change without a restriction is refused.
require_unique_key: boolWhether 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: u64Ceiling on rows one change may affect.
max_rows: usizeCeiling on rows one read may return.
row_count_mode: RowCountModeWhat a change count means.
delimiter: StringThe separator between statements inside a file.
timeout: DurationCeiling for one operation.
max_input_bytes: usizeCeiling 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
impl Policy
Sourcepub fn new(
parse: ParseLimits,
max_affected: u64,
max_rows: usize,
row_count_mode: RowCountMode,
delimiter: String,
timeout: Duration,
) -> Self
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.
Sourcepub fn admit_read_only(&self, what: &str) -> Result<()>
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.
Sourcepub fn admit_change(&self, what: &str) -> Result<()>
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.
Sourcepub fn admit_simulation(&self, what: &str) -> Result<()>
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.