-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There's a lot to unpack here, but the tl;dr is to refer to the charset ultimately to determine if the data is UTF8, if it is, we can decode it to a UTF8 string. This fixes behavior around CHAR/TEXT fields with a binary collation, being surfaces as BINARY/BLOB types by MySQL. For all intents and purposes, BLOB/BINARY/CHAR/TEXT are all effectively identical and interchangeable, the only differentiator is their charset. Either they are a UTF-8 charset, or a binary charset or some other charset. Fixes #169
- Loading branch information
1 parent
3ec5d36
commit 57dcc6c
Showing
12 changed files
with
815 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Golden tests | ||
|
||
This generates a "golden" test result that feeds the "parse e2e" test suite. | ||
|
||
The intent is a full round trip with a known table that exercises every column type with known correct data. | ||
|
||
This excercises different collations, charsets, every integer type. | ||
|
||
`test.sql` acts as the seed data against a PlanetScale branch, then we fetch the data back with `curl`. | ||
|
||
We can run different queries inside the `generate.sh` script either against the current data, or tests that run against `dual`. | ||
|
||
The results are stored back in `$case.json` and a compact version stored in `$case-compact.json`. This compact version is what is shoved into the mock test result for convenience. | ||
|
||
Along with this is a `cli.txt` which is the result of running `select * from test` in a mysql CLI dumping the full human readable table. This table is a good reference for what is expected to be human readable or not. Raw binary data is represented as hexadecimal, vs UTF8 strings are readable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
+----+------+------+------+------+------+------+------+------+------+------------+------------+---------------------+---------------------+----------+------+------+------+------------+------------+------------+------------+------------+------------+------+------+------+------+------+---------+--------------+------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------+------+------+------+------+------+------------+------+ | ||
| id | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z | aa | ab | ac | ad | ae | af | ag | ah | ai | aj | ak | al | xa | xb | xc | xd | | ||
+----+------+------+------+------+------+------+------+------+------+------------+------------+---------------------+---------------------+----------+------+------+------+------------+------------+------------+------------+------------+------------+------+------+------+------+------+---------+--------------+------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------+------+------+------+------+------+------------+------+ | ||
| 1 | 1 | 1 | 1 | 1 | 1 | 1.1 | 1.1 | 1.1 | 1.1 | 0x07 | 1000-01-01 | 1000-01-01 01:01:01 | 1970-01-01 00:01:01 | 01:01:01 | 2006 | p | q | 0x72000000 | 0x73 | 0x74 | 0x75 | 0x76 | 0x77 | x | y | z | aa | foo | foo,bar | {"ad": null} | 0x0000000001020000000300000000000000000000000000000000000000000000000000F03F000000000000F03F00000000000000400000000000000000 | 0x000000000101000000000000000000F03F000000000000F03F | 0x0000000001020000000300000000000000000000000000000000000000000000000000F03F000000000000F03F00000000000000400000000000000000 | 0x00000000010300000002000000040000000000000000000000000000000000000000000000000000000000000000000840000000000000084000000000000000000000000000000000000000000000000004000000000000000000F03F000000000000F03F000000000000F03F00000000000000400000000000000040000000000000F03F000000000000F03F000000000000F03F | 1 | 1 | 1 | 1 | xa | xb | 0x78630000 | xd | | ||
+----+------+------+------+------+------+------+------+------+------+------------+------------+---------------------+---------------------+----------+------+------+------+------------+------------+------------+------------+------------+------------+------+------+------+------+------+---------+--------------+------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------+------+------+------+------+------+------------+------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"fields":[{"name":"a","type":"VARCHAR","charset":8,"flags":1}],"rows":[{"lengths":["2"],"values":"w78="}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"fields": [ | ||
{ | ||
"name": "a", | ||
"type": "VARCHAR", | ||
"charset": 8, | ||
"flags": 1 | ||
} | ||
], | ||
"rows": [ | ||
{ | ||
"lengths": [ | ||
"2" | ||
], | ||
"values": "w78=" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
run_sql() { | ||
name=$1 | ||
query=$2 | ||
echo "{\"query\":\"$query\"}" | | ||
curl -s -u $MYSQL_USER:$MYSQL_PWD \ | ||
-d@- -H'content-type: application/json' \ | ||
https://$MYSQL_HOST/psdb.v1alpha1.Database/Execute | jq .result > $name.json | ||
jq -c . $name.json > $name-compact.json | ||
jq . $name.json | ||
} | ||
|
||
cat test.sql | mysql -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PWD | ||
|
||
run_sql 'testdb' 'select *, NULL from `test`' | ||
run_sql 'dual' 'select _latin1 0xff as a' |
Oops, something went wrong.