Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add test for ticket [56b42d99c1]. Minor style fixes. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | tkt-56b42d99c1 |
Files: | files | file ages | folders |
SHA1: |
c91f525f5a17393e7efe93eb13783ebd |
User & Date: | mistachkin 2013-12-19 06:38:41.995 |
Context
2013-12-19
| ||
13:13 | Update version history docs. check-in: 619ae93189 user: mistachkin tags: tkt-56b42d99c1 | |
06:38 | Add test for ticket [56b42d99c1]. Minor style fixes. check-in: c91f525f5a user: mistachkin tags: tkt-56b42d99c1 | |
02:14 | Use the current isolation level when enlisting into an existing transaction. Fix for [56b42d99c1]. Still needs tests. check-in: 4f050c73ff user: mistachkin tags: tkt-56b42d99c1 | |
Changes
Changes to System.Data.SQLite/SQLiteEnlistment.cs.
1 2 3 4 5 6 7 8 9 10 11 12 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Robert Simpson (robert@blackcastlesoft.com) * * Released to the public domain, use at your own risk! ********************************************************/ #if !PLATFORM_COMPACTFRAMEWORK namespace System.Data.SQLite { using System.Transactions; | | | > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Robert Simpson (robert@blackcastlesoft.com) * * Released to the public domain, use at your own risk! ********************************************************/ #if !PLATFORM_COMPACTFRAMEWORK namespace System.Data.SQLite { using System.Transactions; internal sealed class SQLiteEnlistment : IDisposable, IEnlistmentNotification { internal SQLiteTransaction _transaction; internal Transaction _scope; internal bool _disposeConnection; internal SQLiteEnlistment(SQLiteConnection cnn, Transaction scope) { _transaction = cnn.BeginTransaction(GetSystemDataIsolationLevel( cnn, scope)); _scope = scope; _scope.EnlistVolatile(this, System.Transactions.EnlistmentOptions.None); } /////////////////////////////////////////////////////////////////////////// #region Private Methods private System.Data.IsolationLevel GetSystemDataIsolationLevel( SQLiteConnection connection, Transaction transaction ) { |
︙ | ︙ | |||
69 70 71 72 73 74 75 | // // TODO: Perhaps throw an exception here? // return SQLiteConnection.GetFallbackDefaultIsolationLevel(); } | | | | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | // // TODO: Perhaps throw an exception here? // return SQLiteConnection.GetFallbackDefaultIsolationLevel(); } /////////////////////////////////////////////////////////////////////////// private void Cleanup(SQLiteConnection cnn) { if (_disposeConnection) cnn.Dispose(); _transaction = null; _scope = null; } #endregion /////////////////////////////////////////////////////////////////////////// #region IDisposable Members public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } #endregion /////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteEnlistment).Name); #endif } /////////////////////////////////////////////////////////////////////////// private /* protected virtual */ void Dispose(bool disposing) { if (!disposed) { if (disposing) { |
︙ | ︙ | |||
137 138 139 140 141 142 143 | ////////////////////////////////////// disposed = true; } } #endregion | | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | ////////////////////////////////////// disposed = true; } } #endregion /////////////////////////////////////////////////////////////////////////// #region Destructor ~SQLiteEnlistment() { Dispose(false); } #endregion /////////////////////////////////////////////////////////////////////////// #region IEnlistmentNotification Members public void Commit(Enlistment enlistment) { CheckDisposed(); SQLiteConnection cnn = _transaction.Connection; |
︙ | ︙ | |||
170 171 172 173 174 175 176 | } finally { Cleanup(cnn); } } | | | | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | } finally { Cleanup(cnn); } } /////////////////////////////////////////////////////////////////////////// public void InDoubt(Enlistment enlistment) { CheckDisposed(); enlistment.Done(); } /////////////////////////////////////////////////////////////////////////// public void Prepare(PreparingEnlistment preparingEnlistment) { CheckDisposed(); if (_transaction.IsValid(false) == false) preparingEnlistment.ForceRollback(); else preparingEnlistment.Prepared(); } /////////////////////////////////////////////////////////////////////////// public void Rollback(Enlistment enlistment) { CheckDisposed(); SQLiteConnection cnn = _transaction.Connection; cnn._enlistment = null; |
︙ | ︙ |
Changes to Tests/common.eagle.
︙ | ︙ | |||
1263 1264 1265 1266 1267 1268 1269 | set add ReferencedAssemblies.Add # # NOTE: Create the base command to evaluate and add the property settings # that are almost always needed by our unit tests (i.e. the System # and System.Data assembly references). # | > | | > | 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 | set add ReferencedAssemblies.Add # # NOTE: Create the base command to evaluate and add the property settings # that are almost always needed by our unit tests (i.e. the System # and System.Data assembly references). # set command [list \ compileCSharp $text $memory $symbols $strict results errors \ $add System.dll $add System.Data.dll $add System.Transactions.dll \ $add System.Xml.dll] # # NOTE: Add all the provided file names as assembly references. # foreach fileName $fileNames { lappend command $add [getBinaryFileName $fileName] } |
︙ | ︙ |
Added Tests/tkt-56b42d99c1.eagle.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | ############################################################################### # # tkt-56b42d99c1.eagle -- # # Written by Joe Mistachkin. # Released to the public domain, use at your own risk! # ############################################################################### package require Eagle package require Eagle.Library package require Eagle.Test runTestPrologue ############################################################################### package require System.Data.SQLite.Test runSQLiteTestPrologue ############################################################################### runTest {test tkt-56b42d99c1-1.1 {enlisted transaction isolation} -setup { setupDb [set fileName tkt-56b42d99c1-1.1.db] } -body { set id [object invoke Interpreter.GetActive NextId] set dataSource [file join [getDatabaseDirectory] $fileName] unset -nocomplain results errors set code [compileCSharpWith [subst { using System.Data.SQLite; using System.Reflection; using System.Transactions; namespace _Dynamic${id} { public static class Test${id} { public static bool TryEnlistInTransaction() { TransactionOptions transactionOptions = new TransactionOptions(); transactionOptions.IsolationLevel = IsolationLevel.ReadCommitted; using (TransactionScope transactionScope = new TransactionScope( TransactionScopeOption.Required, transactionOptions)) { using (SQLiteConnection connection1 = new SQLiteConnection( "Data Source=${dataSource};")) { connection1.Open(); using (SQLiteConnection connection2 = new SQLiteConnection( "Data Source=${dataSource};")) { connection2.Open(); BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField; FieldInfo fieldInfo1 = connection1.GetType().GetField( "_enlistment", bindingFlags); object enlistment1 = fieldInfo1.GetValue(connection1); object enlistment2 = fieldInfo1.GetValue(connection2); FieldInfo fieldInfo2 = enlistment1.GetType().GetField( "_transaction", bindingFlags); SQLiteTransaction transaction1 = (SQLiteTransaction)fieldInfo2.GetValue(enlistment1); SQLiteTransaction transaction2 = (SQLiteTransaction)fieldInfo2.GetValue(enlistment2); return (transaction1.IsolationLevel == transaction2.IsolationLevel); } } } } /////////////////////////////////////////////////////////////////////// public static void Main() { // do nothing. } } } }] true true true results errors System.Data.SQLite.dll] list $code $results \ [expr {[info exists errors] ? $errors : ""}] \ [expr {$code eq "Ok" ? [catch { object invoke _Dynamic${id}.Test${id} TryEnlistInTransaction } result] : [set result ""]}] $result } -cleanup { cleanupDb $fileName unset -nocomplain result results errors code dataSource id db fileName } -constraints {eagle monoBug28 command.sql compile.DATA SQLite\ System.Data.SQLite compileCSharp} -match regexp -result {^Ok\ System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 True$}} ############################################################################### runSQLiteTestEpilogue runTestEpilogue |