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()));
}
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()));
}
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());
}
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;
}
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);
}
Aggregations