Skip to content

Commit

Permalink
more mut
Browse files Browse the repository at this point in the history
  • Loading branch information
zorancv committed Nov 29, 2023
1 parent d942c55 commit a3a8405
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 72 deletions.
22 changes: 13 additions & 9 deletions store/postgres/src/block_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ impl From<std::ops::Range<BlockNumber>> for BlockRange {
}

impl ToSql<Range<Integer>, Pg> for BlockRange {
fn to_sql(&self, out: &mut Output<Pg>) -> diesel::serialize::Result {
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> diesel::serialize::Result {
let pair = (self.0, self.1);
ToSql::<Range<Integer>, Pg>::to_sql(&pair, out)
ToSql::<Range<Integer>, Pg>::to_sql(&pair, &mut out.reborrow())
}
}

Expand All @@ -101,7 +101,7 @@ pub struct BlockRangeLowerBoundClause<'a> {
}

impl<'a> QueryFragment<Pg> for BlockRangeLowerBoundClause<'a> {
fn walk_ast(&self, mut out: AstPass<Pg>) -> QueryResult<()> {
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
out.unsafe_to_cache_prepared();

out.push_sql("lower(");
Expand All @@ -120,7 +120,7 @@ pub struct BlockRangeUpperBoundClause<'a> {
}

impl<'a> QueryFragment<Pg> for BlockRangeUpperBoundClause<'a> {
fn walk_ast(&self, mut out: AstPass<Pg>) -> QueryResult<()> {
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
out.unsafe_to_cache_prepared();

out.push_sql("coalesce(upper(");
Expand Down Expand Up @@ -171,12 +171,16 @@ impl<'a> BlockRangeColumn<'a> {
///
/// `filters_by_id` has no impact on correctness. It is a heuristic to determine
/// whether the brin index should be used. If `true`, the brin index is not used.
pub fn contains(&self, out: &mut AstPass<Pg>, filters_by_id: bool) -> QueryResult<()> {
pub fn contains<'b>(
&'b self,
mut out: AstPass<'b, 'b, Pg>,
filters_by_id: bool,
) -> QueryResult<()> {
out.unsafe_to_cache_prepared();

match self {
BlockRangeColumn::Mutable { table, block, .. } => {
self.name(out);
self.name(&mut out);
out.push_sql(" @> ");
out.push_bind_param::<Integer, _>(block)?;

Expand Down Expand Up @@ -207,7 +211,7 @@ impl<'a> BlockRangeColumn<'a> {
out.push_sql("true");
Ok(())
} else {
self.name(out);
self.name(&mut out);
out.push_sql(" <= ");
out.push_bind_param::<Integer, _>(block)
}
Expand Down Expand Up @@ -251,7 +255,7 @@ impl<'a> BlockRangeColumn<'a> {
/// # Panics
///
/// If the underlying table is immutable, this method will panic
pub fn clamp(&self, out: &mut AstPass<Pg>) -> QueryResult<()> {
pub fn clamp<'b>(&'b self, out: &mut AstPass<'b, 'b, Pg>) -> QueryResult<()> {
match self {
BlockRangeColumn::Mutable { block, .. } => {
self.name(out);
Expand All @@ -278,7 +282,7 @@ impl<'a> BlockRangeColumn<'a> {

/// Output an expression that matches all rows that have been changed
/// after `block` (inclusive)
pub(crate) fn changed_since(&self, out: &mut AstPass<Pg>) -> QueryResult<()> {
pub(crate) fn changed_since<'b>(&'b self, out: &mut AstPass<'b, 'b, Pg>) -> QueryResult<()> {
match self {
BlockRangeColumn::Mutable { block, .. } => {
out.push_sql("lower(");
Expand Down
8 changes: 4 additions & 4 deletions store/postgres/src/deployment_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1610,12 +1610,12 @@ impl DeploymentStore {
// - There's no fatal error for the subgraph
// - The error is NOT deterministic
pub(crate) fn unfail_deterministic_error(
&mut self,
&self,
site: Arc<Site>,
current_ptr: &BlockPtr,
parent_ptr: &BlockPtr,
) -> Result<UnfailOutcome, StoreError> {
let conn = &mut self.get_conn()?;
let mut conn = self.get_conn()?;
let deployment_id = &site.deployment;

conn.transaction(|conn| {
Expand Down Expand Up @@ -1707,11 +1707,11 @@ impl DeploymentStore {
// - There's no fatal error for the subgraph
// - The error IS deterministic
pub(crate) fn unfail_non_deterministic_error(
&mut self,
&self,
site: Arc<Site>,
current_ptr: &BlockPtr,
) -> Result<UnfailOutcome, StoreError> {
let conn = &mut self.get_conn()?;
let mut conn = self.get_conn()?;
let deployment_id = &site.deployment;

conn.transaction(|conn| {
Expand Down
Loading

0 comments on commit a3a8405

Please sign in to comment.