Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk/batch INSERT operations and prepared statements. #1167

Open
wiluite opened this issue Sep 13, 2024 · 2 comments
Open

Bulk/batch INSERT operations and prepared statements. #1167

wiluite opened this issue Sep 13, 2024 · 2 comments

Comments

@wiluite
Copy link

wiluite commented Sep 13, 2024

Hello,

Suppose, I have a trivial insertion code (much more simpler than the one, provided in the documention):

CREATE TABLE table1( a DECIMAL NOT NULL );
...

std::vector<int> v (3, 1);
soci::statement stmt = (sql.prepare << "insert into table1 (a) values (:a)", soci::use(v));
v[0] = 1;
v[1] = 2;
v[2] = 3;
stmt.execute(1);
v[0] = 4;
v[1] = 5;
stmt.execute(1);

Now, the following SELECT says the sqlite3 and the Firebird backends worked it out as I'd expected:

a
1
2
3
4
5
3

While dealing with MySQL and PostgreSQL DBMS and their soci backends I got the following results:

a
1
2
3
1
2
3

So, actually, after the first insertion portion something refuses to accept actually changed data as changed.
Could you please hint where to dig? (Or мaybe the problem lies on the surface?)

Thanks!
The Firebird I used is 5. MySQL version is 8. The PostgreSQL is 14.

@vadz
Copy link
Member

vadz commented Sep 14, 2024

This looks like a bug, to be honest. We even have a unit test checking that this works for scalar inserts, see "Multiple use and into", but not for vectors, unfortunately.

I'd have to debug it to see what's going on here...

@wiluite
Copy link
Author

wiluite commented Sep 14, 2024

OK! Look, if it's not too difficult.
Yes, I'd seen the code you pointed to, but I thought you run it against the sqlite3 only (which emulates the bulk).
If there were no problems with inserting scalars across all backends in this mode, then the error is probably somewhere during vector insertion.

As a helpful info: oracle and firebird backends for vectors works well. (maybe fixes for mysql and postgresql could be accomplished by analogy).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants