Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit errors for ignored execution plan #2352

Merged
Merged
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions src/ast/transform/ExecutionPlanChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ bool ExecutionPlanChecker::transform(TranslationUnit& translationUnit) {
for (const Relation* rel : scc) {
for (auto&& clause : program.getClauses(*rel)) {
if (!recursiveClauses.recursive(clause)) {
if (clause->getExecutionPlan() != nullptr) {
auto order = clause->getExecutionPlan()->getOrders().begin()->second;
report.addError(
"Ignored execution plan for non-recursive clause", order->getSrcLoc());
}
continue;
}
if (clause->getExecutionPlan() == nullptr) {
continue;
}
if (isA<SubsumptiveClause>(clause)) {
continue;
}

std::size_t version = 0;
for (const auto* atom : getBodyLiterals<Atom>(*clause)) {
if (scc.count(program.getRelation(*atom)) != 0u) {
Expand Down
25 changes: 25 additions & 0 deletions tests/semantic/execution_plan/execution_plan.dl
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,28 @@ r3(a,d) :- r3(a,b),r3(b,c),r3(c,d).
// this one is not
r4(a,d) :- r4(a,b),r4(b,c),r4(c,d).
.plan 0: (1,2,2), 1: (3,2), 2: (2,3,1,3)

.decl y(a:S)
.output y

y(a) :- r1(a,_), r2(a,_), r3(a,_).
.plan 0:(1,2,3)

.decl x1(a:number)
.decl x2(a:number)
.decl x3(a:number)
.output x1
.output x2
.output x3

// ok
x1(a) <= x1(b) :- a < b.
.plan 0:(1,2)

// Invalid plan: order is only 2.
x2(a) <= x2(b) :- a < b.
.plan 0:(1,2,3)

// Invalid plan: incomplete
x3(a) <= x3(b) :- a < b.
.plan 0:(1,3)
11 changes: 10 additions & 1 deletion tests/semantic/execution_plan/execution_plan.err
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,13 @@ Error: Invalid execution order in plan (expected 3 atoms, not 2) in file executi
Error: Invalid execution order in plan (expected 3 atoms, not 4) in file execution_plan.dl at line 25
.plan 0: (1,2,2), 1: (3,2), 2: (2,3,1,3)
---------------------------------------^---------
4 errors generated, evaluation aborted
Error: Ignored execution plan for non-recursive clause in file execution_plan.dl at line 31
.plan 0:(1,2,3)
----------------^-------
Error: Invalid execution order in plan (expected 2 atoms, not 3) in file execution_plan.dl at line 46
.plan 0:(1,2,3)
----------------^-------
Error: Invalid execution order in plan (incomplete) in file execution_plan.dl at line 50
.plan 0:(1,3)
----------------^-----
7 errors generated, evaluation aborted
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,3 @@ mx(n) <= mx(n) :- my(n).
.decl nx(x:number)
nx(n) <= nx(n) :- nx(n).
.output nx