又一款开源的数据库测试工具,官方地址:https://github.com/sqlancer/sqlancer
测试场景官方说明:
Approach | Description |
---|---|
Pivoted Query Synthesis (PQS) | PQS is the first technique that we designed and implemented. It randomly selects a row, called a pivot row, for which a query is generated that is guaranteed to fetch the row. If the row is not contained in the result set, a bug has been detected. It is fully described here. PQS is the most powerful technique, but also requires more implementation effort than the other two techniques. It is currently unmaintained. |
Non-optimizing Reference Engine Construction (NoREC) | NoREC aims to find optimization bugs. It is described here. It translates a query that is potentially optimized by the DBMS to one for which hardly any optimizations are applicable, and compares the two result sets. A mismatch between the result sets indicates a bug in the DBMS. |
Ternary Logic Partitioning (TLP) | TLP partitions a query into three partitioning queries, whose results are composed and compare to the original query's result set. A mismatch in the result sets indicates a bug in the DBMS. In contrast to NoREC and PQS, it can detect bugs in advanced features such as aggregate functions. |
PINGCap的知乎翻译:
运行效果如下:
1 2 3 4 5 6 7 8 |
java -jar sqlancer-1.1.0.jar --host=192.168.10.101 --port=13306 --username=test1234 --password=test1234 --num-threads=4 --num-tries=5 --max-expression-depth=6 --max-num-inserts=100 mysql --oracle TLP_WHERE ....(此处省略构造表和问题sql之前的query内容) -- SELECT t1.c1 AS ref0 FROM t1; -- cardinality: 73 -- SELECT t1.c1 AS ref0 FROM t1 WHERE (t1.c1) IN (CAST( EXISTS (SELECT 1 wHERE FALSE) AS SIGNED), -1358113199);SELECT t1.c1 AS ref0 FROM t1 WHERE (! ((t1.c1) IN (CAST( EXISTS (SELECT 1 wHERE FALSE) AS SIGNED), -1358113199)));SELECT ALL t1.c1 AS ref0 FROM t1 WHERE ((t1.c1) IN (CAST( EXISTS (SELECT 1 wHERE FALSE) AS SIGNED), -1358113199)) IS NULL; -- cardinality: 72 |
还可以指定测试模式,上面结果是运行TLP模式发现的一处mysql8.0.22的bug
打包方式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 因为maven版本低,所以需要额外指定参数强制使用ssl链接 # mvn package -DskipTests -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dhttps.protocols=TLSv1.2 # 如果默认的库无法下载,可以手动配置强制使用https的库地址 # vi ~/.m2/settings.xml <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="https://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"> <mirrors> <mirror> <id>central</id> <name>Maven Repository Switchboard</name> <url>https://repo.maven.apache.org/maven2/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> </settings> |
会在当前目录下生成target目录,拷贝到待运行机器上,安装上述方式执行即可