Copying an enum or set type column into a string type column results in incorrect conversion
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 873
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 108
Description
Discovered with #9594 (https://github.com/dolthub/dolt/issues/9594#issuecomment-3130323046)
Also happens with set types
dolt
```
tmp/main*> create table set_table(pk int primary key, c0 set('abc','def','ghi'));
Query OK, 0 rows affected (0.01 sec)
tmp/main*> insert into set_table values(0, 'abc,def'),(1,'def'),(2,'ghi');
Query OK, 3 rows affected (0.01 sec)
tmp/main*> create table string_table(pk int primary key, c0 varchar(20));
Query OK, 0 rows affected (0.01 sec)
tmp/main*> insert into string_table select * from set_table;
Query OK, 3 rows affected (0.01 sec)
tmp/main*> select * from string_table;
+----+----+
| pk | c0 |
+----+----+
| 0 | 3 |
| 1 | 2 |
| 2 | 4 |
+----+----+
3 rows in set (0.00 sec)
```
mysql
```
mysql> create table set_Table(pk int primary key, c0 set('abc','def','ghi'));
Query OK, 0 rows affected (0.01 sec)
mysql> insert into set_table values (0, 'abc,def'),(1, 'def'),(2,'ghi');
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> create table string_table(pk int primary key, c0 varchar(20));
Query OK, 0 rows affected (0.01 sec)
mysql> insert into string_table select * from set_table;
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select * from string_table;
+----+---------+
| pk | c0 |
+----+---------+
| 0 | abc,def |
| 1 | def |
| 2 | ghi |
+----+---------+
3 rows in set (0.00 sec)
```
The column values are converted in `rowexec.insertIter.Next` when `col.Type.Convert` is called. We should be using `TypeAwareConversion` here but there's currently not an easy way to get the type of the source column.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.