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 bug-ccfa69fc32 Excluding Merge-Ins

This is equivalent to a diff from 7ef5b80330 to bba06f3a9f

2011-09-12
20:43
Merge fix for ticket [ccfa69fc32] to trunk. check-in: 14a6302a28 user: mistachkin tags: trunk
19:34
Streamline the test case for ticket [ccfa69fc32] and make it more complete by not relying on sort ordering of the IDs. Closed-Leaf check-in: bba06f3a9f user: mistachkin tags: bug-ccfa69fc32
2011-09-11
17:43
Use an overload of the ObjectContext.SaveChanges method that does not require the SaveOptions enumerated type when not compiled against the .NET Framework 4.0. check-in: 34ca66ddcf user: mistachkin tags: bug-ccfa69fc32
14:33
Experimental fix for ticket [ccfa69fc32]. check-in: 42af4d17a5 user: mistachkin tags: bug-ccfa69fc32
13:14
Fix debug builds of the native interop assembly by making sure that SQLITE_WIN32_MALLOC is not defined with SQLITE_MEMDEBUG (i.e. they are mutually exclusive at compile-time). check-in: 7ef5b80330 user: mistachkin tags: trunk
2011-09-07
10:31
Support LINQ queries with EndsWith method, fix for [59edc1018b]. Add test to verify the behavior from ticket [00f86f9739]. Modify test results/handling for ticket [8b7d179c3c] to be consistent with these new tests. check-in: 7810393e98 user: mistachkin tags: trunk

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

723
724
725
726
727
728
729
730
731
732
733
734
735
736
737





738
739
740
741
742
743
744
#if !PLATFORM_COMPACTFRAMEWORK
    /// <summary>
    /// Manual distributed transaction enlistment support
    /// </summary>
    /// <param name="transaction">The distributed transaction to enlist in</param>
    public override void EnlistTransaction(System.Transactions.Transaction transaction)
    {
      if (_transactionLevel > 0 && transaction != null)
        throw new ArgumentException("Unable to enlist in transaction, a local transaction already exists");

      if (_enlistment != null && transaction == _enlistment._scope)
        return;
      else if (_enlistment != null)
        throw new ArgumentException("Already enlisted in a transaction");






      _enlistment = new SQLiteEnlistment(this, transaction);
    }
#endif

    /// <summary>
    /// Looks for a key in the array of key/values of the parameter string.  If not found, return the specified default value
    /// </summary>







<
<
<





>
>
>
>
>







723
724
725
726
727
728
729



730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
#if !PLATFORM_COMPACTFRAMEWORK
    /// <summary>
    /// Manual distributed transaction enlistment support
    /// </summary>
    /// <param name="transaction">The distributed transaction to enlist in</param>
    public override void EnlistTransaction(System.Transactions.Transaction transaction)
    {



      if (_enlistment != null && transaction == _enlistment._scope)
        return;
      else if (_enlistment != null)
        throw new ArgumentException("Already enlisted in a transaction");

      if (_transactionLevel > 0 && transaction != null)
        throw new ArgumentException("Unable to enlist in transaction, a local transaction already exists");
      else if (transaction == null)
        throw new ArgumentNullException("Unable to enlist in transaction, it is null");

      _enlistment = new SQLiteEnlistment(this, transaction);
    }
#endif

    /// <summary>
    /// Looks for a key in the array of key/values of the parameter string.  If not found, return the specified default value
    /// </summary>

Added Tests/tkt-ccfa69fc32.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
###############################################################################
#
# tkt-ccfa69fc32.eagle --
#
# Written by Joe Mistachkin.
# Released to the public domain, use at your own risk!
#
###############################################################################

package require Eagle
package require EagleLibrary
package require EagleTest

runTestPrologue

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

source [file join $path common.eagle]
runSQLiteTestPrologue

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

#
# NOTE: Setup the variables that refer to the various files required by the
#       tests in this file.
#
set testLinqExeFile [getBuildFileName testlinq.exe]
set northwindEfDbFile [file nativename [file join [file dirname $path] \
    testlinq northwindEF.db]]

#
# NOTE: Setup the test constraints specific to the tests in this file.
#
if {![haveConstraint file_[file tail $testLinqExeFile]]} then {
  checkForFile $test_channel $testLinqExeFile
}

if {![haveConstraint file_[file tail $northwindEfDbFile]]} then {
  checkForFile $test_channel $northwindEfDbFile
}

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

runTest {test tkt-ccfa69fc32-1.1 {Entity Framework / Transaction Scope} -body {
  set result [list]

  foreach add [list false true false] {
    set code [catch {
      testExec $testLinqExeFile [list -eventflags Wait -directory \
      [file dirname $testLinqExeFile] -nocarriagereturns -stdout output \
      -success 0] -efTransaction $add
    } error]

    tlog "---- BEGIN STDOUT OUTPUT\n"
    tlog $output
    tlog "\n---- END STDOUT OUTPUT\n"

    lappend result $code

    if {$code == 0} then {
      lappend result [string trim $output]
    } else {
      lappend result [string trim $error]
    }
  }

  set result
} -cleanup {
  unset -nocomplain code output error result add
} -constraints {eagle file_testlinq.exe file_northwindEF.db} -match glob \
-result {0 {1581 1730 1833 2116 2139} 0 {System.Data.UpdateException: * --->\
System.Data.SQLite.SQLiteException: Abort due to constraint violation
PRIMARY KEY must be unique
*} 0 {1 2 3 4 5 6 7 8 9 10 1576 1577 1578 1579 1580 1581 1730 1833 2116 2139}}}

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

unset -nocomplain testLinqExeFile northwindEfDbFile

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

runSQLiteTestEpilogue
runTestEpilogue

Changes to testlinq/Program.cs.

1
2
3
4
5

6
7
8
9
10
11
12
using System;
using System.Diagnostics;
using System.Linq;
using System.Data.Objects;
using System.Text;


namespace testlinq
{
  class Program
  {
      private static int Main(string[] args)
      {





>







1
2
3
4
5
6
7
8
9
10
11
12
13
using System;
using System.Diagnostics;
using System.Linq;
using System.Data.Objects;
using System.Text;
using System.Transactions;

namespace testlinq
{
  class Program
  {
      private static int Main(string[] args)
      {
83
84
85
86
87
88
89


















90
91
92
93
94
95
96

                          if (value != null)
                              value = value.Trim();
                      }

                      return StartsWithTest(value);
                  }


















              default:
                  {
                      Console.WriteLine("unknown test \"{0}\"", arg);
                      return 1;
                  }
          }
      }







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







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

                          if (value != null)
                              value = value.Trim();
                      }

                      return StartsWithTest(value);
                  }
              case "eftransaction":
                  {
                      bool value = false;

                      if (args.Length > 1)
                      {
                          if (!bool.TryParse(args[1], out value))
                          {
                              Console.WriteLine(
                                  "cannot parse \"{0}\" as boolean",
                                  args[1]);

                              return 1;
                          }
                      }

                      return EFTransactionTest(value);
                  }
              default:
                  {
                      Console.WriteLine("unknown test \"{0}\"", arg);
                      return 1;
                  }
          }
      }
174
175
176
177
178
179
180


























































































181
182
183
184
185
186
187
                      Console.Write(' ');

                  Console.Write(customers.CustomerID);

                  once = true;
              }
          }



























































































          return 0;
      }

    private static int OldTests()
    {
      using (northwindEFEntities db = new northwindEFEntities())







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







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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
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
294
295
296
                      Console.Write(' ');

                  Console.Write(customers.CustomerID);

                  once = true;
              }
          }

          return 0;
      }

      //
      // NOTE: Used to test the fix for ticket [ccfa69fc32].
      //
      private static int EFTransactionTest(bool add)
      {
          //
          // NOTE: Some of these territories already exist and should cause
          //       an exception to be thrown when we try to INSERT them.
          //
          long[] territoryIds = new long[] {
                 1,    2,    3,    4,    5, // NOTE: Success
                 6,    7,    8,    9,   10, // NOTE: Success
              1576, 1577, 1578, 1579, 1580, // NOTE: Success
              1581, 1730, 1833, 2116, 2139, // NOTE: Fail (1581)
              2140, 2141                    // NOTE: Skipped
          };

          if (add)
          {
              using (northwindEFEntities db = new northwindEFEntities())
              {
                  using (TransactionScope scope = new TransactionScope())
                  {
                      //
                      // NOTE: *REQUIRED* This is required so that the
                      //       Entity Framework is prevented from opening
                      //       multiple connections to the underlying SQLite
                      //       database (i.e. which would result in multiple
                      //       IMMEDIATE transactions, thereby failing [later
                      //       on] with locking errors).
                      //
                      db.Connection.Open();

                      foreach (int id in territoryIds)
                      {
                          Territories territories = new Territories();

                          territories.TerritoryID = id;
                          territories.TerritoryDescription = String.Format(
                              "Test Territory #{0}", id);
                          territories.Regions = db.Regions.First();

                          db.AddObject("Territories", territories);
                      }

                      try
                      {
#if NET_20
                          db.SaveChanges(false);
#else
                          db.SaveChanges(SaveOptions.None);
#endif
                      }
                      catch (Exception e)
                      {
                          Console.WriteLine(e);
                      }
                      finally
                      {
                          scope.Complete();
                          db.AcceptAllChanges();
                      }
                  }
              }
          }
          else
          {
              using (northwindEFEntities db = new northwindEFEntities())
              {
                  bool once = false;
                  var query = from t in db.Territories
                    where territoryIds.AsQueryable<long>().Contains<long>(t.TerritoryID)
                    orderby t.TerritoryID
                    select t;

                  foreach (Territories territories in query)
                  {
                      if (once)
                          Console.Write(' ');

                      Console.Write(territories.TerritoryID);

                      once = true;
                  }
              }
          }

          return 0;
      }

    private static int OldTests()
    {
      using (northwindEFEntities db = new northwindEFEntities())

Changes to testlinq/testlinq.2008.csproj.

42
43
44
45
46
47
48

49
50
51
52
53
54
55
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Data.Entity" />
    <Reference Include="System.Runtime.Serialization" />

    <Reference Include="System.Xml" />
    <Reference Include="System.Data" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="NorthwindModel2008.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>







>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Data.Entity" />
    <Reference Include="System.Runtime.Serialization" />
    <Reference Include="System.Transactions" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Data" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="NorthwindModel2008.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
67
68
69
70
71
72
73

74
75
76
77
78
79
80
81
82
      <Generator>EntityModelCodeGenerator</Generator>
      <LastGenOutput>NorthwindModel2008.Designer.cs</LastGenOutput>
    </EntityDeploy>
  </ItemGroup>
  <ItemGroup>
    <Service Include="{C8F2D6AC-F9F4-4E40-A399-22F9A9A5CBD2}" />
  </ItemGroup>

  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>







>









68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
      <Generator>EntityModelCodeGenerator</Generator>
      <LastGenOutput>NorthwindModel2008.Designer.cs</LastGenOutput>
    </EntityDeploy>
  </ItemGroup>
  <ItemGroup>
    <Service Include="{C8F2D6AC-F9F4-4E40-A399-22F9A9A5CBD2}" />
  </ItemGroup>
  <Import Project="$(SQLiteNetDir)\System.Data.SQLite\System.Data.SQLite.Properties.targets" />
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

Changes to testlinq/testlinq.2010.csproj.

39
40
41
42
43
44
45

46
47
48
49
50
51
52
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data.Entity" />
    <Reference Include="System.Runtime.Serialization" />

    <Reference Include="System.Xml" />
    <Reference Include="System.Data" />
  </ItemGroup>
  <ItemGroup>
    <Compile Condition="'$(TargetFrameworkVersion)' == 'v3.5'"
             Include="NorthwindModel2008.Designer.cs">
      <AutoGen>True</AutoGen>







>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data.Entity" />
    <Reference Include="System.Runtime.Serialization" />
    <Reference Include="System.Transactions" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Data" />
  </ItemGroup>
  <ItemGroup>
    <Compile Condition="'$(TargetFrameworkVersion)' == 'v3.5'"
             Include="NorthwindModel2008.Designer.cs">
      <AutoGen>True</AutoGen>
80
81
82
83
84
85
86

87
88
89
90
91
92
93
94
95
      <Generator>EntityModelCodeGenerator</Generator>
      <LastGenOutput>NorthwindModel2010.Designer.cs</LastGenOutput>
    </EntityDeploy>
  </ItemGroup>
  <ItemGroup>
    <Service Include="{C8F2D6AC-F9F4-4E40-A399-22F9A9A5CBD2}" />
  </ItemGroup>

  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>







>









81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
      <Generator>EntityModelCodeGenerator</Generator>
      <LastGenOutput>NorthwindModel2010.Designer.cs</LastGenOutput>
    </EntityDeploy>
  </ItemGroup>
  <ItemGroup>
    <Service Include="{C8F2D6AC-F9F4-4E40-A399-22F9A9A5CBD2}" />
  </ItemGroup>
  <Import Project="$(SQLiteNetDir)\System.Data.SQLite\System.Data.SQLite.Properties.targets" />
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>