MyCat作为数据库中间件时,sql中字符串包含@@会偶现报表不存在的错误

[SQL]select * from tbl_caseinfo where caseName = 'tset1@@'

[Err] 1146 - Table 'dbjadcase.tbl_caseinfo' doesn't exist

有时会报上述错误,而有时又可以正常查询。

查了下mycat文档,发现@@是命令字符,不知道是不是与此有关。偶尔又查询成功,考虑是不是和mycat分片规则有关。

朋友们可以试一下,看看有没有什么合适的解决方案。

原来当前使用的1.6.1版本不够新,源码中逻辑如下

case ServerParse.SELECT://if origSQL is like select @@
            if(stmt.contains("@@")){
                return analyseDoubleAtSgin(schema, rrs, stmt);
            }
            break;

新的1.6.5已经修复了这个问题,源码如下:

case ServerParse.SELECT://if origSQL is like select @@
            int index = stmt.indexOf("@@");
            if(index > 0 && "SELECT".equals(stmt.substring(0, index).trim().toUpperCase())){
                return analyseDoubleAtSgin(schema, rrs, stmt);
            }
            break;