diff --git a/src/node_enum.rs b/src/node_enum.rs index 09c1a18..75ec6ef 100644 --- a/src/node_enum.rs +++ b/src/node_enum.rs @@ -212,6 +212,11 @@ impl NodeEnum { iter.push((rel.to_ref(), depth, Context::DML, false)); } } + NodeRef::CallStmt(s) => { + if let Some(n) = s.funccall.as_ref() { + iter.push((n.to_ref(), depth, Context::Call, false)); + } + } // // The following statement types are DDL (changing table structure) // @@ -652,6 +657,12 @@ impl NodeEnum { iter.push((rel.to_mut(), depth, Context::DML)); } } + NodeMut::CallStmt(s) => { + let s = s.as_mut().unwrap(); + if let Some(n) = s.funccall.as_mut() { + iter.push((n.to_mut(), depth, Context::Call)); + } + } // // The following statement types are DDL (changing table structure) // diff --git a/tests/parse_tests.rs b/tests/parse_tests.rs index 754d4c1..f0cbc5f 100644 --- a/tests/parse_tests.rs +++ b/tests/parse_tests.rs @@ -1253,6 +1253,17 @@ fn it_finds_called_functions() { assert_eq!(result.statement_types(), ["SelectStmt"]); } +#[test] +fn it_finds_functions_invoked_with_CALL() { + let result = parse("CALL testfunc(1);").unwrap(); + assert_eq!(result.warnings.len(), 0); + assert_eq!(result.tables().len(), 0); + assert_eq!(result.functions(), ["testfunc"]); + assert_eq!(result.ddl_functions().len(), 0); + assert_eq!(result.call_functions(), ["testfunc"]); + assert_eq!(result.statement_types(), ["CallStmt"]); +} + #[test] fn it_finds_dropped_functions() { let result = parse("DROP FUNCTION IF EXISTS testfunc(x integer);").unwrap();