System.Data.SQLite
Check-in [f8d3d92453]
Not logged in

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

Overview
Comment:Make sure that null is passed to the native sqlite3session_table_filter() API when the callback is null. Also, fix type signature of the session extension xFilter native delegate.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1: f8d3d924537f2526e605a7e9e2fd45986271a9b0
User & Date: mistachkin 2017-10-11 03:29:49
Original Comment: Fix type signature of the session extension xFilter native delegate.
Context
2017-10-11
03:34
More work on tests. check-in: a40c3117c6 user: mistachkin tags: sessions
03:29
Make sure that null is passed to the native sqlite3session_table_filter() API when the callback is null. Also, fix type signature of the session extension xFilter native delegate. check-in: f8d3d92453 user: mistachkin tags: sessions
00:32
More work on tests. check-in: e9782935e2 user: mistachkin tags: sessions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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

  1280   1280   
  1281   1281               if (rc != SQLiteErrorCode.Ok)
  1282   1282                   throw new SQLiteException(rc, "sqlite3session_create");
  1283   1283           }
  1284   1284   
  1285   1285           ///////////////////////////////////////////////////////////////////////
  1286   1286   
         1287  +        private UnsafeNativeMethods.xSessionFilter ApplyTableFilter(
         1288  +            SessionTableFilterCallback callback, /* in: NULL OK */
         1289  +            object clientData                    /* in: NULL OK */
         1290  +            )
         1291  +        {
         1292  +            this.tableFilterCallback = callback;
         1293  +            this.tableFilterClientData = clientData;
         1294  +
         1295  +            return (callback != null) ?
         1296  +                xFilter : (UnsafeNativeMethods.xSessionFilter)null;
         1297  +        }
         1298  +
         1299  +        ///////////////////////////////////////////////////////////////////////
         1300  +
  1287   1301           #region Native Callback Methods
  1288   1302           private int xFilter(
  1289   1303               IntPtr context, /* NOT USED */
  1290         -            byte[] tblName
         1304  +            IntPtr pTblName
  1291   1305               )
  1292   1306           {
  1293   1307               return tableFilterCallback(tableFilterClientData,
  1294         -                SQLiteString.GetStringFromUtf8Bytes(tblName)) ? 1 : 0;
         1308  +                SQLiteString.StringFromUtf8IntPtr(pTblName)) ? 1 : 0;
  1295   1309           }
  1296   1310           #endregion
  1297   1311           #endregion
  1298   1312   
  1299   1313           ///////////////////////////////////////////////////////////////////////
  1300   1314   
  1301   1315           #region ISQLiteSession Members
................................................................................
  1389   1403               SessionTableFilterCallback callback, /* in: NULL OK */
  1390   1404               object clientData                    /* in: NULL OK */
  1391   1405               )
  1392   1406           {
  1393   1407               CheckDisposed();
  1394   1408               CheckHandle();
  1395   1409   
  1396         -            this.tableFilterCallback = callback;
  1397         -            this.tableFilterClientData = clientData;
  1398         -
  1399   1410               UnsafeNativeMethods.sqlite3session_table_filter(
  1400         -                session, xFilter, IntPtr.Zero);
         1411  +                session, ApplyTableFilter(callback, clientData), IntPtr.Zero);
  1401   1412           }
  1402   1413   
  1403   1414           ///////////////////////////////////////////////////////////////////////
  1404   1415   
  1405   1416           public void CreateChangeSet(
  1406   1417               ref byte[] rawData
  1407   1418               )
................................................................................
  1645   1656           {
  1646   1657               if (tableFilterCallback == null)
  1647   1658                   return null;
  1648   1659   
  1649   1660               UnsafeNativeMethods.xSessionFilter xFilter;
  1650   1661   
  1651   1662               xFilter = new UnsafeNativeMethods.xSessionFilter(
  1652         -                delegate(IntPtr context, byte[] tblName)
         1663  +                delegate(IntPtr context, IntPtr pTblName)
  1653   1664               {
  1654   1665                   try
  1655   1666                   {
  1656         -                    string name = SQLiteString.GetStringFromUtf8Bytes(
  1657         -                        tblName);
         1667  +                    string name = SQLiteString.StringFromUtf8IntPtr(
         1668  +                        pTblName);
  1658   1669   
  1659   1670                       return tableFilterCallback(clientData, name) ? 1 : 0;
  1660   1671                   }
  1661   1672                   catch (Exception e)
  1662   1673                   {
  1663   1674                       try
  1664   1675                       {

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

  3802   3802       ///////////////////////////////////////////////////////////////////////////
  3803   3803   
  3804   3804       #region session extension
  3805   3805   #if INTEROP_SESSION_EXTENSION
  3806   3806   #if !PLATFORM_COMPACTFRAMEWORK
  3807   3807       [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  3808   3808   #endif
  3809         -    internal delegate int xSessionFilter(IntPtr context, byte[] tblName);
         3809  +    internal delegate int xSessionFilter(IntPtr context, IntPtr pTblName);
  3810   3810   
  3811   3811   #if !PLATFORM_COMPACTFRAMEWORK
  3812   3812       [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  3813   3813   #endif
  3814   3814       internal delegate SQLiteChangeSetConflictResult xSessionConflict(IntPtr context, SQLiteChangeSetConflictType type, IntPtr iterator);
  3815   3815   
  3816   3816   #if !PLATFORM_COMPACTFRAMEWORK