![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I was wondering if MySQLPP supports some kind of mechanism to do transactions. |
#3
| |||
| |||
|
|
Tim Murison wrote: I was wondering if MySQLPP supports some kind of mechanism to do transactions. Not right now. Patches thoughtfully considered. |
|
Transaction support. Considering block-level semantics: create a "transaction object" on the stack, which takes a ref to the Connection object (?) as a ctor parameter. Transaction object's ctor calls a function on the conn telling it to tell the server to begin a transaction set. When the transaction object is destroyed, it tells the conn object to commit everything. Conn object in this situation must be created in a higher scope, or on the heap. |
#4
| |||
| |||
|
|
-----Original Message----- From: Warren Young [mailto:mysqlpp (AT) etr-usa (DOT) com]=20 Sent: Tuesday, April 05, 2005 5:15 AM To: MySQL++ Mailing List Subject: Re: Transactions with MySQLPP =20 Tim Murison wrote: =20 I was wondering if MySQLPP supports some kind of mechanism to do=20 transactions. =20 Not right now. Patches thoughtfully considered. =20 --=20 MySQL++ Mailing List For list archives: http://lists.mysql.com/plusplus To unsubscribe: =20 http://lists.mysql.com/plusplus?unsu...) f5 (DOT) com =20 =20 |
#5
| |||
| |||
|
|
However, the underlying SQL itself will support transactions: |
#6
| |||
| |||
|
|
However, the underlying SQL itself will support transactions: query << "START TRANSACTION"; query.execute(); query.reset(); query << // your update here query.execute(); query.reset(); query << "COMMIT" query.execute(); |
#7
| |||
| |||
|
|
-----Original Message----- From: Tim Murison [mailto:tmurison (AT) primus (DOT) ca]=20 Sent: Monday, April 11, 2005 2:20 PM To: Steve Roberts Subject: RE: Transactions with MySQLPP =20 On Tue, 2005-05-04 at 07:52 -0700, Steve Roberts wrote: However, the underlying SQL itself will support transactions: =20 query << "START TRANSACTION"; query.execute(); query.reset(); query << // your update here query.execute(); query.reset(); query << "COMMIT" query.execute(); =20 Thanks... I went with this method... =20 At first it seemed to work but when running my program=20 through a full test suite, I noticed that I got failed transactions. One in particular has me stumped, it fails on a foreign key=20 constraint... the perculiar thing is that if I manually enter=20 the same queries through the command line, it works! =20 The only thing I notice that your example does that I don't is query.reset() instead of creating a new query each time...=20 could this be significant? =20 Cheers, =20 -Tim =20 =20 |
#8
| |||
| |||
|
|
All query.reset() does is clear the underlying stringstream object. So long as you reset after execution it "should" work, unless you're trying to get something out of a select statement as you go. I claim no particular expertise on mysql++, I was just trying to pass along something I discovered in the process of developing our application. So far we've had good luck with this method. |
|
-----Original Message----- From: Tim Murison [mailto:tmurison (AT) primus (DOT) ca] Sent: Monday, April 11, 2005 2:20 PM To: Steve Roberts Subject: RE: Transactions with MySQLPP On Tue, 2005-05-04 at 07:52 -0700, Steve Roberts wrote: However, the underlying SQL itself will support transactions: query << "START TRANSACTION"; query.execute(); query.reset(); query << // your update here query.execute(); query.reset(); query << "COMMIT" query.execute(); Thanks... I went with this method... At first it seemed to work but when running my program through a full test suite, I noticed that I got failed transactions. One in particular has me stumped, it fails on a foreign key constraint... the perculiar thing is that if I manually enter the same queries through the command line, it works! The only thing I notice that your example does that I don't is query.reset() instead of creating a new query each time... could this be significant? Cheers, -Tim |
![]() |
| Thread Tools | |
| Display Modes | |
| |