System.Data.SQLite

Check-in [9f103baaad]
Login

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

Overview
Comment:When unhooking native delegates from a connection, use sqlite3_trace_v2() when it is available.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9f103baaad5030d03c76dece544a3df631adf432
User & Date: mistachkin 2018-02-03 22:17:26.329
Context
2018-02-05
08:16
Adapt to an upstream change in the Eagle test suite infrastructure. check-in: d5928e1acd user: mistachkin tags: trunk
2018-02-03
22:17
When unhooking native delegates from a connection, use sqlite3_trace_v2() when it is available. check-in: 9f103baaad user: mistachkin tags: trunk
2018-02-02
17:38
Add header comment to MSBuild properties file. check-in: 4f83b1eda6 user: mistachkin tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to System.Data.SQLite/SQLite3.cs.
2948
2949
2950
2951
2952
2953
2954





2955
2956
2957
2958
2959
2960
2961
      UnsafeNativeMethods.sqlite3_commit_hook(_sql, func, IntPtr.Zero);
    }

    internal override void SetTraceCallback(SQLiteTraceCallback func)
    {
      UnsafeNativeMethods.sqlite3_trace(_sql, func, IntPtr.Zero);
    }






    internal override void SetRollbackHook(SQLiteRollbackCallback func)
    {
      UnsafeNativeMethods.sqlite3_rollback_hook(_sql, func, IntPtr.Zero);
    }

    /// <summary>







>
>
>
>
>







2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
      UnsafeNativeMethods.sqlite3_commit_hook(_sql, func, IntPtr.Zero);
    }

    internal override void SetTraceCallback(SQLiteTraceCallback func)
    {
      UnsafeNativeMethods.sqlite3_trace(_sql, func, IntPtr.Zero);
    }

    internal override void SetTraceCallback2(SQLiteTraceFlags mask, SQLiteTraceCallback2 func)
    {
        UnsafeNativeMethods.sqlite3_trace_v2(_sql, mask, func, IntPtr.Zero);
    }

    internal override void SetRollbackHook(SQLiteRollbackCallback func)
    {
      UnsafeNativeMethods.sqlite3_rollback_hook(_sql, func, IntPtr.Zero);
    }

    /// <summary>
3077
3078
3079
3080
3081
3082
3083









3084
3085
3086
3087
3088
3089
3090
3091
        #endregion

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

        #region Trace Callback (Per-Connection)
        try
        {









            SetTraceCallback(null); /* throw */
        }
#if !NET_COMPACT_20 && TRACE_CONNECTION
        catch (Exception e)
#else
        catch (Exception)
#endif
        {







>
>
>
>
>
>
>
>
>
|







3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
        #endregion

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

        #region Trace Callback (Per-Connection)
        try
        {
            //
            // NOTE: When using version 3.14 (or later) of the SQLite core
            //       library, use the newer sqlite3_trace_v2() API in order
            //       to unhook the trace callback, just in case the older
            //       API is not available (e.g. SQLITE_OMIT_DEPRECATED).
            //
            if (UnsafeNativeMethods.sqlite3_libversion_number() >= 3014000)
                SetTraceCallback2(SQLiteTraceFlags.SQLITE_TRACE_NONE, null); /* throw */
            else
                SetTraceCallback(null); /* throw */
        }
#if !NET_COMPACT_20 && TRACE_CONNECTION
        catch (Exception e)
#else
        catch (Exception)
#endif
        {
Changes to System.Data.SQLite/SQLiteBase.cs.
440
441
442
443
444
445
446

447
448
449
450
451
452
453
#endif

    internal abstract void SetProgressHook(int nOps, SQLiteProgressCallback func);
    internal abstract void SetAuthorizerHook(SQLiteAuthorizerCallback func);
    internal abstract void SetUpdateHook(SQLiteUpdateCallback func);
    internal abstract void SetCommitHook(SQLiteCommitCallback func);
    internal abstract void SetTraceCallback(SQLiteTraceCallback func);

    internal abstract void SetRollbackHook(SQLiteRollbackCallback func);
    internal abstract SQLiteErrorCode SetLogCallback(SQLiteLogCallback func);

    /// <summary>
    /// Checks if the SQLite core library has been initialized in the current process.
    /// </summary>
    /// <returns>







>







440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
#endif

    internal abstract void SetProgressHook(int nOps, SQLiteProgressCallback func);
    internal abstract void SetAuthorizerHook(SQLiteAuthorizerCallback func);
    internal abstract void SetUpdateHook(SQLiteUpdateCallback func);
    internal abstract void SetCommitHook(SQLiteCommitCallback func);
    internal abstract void SetTraceCallback(SQLiteTraceCallback func);
    internal abstract void SetTraceCallback2(SQLiteTraceFlags mask, SQLiteTraceCallback2 func);
    internal abstract void SetRollbackHook(SQLiteRollbackCallback func);
    internal abstract SQLiteErrorCode SetLogCallback(SQLiteLogCallback func);

    /// <summary>
    /// Checks if the SQLite core library has been initialized in the current process.
    /// </summary>
    /// <returns>
1424
1425
1426
1427
1428
1429
1430
1431














    SQLITE_CONFIG_COVERING_INDEX_SCAN = 20, // int
    SQLITE_CONFIG_SQLLOG = 21, // xSqllog, void*
    SQLITE_CONFIG_MMAP_SIZE = 22, // sqlite3_int64, sqlite3_int64
    SQLITE_CONFIG_WIN32_HEAPSIZE = 23, // int nByte
    SQLITE_CONFIG_PCACHE_HDRSZ = 24, // int *psz
    SQLITE_CONFIG_PMASZ = 25 // unsigned int szPma
  }
}





















|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
    SQLITE_CONFIG_COVERING_INDEX_SCAN = 20, // int
    SQLITE_CONFIG_SQLLOG = 21, // xSqllog, void*
    SQLITE_CONFIG_MMAP_SIZE = 22, // sqlite3_int64, sqlite3_int64
    SQLITE_CONFIG_WIN32_HEAPSIZE = 23, // int nByte
    SQLITE_CONFIG_PCACHE_HDRSZ = 24, // int *psz
    SQLITE_CONFIG_PMASZ = 25 // unsigned int szPma
  }

  /// <summary>
  /// These constants are used with the sqlite3_trace_v2() API and the
  /// callbacks registered by it.
  /// </summary>
  [Flags()]
  internal enum SQLiteTraceFlags
  {
      SQLITE_TRACE_NONE = 0x0, // nil
      SQLITE_TRACE_STMT = 0x1, // pStmt, zSql
      SQLITE_TRACE_PROFILE = 0x2, // pStmt, piNsec64
      SQLITE_TRACE_ROW = 0x4, // pStmt
      SQLITE_TRACE_CLOSE = 0x8 // pDb
  }
}
Changes to System.Data.SQLite/SQLiteConnection.cs.
7009
7010
7011
7012
7013
7014
7015





7016
7017
7018
7019
7020
7021
7022
  internal delegate int SQLiteCommitCallback(IntPtr puser);

#if !PLATFORM_COMPACTFRAMEWORK
  [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
#endif
  internal delegate void SQLiteTraceCallback(IntPtr puser, IntPtr statement);






#if !PLATFORM_COMPACTFRAMEWORK
  [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
#endif
  internal delegate void SQLiteRollbackCallback(IntPtr puser);

  /// <summary>
  /// Raised each time the number of virtual machine instructions is







>
>
>
>
>







7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
  internal delegate int SQLiteCommitCallback(IntPtr puser);

#if !PLATFORM_COMPACTFRAMEWORK
  [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
#endif
  internal delegate void SQLiteTraceCallback(IntPtr puser, IntPtr statement);

#if !PLATFORM_COMPACTFRAMEWORK
  [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
#endif
  internal delegate void SQLiteTraceCallback2(SQLiteTraceFlags type, IntPtr puser, IntPtr pCtx1, IntPtr pCtx2);

#if !PLATFORM_COMPACTFRAMEWORK
  [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
#endif
  internal delegate void SQLiteRollbackCallback(IntPtr puser);

  /// <summary>
  /// Raised each time the number of virtual machine instructions is
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
3807
3808
3809
3810
3811
3812
3813







3814
3815
3816
3817
3818
3819
3820
#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern IntPtr sqlite3_trace(IntPtr db, SQLiteTraceCallback func, IntPtr pvUser);








    // Since sqlite3_config() takes a variable argument list, we have to overload declarations
    // for all possible calls that we want to use.
#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, EntryPoint = "sqlite3_config", CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL, EntryPoint = "sqlite3_config")]
#endif







>
>
>
>
>
>
>







3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern IntPtr sqlite3_trace(IntPtr db, SQLiteTraceCallback func, IntPtr pvUser);

#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL)]
#endif
    internal static extern IntPtr sqlite3_trace_v2(IntPtr db, SQLiteTraceFlags mask, SQLiteTraceCallback2 func, IntPtr pvUser);

    // Since sqlite3_config() takes a variable argument list, we have to overload declarations
    // for all possible calls that we want to use.
#if !PLATFORM_COMPACTFRAMEWORK
    [DllImport(SQLITE_DLL, EntryPoint = "sqlite3_config", CallingConvention = CallingConvention.Cdecl)]
#else
    [DllImport(SQLITE_DLL, EntryPoint = "sqlite3_config")]
#endif