Skip to content

Commit eefcde5

Browse files
committed
[Postgres] Add bug 18643
1 parent e0d072b commit eefcde5

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package sqlancer.postgres;
2+
3+
// do not make the fields final to avoid warnings
4+
public final class PostgresBugs {
5+
public static boolean bug18643 = true;
6+
7+
private PostgresBugs() {
8+
}
9+
10+
}

src/sqlancer/postgres/oracle/PostgresCERTOracle.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import sqlancer.common.oracle.TestOracle;
1515
import sqlancer.common.query.SQLQueryAdapter;
1616
import sqlancer.common.query.SQLancerResultSet;
17+
import sqlancer.postgres.PostgresBugs;
1718
import sqlancer.postgres.PostgresGlobalState;
1819
import sqlancer.postgres.PostgresSchema.PostgresColumn;
1920
import sqlancer.postgres.PostgresSchema.PostgresDataType;
@@ -77,14 +78,19 @@ public void check() throws SQLException {
7778

7879
// First query row count
7980
String queryString1 = PostgresVisitor.asString(select);
80-
int rowCount1 = getRow(state, queryString1, queryPlan1Sequences);
81+
long rowCount1 = getRow(state, queryString1, queryPlan1Sequences);
8182

8283
// JOIN and LIMIT mutations not added
83-
boolean increase = mutate(Mutator.LIMIT);
84+
boolean increase;
85+
if (PostgresBugs.bug18643) {
86+
increase = mutate(Mutator.LIMIT, Mutator.OR, Mutator.AND);
87+
} else {
88+
increase = mutate(Mutator.LIMIT);
89+
}
8490

8591
// Second Query row count
8692
String queryString2 = PostgresVisitor.asString(select);
87-
int rowCount2 = getRow(state, queryString2, queryPlan2Sequences);
93+
long rowCount2 = getRow(state, queryString2, queryPlan2Sequences);
8894

8995
// Check query plan equivalence
9096
if (DBMSCommon.editDistance(queryPlan1Sequences, queryPlan2Sequences) > 1) {
@@ -216,9 +222,9 @@ protected boolean mutateLimit() {
216222
return increase;
217223
}
218224

219-
private int getRow(SQLGlobalState<?, ?> globalState, String selectStr, List<String> queryPlanSequences)
225+
private long getRow(SQLGlobalState<?, ?> globalState, String selectStr, List<String> queryPlanSequences)
220226
throws AssertionError, SQLException {
221-
int row = -1;
227+
long row = -1;
222228
String explainQuery = "EXPLAIN " + selectStr;
223229

224230
if (globalState.getOptions().logEachSelect()) {
@@ -239,7 +245,7 @@ private int getRow(SQLGlobalState<?, ?> globalState, String selectStr, List<Stri
239245
if (content.contains("rows=")) {
240246
try {
241247
int ind = content.indexOf("rows=");
242-
int number = Integer.parseInt(content.substring(ind + 5).split(" ")[0]);
248+
long number = Long.parseLong(content.substring(ind + 5).split(" ")[0]);
243249
if (row == -1) {
244250
row = number;
245251

0 commit comments

Comments
 (0)