Search in sources :

Example 1 with TransformSQLJob

use of com.actiontech.dble.sqlengine.TransformSQLJob in project dble by actiontech.

the class SelectHandler method handle.

public static void handle(String stmt, ManagerConnection c, int offset) {
    switch(ManagerParseSelect.parse(stmt, offset)) {
        case VERSION_COMMENT:
            SelectVersionComment.response(c);
            break;
        case SESSION_TX_READ_ONLY:
            SelectSessionTxReadOnly.execute(c);
            break;
        case MAX_ALLOWED_PACKET:
            SelectMaxAllowedPacket.execute(c);
            break;
        default:
            if (isSupportSelect(stmt)) {
                Iterator<PhysicalDBPool> iterator = DbleServer.getInstance().getConfig().getDataHosts().values().iterator();
                if (iterator.hasNext()) {
                    PhysicalDBPool pool = iterator.next();
                    final PhysicalDatasource source = pool.getSource();
                    TransformSQLJob sqlJob = new TransformSQLJob(stmt, pool.getSchemas()[0], source, c);
                    sqlJob.run();
                } else {
                    c.writeErrMessage(ErrorCode.ER_YES, "no valid data host");
                }
            } else {
                c.writeErrMessage(ErrorCode.ER_YES, "Unsupported statement");
            }
    }
}
Also used : PhysicalDatasource(com.actiontech.dble.backend.datasource.PhysicalDatasource) PhysicalDBPool(com.actiontech.dble.backend.datasource.PhysicalDBPool) TransformSQLJob(com.actiontech.dble.sqlengine.TransformSQLJob)

Aggregations

PhysicalDBPool (com.actiontech.dble.backend.datasource.PhysicalDBPool)1 PhysicalDatasource (com.actiontech.dble.backend.datasource.PhysicalDatasource)1 TransformSQLJob (com.actiontech.dble.sqlengine.TransformSQLJob)1