@Override public boolean visit(MySqlExplainStatement x) { String name = x.isDescribe() ? "desc" : "explain"; print0(ucase ? name.toUpperCase() : name); print(' '); if (x.getTableName() != null) { x.getTableName().accept(this); if (x.getColumnName() != null) { print(' '); x.getColumnName().accept(this); } else if (x.getWild() != null) { print(' '); x.getWild().accept(this); String type = x.getType(); if (type != null) { print0(type); if ("format".equalsIgnoreCase(type)) { print0("= "); print0(x.getFormat()); print(' '); if (x.getConnectionId() != null) { print0(ucase ? "FOR CONNECTION " : "for connection "); x.getConnectionId().accept(this); } else { x.getStatement().accept(this);
public MySqlExplainStatement parseDescribe() { // see https://dev.mysql.com/doc/refman/5.7/en/explain.html MySqlExplainStatement describe = new MySqlExplainStatement(); // {DESCRIBE | DESC} if (lexer.token() == Token.DESC || lexer.identifierEquals(DESCRIBE)) { lexer.nextToken(); describe.setDescribe(true); } else { throw new ParserException("expect one of {DESCRIBE | DESC} , actual " + lexer.token() + ", " + lexer.info()); } return parseExplain(describe); }
protected void accept0(SQLASTVisitor visitor) { accept0((MySqlASTVisitor) visitor); }
@Override public boolean visit(MySqlExplainStatement x) { if (repository != null && x.getParent() == null) { repository.resolve(x); } SQLName tableName = x.getTableName(); if (tableName != null) { String table = tableName.toString(); getTableStat(tableName); SQLName columnName = x.getColumnName(); if (columnName != null) { addColumn(table, columnName.getSimpleName()); } } if (x.getStatement() != null) { accept(x.getStatement()); } return false; }
public static void handle(String stmt, ServerConnection c) { try { SQLStatement statement = RouteStrategyFactory.getRouteStrategy().parserSQL(stmt); MySqlExplainStatement describeStatement = (MySqlExplainStatement) statement; SchemaInfo schemaInfo = SchemaUtil.getSchemaInfo(c.getUser(), c.getSchema(), describeStatement.getTableName(), null); c.routeSystemInfoAndExecuteSQL(RouterUtil.removeSchema(stmt, schemaInfo.getSchema()), schemaInfo, ServerParse.DESCRIBE); } catch (Exception e) { c.writeErrMessage(ErrorCode.ER_PARSE_ERROR, e.toString()); return; } } }
public MySqlExplainStatement parseExplain() { // see https://dev.mysql.com/doc/refman/5.7/en/explain.html MySqlExplainStatement explain = new MySqlExplainStatement(); // {EXPLAIN} if (lexer.token() == Token.EXPLAIN) { lexer.nextToken(); } else { throw new ParserException("expect EXPLAIN , actual " + lexer.token() + ", " + lexer.info()); } return parseExplain(explain); }
@Override public void accept0(MySqlASTVisitor visitor) { if (visitor.visit(this)) { // tbl_name [col_name | wild] if (tableName != null) { acceptChild(visitor, tableName); if (columnName != null) { acceptChild(visitor, columnName); } else if (wild != null) { acceptChild(visitor, wild); } } else { // {explainable_stmt | FOR CONNECTION connection_id} if (connectionId != null) { acceptChild(visitor, connectionId); } else { acceptChild(visitor, statement); } } } visitor.endVisit(this); }
@Override public boolean visit(MySqlExplainStatement x) { if (repository != null && x.getParent() == null) { repository.resolve(x); } SQLName tableName = x.getTableName(); if (tableName != null) { String table = tableName.toString(); getTableStat(tableName); SQLName columnName = x.getColumnName(); if (columnName != null) { addColumn(table, columnName.getSimpleName()); } } if (x.getStatement() != null) { accept(x.getStatement()); } return false; }
public MySqlExplainStatement parseExplain() { // see https://dev.mysql.com/doc/refman/5.7/en/explain.html MySqlExplainStatement explain = new MySqlExplainStatement(); // {EXPLAIN} if (lexer.token() == Token.EXPLAIN) { lexer.nextToken(); } else { throw new ParserException("expect EXPLAIN , actual " + lexer.token() + ", " + lexer.info()); } return parseExplain(explain); }
@Override public void accept0(MySqlASTVisitor visitor) { if (visitor.visit(this)) { // tbl_name [col_name | wild] if (tableName != null) { acceptChild(visitor, tableName); if (columnName != null) { acceptChild(visitor, columnName); } else if (wild != null) { acceptChild(visitor, wild); } } else { // {explainable_stmt | FOR CONNECTION connection_id} if (connectionId != null) { acceptChild(visitor, connectionId); } else { acceptChild(visitor, statement); } } } visitor.endVisit(this); }
@Override public boolean visit(MySqlExplainStatement x) { String name = x.isDescribe() ? "desc" : "explain"; print0(ucase ? name.toUpperCase() : name); print(' '); if (x.getTableName() != null) { x.getTableName().accept(this); if (x.getColumnName() != null) { print(' '); x.getColumnName().accept(this); } else if (x.getWild() != null) { print(' '); x.getWild().accept(this); String type = x.getType(); if (type != null) { print0(type); if ("format".equalsIgnoreCase(type)) { print0("= "); print0(x.getFormat()); print(' '); if (x.getConnectionId() != null) { print0(ucase ? "FOR CONNECTION " : "for connection "); x.getConnectionId().accept(this); } else { x.getStatement().accept(this);
public MySqlExplainStatement parseDescribe() { // see https://dev.mysql.com/doc/refman/5.7/en/explain.html MySqlExplainStatement describe = new MySqlExplainStatement(); // {DESCRIBE | DESC} if (lexer.token() == Token.DESC || lexer.identifierEquals(DESCRIBE)) { lexer.nextToken(); describe.setDescribe(true); } else { throw new ParserException("expect one of {DESCRIBE | DESC} , actual " + lexer.token() + ", " + lexer.info()); } return parseExplain(describe); }
protected void accept0(SQLASTVisitor visitor) { accept0((MySqlASTVisitor) visitor); }