[MDEV-26698] Incorrect row number upon INSERT .. SELECT from the same table: rows are counted twice Created: 2021-09-27  Updated: 2022-01-03  Resolved: 2022-01-03

Status: Closed
Project: MariaDB Server
Component/s: Server
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
Fix Version/s: 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Rucha Deodhar
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-10075 Provide index of error causing error ... Closed

 Description   

When INSERT .. SELECT produces an error/warning which reports the number of the problematic row, this number is wrong when SELECT is performed from the same table.

create or replace table t (a tinyint);
insert into t values (1),(100);
insert into t select a*2 from t;

10.7 d552e092c9f3

MariaDB [test]> insert into t select a*2 from t;
ERROR 1264 (22003): Out of range value for column 'a' at row 4

Consequently, ERROR_INDEX from MDEV-10075 is also wrong.

If the the same values are insert-selected from a different table, the counter is correct:

MariaDB [test]> create or replace table tmp select * from t;
Query OK, 2 rows affected (0.044 sec)
Records: 2  Duplicates: 0  Warnings: 0
 
MariaDB [test]> insert into t select a*2 from tmp;
ERROR 1264 (22003): Out of range value for column 'a' at row 2



 Comments   
Comment by Rucha Deodhar [ 2021-12-27 ]

Patch:
https://github.com/MariaDB/server/commit/803b977229c2124bac15e068efffc04251685de1

Generated at Thu Feb 08 09:47:16 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.