diff options
author | 2018-12-06 15:05:22 -0500 | |
---|---|---|
committer | 2018-12-13 15:42:01 -0500 | |
commit | 8469652e97d83dad0aa3870eb6c78c150ca5b869 (patch) | |
tree | accb65a424e325a282a87d0a04c711d1e94026e6 /mdbc-server/src | |
parent | ad9faf285c9348728859c49b0883bff82ec5031e (diff) |
Deprecated unused method. logged CREATE statement.
Change-Id: I39155ef4e523fe4a643089eb26be388ca47aa4d2
Issue-ID: MUSIC-164
Signed-off-by: Vikram Potturi <vikramaditya.potturi@att.com>
Diffstat (limited to 'mdbc-server/src')
-rw-r--r-- | mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java b/mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java index 9455494..8e09065 100644 --- a/mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java +++ b/mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java @@ -78,7 +78,14 @@ public class QueryProcessor { } public static Map<String, List<String>> parseSqlQuery(String query) throws SqlParseException { + logger.info(EELFLoggerDelegate.applicationLogger, "Parsing query: "+query); Map<String, List<String>> tableOpsMap = new HashMap<>(); + //for Create no need to check locks. + if(query.toUpperCase().startsWith("CREATE")) { + logger.error(EELFLoggerDelegate.errorLogger, "CREATE TABLE DDL not currently supported currently."); + return tableOpsMap; + } + /*SqlParser parser = SqlParser.create(query); SqlNode sqlNode = parser.parseQuery();*/ SqlNode sqlNode = getSqlParser(query).parseStmt(); @@ -124,16 +131,22 @@ public class QueryProcessor { SqlNode where = sqlSelect.getWhere(); for (String table : tablesArr) { - String[] split = table.split("`"); - String tableName = split[1]; + + String tableName = null; + if(table.contains("`")) { + String[] split = table.split("`"); + tableName = split[1]; + } else + tableName = table; + List<String> Ops = tableOpsMap.get(tableName); if (Ops == null) Ops = new ArrayList<>(); if (where == null) { Ops.add(Operation.TABLE.getOperation()); - tableOpsMap.put(split[1], Ops); + tableOpsMap.put(tableName, Ops); } else { Ops.add(Operation.SELECT.getOperation()); - tableOpsMap.put(split[1], Ops); + tableOpsMap.put(tableName, Ops); } } } @@ -141,6 +154,7 @@ public class QueryProcessor { return tableOpsMap; } + @Deprecated public static Map<String, List<String>> extractTableFromQuery(String sqlQuery) { List<String> tables = null; Map<String, List<String>> tableOpsMap = new HashMap<>(); @@ -214,8 +228,12 @@ public class QueryProcessor { } public static void main(String[] args) throws SqlParseException { - String sqlQuery = "SELECT name, age FROM table1 t1, table2 t2 WHERE t1.id = t2.id"; - // Map<String, List<String>> tableOpsMap = extractTableFromQuery(sqlQuery); + + String sqlQuery = "CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20))"; + System.out.println(parseSqlQuery(sqlQuery)); + + sqlQuery = "SELECT name, age FROM table1 t1, table2 t2 WHERE t1.id = t2.id"; + //Map<String, List<String>> tableOpsMap = extractTableFromQuery(sqlQuery); System.out.println(parseSqlQuery(sqlQuery)); sqlQuery = "SELECT name, age FROM table1, table2 t2 WHERE id = t2.id"; |