Update of /cvsroot/refdb/refdb/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24395
Modified Files:
Tag: Release_0_9_5_stable
dbfncs.c
Log Message:
added transaction support for MySQL
Index: dbfncs.c
===================================================================
RCS file: /cvsroot/refdb/refdb/src/dbfncs.c,v
retrieving revision 1.15.2.5
retrieving revision 1.15.2.6
diff -u -U2 -r1.15.2.5 -r1.15.2.6
--- dbfncs.c 12 Feb 2005 13:19:46 -0000 1.15.2.5
+++ dbfncs.c 13 Feb 2005 16:32:29 -0000 1.15.2.6
@@ -55,12 +55,14 @@
if (!strcmp(ptr_clrequest->dbserver, "mysql")) {
- /* these settings should work for 3.23 and later. We'll check the
+ /* these settings should work for 3.23.19 and later. We'll check the
database engine version at runtime and fill in more appropriate
- values if we're using a newer version */
+ values if we're using a newer version. Some settings (like
+ transactions) are not supported by older versions, but do not cause
+ an error */
strcpy(ptr_caps->multiple_db, "t");
strcpy(ptr_caps->sql_enum, "t");
strcpy(ptr_caps->rlike, "RLIKE");
strcpy(ptr_caps->not_rlike, "NOT RLIKE");
- strcpy(ptr_caps->transaction, "f");
+ strcpy(ptr_caps->transaction, "t");
strcpy(ptr_caps->localhost, "localhost");
strcpy(ptr_caps->encoding, "");
@@ -1379,5 +1381,12 @@
dbi_result_free(dbires);
}
- else if (!strcmp(drivername, "sqlite")) {
+ else { /* SQLite and MySQL */
+ /* MySQL supports transactions only in transaction-safe tables
+ (InnoDB, BDB) but the transaction-related commands do not cause
+ errors in the other table types. Therefore it safe to use them
+ anyway, even if they don't have the desired effect. The
+ non-transaction-safe tables work in auto-commit mode, i.e. each
+ command is committed immediately. Rollbacks do not have any
+ effect in this case */
dbires = dbi_conn_query(conn, sql_command[1][trans_type]);
LOG_PRINT(LOG_DEBUG, sql_command[1][trans_type]);
@@ -1387,7 +1396,5 @@
dbi_result_free(dbires);
}
- /* else: transactions not supported by other drivers */
- /* ToDo: MySQL > 4.0 knows transactions, but how do we know the server
- version? And the table type? */
+
return 0;
}
|