System.Data.SQLite
Check-in [1164a207ef]
Not logged in

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

Overview
Comment:Add define constants to support enabling or disabling individual groups of trace statements. Remove superfluous cast from the call to the sqlite3_config_none P/Invoke method. Make sure to remove any stale database from previous stress test runs. Stop leaking callbacks from the stress test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1164a207efde84a490b3421418ff3a2f010ca360
User & Date: mistachkin 2012-07-16 04:58:20
Context
2012-07-19
20:46
Update SQLite core to the latest trunk code. Also, update Eagle script library in externals to the latest. check-in: 778ceac87b user: mistachkin tags: trunk
2012-07-16
04:58
Add define constants to support enabling or disabling individual groups of trace statements. Remove superfluous cast from the call to the sqlite3_config_none P/Invoke method. Make sure to remove any stale database from previous stress test runs. Stop leaking callbacks from the stress test. check-in: 1164a207ef user: mistachkin tags: trunk
2012-07-12
08:18
Small changes to the unit testing infrastructure integration to allow the common and vendor directories to be overridden. check-in: 51000d0070 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Doc/Extra/version.html.

49
50
51
52
53
54
55

56
57
58
59
60
61
62
      <li>The <a href="http://nuget.org/packages/System.Data.SQLite">primary NuGet package</a> now supports x86 / x64 and the .NET Framework 2.0 / 4.0 (i.e. in a single package).</li>
      <li>Fix the database cleanup ordering in the tests for ticket <a href="http://system.data.sqlite.org/index.html/info/343d392b51">[343d392b51]</a>.</li>
      <li>Add support for the sqlite3_close_v2 function from the SQLite core library.</li>
      <li>Add support for <a href="http://www.sqlite.org/uri.html">URI file names</a> via the new FullUri connection string property.</li>
      <li>Improve support for the standard SQLite core library in the LINQ assembly and the test suite.</li>
      <li>Add SetMemoryStatus static method to the SQLiteConnection class.</li>
      <li>Improve threaded handling of the delegate used by the SQLiteLog class.</li>

    </ul>
    <p><b>1.0.81.0 - May 27, 2012</b></p>
    <ul>
      <li>Updated to <a href="http://www.sqlite.org/releaselog/3_7_12_1.html">SQLite 3.7.12.1</a>.</li>
      <li>Support compiling the interop assembly without support for the custom extension functions and the CryptoAPI based codec.</li>
      <li>Add DefineConstants property to the SQLiteConnection class to return the list of define constants used when compiling the core managed assembly.</li>
      <li>Add release archive verification tool to the release automation.</li>







>







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
      <li>The <a href="http://nuget.org/packages/System.Data.SQLite">primary NuGet package</a> now supports x86 / x64 and the .NET Framework 2.0 / 4.0 (i.e. in a single package).</li>
      <li>Fix the database cleanup ordering in the tests for ticket <a href="http://system.data.sqlite.org/index.html/info/343d392b51">[343d392b51]</a>.</li>
      <li>Add support for the sqlite3_close_v2 function from the SQLite core library.</li>
      <li>Add support for <a href="http://www.sqlite.org/uri.html">URI file names</a> via the new FullUri connection string property.</li>
      <li>Improve support for the standard SQLite core library in the LINQ assembly and the test suite.</li>
      <li>Add SetMemoryStatus static method to the SQLiteConnection class.</li>
      <li>Improve threaded handling of the delegate used by the SQLiteLog class.</li>
      <li>Add define constants to support enabling or disabling individual groups of trace statements.</li>
    </ul>
    <p><b>1.0.81.0 - May 27, 2012</b></p>
    <ul>
      <li>Updated to <a href="http://www.sqlite.org/releaselog/3_7_12_1.html">SQLite 3.7.12.1</a>.</li>
      <li>Support compiling the interop assembly without support for the custom extension functions and the CryptoAPI based codec.</li>
      <li>Add DefineConstants property to the SQLiteConnection class to return the list of define constants used when compiling the core managed assembly.</li>
      <li>Add release archive verification tool to the release automation.</li>

Changes to SQLite.NET.Settings.targets.

163
164
165
166
167
168
169







































170
171
172
173
174
175
176
                  "SQLite.Interop\props\SQLite.Interop.20XX.[vs]props"

              both for the corresponding version(s) of Visual Studio.
    -->
    <InteropCodec Condition="'$(InteropCodec)' == ''">true</InteropCodec>
  </PropertyGroup>








































  <!--
  ******************************************************************************
  **                            Warning Properties                            **
  ******************************************************************************
  -->

  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







163
164
165
166
167
168
169
170
171
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
                  "SQLite.Interop\props\SQLite.Interop.20XX.[vs]props"

              both for the corresponding version(s) of Visual Studio.
    -->
    <InteropCodec Condition="'$(InteropCodec)' == ''">true</InteropCodec>
  </PropertyGroup>

  <!--
  ******************************************************************************
  **                             Trace Properties                             **
  ******************************************************************************
  -->

  <PropertyGroup>
    <!--
        NOTE: Enable tracing of events related to connection handling?  By
              default, this is disabled.
    -->
    <TraceConnection Condition="'$(TraceConnection)' == ''">false</TraceConnection>

    <!--
        NOTE: Enable tracing of events related to CriticalHandle handling?  By
              default, this is disabled.
    -->
    <TraceHandle Condition="'$(TraceHandle)' == ''">false</TraceHandle>

    <!--
        NOTE: Enable tracing of events related to the native library pre-loading
              code?  By default, this is enabled.
    -->
    <TracePreLoad Condition="'$(TracePreLoad)' == ''">true</TracePreLoad>

    <!--
        NOTE: Enable tracing of events related to the prepared statements?  By
              default, this is disabled.
    -->
    <TraceStatement Condition="'$(TraceStatement)' == ''">false</TraceStatement>

    <!--
        NOTE: Enable tracing of potentially important, but non-fatal error
              conditions that cannot be reported another way?  By default, this
              is enabled.
    -->
    <TraceWarning Condition="'$(TraceWarning)' == ''">true</TraceWarning>
  </PropertyGroup>

  <!--
  ******************************************************************************
  **                            Warning Properties                            **
  ******************************************************************************
  -->

  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">

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

5
6
7
8
9
10
11
12


13
14

15
16
17
18
19
20
21
...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
...
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
...
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
...
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
....
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Collections.Generic;
#if DEBUG


  using System.Diagnostics;
#endif

  using System.Runtime.InteropServices;
  using System.Text;

#if !PLATFORM_COMPACTFRAMEWORK
  [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
#endif
  internal delegate void SQLiteLogCallback(IntPtr puser, int err_code, IntPtr message);
................................................................................
      if (_sql != null)
      {
          if (_usePool)
          {
              SQLiteBase.ResetConnection(_sql, _sql);
              SQLiteConnectionPool.Add(_fileName, _sql, _poolVersion);

#if DEBUG && !NET_COMPACT_20
              Trace.WriteLine(String.Format("Close (Pool): {0}", _sql));
#endif
          }
          else
          {
              _sql.Dispose();
          }
................................................................................
      _usePool = usePool;
      _fileName = strFilename;

      if (usePool)
      {
        _sql = SQLiteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion);

#if DEBUG && !NET_COMPACT_20
        Trace.WriteLine(String.Format("Open (Pool): {0}", (_sql != null) ? _sql.ToString() : "<null>"));
#endif
      }

      if (_sql == null)
      {
        IntPtr db;
................................................................................

#if !SQLITE_STANDARD
        int n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), (int)openFlags, out db);
#else
        int n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), out db, (int)openFlags, IntPtr.Zero);
#endif

#if DEBUG && !NET_COMPACT_20
        Trace.WriteLine(String.Format("Open: {0}", db));
#endif

        if (n > 0) throw new SQLiteException(n, null);

        _sql = new SQLiteConnectionHandle(db);
        lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }
................................................................................
#if !SQLITE_STANDARD
          n = UnsafeNativeMethods.sqlite3_prepare_interop(_sql, psql, b.Length - 1, out stmt, out ptr, out len);
#else
          n = UnsafeNativeMethods.sqlite3_prepare(_sql, psql, b.Length - 1, out stmt, out ptr);
          len = -1;
#endif

#if DEBUG && !NET_COMPACT_20
          Trace.WriteLine(String.Format("Prepare: {0}", stmt));
#endif

          if (n == 17)
            retries++;
          else if (n == 1)
          {
................................................................................
                //
                // NOTE: This method [ab]uses the fact that SQLite will always
                //       return SQLITE_ERROR for any unknown configuration option
                //       *unless* the SQLite library has already been initialized.
                //       In that case it will always return SQLITE_MISUSE.
                //
                int rc = UnsafeNativeMethods.sqlite3_config_none(
                    (int)SQLiteConfigOpsEnum.SQLITE_CONFIG_NONE);

                return (rc == /* SQLITE_MISUSE */ 21);
#if !PLATFORM_COMPACTFRAMEWORK
            }
            finally
            {
                SQLiteLog.Enabled = savedEnabled;







<
>
>


>







 







|







 







|







 







|







 







|







 







|







5
6
7
8
9
10
11

12
13
14
15
16
17
18
19
20
21
22
23
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
...
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
...
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
...
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
....
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
  using System.Collections.Generic;


#if !NET_COMPACT_20 && (TRACE_CONNECTION || TRACE_STATEMENT)
  using System.Diagnostics;
#endif

  using System.Runtime.InteropServices;
  using System.Text;

#if !PLATFORM_COMPACTFRAMEWORK
  [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
#endif
  internal delegate void SQLiteLogCallback(IntPtr puser, int err_code, IntPtr message);
................................................................................
      if (_sql != null)
      {
          if (_usePool)
          {
              SQLiteBase.ResetConnection(_sql, _sql);
              SQLiteConnectionPool.Add(_fileName, _sql, _poolVersion);

#if !NET_COMPACT_20 && TRACE_CONNECTION
              Trace.WriteLine(String.Format("Close (Pool): {0}", _sql));
#endif
          }
          else
          {
              _sql.Dispose();
          }
................................................................................
      _usePool = usePool;
      _fileName = strFilename;

      if (usePool)
      {
        _sql = SQLiteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion);

#if !NET_COMPACT_20 && TRACE_CONNECTION
        Trace.WriteLine(String.Format("Open (Pool): {0}", (_sql != null) ? _sql.ToString() : "<null>"));
#endif
      }

      if (_sql == null)
      {
        IntPtr db;
................................................................................

#if !SQLITE_STANDARD
        int n = UnsafeNativeMethods.sqlite3_open_interop(ToUTF8(strFilename), (int)openFlags, out db);
#else
        int n = UnsafeNativeMethods.sqlite3_open_v2(ToUTF8(strFilename), out db, (int)openFlags, IntPtr.Zero);
#endif

#if !NET_COMPACT_20 && TRACE_CONNECTION
        Trace.WriteLine(String.Format("Open: {0}", db));
#endif

        if (n > 0) throw new SQLiteException(n, null);

        _sql = new SQLiteConnectionHandle(db);
        lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }
................................................................................
#if !SQLITE_STANDARD
          n = UnsafeNativeMethods.sqlite3_prepare_interop(_sql, psql, b.Length - 1, out stmt, out ptr, out len);
#else
          n = UnsafeNativeMethods.sqlite3_prepare(_sql, psql, b.Length - 1, out stmt, out ptr);
          len = -1;
#endif

#if !NET_COMPACT_20 && TRACE_STATEMENT
          Trace.WriteLine(String.Format("Prepare: {0}", stmt));
#endif

          if (n == 17)
            retries++;
          else if (n == 1)
          {
................................................................................
                //
                // NOTE: This method [ab]uses the fact that SQLite will always
                //       return SQLITE_ERROR for any unknown configuration option
                //       *unless* the SQLite library has already been initialized.
                //       In that case it will always return SQLITE_MISUSE.
                //
                int rc = UnsafeNativeMethods.sqlite3_config_none(
                    SQLiteConfigOpsEnum.SQLITE_CONFIG_NONE);

                return (rc == /* SQLITE_MISUSE */ 21);
#if !PLATFORM_COMPACTFRAMEWORK
            }
            finally
            {
                SQLiteLog.Enabled = savedEnabled;

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

4
5
6
7
8
9
10
11


12
13

14
15
16
17
18
19
20
..
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 * 
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
#if DEBUG


  using System.Diagnostics;
#endif

  using System.Runtime.InteropServices;

  /// <summary>
  /// Alternate SQLite3 object, overriding many text behaviors to support UTF-16 (Unicode)
  /// </summary>
  internal class SQLite3_UTF16 : SQLite3
  {
................................................................................
      _usePool = usePool;
      _fileName = strFilename;

      if (usePool)
      {
        _sql = SQLiteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion);

#if DEBUG && !NET_COMPACT_20
        Trace.WriteLine(String.Format("Open (Pool): {0}", (_sql != null) ? _sql.ToString() : "<null>"));
#endif
      }

      if (_sql == null)
      {
        IntPtr db;
................................................................................
#else
        if ((openFlags & SQLiteOpenFlagsEnum.Create) == 0 && System.IO.File.Exists(strFilename) == false)
          throw new SQLiteException((int)SQLiteErrorCode.CantOpen, strFilename);

        int n = UnsafeNativeMethods.sqlite3_open16(strFilename, out db);
#endif

#if DEBUG && !NET_COMPACT_20
        Trace.WriteLine(String.Format("Open: {0}", db));
#endif

        if (n > 0) throw new SQLiteException(n, null);

        _sql = new SQLiteConnectionHandle(db);
        lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }







<
>
>


>







 







|







 







|







4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
19
20
21
22
..
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
...
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
 * 
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;


#if !NET_COMPACT_20 && TRACE_CONNECTION
  using System.Diagnostics;
#endif

  using System.Runtime.InteropServices;

  /// <summary>
  /// Alternate SQLite3 object, overriding many text behaviors to support UTF-16 (Unicode)
  /// </summary>
  internal class SQLite3_UTF16 : SQLite3
  {
................................................................................
      _usePool = usePool;
      _fileName = strFilename;

      if (usePool)
      {
        _sql = SQLiteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion);

#if !NET_COMPACT_20 && TRACE_CONNECTION
        Trace.WriteLine(String.Format("Open (Pool): {0}", (_sql != null) ? _sql.ToString() : "<null>"));
#endif
      }

      if (_sql == null)
      {
        IntPtr db;
................................................................................
#else
        if ((openFlags & SQLiteOpenFlagsEnum.Create) == 0 && System.IO.File.Exists(strFilename) == false)
          throw new SQLiteException((int)SQLiteErrorCode.CantOpen, strFilename);

        int n = UnsafeNativeMethods.sqlite3_open16(strFilename, out db);
#endif

#if !NET_COMPACT_20 && TRACE_CONNECTION
        Trace.WriteLine(String.Format("Open: {0}", db));
#endif

        if (n > 0) throw new SQLiteException(n, null);

        _sql = new SQLiteConnectionHandle(db);
        lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }

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

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
...
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;

#if DEBUG
  using System.Diagnostics;
#endif

  using System.Runtime.InteropServices;
  using System.Collections.Generic;
  using System.Globalization;
  using System.Text;
................................................................................
      {
        if (_dbtypeNames[n].dataType == typ)
          return _dbtypeNames[n].typeName;
      }

      string defaultTypeName = String.Empty;

#if DEBUG && !NET_COMPACT_20
      Trace.WriteLine(String.Format(
          "WARNING: Type mapping failed, returning default name \"{0}\" for type {1}.",
          defaultTypeName, typ));
#endif

      return defaultTypeName;
    }
................................................................................
        {
          return value.dataType;
        }
      }

      DbType defaultDbType = DbType.Object;

#if DEBUG && !NET_COMPACT_20
      Trace.WriteLine(String.Format(
          "WARNING: Type mapping failed, returning default type {0} for name \"{1}\".",
          defaultDbType, Name));
#endif

      return defaultDbType;
    }







|







 







|







 







|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
...
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;

#if !NET_COMPACT_20 && TRACE_WARNING
  using System.Diagnostics;
#endif

  using System.Runtime.InteropServices;
  using System.Collections.Generic;
  using System.Globalization;
  using System.Text;
................................................................................
      {
        if (_dbtypeNames[n].dataType == typ)
          return _dbtypeNames[n].typeName;
      }

      string defaultTypeName = String.Empty;

#if !NET_COMPACT_20 && TRACE_WARNING
      Trace.WriteLine(String.Format(
          "WARNING: Type mapping failed, returning default name \"{0}\" for type {1}.",
          defaultTypeName, typ));
#endif

      return defaultTypeName;
    }
................................................................................
        {
          return value.dataType;
        }
      }

      DbType defaultDbType = DbType.Object;

#if !NET_COMPACT_20 && TRACE_WARNING
      Trace.WriteLine(String.Format(
          "WARNING: Type mapping failed, returning default type {0} for name \"{1}\".",
          defaultDbType, Name));
#endif

      return defaultDbType;
    }

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

55
56
57
58
59
60
61




















62
63
64
65
66
67
68
69
70
#if THROW_ON_DISPOSED
            "THROW_ON_DISPOSED",
#endif

#if TRACE
            "TRACE",
#endif





















#if USE_INTEROP_DLL
            "USE_INTEROP_DLL",
#endif

            null
        });
    }
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









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
#if THROW_ON_DISPOSED
            "THROW_ON_DISPOSED",
#endif

#if TRACE
            "TRACE",
#endif

#if TRACE_CONNECTION
            "TRACE_CONNECTION",
#endif

#if TRACE_HANDLE
            "TRACE_HANDLE",
#endif

#if TRACE_PRELOAD
            "TRACE_PRELOAD",
#endif

#if TRACE_STATEMENT
            "TRACE_STATEMENT",
#endif

#if TRACE_WARNING
            "TRACE_WARNING",
#endif

#if USE_INTEROP_DLL
            "USE_INTEROP_DLL",
#endif

            null
        });
    }
}

Changes to System.Data.SQLite/System.Data.SQLite.Properties.targets.

95
96
97
98
99
100
101

























102
  <!--
      NOTE: Enable support (in the managed assemblies) for encrypted databases
            using the CryptoAPI based codec?
  -->
  <PropertyGroup Condition="'$(InteropCodec)' != 'false'">
    <DefineConstants>$(DefineConstants);INTEROP_CODEC</DefineConstants>
  </PropertyGroup>

























</Project>







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

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
120
121
122
123
124
125
126
127
  <!--
      NOTE: Enable support (in the managed assemblies) for encrypted databases
            using the CryptoAPI based codec?
  -->
  <PropertyGroup Condition="'$(InteropCodec)' != 'false'">
    <DefineConstants>$(DefineConstants);INTEROP_CODEC</DefineConstants>
  </PropertyGroup>

  <!--
      NOTE: Enable various Trace.WriteLine statements included in the code,
            based on several criteria (see the "SQLite.NET.Settings.targets"
            file for more information).
  -->
  <PropertyGroup Condition="'$(TraceConnection)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_CONNECTION</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TraceHandle)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_HANDLE</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TracePreLoad)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_PRELOAD</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TraceStatement)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_STATEMENT</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(TraceWarning)' != 'false'">
    <DefineConstants>$(DefineConstants);TRACE_WARNING</DefineConstants>
  </PropertyGroup>
</Project>

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

4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
...
421
422
423
424
425
426
427

428
429
430

431
432
433
434
435
436
437
438

439



440

441
442
443
444
445
446
447
...
455
456
457
458
459
460
461

462
463
464
465
466
467
468
....
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
....
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
....
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
....
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
....
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
....
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
 * 
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;
#if PRELOAD_NATIVE_LIBRARY || DEBUG

  using System.Diagnostics;
#endif

#if PRELOAD_NATIVE_LIBRARY
  using System.Collections.Generic;
  using System.IO;
  using System.Reflection;
................................................................................

          try
          {
              //
              // NOTE: Show exactly where we are trying to load the native
              //       SQLite library from.
              //

              Trace.WriteLine(String.Format(
                  "Trying to load native SQLite library \"{0}\"...",
                  fileName));


              //
              // NOTE: Attempt to load the native library.  This will either
              //       return a valid native module handle, return IntPtr.Zero,
              //       or throw an exception.
              //
              return LoadLibrary(fileName);
          }

          catch (Exception e)



          {

              try
              {
                  //
                  // NOTE: First, grab the last Win32 error number.
                  //
                  int lastError = Marshal.GetLastWin32Error();

................................................................................
                      "(getLastError = {1}): {2}",
                      fileName, lastError, e)); /* throw */
              }
              catch
              {
                  // do nothing.
              }

          }

          return IntPtr.Zero;
      }
#endif
#endif
      #endregion
................................................................................
#if !PLATFORM_COMPACTFRAMEWORK
        IntPtr localHandle = Interlocked.Exchange(
          ref handle, IntPtr.Zero);

        if (localHandle != IntPtr.Zero)
          SQLiteBase.CloseConnection(this, localHandle);

#if DEBUG && !NET_COMPACT_20
        try
        {
          Trace.WriteLine(String.Format(
              "CloseConnection: {0}", localHandle));
        }
        catch
        {
................................................................................
        }
#endif

#if DEBUG
        return true;
#endif
      }
#if DEBUG && !NET_COMPACT_20
      catch (SQLiteException e)
#else
      catch (SQLiteException)
#endif
      {
#if DEBUG && !NET_COMPACT_20
        try
        {
          Trace.WriteLine(String.Format(
              "CloseConnection: {0}, exception: {1}",
              handle, e));
        }
        catch
................................................................................
#if !PLATFORM_COMPACTFRAMEWORK
        IntPtr localHandle = Interlocked.Exchange(
          ref handle, IntPtr.Zero);

        if (localHandle != IntPtr.Zero)
          SQLiteBase.FinalizeStatement(cnn, localHandle);

#if DEBUG && !NET_COMPACT_20
        try
        {
          Trace.WriteLine(String.Format(
              "FinalizeStatement: {0}", localHandle));
        }
        catch
        {
................................................................................
        }
#endif

#if DEBUG
        return true;
#endif
      }
#if DEBUG && !NET_COMPACT_20
      catch (SQLiteException e)
#else
      catch (SQLiteException)
#endif
      {
#if DEBUG && !NET_COMPACT_20
        try
        {
          Trace.WriteLine(String.Format(
              "FinalizeStatement: {0}, exception: {1}",
              handle, e));
        }
        catch
................................................................................
#if !PLATFORM_COMPACTFRAMEWORK
              IntPtr localHandle = Interlocked.Exchange(
                  ref handle, IntPtr.Zero);

              if (localHandle != IntPtr.Zero)
                  SQLiteBase.FinishBackup(cnn, localHandle);

#if DEBUG && !NET_COMPACT_20
              try
              {
                  Trace.WriteLine(String.Format(
                      "FinishBackup: {0}", localHandle));
              }
              catch
              {
................................................................................
              }
#endif

#if DEBUG
              return true;
#endif
          }
#if DEBUG && !NET_COMPACT_20
          catch (SQLiteException e)
#else
          catch (SQLiteException)
#endif
          {
#if DEBUG && !NET_COMPACT_20
              try
              {
                  Trace.WriteLine(String.Format(
                      "FinishBackup: {0}, exception: {1}",
                      handle, e));
              }
              catch







|
>







 







>



>








>

>
>
>

>







 







>







 







|







 







|





|







 







|







 







|





|







 







|







 







|





|







4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
...
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
....
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
....
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
....
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
....
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
....
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
....
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
 * 
 * Released to the public domain, use at your own risk!
 ********************************************************/

namespace System.Data.SQLite
{
  using System;

#if !NET_COMPACT_20 && (TRACE_PRELOAD || TRACE_HANDLE)
  using System.Diagnostics;
#endif

#if PRELOAD_NATIVE_LIBRARY
  using System.Collections.Generic;
  using System.IO;
  using System.Reflection;
................................................................................

          try
          {
              //
              // NOTE: Show exactly where we are trying to load the native
              //       SQLite library from.
              //
#if !NET_COMPACT_20 && TRACE_PRELOAD
              Trace.WriteLine(String.Format(
                  "Trying to load native SQLite library \"{0}\"...",
                  fileName));
#endif

              //
              // NOTE: Attempt to load the native library.  This will either
              //       return a valid native module handle, return IntPtr.Zero,
              //       or throw an exception.
              //
              return LoadLibrary(fileName);
          }
#if !NET_COMPACT_20 && TRACE_PRELOAD
          catch (Exception e)
#else
          catch (Exception)
#endif
          {
#if !NET_COMPACT_20 && TRACE_PRELOAD
              try
              {
                  //
                  // NOTE: First, grab the last Win32 error number.
                  //
                  int lastError = Marshal.GetLastWin32Error();

................................................................................
                      "(getLastError = {1}): {2}",
                      fileName, lastError, e)); /* throw */
              }
              catch
              {
                  // do nothing.
              }
#endif
          }

          return IntPtr.Zero;
      }
#endif
#endif
      #endregion
................................................................................
#if !PLATFORM_COMPACTFRAMEWORK
        IntPtr localHandle = Interlocked.Exchange(
          ref handle, IntPtr.Zero);

        if (localHandle != IntPtr.Zero)
          SQLiteBase.CloseConnection(this, localHandle);

#if !NET_COMPACT_20 && TRACE_HANDLE
        try
        {
          Trace.WriteLine(String.Format(
              "CloseConnection: {0}", localHandle));
        }
        catch
        {
................................................................................
        }
#endif

#if DEBUG
        return true;
#endif
      }
#if !NET_COMPACT_20 && TRACE_HANDLE
      catch (SQLiteException e)
#else
      catch (SQLiteException)
#endif
      {
#if !NET_COMPACT_20 && TRACE_HANDLE
        try
        {
          Trace.WriteLine(String.Format(
              "CloseConnection: {0}, exception: {1}",
              handle, e));
        }
        catch
................................................................................
#if !PLATFORM_COMPACTFRAMEWORK
        IntPtr localHandle = Interlocked.Exchange(
          ref handle, IntPtr.Zero);

        if (localHandle != IntPtr.Zero)
          SQLiteBase.FinalizeStatement(cnn, localHandle);

#if !NET_COMPACT_20 && TRACE_HANDLE
        try
        {
          Trace.WriteLine(String.Format(
              "FinalizeStatement: {0}", localHandle));
        }
        catch
        {
................................................................................
        }
#endif

#if DEBUG
        return true;
#endif
      }
#if !NET_COMPACT_20 && TRACE_HANDLE
      catch (SQLiteException e)
#else
      catch (SQLiteException)
#endif
      {
#if !NET_COMPACT_20 && TRACE_HANDLE
        try
        {
          Trace.WriteLine(String.Format(
              "FinalizeStatement: {0}, exception: {1}",
              handle, e));
        }
        catch
................................................................................
#if !PLATFORM_COMPACTFRAMEWORK
              IntPtr localHandle = Interlocked.Exchange(
                  ref handle, IntPtr.Zero);

              if (localHandle != IntPtr.Zero)
                  SQLiteBase.FinishBackup(cnn, localHandle);

#if !NET_COMPACT_20 && TRACE_HANDLE
              try
              {
                  Trace.WriteLine(String.Format(
                      "FinishBackup: {0}", localHandle));
              }
              catch
              {
................................................................................
              }
#endif

#if DEBUG
              return true;
#endif
          }
#if !NET_COMPACT_20 && TRACE_HANDLE
          catch (SQLiteException e)
#else
          catch (SQLiteException)
#endif
          {
#if !NET_COMPACT_20 && TRACE_HANDLE
              try
              {
                  Trace.WriteLine(String.Format(
                      "FinishBackup: {0}, exception: {1}",
                      handle, e));
              }
              catch

Changes to Tests/stress.eagle.

17
18
19
20
21
22
23





24
25
26
27
28
29
30
..
71
72
73
74
75
76
77







78
79
80
81
82
83
84
...
476
477
478
479
480
481
482







483
484
485
486
487
488
489
490
491
492

package require System.Data.SQLite.Test
runSQLiteTestPrologue

###############################################################################

runTest {test stress-1.1 {multithreaded stress testing} -setup {





  proc expectedError { error } {
    return [expr {[regexp -- {\sno such table: t1\s} $error] || \
        [regexp -- {\sdatabase is locked\s} $error]}]
  }

  #############################################################################

................................................................................
  set compiled(12) ""
  set compiled(13) ""

  #############################################################################

  set fileName(1) "file::memory:?cache=shared"
  set fileName(2) [file join [getDatabaseDirectory] stress.db]








  #############################################################################

  setupDb $fileName(1) "" "" "" "" "" false true srcDb
  setupDb $fileName(2)

  #############################################################################
................................................................................
} -cleanup {
  rename failTest ""
  rename showTest ""
  rename expectedError ""

  cleanupDb $fileName(2)
  cleanupDb $fileName(1) srcDb








  unset -nocomplain thread index workload srcDb db fileName compiled options \
      count
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result {}}

###############################################################################

runSQLiteTestEpilogue
runTestEpilogue







>
>
>
>
>







 







>
>
>
>
>
>
>







 







>
>
>
>
>
>
>










17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
...
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511

package require System.Data.SQLite.Test
runSQLiteTestPrologue

###############################################################################

runTest {test stress-1.1 {multithreaded stress testing} -setup {
  unset -nocomplain thread index workload srcDb db fileName compiled options \
      count

  #############################################################################

  proc expectedError { error } {
    return [expr {[regexp -- {\sno such table: t1\s} $error] || \
        [regexp -- {\sdatabase is locked\s} $error]}]
  }

  #############################################################################

................................................................................
  set compiled(12) ""
  set compiled(13) ""

  #############################################################################

  set fileName(1) "file::memory:?cache=shared"
  set fileName(2) [file join [getDatabaseDirectory] stress.db]

  #############################################################################

  #
  # NOTE: Make sure to remove any stale database from previous test runs.
  #
  cleanupFile $fileName(2)

  #############################################################################

  setupDb $fileName(1) "" "" "" "" "" false true srcDb
  setupDb $fileName(2)

  #############################################################################
................................................................................
} -cleanup {
  rename failTest ""
  rename showTest ""
  rename expectedError ""

  cleanupDb $fileName(2)
  cleanupDb $fileName(1) srcDb

  foreach index(2) [array names workload] {
    catch {
      object removecallback [list apply $workload($index(2)) $fileName(1) \
          $fileName(2) t1 $count(1)]
    }
  }

  unset -nocomplain thread index workload srcDb db fileName compiled options \
      count
} -constraints \
{eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -result {}}

###############################################################################

runSQLiteTestEpilogue
runTestEpilogue

Changes to readme.htm.

194
195
196
197
198
199
200

201
202
203
204
205
206
207
    <li>The <a href="http://nuget.org/packages/System.Data.SQLite">primary NuGet package</a> now supports x86 / x64 and the .NET Framework 2.0 / 4.0 (i.e. in a single package).</li>
    <li>Fix the database cleanup ordering in the tests for ticket [343d392b51].</li>
    <li>Add support for the sqlite3_close_v2 function from the SQLite core library.</li>
    <li>Add support for <a href="http://www.sqlite.org/uri.html">URI file names</a> via the new FullUri connection string property.</li>
    <li>Improve support for the standard SQLite core library in the LINQ assembly and the test suite.</li>
    <li>Add SetMemoryStatus static method to the SQLiteConnection class.</li>
    <li>Improve threaded handling of the delegate used by the SQLiteLog class.</li>

</ul>
<p>
    <b>1.0.81.0 - May 27, 2012</b>
</p>
<ul>
    <li>Updated to <a href="http://www.sqlite.org/releaselog/3_7_12_1.html">SQLite 3.7.12.1</a>.</li>
    <li>Support compiling the interop assembly without support for the custom extension functions and the CryptoAPI based codec.</li>







>







194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
    <li>The <a href="http://nuget.org/packages/System.Data.SQLite">primary NuGet package</a> now supports x86 / x64 and the .NET Framework 2.0 / 4.0 (i.e. in a single package).</li>
    <li>Fix the database cleanup ordering in the tests for ticket [343d392b51].</li>
    <li>Add support for the sqlite3_close_v2 function from the SQLite core library.</li>
    <li>Add support for <a href="http://www.sqlite.org/uri.html">URI file names</a> via the new FullUri connection string property.</li>
    <li>Improve support for the standard SQLite core library in the LINQ assembly and the test suite.</li>
    <li>Add SetMemoryStatus static method to the SQLiteConnection class.</li>
    <li>Improve threaded handling of the delegate used by the SQLiteLog class.</li>
    <li>Add define constants to support enabling or disabling individual groups of trace statements.</li>
</ul>
<p>
    <b>1.0.81.0 - May 27, 2012</b>
</p>
<ul>
    <li>Updated to <a href="http://www.sqlite.org/releaselog/3_7_12_1.html">SQLite 3.7.12.1</a>.</li>
    <li>Support compiling the interop assembly without support for the custom extension functions and the CryptoAPI based codec.</li>

Changes to www/news.wiki.

10
11
12
13
14
15
16

17
18
19
20
21
22
23
    <li>The [http://nuget.org/packages/System.Data.SQLite|primary NuGet package] now supports x86 / x64 and the .NET Framework 2.0 / 4.0 (i.e. in a single package).</li>
    <li>Fix the database cleanup ordering in the tests for ticket [343d392b51].</li>
    <li>Add support for the sqlite3_close_v2 function from the SQLite core library.</li>
    <li>Add support for [http://www.sqlite.org/uri.html|URI file names] via the new FullUri connection string property.</li>
    <li>Improve support for the standard SQLite core library in the LINQ assembly and the test suite.</li>
    <li>Add SetMemoryStatus static method to the SQLiteConnection class.</li>
    <li>Improve threaded handling of the delegate used by the SQLiteLog class.</li>

</ul>
<p>
    <b>1.0.81.0 - May 27, 2012</b>
</p>
<ul>
    <li>Updated to [http://www.sqlite.org/releaselog/3_7_12_1.html|SQLite 3.7.12.1].</li>
    <li>Support compiling the interop assembly without support for the custom extension functions and the CryptoAPI based codec.</li>







>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    <li>The [http://nuget.org/packages/System.Data.SQLite|primary NuGet package] now supports x86 / x64 and the .NET Framework 2.0 / 4.0 (i.e. in a single package).</li>
    <li>Fix the database cleanup ordering in the tests for ticket [343d392b51].</li>
    <li>Add support for the sqlite3_close_v2 function from the SQLite core library.</li>
    <li>Add support for [http://www.sqlite.org/uri.html|URI file names] via the new FullUri connection string property.</li>
    <li>Improve support for the standard SQLite core library in the LINQ assembly and the test suite.</li>
    <li>Add SetMemoryStatus static method to the SQLiteConnection class.</li>
    <li>Improve threaded handling of the delegate used by the SQLiteLog class.</li>
    <li>Add define constants to support enabling or disabling individual groups of trace statements.</li>
</ul>
<p>
    <b>1.0.81.0 - May 27, 2012</b>
</p>
<ul>
    <li>Updated to [http://www.sqlite.org/releaselog/3_7_12_1.html|SQLite 3.7.12.1].</li>
    <li>Support compiling the interop assembly without support for the custom extension functions and the CryptoAPI based codec.</li>