Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Defer disposing of the connection created by the static SQLiteCommand.Execute method when a data reader is returned. Fix for [daeaf3150a]. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ad79758d0cf4e60f5c58f60207e353bb |
User & Date: | mistachkin 2014-11-07 23:48:19.909 |
Context
2014-11-14
| ||
00:19 | Handle Julian Day values that fall outside of the supported range for OLE Automation dates. Fix for [3e783eecbe]. check-in: 3bd76a0c9d user: mistachkin tags: trunk | |
2014-11-08
| ||
06:41 | Do not emit ORDER BY, LIMIT, and OFFSET clauses for the left SELECT statement when a compound operator is involved. Candidate fix for [0a32885109]. check-in: 1f05aa9dd6 user: mistachkin tags: tkt-0a32885109 | |
2014-11-07
| ||
23:48 | Defer disposing of the connection created by the static SQLiteCommand.Execute method when a data reader is returned. Fix for [daeaf3150a]. check-in: ad79758d0c user: mistachkin tags: trunk | |
22:00 | Change support email address in the design-time components. Pursuant to [17405b6e06]. check-in: 9c43b0b95c user: mistachkin tags: trunk | |
Changes
Changes to Doc/Extra/Provider/version.html.
︙ | ︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | <div id="mainBody"> <h1 class="heading">Version History</h1> <p><b>1.0.95.0 - November XX, 2014 <font color="red">(release scheduled)</font></b></p> <ul> <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_7_1.html">SQLite 3.8.7.1</a>.</li> <li>Make sure SQL statements generated for DbUpdateCommandTree objects are properly delimited.</li> <li>Various minor performance enhancements to the SQLiteDataReader class. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/e122d26e70">[e122d26e70]</a>.</li> <li>In the SQLiteDataReader.VerifyType method, remove duplicate "if" statement for the DbType.SByte value and move the remaining "if" to the Int64 affinity. Fix for <a href="http://system.data.sqlite.org/index.html/info/c5cc2fb334">[c5cc2fb334]</a>. <b>** Potentially Incompatible Change **</b></li> </ul> <p><b>1.0.94.0 - September 9, 2014</b></p> <ul> <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_6.html">SQLite 3.8.6</a>.</li> <li>Updated to <a href="http://www.nuget.org/packages/EntityFramework/6.1.1">Entity Framework 6.1.1</a>.</li> <li>Refactor and simplify NuGet packages in order to support per-solution SQLite interop assembly files. <b>** Potentially Incompatible Change **</b></li> | > | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <div id="mainBody"> <h1 class="heading">Version History</h1> <p><b>1.0.95.0 - November XX, 2014 <font color="red">(release scheduled)</font></b></p> <ul> <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_7_1.html">SQLite 3.8.7.1</a>.</li> <li>Make sure SQL statements generated for DbUpdateCommandTree objects are properly delimited.</li> <li>Various minor performance enhancements to the SQLiteDataReader class. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/e122d26e70">[e122d26e70]</a>.</li> <li>Defer disposing of connections created by the static SQLiteCommand.Execute method when a data reader is returned. Fix for <a href="http://system.data.sqlite.org/index.html/info/daeaf3150a">[daeaf3150a]</a>.</li> <li>In the SQLiteDataReader.VerifyType method, remove duplicate "if" statement for the DbType.SByte value and move the remaining "if" to the Int64 affinity. Fix for <a href="http://system.data.sqlite.org/index.html/info/c5cc2fb334">[c5cc2fb334]</a>. <b>** Potentially Incompatible Change **</b></li> </ul> <p><b>1.0.94.0 - September 9, 2014</b></p> <ul> <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_6.html">SQLite 3.8.6</a>.</li> <li>Updated to <a href="http://www.nuget.org/packages/EntityFramework/6.1.1">Entity Framework 6.1.1</a>.</li> <li>Refactor and simplify NuGet packages in order to support per-solution SQLite interop assembly files. <b>** Potentially Incompatible Change **</b></li> |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteCommand.cs.
︙ | ︙ | |||
702 703 704 705 706 707 708 | return Execute( commandText, executeType, CommandBehavior.Default, connectionString, args); } /// <summary> /// This method creates a new connection, executes the query using the given | | | | | 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | return Execute( commandText, executeType, CommandBehavior.Default, connectionString, args); } /// <summary> /// This method creates a new connection, executes the query using the given /// execution type and command behavior, closes the connection unless a data /// reader is created, and returns the results. If the connection string is /// null, a temporary in-memory database connection will be used. /// </summary> /// <param name="commandText"> /// The text of the command to be executed. /// </param> /// <param name="executeType"> /// The execution type for the command. This is used to determine which method /// of the command object to call, which then determines the type of results |
︙ | ︙ | |||
737 738 739 740 741 742 743 | string commandText, SQLiteExecuteType executeType, CommandBehavior commandBehavior, string connectionString, params object[] args ) { | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > | > | > > > > | > > > > > > > > > > > > | > > > > > > > > > > > > > > > > | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 | string commandText, SQLiteExecuteType executeType, CommandBehavior commandBehavior, string connectionString, params object[] args ) { SQLiteConnection connection = null; try { if (connectionString == null) connectionString = DefaultConnectionString; using (connection = new SQLiteConnection(connectionString)) { connection.Open(); using (SQLiteCommand command = connection.CreateCommand()) { command.CommandText = commandText; if (args != null) { foreach (object arg in args) { if (arg is SQLiteParameter) command.Parameters.Add((SQLiteParameter)arg); else command.Parameters.Add(new SQLiteParameter(DbType.Object, arg)); } } switch (executeType) { case SQLiteExecuteType.None: { // // NOTE: Do nothing. // break; } case SQLiteExecuteType.NonQuery: { return command.ExecuteNonQuery(commandBehavior); } case SQLiteExecuteType.Scalar: { return command.ExecuteScalar(commandBehavior); } case SQLiteExecuteType.Reader: { bool success = true; try { // // NOTE: The CloseConnection flag is being added here. // This should force the returned data reader to // close the connection when it is disposed. In // order to prevent the containing using block // from disposing the connection prematurely, // the innermost finally block sets the internal // no-disposal flag to true. The outer finally // block will reset the internal no-disposal flag // to false so that the data reader will be able // to (eventually) dispose of the connection. // return command.ExecuteReader( commandBehavior | CommandBehavior.CloseConnection); } catch { success = false; throw; } finally { // // NOTE: If an exception was not thrown, that can only // mean the data reader was successfully created // and now owns the connection. Therefore, set // the internal no-disposal flag (temporarily) // in order to exit the containing using block // without disposing it. // if (success) connection._noDispose = true; } } } } } } finally { // // NOTE: Now that the using block has been exited, reset the // internal disposal flag for the connection. This is // always done if the connection was created because // it will be harmless whether or not the data reader // now owns it. // if (connection != null) connection._noDispose = false; } return null; } /// <summary> /// Overrides the default behavior to return a SQLiteDataReader specialization class |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | ︙ | |||
320 321 322 323 324 325 326 | /// <b>False</b> - Skip attempting to expand the data source file name to a fully qualified path before opening. /// </description> /// <description>N</description> /// <description>True</description> /// </item> /// </list> /// </remarks> | | | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | /// <b>False</b> - Skip attempting to expand the data source file name to a fully qualified path before opening. /// </description> /// <description>N</description> /// <description>True</description> /// </item> /// </list> /// </remarks> public sealed partial class SQLiteConnection : DbConnection, ICloneable, IDisposable { #region Private Constants /// <summary> /// The "invalid value" for the <see cref="DbType" /> enumeration used /// by the <see cref="DefaultDbType" /> property. This constant is shared /// by this class and the SQLiteConnectionStringBuilder class. /// </summary> |
︙ | ︙ | |||
430 431 432 433 434 435 436 437 438 439 440 441 442 443 | /// </summary> private string _connectionString; /// <summary> /// Nesting level of the transactions open on the connection /// </summary> internal int _transactionLevel; /// <summary> /// If set, then the connection is currently being disposed. /// </summary> private bool _disposing; /// <summary> /// The default isolation level for new transactions | > > > > > > > | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | /// </summary> private string _connectionString; /// <summary> /// Nesting level of the transactions open on the connection /// </summary> internal int _transactionLevel; /// <summary> /// If this flag is non-zero, the <see cref="Dispose()" /> method will have /// no effect; however, the <see cref="Close" /> method will continue to /// behave as normal. /// </summary> internal bool _noDispose; /// <summary> /// If set, then the connection is currently being disposed. /// </summary> private bool _disposing; /// <summary> /// The default isolation level for new transactions |
︙ | ︙ | |||
603 604 605 606 607 608 609 610 611 612 613 614 615 616 | /// </param> /// <param name="parseViaFramework"> /// Non-zero to parse the connection string using the built-in (i.e. /// framework provided) parser when opening the connection. /// </param> public SQLiteConnection(string connectionString, bool parseViaFramework) { #if (SQLITE_STANDARD || USE_INTEROP_DLL || PLATFORM_COMPACTFRAMEWORK) && PRELOAD_NATIVE_LIBRARY UnsafeNativeMethods.Initialize(); #endif SQLiteLog.Initialize(); #if !PLATFORM_COMPACTFRAMEWORK && !INTEROP_LEGACY_CLOSE && SQLITE_STANDARD | > > | 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | /// </param> /// <param name="parseViaFramework"> /// Non-zero to parse the connection string using the built-in (i.e. /// framework provided) parser when opening the connection. /// </param> public SQLiteConnection(string connectionString, bool parseViaFramework) { _noDispose = false; #if (SQLITE_STANDARD || USE_INTEROP_DLL || PLATFORM_COMPACTFRAMEWORK) && PRELOAD_NATIVE_LIBRARY UnsafeNativeMethods.Initialize(); #endif SQLiteLog.Initialize(); #if !PLATFORM_COMPACTFRAMEWORK && !INTEROP_LEGACY_CLOSE && SQLITE_STANDARD |
︙ | ︙ | |||
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 | dateFormat, kind, dateTimeFormat, IntPtr.Zero, null, false); } } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteConnection).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// protected override void Dispose(bool disposing) { _disposing = true; try { if (!disposed) { //if (disposing) | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 | dateFormat, kind, dateTimeFormat, IntPtr.Zero, null, false); } } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable Members /// <summary> /// Disposes and finalizes the connection, if applicable. /// </summary> public new void Dispose() { if (_noDispose) return; base.Dispose(); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteConnection).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// protected override void Dispose(bool disposing) { #if !NET_COMPACT_20 && TRACE_WARNING if ((_flags & SQLiteConnectionFlags.TraceWarning) == SQLiteConnectionFlags.TraceWarning) { if (_noDispose) { System.Diagnostics.Trace.WriteLine(String.Format(CultureInfo.CurrentCulture, "WARNING: Disposing of connection \"{0}\" with the no-dispose flag set.", _connectionString)); } } #endif _disposing = true; try { if (!disposed) { //if (disposing) |
︙ | ︙ |
Added Tests/tkt-daeaf3150a.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 | ############################################################################### # # tkt-daeaf3150a.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-daeaf3150a-1.1 {static Execute connection disposal} -setup { unset -nocomplain result sql } -body { set sql(1) { \ CREATE TABLE t1(x); \ INSERT INTO t1 (x) VALUES (NULL); \ SELECT x FROM t1 ORDER BY x; \ } set sql(2) { \ CREATE TABLE t1(x); \ INSERT INTO t1 (x) VALUES (?); \ SELECT x FROM t1 ORDER BY x; \ } set result(1) [object invoke System.Data.SQLite.SQLiteCommand Execute \ "this will not execute" None null] set result(2) [object invoke System.Data.SQLite.SQLiteCommand Execute \ $sql(1) NonQuery null] set result(3) [object invoke System.Data.SQLite.SQLiteCommand Execute \ $sql(1) Scalar null] set result(4) [object invoke System.Data.SQLite.SQLiteCommand Execute \ $sql(1) Reader null] object invoke $result(4) Read; object invoke $result(4) Close set result(5) [object invoke System.Data.SQLite.SQLiteCommand Execute \ "this will not execute" None null 1] set result(6) [object invoke System.Data.SQLite.SQLiteCommand Execute \ $sql(2) NonQuery null 1] set result(7) [object invoke System.Data.SQLite.SQLiteCommand Execute \ $sql(2) Scalar null 1] set result(8) [object invoke System.Data.SQLite.SQLiteCommand Execute \ $sql(2) Reader null 1] list $result(1) $result(2) $result(3) $result(4) $result(5) $result(6) \ $result(7) $result(8) } -cleanup { unset -nocomplain result sql } -constraints {eagle monoBug28 SQLite System.Data.SQLite} -match regexp \ -result {^\{\} 1 System#DBNull#\d+ System#Data#SQLite#SQLiteDataReader#\d+ \{\}\ 1 1 System#Data#SQLite#SQLiteDataReader#\d+$}} ############################################################################### runSQLiteTestEpilogue runTestEpilogue |
Changes to readme.htm.
︙ | ︙ | |||
211 212 213 214 215 216 217 218 219 220 221 222 223 224 | <p> <b>1.0.95.0 - November XX, 2014 <font color="red">(release scheduled)</font></b> </p> <ul> <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_7.html">SQLite 3.8.7</a>.</li> <li>Make sure SQL statements generated for DbUpdateCommandTree objects are properly delimited.</li> <li>Various minor performance enhancements to the SQLiteDataReader class. Pursuant to [e122d26e70].</li> <li>In the SQLiteDataReader.VerifyType method, remove duplicate "if" statement for the DbType.SByte value and move the remaining "if" to the Int64 affinity. Fix for [c5cc2fb334]. <b>** Potentially Incompatible Change **</b></li> </ul> <p> <b>1.0.94.0 - September 9, 2014</b> </p> <ul> <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_6.html">SQLite 3.8.6</a>.</li> | > | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | <p> <b>1.0.95.0 - November XX, 2014 <font color="red">(release scheduled)</font></b> </p> <ul> <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_7.html">SQLite 3.8.7</a>.</li> <li>Make sure SQL statements generated for DbUpdateCommandTree objects are properly delimited.</li> <li>Various minor performance enhancements to the SQLiteDataReader class. Pursuant to [e122d26e70].</li> <li>Defer disposing of connections created by the static SQLiteCommand.Execute method when a data reader is returned. Fix for [daeaf3150a].</li> <li>In the SQLiteDataReader.VerifyType method, remove duplicate "if" statement for the DbType.SByte value and move the remaining "if" to the Int64 affinity. Fix for [c5cc2fb334]. <b>** Potentially Incompatible Change **</b></li> </ul> <p> <b>1.0.94.0 - September 9, 2014</b> </p> <ul> <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_6.html">SQLite 3.8.6</a>.</li> |
︙ | ︙ |
Changes to www/news.wiki.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <title>News</title> <b>Version History</b> <p> <b>1.0.95.0 - November XX, 2014 <font color="red">(release scheduled)</font></b> </p> <ul> <li>Updated to [http://www.sqlite.org/releaselog/3_8_7_1.html|SQLite 3.8.7.1].</li> <li>Make sure SQL statements generated for DbUpdateCommandTree objects are properly delimited.</li> <li>Various minor performance enhancements to the SQLiteDataReader class. Pursuant to [e122d26e70].</li> <li>In the SQLiteDataReader.VerifyType method, remove duplicate "if" statement for the DbType.SByte value and move the remaining "if" to the Int64 affinity. Fix for [c5cc2fb334]. <b>** Potentially Incompatible Change **</b></li> </ul> <p> <b>1.0.94.0 - September 9, 2014</b> </p> <ul> <li>Updated to [http://www.sqlite.org/releaselog/3_8_6.html|SQLite 3.8.6].</li> | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <title>News</title> <b>Version History</b> <p> <b>1.0.95.0 - November XX, 2014 <font color="red">(release scheduled)</font></b> </p> <ul> <li>Updated to [http://www.sqlite.org/releaselog/3_8_7_1.html|SQLite 3.8.7.1].</li> <li>Make sure SQL statements generated for DbUpdateCommandTree objects are properly delimited.</li> <li>Various minor performance enhancements to the SQLiteDataReader class. Pursuant to [e122d26e70].</li> <li>Defer disposing of connections created by the static SQLiteCommand.Execute method when a data reader is returned. Fix for [daeaf3150a].</li> <li>In the SQLiteDataReader.VerifyType method, remove duplicate "if" statement for the DbType.SByte value and move the remaining "if" to the Int64 affinity. Fix for [c5cc2fb334]. <b>** Potentially Incompatible Change **</b></li> </ul> <p> <b>1.0.94.0 - September 9, 2014</b> </p> <ul> <li>Updated to [http://www.sqlite.org/releaselog/3_8_6.html|SQLite 3.8.6].</li> |
︙ | ︙ |