use of com.actiontech.dble.plan.common.item.function.castfunc.ItemNCharTypecast in project dble by actiontech.
the class MySQLItemVisitor method endVisit.
@Override
public void endVisit(SQLCastExpr x) {
Item a = getItem(x.getExpr());
SQLDataType dataType = x.getDataType();
if (dataType instanceof SQLCharacterDataType) {
SQLCharacterDataType charType = (SQLCharacterDataType) dataType;
String upType = charType.getName().toUpperCase();
List<Integer> args = changeExprListToInt(charType.getArguments());
String charSetName = charType.getCharSetName();
if (upType.equals("CHAR")) {
int len = -1;
if (args.size() > 0) {
len = args.get(0);
}
item = new ItemCharTypecast(a, len, charSetName);
} else if (charSetName == null) {
int len = -1;
if (args.size() > 0) {
len = args.get(0);
}
item = new ItemNCharTypecast(a, len);
} else {
throw new MySQLOutPutException(ErrorCode.ER_PARSE_ERROR, "", "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'character set " + charSetName + ")'");
}
} else {
CastType castType = getCastType((SQLDataTypeImpl) dataType);
item = ItemCreate.getInstance().createFuncCast(a, castType);
}
initName(x);
}
Aggregations