Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
1.2.2
-
None
-
2021-7
Description
Build tested: 1.2.2-1
When executing an insert..select statement from a table that has 5 rows, with batch insert off, all 5 rows were inserted correctly. But when I repeat the same insert..select statement, the first inserted row is shorter than the source row.
I simplified the test case by insert..select only one row, the execute is still correct, but from the 2nd execution and onward, the insert is not correct.
When batch insert is enabled (using cpimort), it does not have this issue.
The same issue occurs to blob, longblob, text, and longtext data types.
MariaDB [mytest]> set infinidb_use_import_for_batchinsert=0;
Query OK, 0 rows affected (0.001 sec)
MariaDB [mytest]> desc text1;
---------------------------------+
Field | Type | Null | Key | Default | Extra |
---------------------------------+
c1 | int(11) | YES | NULL | ||
c2 | text | YES | NULL |
---------------------------------+
2 rows in set (0.002 sec)
MariaDB [mytest]> desc text2;
---------------------------------+
Field | Type | Null | Key | Default | Extra |
---------------------------------+
c1 | int(11) | YES | NULL | ||
c2 | text | YES | NULL |
---------------------------------+
2 rows in set (0.002 sec)
MariaDB [mytest]> select * from text1;
Empty set (0.011 sec)
MariaDB [mytest]> select c1, length(c2) from text2;
----------------+
c1 | length(c2) |
----------------+
1 | 60000 |
2 | 60000 |
3 | 60000 |
4 | 60000 |
5 | 60000 |
----------------+
5 rows in set (0.096 sec)
MariaDB [mytest]> insert into text1 select * from text2;
Query OK, 5 rows affected (0.383 sec)
Records: 5 Duplicates: 0 Warnings: 0
MariaDB [mytest]> select c1, length(c2) from text1;
----------------+
c1 | length(c2) |
----------------+
1 | 60000 |
2 | 60000 |
3 | 60000 |
4 | 60000 |
5 | 60000 |
1 | 57950 |
2 | 60000 |
3 | 60000 |
4 | 60000 |
5 | 60000 |
----------------+
10 rows in set (0.018 sec)
MariaDB [mytest]> truncate table text1;
Query OK, 0 rows affected (0.499 sec)
MariaDB [mytest]> insert into text1 select * from text2 where text2.c1 = 1;
Query OK, 1 row affected (0.227 sec)
Records: 1 Duplicates: 0 Warnings: 0
MariaDB [mytest]> select c1, length(c2) from text1;
----------------+
c1 | length(c2) |
----------------+
1 | 60000 |
----------------+
1 row in set (0.016 sec)
MariaDB [mytest]> insert into text1 select * from text2 where text2.c1 = 1;
Query OK, 1 row affected (0.182 sec)
Records: 1 Duplicates: 0 Warnings: 0
MariaDB [mytest]> select c1, length(c2) from text1;
----------------+
c1 | length(c2) |
----------------+
1 | 60000 |
1 | 54698 |
----------------+
2 rows in set (0.041 sec)
MariaDB [mytest]> insert into text1 select * from text2 where text2.c1 = 1;
Query OK, 1 row affected (0.270 sec)
Records: 1 Duplicates: 0 Warnings: 0
MariaDB [mytest]> select c1, length(c2) from text1;
----------------+
c1 | length(c2) |
----------------+
1 | 60000 |
1 | 54698 |
1 | 57552 |
----------------+
3 rows in set (0.013 sec)
MariaDB [mytest]> insert into text1 select * from text2 where text2.c1 = 1;
Query OK, 1 row affected (0.246 sec)
Records: 1 Duplicates: 0 Warnings: 0
MariaDB [mytest]> select c1, length(c2) from text1;
----------------+
c1 | length(c2) |
----------------+
1 | 60000 |
1 | 54698 |
1 | 57552 |
1 | 52242 |
----------------+
4 rows in set (0.016 sec)
When enabled batch insert (using cpimport), the same insertselect statement worked
MariaDB [mytest]> insert into text1 select * from text2 where text2.c1 = 1;
Query OK, 1 row affected (1.213 sec)
Records: 1 Duplicates: 0 Warnings: 0
MariaDB [mytest]> select c1, length(c2) from text1;
----------------+
c1 | length(c2) |
----------------+
1 | 60000 |
1 | 54698 |
1 | 57552 |
1 | 52242 |
1 | 60000 |
----------------+
5 rows in set (0.024 sec)