Skip to content
Merged
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
10 changes: 3 additions & 7 deletions pgdog/src/frontend/router/parser/cache/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ impl Ast {
search_path: Option<&ParameterValue>,
) -> Result<Self, Error> {
let now = Instant::now();
let ast = pg_raw_parse::parse(query.query_without_comment).map_err(Error::Parse)?;

// Run the rewrite unconditionally. Even when a shard comment will
// route the query to a specific shard, we need to know whether the
Expand All @@ -94,14 +93,11 @@ impl Ast {
});
let mut rewrite_plan = Default::default();
let ast = make::try_owned(|mem| {
// FIXME(sage): We should have a parse function on mem so we don't
// need to parse and then copy the parsed tree just to throw the
// original away
let mut copy = mem.make_unique(&*ast.into_inner());
if let Some(stmt) = copy.as_mut().into_iter().next() {
let mut ast = mem.parse(query.query_without_comment)?;
if let Some(stmt) = ast.as_mut().into_iter().next() {
rewrite_plan = rewriter.maybe_rewrite(stmt, mem)?;
}
Ok::<_, Error>(copy)
Ok::<_, Error>(ast)
})?;

let elapsed = now.elapsed();
Expand Down
Loading