[MDEV-30523] Bulk: insert with subselect inserts wrong data Created: 2023-01-31  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Prepared Statements
Affects Version/s: 10.7.3, 10.3, 10.4, 10.10.3, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Georg Richter Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

This issue was initially reported on stackoverflow

When using subselects in bulk insert wrong values are inserted.

How to repeat:

SQL:

create table t1 (a int);
create table t2 like t1;
insert into t2 values (1),(2);

Python script:

import mariadb
conn= mariadb.connect(db="test")
cursor=conn.cursor()
cursor.executemany("INSERT INTO t1 VALUES ((SELECT a FROM t2 WHERE a=?))", [(1,),(2,)])
cursor.execute("SELECT a FROM t1")
row= cursor.fetchall()
print(row)

Output:

[(1,), (1,)]

Expected Output:

[(1,), (2,)]



 Comments   
Comment by Alice Sherepa [ 2023-02-01 ]

I repeated as described on 10.3(f812f8e1ab7acc5dd17d)-10.11

Comment by Georg Richter [ 2023-09-01 ]

See also https://stackoverflow.com/questions/77023141/batchupdateexception-for-batch-size-other-than-1

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