Skip to content

Commit 9f6faa8

Browse files
Handle "CALL fn()" (#60)
Co-authored-by: Sean Linsley <[email protected]>
1 parent d1bdace commit 9f6faa8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/node_enum.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ impl NodeEnum {
212212
iter.push((rel.to_ref(), depth, Context::DML, false));
213213
}
214214
}
215+
NodeRef::CallStmt(s) => {
216+
if let Some(n) = s.funccall.as_ref() {
217+
iter.push((n.to_ref(), depth, Context::Call, false));
218+
}
219+
}
215220
//
216221
// The following statement types are DDL (changing table structure)
217222
//
@@ -652,6 +657,12 @@ impl NodeEnum {
652657
iter.push((rel.to_mut(), depth, Context::DML));
653658
}
654659
}
660+
NodeMut::CallStmt(s) => {
661+
let s = s.as_mut().unwrap();
662+
if let Some(n) = s.funccall.as_mut() {
663+
iter.push((n.to_mut(), depth, Context::Call));
664+
}
665+
}
655666
//
656667
// The following statement types are DDL (changing table structure)
657668
//

tests/parse_tests.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,17 @@ fn it_finds_called_functions() {
12531253
assert_eq!(result.statement_types(), ["SelectStmt"]);
12541254
}
12551255

1256+
#[test]
1257+
fn it_finds_functions_invoked_with_CALL() {
1258+
let result = parse("CALL testfunc(1);").unwrap();
1259+
assert_eq!(result.warnings.len(), 0);
1260+
assert_eq!(result.tables().len(), 0);
1261+
assert_eq!(result.functions(), ["testfunc"]);
1262+
assert_eq!(result.ddl_functions().len(), 0);
1263+
assert_eq!(result.call_functions(), ["testfunc"]);
1264+
assert_eq!(result.statement_types(), ["CallStmt"]);
1265+
}
1266+
12561267
#[test]
12571268
fn it_finds_dropped_functions() {
12581269
let result = parse("DROP FUNCTION IF EXISTS testfunc(x integer);").unwrap();

0 commit comments

Comments
 (0)