Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pgdog/src/frontend/router/parser/query/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ impl QueryParser {
) -> Result<Command, Error> {
if stmt.kind == VAR_RESET_ALL {
Ok(Command::ResetAll)
} else if stmt.kind == VAR_SET_MULTI {
// SET TRANSACTION
} else if stmt.kind == VAR_SET_MULTI || stmt.kind == VAR_SET_CURRENT {
// SET TRANSACTION, or SET ... FROM CURRENT which doesn't change the value.
Ok(Command::Query(
Route::write(context.shards_calculator.shard().clone())
.with_read(context.read_only),
Expand Down
16 changes: 16 additions & 0 deletions pgdog/src/frontend/router/parser/query/test/test_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,19 @@ fn test_single_shard_set() {
_ => panic!("not a set"),
}
}

#[test]
fn test_set_from_current_passthrough() {
let mut test = QueryParserTest::new();

let command = test.execute(vec![Query::new("SET work_mem FROM CURRENT").into()]);
assert!(
matches!(command, Command::Query(_)),
"expected Command::Query, got {command:#?}",
);

let command = test.execute(vec![
Query::new("SET statement_timeout TO 1; SET work_mem FROM CURRENT").into(),
]);
assert!(matches!(command, Command::Split(queries) if queries.len() == 2));
}