no-mistakes-postgres-engine 0.109.129

PostgreSQL embedded SQL extraction, schema catalog, and replay-safety analysis for no-mistakes
Documentation
mod collected;
use super::super::helpers;
use super::super::relative::{PendingRelativeCall, PendingRelativeSpan};
use super::super::scoped_bindings::ScopedExecutors;
use super::executors::MemberQueryProof;
use super::resolve;
use crate::embedded::{EmbeddedSqlCall, EmbeddedSqlFragment, EmbeddedSqlKind};
use std::collections::{BTreeMap, HashMap, HashSet};
mod collect;
use collected::CollectedCalls;
mod fragment;
pub(crate) use collect::collect_calls;
#[derive(Clone)]
pub(super) struct FrozenAlias {
    pub(super) scope: usize,
    pub(super) name: String,
    pub(super) local: String,
    pub(super) span: u32,
    pub(super) args: Vec<helpers::SiteArg>,
}

#[derive(Clone)]
pub(crate) struct BindingState {
    pub(super) value_identity: Option<std::num::NonZeroU32>,
    pub(super) builder_identity: Option<std::num::NonZeroU32>,
    pub(super) builder_effect_revision: u64,
    pub(super) condition_key: Option<(u64, u32)>,
    pub(super) variants: Option<Vec<super::variants::Recovered>>,
    pub(crate) sql: Option<String>,
    pub(crate) kind: EmbeddedSqlKind,
    pub(crate) line: u32,
    // None: ineligible; Some(false): awaiting or pending proof; Some(true): proven.
    pub(super) executor_alias: Option<bool>,
    pub(crate) initialized: bool,
    pub(crate) sql_builder: bool,
    pub(crate) sql_source_positions: Vec<super::super::EmbeddedSqlSourcePosition>,
}

pub(crate) struct ScopeVisitor<'a> {
    #[cfg(feature = "test-instrumentation")]
    pub(super) lock_summary_passes: usize,
    pub(super) lock_helper_applications: crate::fx::FxHashMap<(u32, u32), Vec<usize>>,
    pub(super) awaited_lock_helper_calls: crate::fx::FxHashSet<u32>,
    pub(super) adjacent_discarded_queries: crate::fx::FxHashMap<u32, u32>,
    pub(super) imported_lock_helpers: Vec<super::lock_helpers::Invocation>,
    pub(super) lock_helpers: super::lock_helpers::LockHelpers,
    pub(super) incomplete_transaction_owners: crate::fx::FxHashSet<u32>,
    pub(super) exited_functions: crate::fx::FxHashSet<u32>,
    pub(super) stable_parameter_fields:
        crate::fx::FxHashMap<u32, super::stable_binds::ParameterFields>,
    pub(super) stable_primitives: crate::fx::FxHashSet<u32>,
    pub(super) scalar_literals: crate::fx::FxHashMap<std::num::NonZeroU32, String>,
    pub(crate) head_calls_only: bool,
    pub(crate) exact_sql_origins: bool,
    pub(crate) source: &'a str,
    pub(crate) configured_module: String,
    pub(super) executor_options: &'a super::super::EmbeddedSqlOptions,
    pub(crate) query_members: bool,
    pub(crate) query_binding: bool,
    pub(crate) bindings: &'a HashSet<String>,
    pub(in crate::embedded) scoped: &'a ScopedExecutors,
    pub(crate) provisional: &'a [PendingRelativeSpan],
    pub(crate) scopes: Vec<HashMap<String, BindingState>>,
    pub(super) undeclared_scopes:
        Vec<HashMap<String, super::super::scoped_bindings::UndeclaredReceiverTypes>>,
    pub(super) undeclared_executor_types: Vec<super::super::UndeclaredExecutorType>,
    pub(super) executor_methods: Vec<String>,
    pub(crate) relative_proofs: Vec<HashMap<String, u32>>,
    pub(crate) namespace_proofs: Vec<HashSet<String>>,
    pub(crate) imported_namespace_names: HashMap<String, String>,
    pub(crate) imported_value_origins: HashMap<String, (String, String)>,
    pub(crate) member_query_proof: MemberQueryProof,
    pub(super) builder_aliases: crate::fx::FxHashMap<String, Vec<String>>,
    pub(super) argument_effects: Vec<super::executor_arguments::ArgumentEffect>,
    pub(super) argument_frames: usize,
    pub(super) builder_reference_exemptions: Vec<u32>,
    /// Inner links of a fluent append chain already applied by its outer call.
    pub(super) consumed_links: crate::fx::FxHashSet<u32>,
    /// Calls that are a whole expression statement: their value is discarded.
    pub(super) statement_calls: crate::fx::FxHashSet<u32>,
    pub(super) preproof_references: crate::fx::FxHashSet<(u32, String)>,
    pub(super) escaped_forwarded: crate::fx::FxHashSet<(u32, String)>,
    pub(super) forwarded_bodies: crate::fx::FxHashMap<(u32, String), oxc_span::Span>,
    pub(super) executor_alias_refs:
        crate::fx::FxHashMap<u32, crate::fx::FxHashMap<String, Vec<oxc_span::Span>>>,
    pub(super) executor_reference_spans: crate::fx::FxHashSet<(u32, u32)>,
    pub(super) executor_direct_refs: crate::fx::FxHashSet<(u32, u32)>,
    pub(super) executor_invoked_refs: crate::fx::FxHashSet<(u32, u32)>,
    pub(crate) calls: Vec<EmbeddedSqlCall>,
    pub(crate) call_spans: Vec<(u32, u32)>,
    /// Local names bound by value imports; a call to one is an imported helper.
    pub(crate) imported_names: crate::fx::FxHashSet<String>,
    /// Runtime namespace imports, independent of configured executor modules.
    pub(super) constant_namespaces: crate::fx::FxHashSet<String>,
    /// The `const` initializer being walked, when it is a recognized IIFE.
    pub(super) iife: Option<super::iife::Iife>,
    pub(crate) imported_sites: std::cell::RefCell<helpers::Sites>,
    pub(crate) pending_spans: BTreeMap<u32, (u32, u32)>,
    pub(crate) diagnostic_member_queries: BTreeMap<u32, crate::embedded::UnprovenMemberQuery>,
    pub(crate) pending_calls: Vec<PendingRelativeCall>,
    pub(crate) confirmed_order: Vec<u32>,
    pub(crate) next_seq: u32,
    pub(crate) track_order: bool,
    pub(crate) fragments: Vec<EmbeddedSqlFragment>,
    pub(crate) fragment_sites: Vec<Option<u32>>,
    pub(crate) fragment_variants: Vec<Vec<super::super::EmbeddedSqlVariant>>,
    pub(crate) suppress_nested_builder_fragments: usize,
    pub(crate) variant_paths: Vec<Vec<(u64, u32)>>,
    pub(super) append_decision_offs: std::cell::RefCell<crate::fx::FxHashMap<u64, (u32, u32)>>,
    pub(super) variant_guard_owner: Option<usize>,
    pub(crate) control_depth: usize,
    pub(super) caught_effect_depth: usize,
    pub(super) caught_try: Option<(u32, usize)>,
    pub(crate) loop_depth: usize,
    pub(super) execution_loop: Option<u32>,
    pub(crate) function_scopes: Vec<usize>,
    pub(crate) var_scopes: Vec<usize>,
    pub(crate) functions: resolve::LocalFunctions,
    pub(crate) sql_statement_types: HashSet<String>,
    pub(crate) unproven_member_queries: Vec<crate::embedded::UnprovenMemberQuery>,
    pub(super) transaction_options: super::transaction::options::State,
    pub(super) literal_objects: super::const_literals::LiteralObjects,
    pub(super) vitest_it_imports: crate::fx::FxHashSet<String>,
    pub(super) finite_cases: Vec<super::finite_identifiers::FiniteCase>,
    pub(super) guarded_cases: Vec<super::guarded_sql::GuardedCase>,
    pub(super) set_intrinsic_safe: bool,
    pub(super) declaring_const: bool,
    pub(super) declaring_plain_const: bool,
    pub(super) clause_unions: crate::fx::FxHashSet<(usize, String)>,
    pub(crate) exported_constants:
        crate::fx::FxHashMap<String, super::super::helpers::ExportedConstant>,
    pub(super) plain: super::plain_returns::PlainState,
    pub(super) call_fragment_state: super::call_fragments::CallFragmentState,
    pub(super) frozen_aliases: Vec<FrozenAlias>,
    pub(super) site_groups: std::cell::RefCell<crate::fx::FxHashMap<usize, u32>>,
}