System.Data.SQLite

Login
This project makes use of Eagle, provided by Mistachkin Systems.
Eagle: Secure Software Automation

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch tkt-56b42d99c1 Excluding Merge-Ins

This is equivalent to a diff from 29f80bd37b to fb303dde33

2013-12-20
17:02
Use the current isolation level when enlisting into an existing transaction. Fix for [56b42d99c1]. check-in: f89efea9e9 user: mistachkin tags: trunk
2013-12-19
13:14
Merge updates from trunk. Closed-Leaf check-in: fb303dde33 user: mistachkin tags: tkt-56b42d99c1
13:13
Update version history docs. check-in: 619ae93189 user: mistachkin tags: tkt-56b42d99c1
13:11
Update version history docs. check-in: 29f80bd37b user: mistachkin tags: trunk
13:01
Do not use the 16-bit 'short' type to keep track of numeric precision or scale when building the schema table for a query. Fix for [ef2216192d]. check-in: c07cca890b user: mistachkin tags: trunk

Changes to Doc/Extra/version.html.

50
51
52
53
54
55
56

57
58
59
60
61
62
63
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64







+







      <li>Add Visual Studio 2013 support to the redesigned designer support installer.</li>
      <li>Add support for Windows Embedded Compact 2013.</li>
      <li>Add experimental support for the native regexp extension.</li>
      <li>Never create a new connection wrapper in the SQLiteConnection.Shutdown method.&nbsp;<b>** Potentially Incompatible Change **</b></li>
      <li>Add experimental GetMemoryStatistics, ReleaseMemory, and Shutdown methods to the SQLiteConnection class.</li>
      <li>Add memory leak detection to the test project for the .NET Compact Framework.</li>
      <li>Add SQLITE_ENABLE_MEMORY_MANAGEMENT compile-time option to the interop assembly.</li>
      <li>Use current isolation level when enlisting into an existing transaction. Fix for <a href="http://system.data.sqlite.org/index.html/info/56b42d99c1">[56b42d99c1]</a>.</li>
      <li>Better handling of non-error log messages from the SQLite core library. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/44df10ea90">[44df10ea90]</a>.</li>
      <li>Add TraceWarning connection flag to enable tracing of type mapping failures and disable tracing of them by default. Pursuant to <a href="http://system.data.sqlite.org/index.html/info/6d45c782e4">[6d45c782e4]</a>.</li>
      <li>Use 32-bit values to keep track of numeric precision and scale when building the schema table for a query. Fix for <a href="http://system.data.sqlite.org/index.html/info/ef2216192d">[ef2216192d]</a>.</li>
    </ul>
    <p><b>1.0.89.0 - October 28, 2013</b></p>
    <ul>
      <li>Updated to <a href="http://www.sqlite.org/releaselog/3_8_1.html">SQLite 3.8.1</a>.</li>

Changes to System.Data.SQLite/SQLiteConnection.cs.

1104
1105
1106
1107
1108
1109
1110



























1111
1112
1113
1114
1115
1116
1117
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







                new StateChangeEventArgs(oldState, newState);

            StateChange(this, localEventArgs);

            eventArgs = localEventArgs;
        }
    }

#if !PLATFORM_COMPACTFRAMEWORK
    /// <summary>
    /// Determines and returns the fallback default isolation level when one cannot be
    /// obtained from an existing connection instance.
    /// </summary>
    /// <returns>
    /// The fallback default isolation level for this connection instance -OR-
    /// <see cref="IsolationLevel.Unspecified" /> if it cannot be determined.
    /// </returns>
    internal static IsolationLevel GetFallbackDefaultIsolationLevel()
    {
        return DefaultIsolationLevel;
    }

    /// <summary>
    /// Determines and returns the default isolation level for this connection instance.
    /// </summary>
    /// <returns>
    /// The default isolation level for this connection instance -OR-
    /// <see cref="IsolationLevel.Unspecified" /> if it cannot be determined.
    /// </returns>
    internal IsolationLevel GetDefaultIsolationLevel()
    {
        return _defaultIsolation;
    }
#endif

    /// <summary>
    /// OBSOLETE.  Creates a new SQLiteTransaction if one isn't already active on the connection.
    /// </summary>
    /// <param name="isolationLevel">This parameter is ignored.</param>
    /// <param name="deferredLock">When TRUE, SQLite defers obtaining a write lock until a write operation is requested.
    /// When FALSE, a writelock is obtained immediately.  The default is TRUE, but in a multi-threaded multi-writer

Changes to System.Data.SQLite/SQLiteEnlistment.cs.

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
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
110
111

112
113
114
115
116
117
118
119












-
+







-
+
+
+





-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+









-
+











-
+







/********************************************************
 * 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 : IEnlistmentNotification, IDisposable
  internal sealed class SQLiteEnlistment : IDisposable, IEnlistmentNotification
  {
    internal SQLiteTransaction _transaction;
    internal Transaction _scope;
    internal bool _disposeConnection;

    internal SQLiteEnlistment(SQLiteConnection cnn, Transaction scope)
    {
      _transaction = cnn.BeginTransaction();
      _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
        )
    {
        if (transaction == null)
        {
            //
            // TODO: Perhaps throw an exception here if the connection
            //       is null?
            //
            return (connection != null) ?
                connection.GetDefaultIsolationLevel() :
                SQLiteConnection.GetFallbackDefaultIsolationLevel();
        }

        System.Transactions.IsolationLevel isolationLevel =
            transaction.IsolationLevel;

        //
        // TODO: Are these isolation level mappings actually correct?
        //
        switch (isolationLevel)
        {
            case IsolationLevel.Chaos:
                return System.Data.IsolationLevel.Chaos;
            case IsolationLevel.ReadCommitted:
                return System.Data.IsolationLevel.ReadCommitted;
            case IsolationLevel.ReadUncommitted:
                return System.Data.IsolationLevel.ReadUncommitted;
            case IsolationLevel.RepeatableRead:
                return System.Data.IsolationLevel.RepeatableRead;
            case IsolationLevel.Serializable:
                return System.Data.IsolationLevel.Serializable;
            case IsolationLevel.Snapshot:
                return System.Data.IsolationLevel.Snapshot;
            case IsolationLevel.Unspecified:
                return System.Data.IsolationLevel.Unspecified;
        }

        //
        // 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)
            {
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
139
140
141
142
143
144
145

146
147
148
149
150
151
152
153
154

155
156









157

158
159
160
161
162
163
164







-
+








-
+

-
-
-
-
-
-
-
-
-

-







            //////////////////////////////////////

            disposed = true;
        }
    }
    #endregion

    ///////////////////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////

    #region Destructor
    ~SQLiteEnlistment()
    {
        Dispose(false);
    }
    #endregion

    ///////////////////////////////////////////////////////////////////////////////////////////////
    ///////////////////////////////////////////////////////////////////////////

    private void Cleanup(SQLiteConnection cnn)
    {
      if (_disposeConnection)
        cnn.Dispose();

      _transaction = null;
      _scope = null;
    }

    #region IEnlistmentNotification Members

    public void Commit(Enlistment enlistment)
    {
      CheckDisposed();

      SQLiteConnection cnn = _transaction.Connection;
      cnn._enlistment = null;

119
120
121
122
123
124
125


126
127
128
129
130


131
132
133
134
135
136
137
138
139
140


141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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
207
208
209
210
211
212
213
214
215
216
217

218
219
220
221







+
+





+
+










+
+


















-




      }
      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;

      try
      {
        _transaction.Rollback();
        enlistment.Done();
      }
      finally
      {
        Cleanup(cnn);
      }
    }

    #endregion
  }
}
#endif // !PLATFORM_COMPACT_FRAMEWORK

Changes to Tests/common.eagle.

1263
1264
1265
1266
1267
1268
1269

1270
1271



1272
1273
1274
1275
1276
1277
1278
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 \
      set command [list compileCSharp $text $memory $symbols $strict results \
          errors $add System.dll $add System.Data.dll $add System.Xml.dll]
          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

Changes to readme.htm.

195
196
197
198
199
200
201

202
203
204
205
206
207
208
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209







+







    <li>Add Visual Studio 2013 support to the redesigned designer support installer.</li>
    <li>Add support for Windows Embedded Compact 2013.</li>
    <li>Add experimental support for the native regexp extension.</li>
    <li>Never create a new connection wrapper in the SQLiteConnection.Shutdown method.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add experimental GetMemoryStatistics, ReleaseMemory, and Shutdown methods to the SQLiteConnection class.</li>
    <li>Add memory leak detection to the test project for the .NET Compact Framework.</li>
    <li>Add SQLITE_ENABLE_MEMORY_MANAGEMENT compile-time option to the interop assembly.</li>
    <li>Use current isolation level when enlisting into an existing transaction. Fix for [56b42d99c1].</li>
    <li>Better handling of non-error log messages from the SQLite core library. Pursuant to [44df10ea90].</li>
    <li>Add TraceWarning connection flag to enable tracing of type mapping failures and disable tracing of them by default. Pursuant to [6d45c782e4].</li>
    <li>Use 32-bit values to keep track of numeric precision and scale when building the schema table for a query. Fix for [ef2216192d].</li>
</ul>
<p>
    <b>1.0.89.0 - October 28, 2013</b>
</p>

Changes to www/news.wiki.

11
12
13
14
15
16
17

18
19
20
21
22
23
24
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25







+







    <li>Add Visual Studio 2013 support to the redesigned designer support installer.</li>
    <li>Add support for Windows Embedded Compact 2013.</li>
    <li>Add experimental support for the native regexp extension.</li>
    <li>Never create a new connection wrapper in the SQLiteConnection.Shutdown method.&nbsp;<b>** Potentially Incompatible Change **</b></li>
    <li>Add experimental GetMemoryStatistics, ReleaseMemory, and Shutdown methods to the SQLiteConnection class.</li>
    <li>Add memory leak detection to the test project for the .NET Compact Framework.</li>
    <li>Add SQLITE_ENABLE_MEMORY_MANAGEMENT compile-time option to the interop assembly.</li>
    <li>Use current isolation level when enlisting into an existing transaction. Fix for [56b42d99c1].</li>
    <li>Better handling of non-error log messages from the SQLite core library. Pursuant to [44df10ea90].</li>
    <li>Add TraceWarning connection flag to enable tracing of type mapping failures and disable tracing of them by default. Pursuant to [6d45c782e4].</li>
    <li>Use 32-bit values to keep track of numeric precision and scale when building the schema table for a query. Fix for [ef2216192d].</li>
</ul>
<p>
    <b>1.0.89.0 - October 28, 2013</b>
</p>