From 0ee9c83d642bce62e499e4f41a3cb1c27ff6a62b Mon Sep 17 00:00:00 2001 From: Donnie Pinkston <donnie@cms.caltech.edu> Date: Thu, 17 Jan 2019 16:45:19 -0800 Subject: [PATCH] Add "SHOW '...' STATS" command back into parser Somehow when upgrading the NanoDB parser to ANTLR4, I forgot to include the SHOW STATS command. This is essential for the storage lab, so of course I added it back in as quickly as possible. --- .../antlr4/edu/caltech/nanodb/sqlparse/NanoSQL.g4 | 7 +++++++ .../caltech/nanodb/sqlparse/NanoSQLTranslator.java | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/antlr4/edu/caltech/nanodb/sqlparse/NanoSQL.g4 b/src/main/antlr4/edu/caltech/nanodb/sqlparse/NanoSQL.g4 index 04047f8..01cba5b 100644 --- a/src/main/antlr4/edu/caltech/nanodb/sqlparse/NanoSQL.g4 +++ b/src/main/antlr4/edu/caltech/nanodb/sqlparse/NanoSQL.g4 @@ -43,6 +43,7 @@ commandNoSemicolon: | showTablesStmt | showPropsStmt | setPropStmt + | showSystemStatsStmt ; @@ -204,6 +205,9 @@ rollbackTxnStmt: //============================================================================ // Other utility statements +// SHOW PROPERTIES +// SET PROPERTY '...' = ... +// SHOW '...' STATS // FLUSH // CRASH // EXIT (or QUIT) @@ -215,6 +219,9 @@ showPropsStmt: setPropStmt: SET PROPERTY name=STRING_LITERAL '=' expression ; +showSystemStatsStmt: + SHOW name=STRING_LITERAL STATS ; + flushStmt: FLUSH ; diff --git a/src/main/java/edu/caltech/nanodb/sqlparse/NanoSQLTranslator.java b/src/main/java/edu/caltech/nanodb/sqlparse/NanoSQLTranslator.java index fe6dd9d..d213621 100644 --- a/src/main/java/edu/caltech/nanodb/sqlparse/NanoSQLTranslator.java +++ b/src/main/java/edu/caltech/nanodb/sqlparse/NanoSQLTranslator.java @@ -5,6 +5,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; +import edu.caltech.nanodb.commands.ShowSystemStatsCommand; import edu.caltech.nanodb.expressions.ArithmeticOperator; import edu.caltech.nanodb.expressions.BooleanOperator; import edu.caltech.nanodb.expressions.ColumnName; @@ -166,6 +167,16 @@ public class NanoSQLTranslator extends NanoSQLBaseVisitor<Object> { (Expression) visit(ctx.expression())); } + @Override + public Object visitShowSystemStatsStmt(NanoSQLParser.ShowSystemStatsStmtContext ctx) { + String systemName = ctx.name.getText(); + + // Remove the quotes from around the subsystem name + systemName = systemName.substring(1, systemName.length() - 1); + + return new ShowSystemStatsCommand(systemName); + } + //=== TABLE/INDEX UTILITY COMMANDS ======================================= @Override -- GitLab