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: All buged fixed.


From: gnunet
Subject: [GNUnet-SVN] [taler-schemafuzz] branch master updated: All buged fixed. Only FK violation left to handle.(DEFFERED ?)
Date: Mon, 04 Jun 2018 10:40:43 +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 19de5e7  All buged fixed. Only FK violation left to handle.(DEFFERED ?)
19de5e7 is described below

commit 19de5e7918e6daa19616e2e71ec1bf2cc842d2ca
Author: Feideus <address@hidden>
AuthorDate: Mon Jun 4 10:40:26 2018 +0200

    All buged fixed. Only FK violation left to handle.(DEFFERED ?)
---
 src/main/java/org/schemaspy/DBFuzzer.java          | 40 ++++++++--------
 .../java/org/schemaspy/model/GenericTreeNode.java  | 56 ++++++++++++++++------
 2 files changed, 62 insertions(+), 34 deletions(-)

diff --git a/src/main/java/org/schemaspy/DBFuzzer.java 
b/src/main/java/org/schemaspy/DBFuzzer.java
index 772c1e4..1a5f24e 100644
--- a/src/main/java/org/schemaspy/DBFuzzer.java
+++ b/src/main/java/org/schemaspy/DBFuzzer.java
@@ -178,26 +178,26 @@ public class DBFuzzer
     //Extract Random row from the db specified in sqlService
     public Row pickRandomRow()
     {
-      Table randomTable = pickRandomTable();
-
-
-      String theQuery = "SELECT * FROM "+randomTable.getName()+" ORDER BY 
RANDOM() LIMIT 1";
-      //String theQuery = "SELECT * FROM test_table2 ORDER BY RANDOM() LIMIT 
1"; // Change test_table2 to test_table here to swap back to line finding
-      QueryResponseParser qrp = new QueryResponseParser();
-      ResultSet rs = null;
-      Row res = null ;
-      PreparedStatement stmt;
-
-        try
-        {
-             stmt = analyzer.getSqlService().prepareStatement(theQuery);
-             rs = stmt.executeQuery();
-             res = 
qrp.parse(rs,analyzer.getDb().getTablesMap().get(randomTable.getName())).getRows().get(0);
 //randomTable should be set there
-        }
-        catch (Exception e)
-        {
-          LOGGER.info("This query threw an error"+e);
-        }
+        Row res = null;
+
+      do {
+          Table randomTable = pickRandomTable();
+
+          String theQuery = "SELECT * FROM " + randomTable.getName() + " ORDER 
BY RANDOM() LIMIT 1";
+          //String theQuery = "SELECT * FROM test_table2 ORDER BY RANDOM() 
LIMIT 1"; // Change test_table2 to test_table here to swap back to line finding
+          QueryResponseParser qrp = new QueryResponseParser();
+          ResultSet rs = null;
+          PreparedStatement stmt;
+
+          try {
+              stmt = analyzer.getSqlService().prepareStatement(theQuery);
+              rs = stmt.executeQuery();
+              res = qrp.parse(rs, 
analyzer.getDb().getTablesMap().get(randomTable.getName())).getRows().get(0); 
//randomTable should be set there
+          } catch (Exception e) {
+              LOGGER.info("This query threw an error" + e);
+          }
+      }
+      while(res == null);
         return res;
     }
 
diff --git a/src/main/java/org/schemaspy/model/GenericTreeNode.java 
b/src/main/java/org/schemaspy/model/GenericTreeNode.java
index 46b039b..e6f2f15 100644
--- a/src/main/java/org/schemaspy/model/GenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/GenericTreeNode.java
@@ -228,7 +228,10 @@ public class GenericTreeNode {
     public ArrayList<SingleChange> 
discoverMutationPossibilities(GenericTreeNode rootMutation) {
 
         if(initial_state_row == null)
+        {
+            System.out.println("NO INITIAL STATE");
             return null ;
+        }
 
         ArrayList<SingleChange> possibilities = new ArrayList<SingleChange>();
 
@@ -246,7 +249,7 @@ public class GenericTreeNode {
             }
         }
         if(possibilities.isEmpty())
-            System.out.println("No raw Mutation could be found for this row"); 
// TO BE HANDLED. juste create another GenericTreeNode
+            System.out.println("No raw Mutation could be found for this row");
 
         //REMOVING POSSIBILITIES THAT DONT MATCH CONSTRAINTS
     //        for(SingleChange singleChange : possibilities)
@@ -265,27 +268,37 @@ public class GenericTreeNode {
         String typeName = tableColumn.getTypeName();
         GenericTreeNode rootForThisMutation = FirstApperanceOf(this);
 
+
         switch (typeName) {
             case "smallint":
             case "integer":
             case "int2":
 
-                int tmp = 
Integer.parseInt(rootForThisMutation.getInitial_state_row().getContent().get(tableColumn.getName()).toString());
-                oneChange.add(new SingleChange(tableColumn, this, 
column_value, Integer.toString(tmp++)));
-                oneChange.add(new SingleChange(tableColumn, this, 
column_value, Integer.toString(32767)));
-                oneChange.add(new SingleChange(tableColumn, this, 
column_value, Integer.toString(1)));
-                break;
-
+                Object tmp3 = 
rootForThisMutation.getInitial_state_row().getContent().get(tableColumn.getName());
+                if( tmp3 != null && tmp3.toString() != "" )
+                {
+                    int tmp = 
Integer.parseInt(rootForThisMutation.getInitial_state_row().getContent().get(tableColumn.getName()).toString());
+                    oneChange.add(new SingleChange(tableColumn, this, 
column_value, Integer.toString(tmp++)));
+                    oneChange.add(new SingleChange(tableColumn, this, 
column_value, Integer.toString(32767)));
+                    oneChange.add(new SingleChange(tableColumn, this, 
column_value, Integer.toString(1)));
+                    break;
+                }
             case "character":
-            case "character varying":
+            case "character varying": // MIXED CHARACTERS/NUMBERS STRINGS MAKE 
CHARAT CRASH AT 0 IF FIRST CHAR IS NUMBER. USE REGEX TO FIND FIRST ACTUAL 
LETTER ?
             case "varchar":
 
-                    char tmp2 = (char) 
rootForThisMutation.getInitial_state_row().getContent().get(tableColumn.getName()).toString().charAt(0);
+
+                Object tmp4 = 
rootForThisMutation.getInitial_state_row().getContent().get(tableColumn.getName());
+                if(tmp4 != null && tmp4.toString() != "" )
+                {
+
+                    char tmp2 = tmp4.toString().replaceAll("\\d","").charAt(0);
                     char nextChar = (char) (tmp2 + 1);
                     char prevChar = (char) (tmp2 - 1);
                     SingleChange sg = new SingleChange(tableColumn, this, 
column_value, (Character.toString(nextChar) + 
column_value.toString().substring(1)));
-                    oneChange.add(new SingleChange(tableColumn, this, 
column_value, (Character.toString(nextChar) + 
column_value.toString().substring(1))));oneChange.add(new 
SingleChange(tableColumn, this, column_value, (Character.toString(prevChar) + 
column_value.toString().substring(1))));
-
+                    oneChange.add(new SingleChange(tableColumn, this, 
column_value, (Character.toString(nextChar) + 
column_value.toString().substring(1))));
+                    oneChange.add(new SingleChange(tableColumn, this, 
column_value, (Character.toString(prevChar) + 
column_value.toString().substring(1))));
+                }
                 break;
             case "bool":
                 if (column_value.equals("f"))
@@ -331,7 +344,6 @@ public class GenericTreeNode {
                 System.out.println("Unsupported dataType = "+typeName);
         }
 
-
         return oneChange;
     }
 
@@ -410,7 +422,16 @@ public class GenericTreeNode {
                         || 
chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("date"))
                     theQuery = theQuery + (entry.getKey() + "='" + 
entry.getValue().toString() + "', ");
                 else
-                    theQuery = theQuery + (entry.getKey() + "=" + 
entry.getValue().toString() + ", ");
+                {
+                    if(entry.getValue() == null || entry.getValue().toString() 
== "" || entry.getValue().toString() == null)
+                    {
+                        String tmp = "null";
+                        theQuery = theQuery + (entry.getKey() + "=" + tmp+ ", 
"); // A CHANGER DURGENCE
+
+                    }
+                    else
+                        theQuery = theQuery + (entry.getKey() + "=" + 
entry.getValue().toString() + ", ");
+                }
             }
         }
 
@@ -428,7 +449,14 @@ public class GenericTreeNode {
                             || 
chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("date"))
                         theQuery = theQuery + (entry.getKey() + "='" + 
entry.getValue().toString() + "' AND ");
                     else
-                        theQuery = theQuery + (entry.getKey() + "=" + 
entry.getValue().toString() + " AND ");
+                    {
+                        if (entry.getValue() == null || 
entry.getValue().toString() == "" || entry.getValue().toString() == null) {
+                            String tmp = "null";
+                            theQuery = theQuery + (entry.getKey() + "=" + tmp 
+ " AND "); // A CHANGER DURGENCE
+
+                        } else
+                            theQuery = theQuery + (entry.getKey() + "=" + 
entry.getValue().toString() + " AND ");;
+                    }
                 }
                 else
                 {

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



reply via email to

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