runs randomly generated queries against go-mysql-server, the sql engine inside dolt, and a real mysql server side by side, and writes every query whose result differs to a file.
the queries go after the parts of a sql engine that are easy to get wrong: correlated EXISTS / IN subqueries, derived tables with windows and LIMIT, lateral joins, outer joins, NULL in IN / NOT IN, mixed signed / unsigned / decimal / double arithmetic, GROUP BY with HAVING, window frames, DISTINCT with ORDER BY and LIMIT, and set operations.
you need go and a mysql 8 server to compare against.
go build -tags gms_pure_go -o difftest .
./difftest -mysql 'root@unix(/path/to/mysql.sock)/' -n 3000 -seed 1 -out diffs.txtit starts go-mysql-server in-process on port 33070 (-port), creates a difftest database with two small tables on both servers, and prints a count per outcome:
same: both returned the same rowsresult-diff: different rows, the interesting oneformat-diff: same values, printed differently (1e+10vs10000000000)gms-error/mysql-error: only one side failedgms-unsupported: go-mysql-server doesn't support the syntaxboth-error: both failed
some mysql behavior lives in dolt rather than go-mysql-server. to test a running dolt sql-server instead of the in-process engine, pass its DSN. the gms- outcomes become dolt-.
dolt sql-server -H 127.0.0.1 -P 33071
./difftest -dolt 'root@tcp(127.0.0.1:33071)/' -mysql 'root@unix(/path/to/mysql.sock)/' -n 3000 -seed 1 -out diffs.txt- the database uses
utf8mb4_0900_binon both sides. that's the go-mysql-server default, and mysql's default collation is case insensitive, which otherwise shows up as a difference in everyGROUP BYorPARTITION BYon a string. - every
ORDER BYinside a window function,LIMITor derived table ends with a unique key, so there is exactly one right answer. - rows are compared as a sorted multiset, and numbers by value.
to check a fix, or to filter out bugs that already have a fix waiting, point go-mysql-server at a local checkout:
go mod edit -replace github.com/dolthub/go-mysql-server=../go-mysql-serveragainst go-mysql-server it found SELECT DISTINCT CEIL(a) FROM t ORDER BY 1 LIMIT 3 failing with an internal error while similar queries returned the wrong rows (dolthub/go-mysql-server#4065), SELECT COUNT(1), COUNT(*) FROM t failing (dolthub/go-mysql-server#4066), and UNION, INTERSECT and EXCEPT treating 5 and 5.00 as different values (dolthub/go-mysql-server#4067). it also found dolthub/dolt#11548 again, a correlated EXISTS over a derived table with LIMIT returning wrong rows, which was fixed in dolthub/go-mysql-server#4061.
against dolt 2.6.2 it found ROUND on a DOUBLE rounding half away from zero where mysql rounds half to even (dolthub/dolt#12310), a signed value DIV an unsigned one wrapping around where mysql raises an out of range error (dolthub/dolt#12311), and a window SUM over a DECIMAL column returning float results (dolthub/dolt#12312).
MIT