LAST_INSERT_ID() and Connections not being closed?

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
LVdB
Posts: 17
Joined: Mon 11 Sep 2006 12:53

LAST_INSERT_ID() and Connections not being closed?

Post by LVdB » Mon 29 Jan 2007 15:20

Hi,

I read somewhere (on the forum or in the documentation, I cannot recall) that MySQLDirect.NET keeps connections open behind the scenes, for performance reasons.

I am worried this might lead to a problem using for example LAST_INSERT_ID() (see http://dev.mysql.com/doc/refman/5.0/en/ ... ement.html ). If one thread performs an INSERT into a table that has a AUTO_INCREMENT column, then using the still open connection calls LAST_INSERT_ID(), it will return the correct answer. But what if another thread also performs an INSERT on an AUTO_INCREMENT column in the middle of this first thread (using the same connection which was kept open by MySQLDirect.NET) - then the LAST_INSERT_ID() returned on the first thread would be wrong.

Unless, of course, you have taking this into account already, which I suppose is likely!

Luc

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Tue 30 Jan 2007 12:17

Don't worry about that. We take care of it.

LVdB
Posts: 17
Joined: Mon 11 Sep 2006 12:53

Post by LVdB » Tue 30 Jan 2007 12:27

Excellent! Thanks for the reply.

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Tue 30 Jan 2007 12:36

You're welcome:)

Post Reply