use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class MySQLItemVisitor method getCastType.
private CastType getCastType(SQLDataTypeImpl dataTypeImpl) {
CastType castType = new CastType();
String upType = dataTypeImpl.getName().toUpperCase();
List<Integer> args = changeExprListToInt(dataTypeImpl.getArguments());
switch(upType) {
case "BINARY":
castType.setTarget(CastTarget.ITEM_CAST_BINARY);
if (args.size() > 0) {
castType.setLength(args.get(0));
}
break;
case "DATE":
castType.setTarget(CastTarget.ITEM_CAST_DATE);
break;
case "DATETIME":
castType.setTarget(CastTarget.ITEM_CAST_DATETIME);
if (args.size() > 0) {
castType.setLength(args.get(0));
}
break;
case "DECIMAL":
castType.setTarget(CastTarget.ITEM_CAST_DECIMAL);
if (args.size() > 0) {
castType.setLength(args.get(0));
}
if (args.size() > 1) {
castType.setDec(args.get(1));
}
break;
case "NCHAR":
castType.setTarget(CastTarget.ITEM_CAST_NCHAR);
if (args.size() > 0) {
castType.setLength(args.get(0));
}
break;
case "SIGNED":
castType.setTarget(CastTarget.ITEM_CAST_SIGNED_INT);
break;
case "UNSIGNED":
castType.setTarget(CastTarget.ITEM_CAST_UNSIGNED_INT);
break;
case "TIME":
castType.setTarget(CastTarget.ITEM_CAST_TIME);
if (args.size() > 0) {
castType.setLength(args.get(0));
}
break;
default:
// not support SIGNED INT /UNSIGNED INT/JSON
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "not supported cast as:" + upType);
}
return castType;
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class NonBlockingSession method executeMultiSelect.
private void executeMultiSelect(RouteResultset rrs) {
SQLSelectStatement ast = (SQLSelectStatement) rrs.getSqlStatement();
MySQLPlanNodeVisitor visitor = new MySQLPlanNodeVisitor(this.getSource().getSchema(), this.getSource().getCharset().getResultsIndex(), DbleServer.getInstance().getTmManager(), false);
visitor.visit(ast);
PlanNode node = visitor.getTableNode();
if (node.isCorrelatedSubQuery()) {
throw new MySQLOutPutException(ErrorCode.ER_UNKNOWN_ERROR, "", "Correlated Sub Queries is not supported ");
}
node.setSql(rrs.getStatement());
node.setUpFields();
PlanUtil.checkTablesPrivilege(source, node, ast);
node = MyOptimizer.optimize(node);
if (PlanUtil.containsSubQuery(node)) {
final PlanNode finalNode = node;
DbleServer.getInstance().getComplexQueryExecutor().execute(new Runnable() {
// sub Query build will be blocked, so use ComplexQueryExecutor
@Override
public void run() {
executeMultiResultSet(finalNode);
}
});
} else {
if (!visitor.isContainSchema()) {
node.setAst(ast);
}
executeMultiResultSet(node);
}
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class NonBlockingSession method executeMultiResultSet.
private void executeMultiResultSet(PlanNode node) {
init();
HandlerBuilder builder = new HandlerBuilder(node, this);
try {
// no next
builder.build(false);
} catch (SQLSyntaxErrorException e) {
LOGGER.info(String.valueOf(source) + " execute plan is : " + node, e);
source.writeErrMessage(ErrorCode.ER_YES, "optimizer build error");
} catch (NoSuchElementException e) {
LOGGER.info(String.valueOf(source) + " execute plan is : " + node, e);
this.terminate();
source.writeErrMessage(ErrorCode.ER_NO_VALID_CONNECTION, "no valid connection");
} catch (MySQLOutPutException e) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info(String.valueOf(source) + " execute plan is : " + node, e);
}
this.terminate();
source.writeErrMessage(e.getSqlState(), e.getMessage(), e.getErrorCode());
} catch (Exception e) {
LOGGER.info(String.valueOf(source) + " execute plan is : " + node, e);
this.terminate();
source.writeErrMessage(ErrorCode.ER_HANDLE_DATA, e.toString());
}
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class JoinNode method buildJoinFilters.
private void buildJoinFilters() {
nameContext.setFindInSelect(false);
nameContext.setSelectFirst(false);
if (usingFields != null) {
for (String using : usingFields) {
using = StringUtil.removeBackQuote(using);
String lName = findTbNameByUsing(this.getLeftNode(), using);
String rName = findTbNameByUsing(this.getRightNode(), using);
if (lName.equals(rName)) {
throw new MySQLOutPutException(ErrorCode.ER_NONUNIQ_TABLE, "42000", "Not unique table/alias: '" + lName + "'");
}
Item filter = setUpItem(genJoinFilter(using, lName, rName));
joinFilter.add((ItemFuncEqual) filter);
}
} else {
for (int index = 0; index < joinFilter.size(); index++) {
Item bf = joinFilter.get(index);
bf = setUpItem(bf);
if (bf.getReferTables().size() == 1) {
throw new MySQLOutPutException(ErrorCode.ER_NONUNIQ_TABLE, "42000", "Not unique table/alias: '" + this.getLeftNode().getPureName() + "'");
}
joinFilter.set(index, (ItemFuncEqual) bf);
}
}
}
use of com.actiontech.dble.plan.common.exception.MySQLOutPutException in project dble by actiontech.
the class JoinNode method getFieldList.
private List<String> getFieldList(PlanNode node) {
List<String> fields = new ArrayList<>();
Set<String> checkDup = new HashSet<>();
for (NamedField field : node.getOuterFields().keySet()) {
String fieldName = field.getName().toLowerCase();
if (checkDup.contains(fieldName)) {
throw new MySQLOutPutException(ErrorCode.ER_DUP_FIELDNAME, "42S21", " Duplicate column name '" + fieldName + "'");
}
checkDup.add(fieldName);
fields.add(fieldName);
}
return fields;
}
Aggregations