From abdcc837e5308da9143006e25b05127308c65197 Mon Sep 17 00:00:00 2001 From: Eklavya Sahani Date: Tue, 1 Apr 2025 17:10:19 +0530 Subject: [PATCH 1/2] Add new feature --- src/sqlancer/Main.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sqlancer/Main.java b/src/sqlancer/Main.java index 7df750bf1..29b93b106 100644 --- a/src/sqlancer/Main.java +++ b/src/sqlancer/Main.java @@ -792,7 +792,6 @@ public void run() { lastNrQueries = currentNrQueries; lastNrDbs = currentNrDbs; } - }, 5, 5, TimeUnit.SECONDS); + }, 10, 10, TimeUnit.SECONDS); } - -} +} \ No newline at end of file From 7761246589a46aad3b743c705c278bcb8603d32d Mon Sep 17 00:00:00 2001 From: Eklavya Sahani Date: Fri, 4 Apr 2025 00:20:09 +0530 Subject: [PATCH 2/2] Solved the Bug issue --- src/sqlancer/Main.java | 43 +++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/sqlancer/Main.java b/src/sqlancer/Main.java index 29b93b106..ff7415d1e 100644 --- a/src/sqlancer/Main.java +++ b/src/sqlancer/Main.java @@ -167,7 +167,7 @@ private FileWriter getLogFileWriter() { public FileWriter getCurrentFileWriter() { if (!logEachSelect) { - throw new UnsupportedOperationException(); + return null; // Instead of throwing an exception } if (currentFileWriter == null) { try { @@ -177,7 +177,7 @@ public FileWriter getCurrentFileWriter() { } } return currentFileWriter; - } + } public FileWriter getQueryPlanFileWriter() { if (!logQueryPlan) { @@ -209,16 +209,18 @@ public FileWriter getReduceFileWriter() { public void writeCurrent(StateToReproduce state) { if (!logEachSelect) { - throw new UnsupportedOperationException(); + return; // Skip logging if logEachSelect is false } - printState(getCurrentFileWriter(), state); - try { - currentFileWriter.flush(); - - } catch (IOException e) { - e.printStackTrace(); + FileWriter writer = getCurrentFileWriter(); + if (writer != null) { + printState(writer, state); + try { + writer.flush(); + } catch (IOException e) { + e.printStackTrace(); + } } - } + } public void writeCurrent(String input) { write(databaseProvider.getLoggableFactory().createLoggable(input)); @@ -230,16 +232,18 @@ public void writeCurrentNoLineBreak(String input) { private void write(Loggable loggable) { if (!logEachSelect) { - throw new UnsupportedOperationException(); + return; // Skip writing if logging is disabled } - try { - getCurrentFileWriter().write(loggable.getLogString()); - - currentFileWriter.flush(); - } catch (IOException e) { - throw new AssertionError(); + FileWriter writer = getCurrentFileWriter(); + if (writer != null) { + try { + writer.write(loggable.getLogString()); + writer.flush(); + } catch (IOException e) { + throw new AssertionError(e); + } } - } + } public void writeQueryPlan(String queryPlan) { if (!logQueryPlan) { @@ -792,6 +796,7 @@ public void run() { lastNrQueries = currentNrQueries; lastNrDbs = currentNrDbs; } - }, 10, 10, TimeUnit.SECONDS); + }, 5, 5, TimeUnit.SECONDS); } + } \ No newline at end of file