gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-schemafuzz] branch master updated: Minor crashes but


From: gnunet
Subject: [GNUnet-SVN] [taler-schemafuzz] branch master updated: Minor crashes but working
Date: Tue, 12 Jun 2018 12:26:04 +0200

This is an automated email from the git hooks/post-receive script.

erwan-ulrich pushed a commit to branch master
in repository schemafuzz.

The following commit(s) were added to refs/heads/master by this push:
     new 26bd375  Minor crashes but working
26bd375 is described below

commit 26bd375c36ea05b2693581e839986eb0feef4988
Author: Feideus <address@hidden>
AuthorDate: Tue Jun 12 12:25:59 2018 +0200

    Minor crashes but working
---
 firstUnusedId.sh                                   |  1 -
 .../java/org/schemaspy/model/GenericTreeNode.java  | 55 ++++++++++------------
 2 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/firstUnusedId.sh b/firstUnusedId.sh
deleted file mode 100644
index 56d96c9..0000000
--- a/firstUnusedId.sh
+++ /dev/null
@@ -1 +0,0 @@
-psql -U feideus -d sample_database2 -c "\i tryout.sql" | sed '3q;d'
diff --git a/src/main/java/org/schemaspy/model/GenericTreeNode.java 
b/src/main/java/org/schemaspy/model/GenericTreeNode.java
index 2ba8723..2174d84 100644
--- a/src/main/java/org/schemaspy/model/GenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/GenericTreeNode.java
@@ -232,7 +232,7 @@ public class GenericTreeNode {
                 e.printStackTrace();
             }
         }
-        possibilities = 
removePotentialChangesThatDontMatchConstraints(possibilities,sqlService);
+        //possibilities = 
removePotentialChangesThatDontMatchConstraints(possibilities,sqlService);
         if(possibilities.isEmpty())
             System.out.println("No raw Mutation could be found for this row");
 
@@ -751,9 +751,7 @@ public class GenericTreeNode {
             e.printStackTrace();
         }
 
-
-
-        initial_state_row = response.getRows().get(0); // there should be only 
one row.
+        setInitial_state_row(response.getRows().get(0)); // there should be 
only one row. post change row ?
 
 
 
@@ -784,10 +782,20 @@ public class GenericTreeNode {
         {
             try
             {
-                Process fuID = new ProcessBuilder("/bin/bash", 
"firstUnusedId.sh").start();
-                String newValueAsString = getScriptResponse(fuID);
-                int newValue = 
Integer.parseInt(newValueAsString.replaceAll("\\s+",""));
-                chosenChange.setNewValue(newValue);
+                String columnName= 
chosenChange.getParentTableColumn().getName();
+                String tableName = 
chosenChange.getParentTableColumn().getTable().getName();
+
+                semiQuery = "SELECT * FROM ( SELECT  1 AS "+columnName+" ) q1 
WHERE NOT EXISTS ( SELECT  1 FROM "+tableName+" WHERE   "+columnName+" = 1) " +
+                            "UNION ALL SELECT  * FROM    ( SELECT  
"+columnName+" + 1 FROM "+tableName+" t WHERE NOT EXISTS ( SELECT  1 FROM 
"+tableName+" ti WHERE ti."+columnName+" = t."+columnName+" + 1) " +
+                            "ORDER BY "+columnName+" LIMIT 1) q2 LIMIT 1";
+
+                Statement stmt = sqlService.getConnection().createStatement();
+                ResultSet res = stmt.executeQuery(semiQuery);
+                qrp = new QueryResponseParser();
+                ArrayList<Row> rows = new ArrayList<Row>(qrp.parse(res, 
chosenChange.getParentTableColumn().getTable()).getRows());
+                response = new QueryResponse(rows);
+
+                
chosenChange.setNewValue(response.getRows().get(0).getValueOfColumn(columnName));
             }
             catch(Exception e)
             {
@@ -796,12 +804,17 @@ public class GenericTreeNode {
         }
     }
 
+    public void setInitial_state_row(Row initial_state_row) {
+        this.initial_state_row = initial_state_row;
+        initPostChangeRow();
+    }
+
     public boolean checkIfHasParentFk(Database db)
     {
         Collection<ForeignKeyConstraint> lesFk= 
db.getLesForeignKeys().get(chosenChange.getParentTableColumn().getTable().getName().toUpperCase());
         for(ForeignKeyConstraint fk : lesFk)
         {
-            if(!fk.getParentColumns().isEmpty())
+            
if(fk.getChildColumns().contains(chosenChange.getParentTableColumn()) && 
!fk.getParentColumns().isEmpty())
                 return true;
         }
         return false;
@@ -845,30 +858,12 @@ public class GenericTreeNode {
                     e.printStackTrace();
                 }
 
+
+                SingleChange tmp = sg;
                 if(response.getRows() != null)
-                    newPossibilities.remove(sg);
+                    newPossibilities.remove(tmp);
             }
         }
         return newPossibilities;
     }
-
-    public String getScriptResponse(Process p)
-    {
-        String response = "";
-        try
-        {
-
-            BufferedReader r = new BufferedReader(new 
InputStreamReader(p.getInputStream()));
-            String line;
-            while ((line = r.readLine())!=null) {
-                response = response+line;
-            }
-            r.close();
-        }
-        catch(Exception e)
-        {
-            System.out.println("error while reading process output"+e);
-        }
-        return response;
-    }
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]