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