Skip to content

Commit d6a6405

Browse files
committed
adapter: DEALLOCATE stmts while in transaction
The existing `DEALLOCATE` support missed the case of a DEALLOCATE being requested while a transaction is open. Becuase of that, the adapter will naively forward along the request _with the prepared statement id the application provided_. We can't pass along that id as we have an alternate id when we prepared the statment, and that's the one we must send to the upstream. This CL moves the `SqlQuery::Deallocate` statement handling slightly higher in `Backend::query()`, just before where it checks if it's in a transaction. Also, cleans up the existing handling in `Backend::query_adhoc_non_select()` as it should not execute there any longer (but we need to handle the enum variant nonetheless). Fixes: REA-3983 Release-Note-Core: Fixed a bug with handling DEALLOCATE statements within a transaction. Change-Id: Iccfcc8ebfc8cf50840659f487e11d9099720a576 Reviewed-on: https://gerrit.readyset.name/c/readyset/+/7184 Tested-by: Buildkite CI Reviewed-by: Luke Osborne <luke@readyset.io>
1 parent deb2d62 commit d6a6405

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

readyset-adapter/src/backend.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,8 +2825,6 @@ where
28252825
upstream.query(raw_query).await.map(QueryResult::Upstream)
28262826
}
28272827

2828-
SqlQuery::Deallocate(stmt) => Ok(Self::handle_deallocate_statement(stmt)),
2829-
28302828
SqlQuery::StartTransaction(_) | SqlQuery::Commit(_) | SqlQuery::Rollback(_) => {
28312829
Self::handle_transaction_boundaries(
28322830
Some(upstream),
@@ -2836,6 +2834,7 @@ where
28362834
.await
28372835
}
28382836
SqlQuery::CreateCache(_)
2837+
| SqlQuery::Deallocate(_)
28392838
| SqlQuery::DropCache(_)
28402839
| SqlQuery::DropAllCaches(_)
28412840
| SqlQuery::DropAllProxiedQueries(_)
@@ -2863,10 +2862,7 @@ where
28632862
SqlQuery::Insert(q) => noria.handle_insert(q).await,
28642863
SqlQuery::Update(q) => noria.handle_update(q).await,
28652864
SqlQuery::Delete(q) => noria.handle_delete(q).await,
2866-
2867-
SqlQuery::Deallocate(stmt) => {
2868-
return Ok(Self::handle_deallocate_statement(stmt.clone()))
2869-
}
2865+
SqlQuery::Deallocate(_) => unreachable!("deallocate path returns prior"),
28702866

28712867
// Return an empty result as we are allowing unsupported set statements. Commit
28722868
// messages are dropped - we do not support transactions in noria standalone.
@@ -3040,6 +3036,7 @@ where
30403036
Self::query_fallback(self.upstream.as_mut(), query, &mut event).await
30413037
}
30423038
}
3039+
Ok(SqlQuery::Deallocate(stmt)) => Ok(Self::handle_deallocate_statement(stmt)),
30433040
Ok(_) if self.state.proxy_state.should_proxy() => {
30443041
Self::query_fallback(self.upstream.as_mut(), query, &mut event).await
30453042
}

0 commit comments

Comments
 (0)