This is a discussion on Transactions in version 3 series of mysql within the MySQL Database forums, part of the Database Forums category; I'm using the C API on a major version3 database and am wondering how transaction control is implemented? In ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm using the C API on a major version3 database and am wondering how
transaction control is implemented? In major version 4 databases you can set autocommit and do individual transaction processing using the following functions mysql_autocommit() mysql_commit() mysql_rollback() So how do you do transaction processing in a major version 3 database. I cannot find any equivalent functions as those listed above so am confused? TIA, Pep. |
|
|||
|
> I'm using the C API on a major version3 database and am wondering how
> transaction control is implemented? > > In major version 4 databases you can set autocommit and do individual > transaction processing using the following functions > > mysql_autocommit() > mysql_commit() > mysql_rollback() > > So how do you do transaction processing in a major version 3 database. > I cannot find any equivalent functions as those listed above so am > confused? MySQL 3 only supported transactions for the 3rd party InnoDB table type. InnoDB is included in v4. So if you're using v3, I guess you have to use a newer version of the C API that has these calls. -- Martijn Tonies Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle & MS SQL Server Upscene Productions http://www.upscene.com My thoughts: http://blog.upscene.com/martijn/ Database development questions? Check the forum! http://www.databasedevelopmentforum.com |
|
|||
|
"Pep" <pepaltavista@yahoo.co.uk> wrote:
> I'm using the C API on a major version3 database and am wondering how > transaction control is implemented? > > In major version 4 databases you can set autocommit and do individual > transaction processing using the following functions > > mysql_autocommit() > mysql_commit() > mysql_rollback() > > So how do you do transaction processing in a major version 3 database. > I cannot find any equivalent functions as those listed above so am > confused? Those functions are pure convenience functions. You can achive the same using mysql_query() & friends. From $MYSQLSOURCE/libmysql/libmysql.c: my_bool STDCALL mysql_commit(MYSQL * mysql) { DBUG_ENTER("mysql_commit"); DBUG_RETURN((my_bool) mysql_real_query(mysql, "commit", 6)); } Got the idea? XL -- Axel Schwenke, Senior Software Developer, MySQL AB Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/ MySQL User Forums: http://forums.mysql.com/ |
|
|||
|
Axel Schwenke wrote: > "Pep" <pepaltavista@yahoo.co.uk> wrote: > > I'm using the C API on a major version3 database and am wondering how > > transaction control is implemented? > > > > In major version 4 databases you can set autocommit and do individual > > transaction processing using the following functions > > > > mysql_autocommit() > > mysql_commit() > > mysql_rollback() > > > > So how do you do transaction processing in a major version 3 database. > > I cannot find any equivalent functions as those listed above so am > > confused? > > Those functions are pure convenience functions. You can achive the same > using mysql_query() & friends. From $MYSQLSOURCE/libmysql/libmysql.c: > > my_bool STDCALL mysql_commit(MYSQL * mysql) > { > DBUG_ENTER("mysql_commit"); > DBUG_RETURN((my_bool) mysql_real_query(mysql, "commit", 6)); > } > > > Got the idea? > > > XL > -- > Axel Schwenke, Senior Software Developer, MySQL AB > > Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/ > MySQL User Forums: http://forums.mysql.com/ I'll investigate your post further when I get some peace in my project schedule. For the meantime, do I suppose correct that the series 3 mysql server automatically commits all changes I make to the database? Cheers, Pep. |
|
|||
|
"Pep" <pepaltavista@yahoo.co.uk> wrote:
> Axel Schwenke wrote: >> > mysql_autocommit() >> > mysql_commit() >> > mysql_rollback() >> >> Those functions are pure convenience functions. You can achive the same >> using mysql_query() & friends. From $MYSQLSOURCE/libmysql/libmysql.c: >> >> my_bool STDCALL mysql_commit(MYSQL * mysql) >> { >> DBUG_ENTER("mysql_commit"); >> DBUG_RETURN((my_bool) mysql_real_query(mysql, "commit", 6)); >> } > For the meantime, do I suppose correct that the series 3 mysql server > automatically commits all changes I make to the database? It's not that easy. Please do yourself a favour and read this up in the MySQL manual. In an nutshell: In all currently available MySQL versions, transaction support is limited to InnoDB tables. Transactions are controlled with the BEGIN, COMMIT and ROLLBACK SQL statements and the AUTOCOMMIT server variable. The C API calls you mentioned above are just convenient abbreviations for sending COMMIT, ROLLBACK and SET AUTOCOMMIT=0|1 statements to the server. You get the same effect by just sending those statements to the server via mysql_query(). Just like the implementation above shows. HTH, XL -- Axel Schwenke, Senior Software Developer, MySQL AB Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/ MySQL User Forums: http://forums.mysql.com/ |
|
|||
|
Axel Schwenke wrote: > "Pep" <pepaltavista@yahoo.co.uk> wrote: > > Axel Schwenke wrote: > > >> > mysql_autocommit() > >> > mysql_commit() > >> > mysql_rollback() > >> > >> Those functions are pure convenience functions. You can achive the same > >> using mysql_query() & friends. From $MYSQLSOURCE/libmysql/libmysql.c: > >> > >> my_bool STDCALL mysql_commit(MYSQL * mysql) > >> { > >> DBUG_ENTER("mysql_commit"); > >> DBUG_RETURN((my_bool) mysql_real_query(mysql, "commit", 6)); > >> } > > > > For the meantime, do I suppose correct that the series 3 mysql server > > automatically commits all changes I make to the database? > > It's not that easy. Please do yourself a favour and read this up in the > MySQL manual. In an nutshell: > > In all currently available MySQL versions, transaction support is > limited to InnoDB tables. Transactions are controlled with the BEGIN, > COMMIT and ROLLBACK SQL statements and the AUTOCOMMIT server variable. > > The C API calls you mentioned above are just convenient abbreviations > for sending COMMIT, ROLLBACK and SET AUTOCOMMIT=0|1 statements to the > server. You get the same effect by just sending those statements to the > server via mysql_query(). Just like the implementation above shows. > > > HTH, XL > -- > Axel Schwenke, Senior Software Developer, MySQL AB > > Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/ > MySQL User Forums: http://forums.mysql.com/ Thanks, Pep. |