Skip to main content

no_mistakes_postgres_engine/embedded/
call.rs

1use super::{EmbeddedSqlSourcePosition, SqlByteOrigins};
2mod variants;
3pub use variants::MAX_FROZEN_OBJECT_SQL_VARIANTS;
4pub use variants::{EmbeddedSqlVariant, MAX_EMBEDDED_SQL_VARIANTS};
5
6/// One executor call site and its recovered SQL text. For `Dynamic` calls,
7/// `sql_text` keeps identifier placeholders or the prefix before an unresolved fragment.
8#[derive(Debug, Clone, PartialEq, Eq, Default)]
9pub struct EmbeddedSqlCall {
10    /// Concrete alternatives for a recoverable Dynamic call; empty for legacy calls.
11    pub variants: Vec<EmbeddedSqlVariant>,
12    pub lock_scope_analysis: bool,
13    #[doc(hidden)]
14    pub track_share_lock_writes: bool,
15    #[doc(hidden)]
16    pub track_redundant_prelocks: bool,
17    #[doc(hidden)]
18    pub next_discarded_query: Option<u32>,
19    #[doc(hidden)]
20    pub stable_prelock_parameters: Vec<bool>,
21    pub helper_definition: bool,
22    pub lock_helper: Option<Box<(String, u32)>>,
23    pub transaction_id: Option<u32>,
24    #[doc(hidden)]
25    pub caller_transaction_id: Option<u32>,
26    pub transaction_line: Option<u32>,
27    pub executor_transaction_known: bool,
28    pub execution_unconditional: bool,
29    #[doc(hidden)]
30    pub execution_awaited: bool,
31    #[doc(hidden)]
32    pub execution_scope: u32,
33    #[doc(hidden)]
34    pub execution_range: (u32, u32),
35    #[doc(hidden)]
36    pub bound_value_origins: Vec<(u32, u32, u32)>,
37    #[doc(hidden)]
38    pub bound_value_sql: Option<String>,
39    pub bound_parameters: Vec<Option<String>>,
40    pub line: u32,
41    pub callee: String,
42    pub sql_text: Option<String>,
43    pub kind: EmbeddedSqlKind,
44    pub declaration_line: Option<u32>,
45    /// Compact physical-line mapping for literal and template recovery.
46    pub sql_source_positions: Vec<EmbeddedSqlSourcePosition>,
47    #[doc(hidden)]
48    pub sql_source_offsets: SqlByteOrigins,
49    /// SQL line and column of each generated interpolation marker, before any user-authored
50    /// identifier with the same spelling can be confused for it.
51    pub recovered_placeholder_positions: Vec<(u32, u32)>,
52}
53
54/// How executed SQL was recovered from TypeScript.
55#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, serde::Serialize)]
56#[serde(rename_all = "camelCase")]
57pub enum EmbeddedSqlKind {
58    #[default]
59    Inline,
60    ImmutableLocal,
61    Composed,
62    Dynamic,
63}