Search in sources :

Example 21 with ErrorPacket

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

the class CreateViewHandler method handle.

public static void handle(String stmt, ServerConnection c, boolean isReplace) {
    // create a new object of the view
    ViewMeta vm = new ViewMeta(stmt, c.getSchema(), DbleServer.getInstance().getTmManager());
    ErrorPacket error = vm.initAndSet(isReplace);
    if (error != null) {
        // if any error occurs when parse sql into view object
        c.writeErrMessage(error.getErrNo(), new String(error.getMessage()));
        return;
    }
    // or just save the create sql into file
    saveCreateSqlToReposoitory(stmt, vm.getViewName(), c.getSchema());
    // if the create success with no error send back OK
    c.write(c.writeToBuffer(OkPacket.OK, c.allocate()));
}
Also used : ViewMeta(com.actiontech.dble.meta.ViewMeta) ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket)

Example 22 with ErrorPacket

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

the class SetTestJob method errorResponse.

@Override
public void errorResponse(byte[] err, BackendConnection conn) {
    ErrorPacket errPg = new ErrorPacket();
    errPg.read(err);
    doFinished(true);
    // conn context not change
    conn.release();
    sc.writeErrMessage(errPg.getErrNo(), new String(errPg.getMessage()));
}
Also used : ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket)

Example 23 with ErrorPacket

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

the class TransformSQLJob method connectionError.

@Override
public void connectionError(Throwable e, BackendConnection conn) {
    LOGGER.info("can't get connection for sql :" + sql);
    ErrorPacket errPacket = new ErrorPacket();
    errPacket.setPacketId(0);
    errPacket.setErrNo(ErrorCode.ER_YES);
    errPacket.setMessage(StringUtil.encode(e.toString(), StandardCharsets.UTF_8.toString()));
    writeError(errPacket.toBytes());
}
Also used : ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket)

Example 24 with ErrorPacket

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

the class SchemaMeta method getView.

/**
 * try to get a view meta of querynode
 *
 * @param name
 * @return
 */
public QueryNode getView(String name) {
    ViewMeta view = viewMetas.get(name);
    QueryNode queryNode = null;
    if (view != null) {
        if (view.getViewQuery() != null) {
            queryNode = view.getViewQuery().copy();
        } else {
            ErrorPacket error = view.initAndSet(true);
            if (error != null) {
                throw new RuntimeException(" View '" + view.getViewName() + "' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them");
            } else {
                queryNode = view.getViewQuery().copy();
            }
        }
    }
    return queryNode;
}
Also used : ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket) QueryNode(com.actiontech.dble.plan.node.QueryNode)

Example 25 with ErrorPacket

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

the class FrontendConnection method writeErrMessage.

private void writeErrMessage(byte id, int vendorCode, String sqlState, String msg) {
    ErrorPacket err = new ErrorPacket();
    err.setPacketId(id);
    err.setErrNo(vendorCode);
    err.setSqlState(StringUtil.encode(sqlState, charsetName.getResults()));
    err.setMessage(StringUtil.encode(msg, charsetName.getResults()));
    err.write(this);
}
Also used : ErrorPacket(com.actiontech.dble.net.mysql.ErrorPacket)

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