Skip to content

Commit 9e63390

Browse files
committed
fix that ql/cand-missing-nomagic had a catastrophic join-order
1 parent 393a8c2 commit 9e63390

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ql/ql/src/queries/performance/MissingNomagic.ql

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ predicate hasNameWithNumberSuffix(Predicate p, string name, int n) {
3838
p.getName() = name + n.toString()
3939
}
4040

41+
pragma[noinline]
42+
predicate isHelperPredicate(string orgName, string helperName) {
43+
orgName = any(Predicate p).getName() and
44+
helperName =
45+
orgName.regexpCapture("(.+)" + ["0", "helper", "aux", "cand", "Helper", "Aux", "Cand"], 1)
46+
}
47+
4148
/**
4249
* A candidate predicate for another predicate.
4350
*
@@ -47,15 +54,14 @@ predicate hasNameWithNumberSuffix(Predicate p, string name, int n) {
4754
class CandidatePredicate extends Predicate {
4855
Predicate pred;
4956

57+
pragma[nomagic]
5058
CandidatePredicate() {
5159
// This predicate "guards" the predicate `pred` (i.e., it's always evaluated before `pred`).
5260
guards(this, pred.getBody()) and
5361
(
5462
// The name of `pred` is "foo", and the name of this predicate is `foo0`, or `fooHelper`, or any
5563
// other the other cases.
56-
pragma[only_bind_into](pred).getName() =
57-
this.getName()
58-
.regexpCapture("(.+)" + ["0", "helper", "aux", "cand", "Helper", "Aux", "Cand"], 1)
64+
isHelperPredicate(this.getName(), pred.getName())
5965
or
6066
// Or this predicate is named "foo02" and `pred` is named "foo01".
6167
exists(int n, string name |
@@ -66,6 +72,7 @@ class CandidatePredicate extends Predicate {
6672
}
6773

6874
/** Holds if this predicate is a candidate predicate for `p`. */
75+
pragma[nomagic]
6976
predicate isCandidateFor(Predicate p) { p = pred }
7077
}
7178

0 commit comments

Comments
 (0)