db: fix handling of nested calls