Search in sources :

Example 26 with ErrorPacket

use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.

the class ViewMeta method init.

public ErrorPacket init(boolean isReplace) {
    ViewMetaParser viewParser = new ViewMetaParser(createSql);
    try {
        viewParser.parseCreateView(this);
        // check if the select part has
        this.checkDuplicate(viewParser, isReplace);
        SQLSelectStatement selectStatement = (SQLSelectStatement) RouteStrategyFactory.getRouteStrategy().parserSQL(selectSql);
        MySQLPlanNodeVisitor msv = new MySQLPlanNodeVisitor(this.schema, 63, tmManager, true);
        msv.visit(selectStatement.getSelect().getQuery());
        PlanNode selNode = msv.getTableNode();
        selNode.setUpFields();
        // set the view column name into
        this.setFieldsAlias(selNode);
        viewQuery = new QueryNode(selNode);
    } catch (Exception e) {
        // the select part sql is wrong & report the error
        ErrorPacket error = new ErrorPacket();
        error.setMessage(e.getMessage() == null ? "unknow error".getBytes(StandardCharsets.UTF_8) : e.getMessage().getBytes(StandardCharsets.UTF_8));
        error.setErrNo(CREATE_VIEW_ERROR);
        return error;
    }
    return null;
}
Also used : PlanNode(com.actiontech.dble.plan.node.PlanNode) ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket) QueryNode(com.actiontech.dble.plan.node.QueryNode) SQLSelectStatement(com.alibaba.druid.sql.ast.statement.SQLSelectStatement) MySQLPlanNodeVisitor(com.actiontech.dble.plan.visitor.MySQLPlanNodeVisitor)

Example 27 with ErrorPacket

use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.

the class ViewMeta method initAndSet.

public ErrorPacket initAndSet(boolean isReplace) {
    // check the create sql is legal
    // parse sql into three parts
    ViewMetaParser viewParser = new ViewMetaParser(createSql);
    viewParser.parseCreateView(this);
    try {
        if ("".equals(viewName)) {
            throw new Exception("sql not supported ");
        }
        tmManager.addMetaLock(schema, viewName);
        // check if the select part has
        this.checkDuplicate(viewParser, isReplace);
        SQLSelectStatement selectStatement = (SQLSelectStatement) RouteStrategyFactory.getRouteStrategy().parserSQL(selectSql);
        MySQLPlanNodeVisitor msv = new MySQLPlanNodeVisitor(this.schema, 63, tmManager, true);
        msv.visit(selectStatement.getSelect().getQuery());
        PlanNode selNode = msv.getTableNode();
        selNode.setUpFields();
        // set the view column name into
        this.setFieldsAlias(selNode);
        viewQuery = new QueryNode(selNode);
        tmManager.getCatalogs().get(schema).getViewMetas().put(viewName, this);
    } catch (Exception e) {
        // the select part sql is wrong & report the error
        ErrorPacket error = new ErrorPacket();
        error.setMessage(e.getMessage() == null ? "unknown error".getBytes(StandardCharsets.UTF_8) : e.getMessage().getBytes(StandardCharsets.UTF_8));
        error.setErrNo(CREATE_VIEW_ERROR);
        return error;
    } finally {
        tmManager.removeMetaLock(schema, viewName);
    }
    return null;
}
Also used : PlanNode(com.actiontech.dble.plan.node.PlanNode) ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket) QueryNode(com.actiontech.dble.plan.node.QueryNode) SQLSelectStatement(com.alibaba.druid.sql.ast.statement.SQLSelectStatement) MySQLPlanNodeVisitor(com.actiontech.dble.plan.visitor.MySQLPlanNodeVisitor)

Example 28 with ErrorPacket

use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.

the class BaseHandlerBuilder method handleSubQuery.

private void handleSubQuery(final ReentrantLock lock, final Condition finishSubQuery, final AtomicBoolean finished, final AtomicInteger subNodes, final CopyOnWriteArrayList<ErrorPacket> errorPackets, final PlanNode planNode, final SubQueryHandler tempHandler) {
    DbleServer.getInstance().getComplexQueryExecutor().execute(new Runnable() {

        @Override
        public void run() {
            try {
                DMLResponseHandler endHandler = hBuilder.buildNode(session, planNode, false);
                endHandler.setNextHandler(tempHandler);
                CallBackHandler tempDone = new CallBackHandler() {

                    @Override
                    public void call() throws Exception {
                        if (tempHandler.getErrorPacket() != null) {
                            errorPackets.add(tempHandler.getErrorPacket());
                        }
                        subQueryFinished(subNodes, lock, finished, finishSubQuery);
                    }
                };
                tempHandler.setTempDoneCallBack(tempDone);
                HandlerBuilder.startHandler(endHandler);
            } catch (Exception e) {
                LOGGER.info("execute ItemScalarSubQuery error", e);
                ErrorPacket errorPackage = new ErrorPacket();
                errorPackage.setErrNo(ErrorCode.ER_UNKNOWN_ERROR);
                String errorMsg = e.getMessage() == null ? e.toString() : e.getMessage();
                errorPackage.setMessage(errorMsg.getBytes(StandardCharsets.UTF_8));
                errorPackets.add(errorPackage);
            }
        }
    });
}
Also used : CallBackHandler(com.actiontech.dble.backend.mysql.nio.handler.util.CallBackHandler) ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket) DMLResponseHandler(com.actiontech.dble.backend.mysql.nio.handler.query.DMLResponseHandler) MySQLOutPutException(com.actiontech.dble.plan.common.exception.MySQLOutPutException)

Example 29 with ErrorPacket

use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.

the class ResetConnHandler method errorResponse.

@Override
public void errorResponse(byte[] err, BackendConnection conn) {
    ErrorPacket errPg = new ErrorPacket();
    errPg.read(err);
    conn.close(new String(errPg.getMessage()));
}
Also used : ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket)

Example 30 with ErrorPacket

use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.

the class BaseSelectHandler method errorResponse.

@Override
public void errorResponse(byte[] err, BackendConnection conn) {
    ((MySQLConnection) conn).setRunning(false);
    ErrorPacket errPacket = new ErrorPacket();
    errPacket.read(err);
    String errMsg;
    try {
        errMsg = new String(errPacket.getMessage(), CharsetUtil.getJavaCharset(conn.getCharset().getResults()));
    } catch (UnsupportedEncodingException e) {
        errMsg = "UnsupportedEncodingException:" + conn.getCharset();
    }
    LOGGER.info(conn.toString() + errMsg);
    if (terminate.get())
        return;
    session.onQueryError(errMsg.getBytes());
}
Also used : ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MySQLConnection(com.actiontech.dble.backend.mysql.nio.MySQLConnection)

Aggregations

ErrorPacket (com.actiontech.dble.net.mysql.ErrorPacket)33 MySQLConnection (com.actiontech.dble.backend.mysql.nio.MySQLConnection)3 QueryNode (com.actiontech.dble.plan.node.QueryNode)3 ViewMeta (com.actiontech.dble.meta.ViewMeta)2 MySQLOutPutException (com.actiontech.dble.plan.common.exception.MySQLOutPutException)2 PlanNode (com.actiontech.dble.plan.node.PlanNode)2 MySQLPlanNodeVisitor (com.actiontech.dble.plan.visitor.MySQLPlanNodeVisitor)2 SQLSelectStatement (com.alibaba.druid.sql.ast.statement.SQLSelectStatement)2 PhysicalDBNode (com.actiontech.dble.backend.datasource.PhysicalDBNode)1 DMLResponseHandler (com.actiontech.dble.backend.mysql.nio.handler.query.DMLResponseHandler)1 AllAnySubQueryHandler (com.actiontech.dble.backend.mysql.nio.handler.query.impl.subquery.AllAnySubQueryHandler)1 InSubQueryHandler (com.actiontech.dble.backend.mysql.nio.handler.query.impl.subquery.InSubQueryHandler)1 SingleRowSubQueryHandler (com.actiontech.dble.backend.mysql.nio.handler.query.impl.subquery.SingleRowSubQueryHandler)1 SubQueryHandler (com.actiontech.dble.backend.mysql.nio.handler.query.impl.subquery.SubQueryHandler)1 CallBackHandler (com.actiontech.dble.backend.mysql.nio.handler.util.CallBackHandler)1 CoordinatorLogEntry (com.actiontech.dble.backend.mysql.xa.CoordinatorLogEntry)1 TxState (com.actiontech.dble.backend.mysql.xa.TxState)1 HeartbeatPacket (com.actiontech.dble.net.mysql.HeartbeatPacket)1 OkPacket (com.actiontech.dble.net.mysql.OkPacket)1 ItemAllAnySubQuery (com.actiontech.dble.plan.common.item.subquery.ItemAllAnySubQuery)1