improved sql parser.

This commit is contained in:
wenshao
2017-08-10 14:29:21 +08:00
parent 85db17a907
commit 1c900720d8
9 changed files with 258 additions and 6 deletions
@@ -275,10 +275,27 @@ public class SchemaRepository {
for (SQLStatement stmt : stmtList) {
if (stmt instanceof MySqlShowColumnsStatement) {
MySqlShowColumnsStatement showColumns = ((MySqlShowColumnsStatement) stmt);
SQLName table = showColumns.getTable();
SchemaObject schemaObject = findTable(table);
MySqlCreateTableStatement createTableStmt = (MySqlCreateTableStatement) schemaObject.getStatement();
createTableStmt.showCoumns(buf);
SQLName db = showColumns.getDatabase();
Schema schema;
if (db == null) {
schema = getDefaultSchema();
} else {
schema = findSchema(db.getSimpleName());
}
SQLName table = null;
SchemaObject schemaObject = null;
if (schema != null) {
table = showColumns.getTable();
schemaObject = schema.findTable(table.getSimpleName());
}
if (schemaObject == null) {
buf.append("ERROR 1146 (42S02): Table '" + table + "' doesn't exist\n");
} else {
MySqlCreateTableStatement createTableStmt = (MySqlCreateTableStatement) schemaObject.getStatement();
createTableStmt.showCoumns(buf);
}
} else if (stmt instanceof MySqlShowCreateTableStatement) {
MySqlShowCreateTableStatement showCreateTableStmt = (MySqlShowCreateTableStatement) stmt;
SQLName table = showCreateTableStmt.getName();