Open systay opened 3 months ago
There's another thing that goes wrong here when there's no row(s). MySQL returns no rows, but with a NEWDECIMAL
type, by Vitess seems to return NULL_TYPE
.
--- FAIL: TestSubqueries (0.02s)
--- FAIL: TestSubqueries/0_SELECT_(SELECT_SUM(LENGTH(extra_info))_FROM_user_extra)_AS_total_length_extra_info_FROM_user (0.00s)
mysql.go:265: for column total_length_extra_info field types do not match
Not equal:
MySQL: DECIMAL
Vitess: NULL_TYPE
mysql> SELECT SUM(LENGTH(extra_info)) FROM user_extra;
Field 1: `SUM(LENGTH(extra_info))`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: NEWDECIMAL
Collation: binary (63)
Length: 32
Max_length: 0
Decimals: 0
Flags: BINARY NUM
+-------------------------+
| SUM(LENGTH(extra_info)) |
+-------------------------+
| NULL |
+-------------------------+
1 row in set (0.01 sec)
mysql> SELECT (SELECT SUM(LENGTH(extra_info)) FROM user_extra) AS total_length_extra_info FROM user;
Field 1: `total_length_extra_info`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: NEWDECIMAL
Collation: binary (63)
Length: 32
Max_length: 0
Decimals: 0
Flags: BINARY NUM
0 rows in set (0.01 sec)
Given the following query:
Vitess returns the wrong type. MySQL would return a
DECIMAL
, but Vitess returns anINT64
.The weird thing is that this only happens then the
SUM
query is in a subquery - if run as a standalone query we get the correct type.The plan used is: