freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Frediano Ziglio <freddyz77 AT tin.it>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] ODBC 'trans2' patch
- Date: Thu, 28 Aug 2003 05:55:56 -0000
Il gio, 2003-08-28 alle 00:57, Peter Deacon ha scritto:
> The ASE ODBC driver on the windows platform uses begin/commit transaction
> instead of set chained so now does FreeTDS..
>
> Ran into some compatibility problems when using chained mode and stored
> procedures. When a proc is created it can only execute with the mode
> it was created in unless you explicitly set otherwise.
>
> sqlstates :)
>
> Minor fix for recent changes. Found some memory leaks but I think
> freddy already fixed them.
>
> Have Fun!
> Peter
Applied!
Are you sure that ASE ODBC/MS ODBC driver do not use chained mode ?
What happen setting autocommit if we are in a transaction ?
(attached an updated patch, still not applied transactions change)
freddy77
Index: src/odbc/odbc.c =================================================================== RCS file: /cvsroot/freetds/freetds/src/odbc/odbc.c,v retrieving revision 1.224 diff -u -u -1 -0 -b -r1.224 odbc.c --- src/odbc/odbc.c 28 Aug 2003 05:47:55 -0000 1.224 +++ src/odbc/odbc.c 28 Aug 2003 05:48:38 -0000 @@ -165,22 +165,26 @@ * We may not be connected yet and dbc->tds_socket * may not initialized. */ if (tds) { /* mssql: SET IMPLICIT_TRANSACTION ON * sybase: SET CHAINED ON */ /* implicit transactions are on if autocommit is off :-| */ if (TDS_IS_MSSQL(tds)) sprintf(query, "set implicit_transactions %s", (state == SQL_AUTOCOMMIT_ON) ? "off" : "on"); + else { + if (state == SQL_AUTOCOMMIT_ON) + strcpy(query, "while @@TRANCOUNT > 1 commit commit"); else - sprintf(query, "set chained %s", (state == SQL_AUTOCOMMIT_ON) ? "off" : "on"); + strcpy(query, "BEGIN TRANSACTION"); + } tdsdump_log(TDS_DBG_INFO1, "change_autocommit: executing %s\n", query); if (tds_submit_query(tds, query, NULL) != TDS_SUCCEED) { odbc_errs_add(&dbc->errs, "HY000", "Could not change transaction status", NULL); ODBC_RETURN(dbc, SQL_ERROR); } if (tds_process_simple_query(tds) != TDS_SUCCEED) { odbc_errs_add(&dbc->errs, "HY000", "Could not change transaction status", NULL); ODBC_RETURN(dbc, SQL_ERROR); @@ -2841,25 +2845,31 @@ } #endif /* TODO join all this similar function... */ /* spinellia AT acm.org : copied shamelessly from change_database */ /* transaction support */ /* 1 = commit, 0 = rollback */ static SQLRETURN change_transaction(TDS_DBC * dbc, int state) { + char *query; TDSSOCKET *tds = dbc->tds_socket; tdsdump_log(TDS_DBG_INFO1, "change_transaction(0x%x,%d)\n", dbc, state); - if (tds_submit_query(tds, state ? "IF @@TRANCOUNT > 0 commit" : "IF @@TRANCOUNT > 0 rollback", NULL) != TDS_SUCCEED) { + if (dbc->attr.attr_autocommit == SQL_AUTOCOMMIT_ON || TDS_IS_MSSQL(tds)) + query = state ? "IF @@TRANCOUNT > 0 commit" : "IF @@TRANCOUNT > 0 rollback"; + else + query = state ? "IF @@TRANCOUNT > 0 commit BEGIN TRANSACTION" : "IF @@TRANCOUNT > 0 rollback BEGIN TRANSACTION"; + + if (tds_submit_query(tds, query, NULL) != TDS_SUCCEED) { odbc_errs_add(&dbc->errs, "HY000", "Could not perform COMMIT or ROLLBACK", NULL); return SQL_ERROR; } if (tds_process_simple_query(tds) != TDS_SUCCEED) return SQL_ERROR; return SQL_SUCCESS; }
-
[freetds] ODBC 'trans2' patch,
Peter Deacon, 08/27/2003
-
Re: [freetds] ODBC 'trans2' patch,
Frediano Ziglio, 08/28/2003
- Re: [freetds] ODBC 'trans2' patch, Peter Deacon, 08/28/2003
-
Re: [freetds] ODBC 'trans2' patch,
Frediano Ziglio, 08/28/2003
Archive powered by MHonArc 2.6.24.