VeastLee 2019-01-25 10:44 采纳率: 0%
浏览 1054
已采纳

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

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

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

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

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

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

  • 写回答

1条回答 默认 最新

  • VeastLee 2019-01-25 11:38
    关注

    原来当前使用的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;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?