Internal memtables don't do type checking for the rows they return
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Normally, if a column's type has a size limitation, and a column value in a row exceeds that limitation, a "Data Too Long" warning will be raised and the column value will be truncated. However, as discovered in issue #56057, internal memtables don't do any type checking for the columns of the rows they return. This means that, if there is a bug in a memtable retriever that returns the wrong type of data for a column, this error will not be checked and will silently go unnoticed.
### 1. Minimal reproduce step (Required)
```sql
show columns in information_schema.processlist like 'state';
select state, length(state) from information_schema.processlist;
show warnings;
```
### 2. What did you expect to see? (Required)
```
mysql> show columns in information_schema.processlist like 'state';
+-------+------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+------+---------+-------+
| STATE | varchar(7) | YES | | NULL | |
+-------+------------+------+------+---------+-------+
1 row in set (0.00 sec)
mysql> select state, length(state) from information_schema.processlist;
+---------+---------------+
| state | length(state) |
+---------+---------------+
| autocom | 7 |
+---------+---------------+
1 row in set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+-----------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------+
| Warning | 1406 | Data Too Long, field len 7, data len 10 |
+---------+------+-----------------------------------------+
1 row in set (0.00 sec)
```
### 3. What did you see instead (Required)
```
mysql> show columns in information_schema.processlist like 'state';
+-------+------------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+------+---------+-------+
| STATE | varchar(7) | YES | | NULL | |
+-------+------------+------+------+---------+-------+
1 row in set (0.01 sec)
mysql> select state, length(state) from information_schema.processlist;
+------------+---------------+
| state | length(state) |
+------------+---------------+
| autocommit | 10 |
+------------+---------------+
1 row in set (0.00 sec)
mysql> show warnings;
Empty set (0.00 sec)
```
### 4. What is your TiDB version? (Required)
```
mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v9.0.0-alpha-489-g755cc34900
Edition: Community
Git Commit Hash: 755cc34900f4c6dd7ead4fd4e408ba01a0cb2283
Git Branch: master
UTC Build Time: 2025-03-29 03:07:55
GoVersion: go1.24.0
Race Enabled: false
Check Table Before Drop: false
Store: unistore
1 row in set (0.00 sec)
```
Contributor guide
Assessment
This issue has not been assessed yet.