Skip to content

Commit cf1271c

Browse files
committed
coord: always include system indexes in read transactions
System views from pg_catalog and mz_catalog are sometimes used by applications (for example Metabase if it doesn't recognize a data type) after the first query of a transaction. This previously would cause a timedomain error. One solution to this is to always include system indexes in read transactions. The cost is mostly that system indexes can now be held back from compaction more than previously. This seems ok because they don't change quickly, so should hopefully not cause memory issues. Fixes #9375 Fixes #9374
1 parent 7f0e1ac commit cf1271c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/sql/src/plan/transform_ast.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ impl<'a> Desugarer<'a> {
373373
args: func.args,
374374
},
375375
alias: Some(TableAlias {
376-
name: name,
376+
name,
377377
columns: vec![],
378378
strict: false,
379379
}),
@@ -633,7 +633,7 @@ impl<'a> Desugarer<'a> {
633633
// nodes (and thus any subquery Expr) are ignored.
634634
struct TableFuncRewriter<'a> {
635635
scx: &'a StatementContext<'a>,
636-
disallowed: Vec<&'static str>,
636+
disallowed_context: Vec<&'static str>,
637637
table_func: Option<(Function<Raw>, Ident)>,
638638
status: Result<(), anyhow::Error>,
639639
}
@@ -644,15 +644,16 @@ impl<'ast> VisitMut<'ast, Raw> for TableFuncRewriter<'_> {
644644
}
645645

646646
fn visit_query_mut(&mut self, _node: &'ast mut Query<Raw>) {
647-
// Do not descend into Query nodes.
647+
// Do not descend into Query nodes so subqueries can have their own table
648+
// functions rewritten.
648649
}
649650
}
650651

651652
impl<'a> TableFuncRewriter<'a> {
652653
fn new(scx: &'a StatementContext<'a>) -> TableFuncRewriter<'a> {
653654
TableFuncRewriter {
654655
scx,
655-
disallowed: Vec::new(),
656+
disallowed_context: Vec::new(),
656657
table_func: None,
657658
status: Ok(()),
658659
}
@@ -676,15 +677,15 @@ impl<'a> TableFuncRewriter<'a> {
676677
// This block does two things:
677678
// - Check if expr is a context where table functions are disallowed.
678679
// - Check if expr is a table function, and attempt to replace if so.
679-
let disallowed = match expr {
680+
let disallowed_context = match expr {
680681
Expr::Case { .. } => Some("CASE"),
681682
Expr::Coalesce { .. } => Some("COALESCE"),
682683
Expr::Function(func) => {
683684
if let Ok(item) = self.scx.resolve_function(func.name.clone()) {
684685
match item.func()? {
685686
Func::Aggregate(_) => Some("aggregate function calls"),
686687
Func::Set(_) | Func::Table(_) => {
687-
if let Some(context) = self.disallowed.last() {
688+
if let Some(context) = self.disallowed_context.last() {
688689
bail!("table functions are not allowed in {}", context);
689690
}
690691
let name = Ident::new(item.name().item.clone());
@@ -714,14 +715,14 @@ impl<'a> TableFuncRewriter<'a> {
714715
_ => None,
715716
};
716717

717-
if let Some(disallowed) = disallowed {
718-
self.disallowed.push(disallowed);
718+
if let Some(context) = disallowed_context {
719+
self.disallowed_context.push(context);
719720
}
720721

721722
visit_mut::visit_expr_mut(self, expr);
722723

723-
if disallowed.is_some() {
724-
self.disallowed.pop();
724+
if disallowed_context.is_some() {
725+
self.disallowed_context.pop();
725726
}
726727

727728
Ok(())

0 commit comments

Comments
 (0)