System.Data.SQLite
Check-in [54ebb78b16]
Not logged in

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

Overview
Comment:Fix issue with P/Invoke portability to Windows CE by wrapping sqlite3_msize() on that platform. Enhance tests.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | preRelease
Files: files | file ages | folders
SHA1: 54ebb78b1681dcf0cb8ab02c9a556fad5a059a37
User & Date: mistachkin 2018-08-07 00:06:36
Context
2018-08-07
00:11
Update SQLite core library docs from upstream. Update version history docs. check-in: 4642ef13b9 user: mistachkin tags: preRelease
00:06
Fix issue with P/Invoke portability to Windows CE by wrapping sqlite3_msize() on that platform. Enhance tests. check-in: 54ebb78b16 user: mistachkin tags: preRelease
2018-08-06
11:16
Update version history docs. check-in: 66c7e0e130 user: mistachkin tags: preRelease
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to SQLite.Interop/src/generic/interop.c.

   246    246     sqlite3InteropDebug("INTEROP_LOG (%d) %s\n", iCode, zMsg);
   247    247   }
   248    248   #endif
   249    249   
   250    250   SQLITE_API int WINAPI sqlite3_malloc_size_interop(void *p){
   251    251     return sqlite3MallocSize(p);
   252    252   }
          253  +
          254  +SQLITE_API void WINAPI sqlite3_msize_interop(void *p, sqlite_uint64 *pN)
          255  +{
          256  +  if (!pN) return;
          257  +  *pN = sqlite3_msize(p);
          258  +}
   253    259   
   254    260   #if defined(INTEROP_LEGACY_CLOSE) || SQLITE_VERSION_NUMBER < 3007014
   255    261   SQLITE_PRIVATE void * sqlite3DbMallocZero_interop(sqlite3 *db, int n)
   256    262   {
   257    263     void *p;
   258    264     if (db) {
   259    265       sqlite3_mutex_enter(db->mutex);

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

  3410   3410   
  3411   3411           #region Memory Version Helper Methods
  3412   3412           /// <summary>
  3413   3413           /// Determines if the native sqlite3_msize() API can be used, based on
  3414   3414           /// the available version of the SQLite core library.
  3415   3415           /// </summary>
  3416   3416           /// <returns>
  3417         -        /// Non-zero if the native sqlite3_msize() API property is supported
  3418         -        /// by the SQLite core library.
         3417  +        /// Non-zero if the native sqlite3_msize() API is supported by the
         3418  +        /// SQLite core library.
  3419   3419           /// </returns>
  3420   3420           private static bool CanUseSize64()
  3421   3421           {
         3422  +#if !PLATFORM_COMPACTFRAMEWORK || !SQLITE_STANDARD
  3422   3423               if (UnsafeNativeMethods.sqlite3_libversion_number() >= 3008007)
  3423   3424                   return true;
         3425  +#endif
  3424   3426   
  3425   3427               return false;
  3426   3428           }
  3427   3429           #endregion
  3428   3430   
  3429   3431           ///////////////////////////////////////////////////////////////////////
  3430   3432   
................................................................................
  3590   3592           /// </returns>
  3591   3593           public static ulong Size64(IntPtr pMemory)
  3592   3594           {
  3593   3595   #if DEBUG
  3594   3596               SQLiteMarshal.CheckAlignment("Size64", pMemory, 0, IntPtr.Size);
  3595   3597   #endif
  3596   3598   
         3599  +#if !PLATFORM_COMPACTFRAMEWORK
  3597   3600               return UnsafeNativeMethods.sqlite3_msize(pMemory);
         3601  +#elif !SQLITE_STANDARD
         3602  +            ulong size = 0;
         3603  +            UnsafeNativeMethods.sqlite3_msize_interop(pMemory, ref size);
         3604  +            return size;
         3605  +#else
         3606  +            throw new NotImplementedException();
         3607  +#endif
  3598   3608           }
  3599   3609   
  3600   3610           ///////////////////////////////////////////////////////////////////////
  3601   3611   
  3602   3612           /// <summary>
  3603   3613           /// Frees a memory block previously obtained from the
  3604   3614           /// <see cref="Allocate" /> or <see cref="Allocate64" /> methods.  If

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

  4776   4776   
  4777   4777       [DllImport(SQLITE_DLL)]
  4778   4778       internal static extern void sqlite3_result_double_interop(IntPtr context, ref double value);
  4779   4779   
  4780   4780       [DllImport(SQLITE_DLL)]
  4781   4781       internal static extern void sqlite3_result_int64_interop(IntPtr context, ref Int64 value);
  4782   4782   
         4783  +    [DllImport(SQLITE_DLL)]
         4784  +    internal static extern void sqlite3_msize_interop(IntPtr p, ref ulong size);
         4785  +
  4783   4786       [DllImport(SQLITE_DLL)]
  4784   4787       internal static extern IntPtr sqlite3_create_disposable_module_interop(
  4785   4788           IntPtr db, IntPtr name, IntPtr pModule, int iVersion, xCreate xCreate,
  4786   4789           xConnect xConnect, xBestIndex xBestIndex, xDisconnect xDisconnect,
  4787   4790           xDestroy xDestroy, xOpen xOpen, xClose xClose, xFilter xFilter,
  4788   4791           xNext xNext, xEof xEof, xColumn xColumn, xRowId xRowId, xUpdate xUpdate,
  4789   4792           xBegin xBegin, xSync xSync, xCommit xCommit, xRollback xRollback,

Changes to testce/TestCases.cs.

     1      1   /********************************************************
     2      2    * ADO.NET 2.0 Data Provider for SQLite Version 3.X
     3      3    * Written by Robert Simpson (robert@blackcastlesoft.com)
     4         - * 
            4  + *
     5      5    * Released to the public domain, use at your own risk!
     6      6    ********************************************************/
     7      7   
     8      8   using System;
     9      9   using System.Collections.Generic;
    10     10   using System.Data.Common;
    11     11   using System.Data;
................................................................................
    12     12   using System.Data.SQLite;
    13     13   using System.Threading;
    14     14   
    15     15   namespace test
    16     16   {
    17     17   
    18     18     /// <summary>
    19         -  /// Scalar user-defined function.  In this example, the same class is declared twice with 
           19  +  /// Scalar user-defined function.  In this example, the same class is declared twice with
    20     20     /// different function names to demonstrate how to use alias names for user-defined functions.
    21     21     /// </summary>
    22     22     [SQLiteFunction(Name = "Foo", Arguments = 2, FuncType = FunctionType.Scalar)]
    23     23     [SQLiteFunction(Name = "TestFunc", Arguments = 2, FuncType = FunctionType.Scalar)]
    24     24     class TestFunc : SQLiteFunction
    25     25     {
    26     26       public override object Invoke(object[] args)
................................................................................
   210    210   
   211    211             WriteMemoryStatistics(false);
   212    212             frm.WriteLine(String.Empty);
   213    213         }
   214    214   
   215    215         total++;
   216    216         try { CreateTable(cnn); frm.WriteLine("SUCCESS - CreateTable"); passed++; }
   217         -      catch (Exception) { frm.WriteLine("FAIL - CreateTable"); failed++; }
          217  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - CreateTable: {0}", e)); failed++; }
   218    218   
   219    219         total++;
   220    220         try { DataTypeTest(cnn); frm.WriteLine("SUCCESS - DataType Test"); passed++; }
   221         -      catch (Exception) { frm.WriteLine("FAIL - DataType Test"); failed++; }
          221  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - DataType Test: {0}", e)); failed++; }
   222    222   
   223    223         total++;
   224    224         try { FullTextTest(cnn); frm.WriteLine("SUCCESS - Full Text Search"); passed++; }
   225         -      catch (Exception) { frm.WriteLine("FAIL - Full Text Search"); failed++; }
          225  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - Full Text Search: {0}", e)); failed++; }
   226    226   
   227    227         total++;
   228    228         try { KeyInfoTest(cnn); frm.WriteLine("SUCCESS - KeyInfo Fetch"); passed++; }
   229         -      catch (Exception) { frm.WriteLine("FAIL - KeyInfo Fetch"); failed++; }
          229  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - KeyInfo Fetch: {0}", e)); failed++; }
   230    230   
   231    231         total++;
   232    232         try { InsertTable(cnn); frm.WriteLine("SUCCESS - InsertTable"); passed++; }
   233         -      catch (Exception) { frm.WriteLine("FAIL - InsertTable"); failed++; }
          233  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - InsertTable: {0}", e)); failed++; }
   234    234   
   235    235         total++;
   236    236         try { VerifyInsert(cnn); frm.WriteLine("SUCCESS - VerifyInsert"); passed++; }
   237         -      catch (Exception) { frm.WriteLine("FAIL - VerifyInsert"); failed++; }
          237  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - VerifyInsert: {0}", e)); failed++; }
   238    238   
   239    239         total++;
   240         -      try { CoersionTest(cnn); frm.WriteLine("FAIL - CoersionTest"); failed++; }
   241         -      catch (Exception) { frm.WriteLine("SUCCESS - CoersionTest"); passed++; }
          240  +      try { CoercionTest(cnn); frm.WriteLine("FAIL - CoercionTest"); failed++; }
          241  +      catch (Exception) { frm.WriteLine("SUCCESS - CoercionTest"); passed++; }
   242    242   
   243    243         total++;
   244    244         try { ParameterizedInsert(cnn); frm.WriteLine("SUCCESS - ParameterizedInsert"); passed++; }
   245         -      catch (Exception) { frm.WriteLine("FAIL - ParameterizedInsert"); failed++; }
          245  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - ParameterizedInsert: {0}", e)); failed++; }
   246    246   
   247    247         total++;
   248    248         try { BinaryInsert(cnn); frm.WriteLine("SUCCESS - BinaryInsert"); passed++; }
   249         -      catch (Exception) { frm.WriteLine("FAIL - BinaryInsert"); failed++; }
          249  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - BinaryInsert: {0}", e)); failed++; }
   250    250   
   251    251         total++;
   252    252         try { VerifyBinaryData(cnn); frm.WriteLine("SUCCESS - VerifyBinaryData"); passed++; }
   253         -      catch (Exception) { frm.WriteLine("FAIL - VerifyBinaryData"); failed++; }
          253  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - VerifyBinaryData: {0}", e)); failed++; }
   254    254   
   255    255         total++;
   256    256         try { LockTest(cnn, sql, isolatedSql); frm.WriteLine("SUCCESS - LockTest"); passed++; }
   257         -      catch (Exception) { frm.WriteLine("FAIL - LockTest"); failed++; }
          257  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - LockTest: {0}", e)); failed++; }
   258    258   
   259    259         total++;
   260    260         try { ParameterizedInsertMissingParams(cnn); frm.WriteLine("FAIL - ParameterizedInsertMissingParams"); failed++; }
   261    261         catch (Exception) { frm.WriteLine("SUCCESS - ParameterizedInsertMissingParams"); passed++; }
   262    262   
   263    263         total++;
   264    264         try { InsertMany(cnn, false); frm.WriteLine("SUCCESS - InsertMany"); passed++; }
   265         -      catch (Exception) { frm.WriteLine("FAIL - InsertMany"); failed++; }
          265  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - InsertMany: {0}", e)); failed++; }
   266    266   
   267    267         total++;
   268    268         try { InsertMany(cnn, true); frm.WriteLine("SUCCESS - InsertManyWithIdentityFetch"); passed++; }
   269         -      catch (Exception) { frm.WriteLine("FAIL - InsertManyWithIdentityFetch"); failed++; }
          269  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - InsertManyWithIdentityFetch: {0}", e)); failed++; }
   270    270   
   271    271         total++;
   272    272         try { FastInsertMany(cnn); frm.WriteLine("SUCCESS - FastInsertMany"); passed++; }
   273         -      catch (Exception) { frm.WriteLine("FAIL - FastInsertMany"); failed++; }
          273  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - FastInsertMany: {0}", e)); failed++; }
   274    274   
   275    275         total++;
   276    276         try { IterationTest(cnn); frm.WriteLine("SUCCESS - Iteration Test"); passed++; }
   277         -      catch (Exception) { frm.WriteLine("FAIL - Iteration Test"); failed++; }
          277  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - Iteration Test: {0}", e)); failed++; }
   278    278   
   279    279         total++;
   280    280         try { UserFunction(cnn); frm.WriteLine("SUCCESS - UserFunction"); passed++; }
   281         -      catch (Exception) { frm.WriteLine("FAIL - UserFunction"); failed++; }
          281  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - UserFunction: {0}", e)); failed++; }
   282    282   
   283    283         total++;
   284    284         try { UserAggregate(cnn); frm.WriteLine("SUCCESS - UserAggregate"); passed++; }
   285         -      catch (Exception) { frm.WriteLine("FAIL - UserAggregate"); failed++; }
          285  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - UserAggregate: {0}", e)); failed++; }
   286    286   
   287    287         total++;
   288    288         try { UserCollation(cnn); frm.WriteLine("SUCCESS - UserCollation"); passed++; }
   289         -      catch (Exception) { frm.WriteLine("FAIL - UserCollation"); failed++; }
          289  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - UserCollation: {0}", e)); failed++; }
   290    290   
   291    291         total++;
   292    292         try { Int64Properties(cnn); frm.WriteLine("SUCCESS - Int64Properties"); passed++; }
   293         -      catch (Exception) { frm.WriteLine("FAIL - Int64Properties"); failed++; }
          293  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - Int64Properties: {0}", e)); failed++; }
   294    294   
   295    295   #if INTEROP_VIRTUAL_TABLE
   296    296         total++;
   297    297         try { ManagedVirtualTable(cnn); frm.WriteLine("SUCCESS - ManagedVirtualTable"); passed++; }
   298         -      catch (Exception) { frm.WriteLine("FAIL - ManagedVirtualTable"); failed++; }
          298  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - ManagedVirtualTable: {0}", e)); failed++; }
   299    299   #endif
   300    300   
   301    301         total++;
   302    302         try { MultipleThreadStress(cnn); frm.WriteLine("SUCCESS - MultipleThreadStress"); passed++; }
   303         -      catch (Exception) { frm.WriteLine("FAIL - MultipleThreadStress"); failed++; }
          303  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - MultipleThreadStress: {0}", e)); failed++; }
   304    304   
   305    305         total++;
   306    306         try { SimpleRTree(cnn); frm.WriteLine("SUCCESS - SimpleRTree"); passed++; }
   307         -      catch (Exception) { frm.WriteLine("FAIL - SimpleRTree"); failed++; }
          307  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - SimpleRTree: {0}", e)); failed++; }
   308    308   
   309    309         total++;
   310    310         try { DropTable(cnn); frm.WriteLine("SUCCESS - DropTable"); passed++; }
   311         -      catch (Exception) { frm.WriteLine("FAIL - DropTable"); failed++; }
          311  +      catch (Exception e) { frm.WriteLine(String.Format("FAIL - DropTable: {0}", e)); failed++; }
   312    312   
   313    313         frm.WriteLine("\r\nTests Finished.");
   314    314   
   315    315         if (cnn2 != null)
   316    316             cnn2.Close();
   317    317   
   318    318         WriteMemoryStatistics(true);
................................................................................
   584    584               if (Field5.CompareTo(DateTime.Parse("2005-01-01 13:49:00")) != 0) throw new ArgumentOutOfRangeException("Non-Match on Field5");
   585    585             }
   586    586             else throw new ArgumentOutOfRangeException("No data in table");
   587    587           }
   588    588         }
   589    589       }
   590    590   
   591         -    internal void CoersionTest(DbConnection cnn)
          591  +    internal void CoercionTest(DbConnection cnn)
   592    592       {
   593    593         using (DbCommand cmd = cnn.CreateCommand())
   594    594         {
   595    595           cmd.CommandText = "SELECT Field1, Field2, Field3, Field4, Field5, 'A', 1, 1 + 1, 3.14159 FROM TestCase";
   596    596           using (DbDataReader rd = cmd.ExecuteReader())
   597    597           {
   598    598             if (rd.Read())
................................................................................
  1008   1008   
  1009   1009       // Causes the user-defined collation sequence to be iterated through
  1010   1010       internal void UserCollation(DbConnection cnn)
  1011   1011       {
  1012   1012         using (DbCommand cmd = cnn.CreateCommand())
  1013   1013         {
  1014   1014           // Using a default collating sequence in descending order, "Param Field3" will appear at the top
  1015         -        // and "Field3" will be next, followed by a NULL.  Our user-defined collating sequence will 
         1015  +        // and "Field3" will be next, followed by a NULL.  Our user-defined collating sequence will
  1016   1016           // deliberately place them out of order so Field3 is first.
  1017   1017           cmd.CommandText = "SELECT Field3 FROM TestCase ORDER BY Field3 COLLATE MYSEQUENCE DESC";
  1018   1018           string s = (string)cmd.ExecuteScalar();
  1019   1019           if (s != "Field3") throw new ArgumentOutOfRangeException("MySequence didn't sort properly");
  1020   1020         }
  1021   1021       }
  1022   1022