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

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

Overview
Comment:Extend OnChanged notifications to handle basic connection pool integration.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b2cffa59749e1366a67c3546c45b3878d8ee2fb6
User & Date: mistachkin 2015-07-16 00:56:18
Context
2015-07-16
01:10
Augment the OpenedFromPool OnChanged notification to include the pool version. check-in: e769f25743 user: mistachkin tags: trunk
00:56
Extend OnChanged notifications to handle basic connection pool integration. check-in: b2cffa5974 user: mistachkin tags: trunk
2015-07-14
22:03
Add experimental support for the FTS5 loadable extension. check-in: b1750e5eba user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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

   126    126       {
   127    127           if (db != IntPtr.Zero)
   128    128           {
   129    129               _sql = new SQLiteConnectionHandle(db, ownHandle);
   130    130               _fileName = fileName;
   131    131   
   132    132               SQLiteConnection.OnChanged(null, new ConnectionEventArgs(
   133         -                SQLiteConnectionEventType.NewCriticalHandle, null, null,
   134         -                null, null, _sql, fileName, new object[] { fmt, kind,
   135         -                fmtString, db, fileName, ownHandle }));
          133  +                SQLiteConnectionEventType.NewCriticalHandle, null,
          134  +                null, null, null, _sql, fileName, new object[] {
          135  +                typeof(SQLite3), fmt, kind, fmtString, db, fileName,
          136  +                ownHandle }));
   136    137           }
   137    138       }
   138    139   
   139    140       ///////////////////////////////////////////////////////////////////////////////////////////////
   140    141   
   141    142       #region IDisposable "Pattern" Members
   142    143       private bool disposed;
................................................................................
   240    241                 {
   241    242   #if INTEROP_VIRTUAL_TABLE
   242    243                     DisposeModules();
   243    244   #endif
   244    245   
   245    246                     SQLiteConnectionPool.Add(_fileName, _sql, _poolVersion);
   246    247   
          248  +                  SQLiteConnection.OnChanged(null, new ConnectionEventArgs(
          249  +                      SQLiteConnectionEventType.ClosedToPool, null, null,
          250  +                      null, null, _sql, _fileName, new object[] {
          251  +                      typeof(SQLite3), canThrow, _fileName, _poolVersion }));
          252  +
   247    253   #if !NET_COMPACT_20 && TRACE_CONNECTION
   248    254                     Trace.WriteLine(String.Format("Close (Pool) Success: {0}", _sql));
   249    255   #endif
   250    256                 }
   251    257   #if !NET_COMPACT_20 && TRACE_CONNECTION
   252    258                 else
   253    259                 {
................................................................................
   754    760         _usePool = usePool;
   755    761         _fileName = strFilename;
   756    762   
   757    763         if (usePool)
   758    764         {
   759    765           _sql = SQLiteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion);
   760    766   
          767  +        SQLiteConnection.OnChanged(null, new ConnectionEventArgs(
          768  +            SQLiteConnectionEventType.OpenedFromPool, null, null,
          769  +            null, null, _sql, strFilename, new object[] {
          770  +            typeof(SQLite3), strFilename, vfsName, connectionFlags,
          771  +            openFlags, maxPoolSize, usePool }));
          772  +
   761    773   #if !NET_COMPACT_20 && TRACE_CONNECTION
   762    774           Trace.WriteLine(String.Format("Open (Pool): {0}", (_sql != null) ? _sql.ToString() : "<null>"));
   763    775   #endif
   764    776         }
   765    777   
   766    778         if (_sql == null)
   767    779         {
................................................................................
   793    805   
   794    806             if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, null);
   795    807             _sql = new SQLiteConnectionHandle(db, true);
   796    808           }
   797    809           lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }
   798    810   
   799    811           SQLiteConnection.OnChanged(null, new ConnectionEventArgs(
   800         -            SQLiteConnectionEventType.NewCriticalHandle, null, null,
   801         -            null, null, _sql, strFilename, new object[] { strFilename,
   802         -            vfsName, connectionFlags, openFlags, maxPoolSize, usePool }));
          812  +            SQLiteConnectionEventType.NewCriticalHandle, null,
          813  +            null, null, null, _sql, strFilename, new object[] {
          814  +            typeof(SQLite3), strFilename, vfsName, connectionFlags,
          815  +            openFlags, maxPoolSize, usePool }));
   803    816         }
   804    817   
   805    818         // Bind functions to this connection.  If any previous functions of the same name
   806    819         // were already bound, then the new bindings replace the old.
   807    820         if ((connectionFlags & SQLiteConnectionFlags.NoBindFunctions) != SQLiteConnectionFlags.NoBindFunctions)
   808    821         {
   809    822             if (_functions == null)
................................................................................
  1184   1197               }
  1185   1198             }
  1186   1199   
  1187   1200             if (statementHandle != null)
  1188   1201             {
  1189   1202               SQLiteConnection.OnChanged(null, new ConnectionEventArgs(
  1190   1203                 SQLiteConnectionEventType.NewCriticalHandle, null, null,
  1191         -              null, null, statementHandle, strSql, new object[] { cnn,
  1192         -              strSql, previous, timeoutMS }));
         1204  +              null, null, statementHandle, strSql, new object[] {
         1205  +              typeof(SQLite3), cnn, strSql, previous, timeoutMS }));
  1193   1206             }
  1194   1207   
  1195   1208             if (ShouldThrowForCancel())
  1196   1209             {
  1197   1210                 if ((n == SQLiteErrorCode.Ok) ||
  1198   1211                     (n == SQLiteErrorCode.Row) ||
  1199   1212                     (n == SQLiteErrorCode.Done))
................................................................................
  2614   2627                       throw new SQLiteException("failed to initialize backup");
  2615   2628               }
  2616   2629   
  2617   2630               backupHandle = new SQLiteBackupHandle(destHandle, backup);
  2618   2631           }
  2619   2632   
  2620   2633           SQLiteConnection.OnChanged(null, new ConnectionEventArgs(
  2621         -            SQLiteConnectionEventType.NewCriticalHandle, null, null,
  2622         -            null, null, backupHandle, null, new object[] { destCnn,
  2623         -            destName, sourceName }));
         2634  +            SQLiteConnectionEventType.NewCriticalHandle, null,
         2635  +            null, null, null, backupHandle, null, new object[] {
         2636  +            typeof(SQLite3), destCnn, destName, sourceName }));
  2624   2637   
  2625   2638           return new SQLiteBackup(
  2626   2639               this, backupHandle, destHandle, zDestName, sourceHandle,
  2627   2640               zSourceName);
  2628   2641       }
  2629   2642   
  2630   2643       /// <summary>

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

   148    148         _usePool = usePool;
   149    149         _fileName = strFilename;
   150    150   
   151    151         if (usePool)
   152    152         {
   153    153           _sql = SQLiteConnectionPool.Remove(strFilename, maxPoolSize, out _poolVersion);
   154    154   
          155  +        SQLiteConnection.OnChanged(null, new ConnectionEventArgs(
          156  +            SQLiteConnectionEventType.OpenedFromPool, null, null,
          157  +            null, null, _sql, strFilename, new object[] {
          158  +            typeof(SQLite3_UTF16), strFilename, vfsName,
          159  +            connectionFlags, openFlags, maxPoolSize, usePool }));
          160  +
   155    161   #if !NET_COMPACT_20 && TRACE_CONNECTION
   156    162           Trace.WriteLine(String.Format("Open16 (Pool): {0}", (_sql != null) ? _sql.ToString() : "<null>"));
   157    163   #endif
   158    164         }
   159    165   
   160    166         if (_sql == null)
   161    167         {
................................................................................
   202    208   
   203    209             if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, null);
   204    210             _sql = new SQLiteConnectionHandle(db, true);
   205    211           }
   206    212           lock (_sql) { /* HACK: Force the SyncBlock to be "created" now. */ }
   207    213   
   208    214           SQLiteConnection.OnChanged(null, new ConnectionEventArgs(
   209         -            SQLiteConnectionEventType.NewCriticalHandle, null, null,
   210         -            null, null, _sql, strFilename, new object[] { strFilename,
   211         -            vfsName, connectionFlags, openFlags, maxPoolSize, usePool }));
          215  +            SQLiteConnectionEventType.NewCriticalHandle, null,
          216  +            null, null, null, _sql, strFilename, new object[] {
          217  +            typeof(SQLite3_UTF16), strFilename, vfsName,
          218  +            connectionFlags, openFlags, maxPoolSize, usePool }));
   212    219         }
   213    220   
   214    221         // Bind functions to this connection.  If any previous functions of the same name
   215    222         // were already bound, then the new bindings replace the old.
   216    223         if ((connectionFlags & SQLiteConnectionFlags.NoBindFunctions) != SQLiteConnectionFlags.NoBindFunctions)
   217    224         {
   218    225             if (_functions == null)

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

   966    966               result = (nativeHandle != IntPtr.Zero) ?
   967    967                   new SQLiteConnectionHandle(nativeHandle, true) : null;
   968    968           }
   969    969   
   970    970           if (result != null)
   971    971           {
   972    972               SQLiteConnection.OnChanged(null, new ConnectionEventArgs(
   973         -                SQLiteConnectionEventType.NewCriticalHandle, null, null,
   974         -                null, null, result, null, new object[] { nativeHandle }));
          973  +                SQLiteConnectionEventType.NewCriticalHandle, null,
          974  +                null, null, null, result, null, new object[] {
          975  +                typeof(SQLiteConnection), nativeHandle }));
   975    976           }
   976    977   
   977    978           return result;
   978    979       }
   979    980   
   980    981       ///////////////////////////////////////////////////////////////////////////////////////////////
   981    982   

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

  2208   2208         /// A data reader is being disposed.
  2209   2209         /// </summary>
  2210   2210         DisposingDataReader = 13,
  2211   2211   
  2212   2212         /// <summary>
  2213   2213         /// A data reader is being closed.
  2214   2214         /// </summary>
  2215         -      ClosingDataReader = 14
         2215  +      ClosingDataReader = 14,
         2216  +
         2217  +      /// <summary>
         2218  +      /// A native resource was opened (i.e. obtained) from the pool.
         2219  +      /// </summary>
         2220  +      OpenedFromPool = 15,
         2221  +
         2222  +      /// <summary>
         2223  +      /// A native resource was closed (i.e. released) to the pool.
         2224  +      /// </summary>
         2225  +      ClosedToPool = 16
  2216   2226     }
  2217   2227   
  2218   2228     /// <summary>
  2219   2229     /// This implementation of SQLite for ADO.NET can process date/time fields in
  2220   2230     /// databases in one of six formats.
  2221   2231     /// </summary>
  2222   2232     /// <remarks>