Search in sources :

Example 1 with Procedure

use of com.actiontech.dble.route.Procedure in project dble by actiontech.

the class AbstractRouteStrategy method parseProcedure.

private Procedure parseProcedure(String sql) {
    Procedure procedure = new Procedure();
    procedure.setOriginSql(sql);
    procedure.setResultList(false);
    SQLStatementParser parser = new MySqlStatementParser(sql);
    SQLStatement statement = parser.parseStatement();
    if (statement instanceof SQLCallStatement) {
        parseProcedureForCall(procedure, sql, (SQLCallStatement) statement);
    }
    return procedure;
}
Also used : SQLStatementParser(com.alibaba.druid.sql.parser.SQLStatementParser) Procedure(com.actiontech.dble.route.Procedure) SQLCallStatement(com.alibaba.druid.sql.ast.statement.SQLCallStatement) MySqlStatementParser(com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Example 2 with Procedure

use of com.actiontech.dble.route.Procedure in project dble by actiontech.

the class AbstractRouteStrategy method route.

@Override
public RouteResultset route(SchemaConfig schema, int sqlType, String origSQL, ServerConnection sc, LayerCachePool cachePool) throws SQLException {
    RouteResultset rrs = new RouteResultset(origSQL, sqlType);
    /*
         * debug mode and load data ,no cache
         */
    if (LOGGER.isDebugEnabled() && origSQL.startsWith(LoadData.LOAD_DATA_HINT)) {
        rrs.setCacheAble(false);
    }
    if (sqlType == ServerParse.CALL) {
        rrs.setCallStatement(true);
        Procedure procedure = parseProcedure(origSQL);
        rrs.setProcedure(procedure);
    }
    if (schema == null) {
        rrs = routeNormalSqlWithAST(null, origSQL, rrs, cachePool, sc);
    } else {
        if (sqlType == ServerParse.SHOW) {
            rrs.setStatement(origSQL);
            rrs = RouterUtil.routeToSingleNode(rrs, schema.getRandomDataNode());
        } else {
            rrs = routeNormalSqlWithAST(schema, origSQL, rrs, cachePool, sc);
        }
    }
    return rrs;
}
Also used : Procedure(com.actiontech.dble.route.Procedure) RouteResultset(com.actiontech.dble.route.RouteResultset)

Aggregations

Procedure (com.actiontech.dble.route.Procedure)2 RouteResultset (com.actiontech.dble.route.RouteResultset)1 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 SQLCallStatement (com.alibaba.druid.sql.ast.statement.SQLCallStatement)1 MySqlStatementParser (com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser)1 SQLStatementParser (com.alibaba.druid.sql.parser.SQLStatementParser)1