Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Moved log handler from SQLiteConnection object to SQLiteFactory object to prevent if from being prematurely GCed. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
c520cba472cb750ff16917bce994b4ce |
User & Date: | shaneh 2011-05-23 04:12:28.365 |
Context
2011-05-24
| ||
01:17 | Correct System.Data.SQLite.Linq version and resource information. Fix for [6489c5a396] and [133daf50d6]. check-in: 9ce4a2e044 user: shaneh tags: trunk | |
2011-05-23
| ||
04:12 | Moved log handler from SQLiteConnection object to SQLiteFactory object to prevent if from being prematurely GCed. check-in: c520cba472 user: shaneh tags: trunk | |
04:07 | Updated method for flagging test cases that are SQLite specific. check-in: 9525e5cf45 user: shaneh tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLite3.cs.
︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | + + + + + | namespace System.Data.SQLite { using System; using System.Runtime.InteropServices; using System.Collections.Generic; using System.Globalization; #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif internal delegate void SQLiteLogCallback(IntPtr puser, int err_code, IntPtr message); /// <summary> /// This class implements SQLiteBase completely, and is the guts of the code that interop's SQLite with .NET /// </summary> internal class SQLite3 : SQLiteBase { /// <summary> /// The opaque pointer returned to us by the sqlite provider |
︙ |
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | |||
203 204 205 206 207 208 209 | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | - - | internal long _version; private event SQLiteUpdateEventHandler _updateHandler; private event SQLiteCommitHandler _commitHandler; private event SQLiteTraceEventHandler _traceHandler; private event EventHandler _rollbackHandler; |
︙ | |||
811 812 813 814 815 816 817 | 809 810 811 812 813 814 815 816 817 818 819 820 821 822 | - - - - - - | FindKey(opts, "DateTimeFormat", "ISO8601"), true); if (bUTF16) // SQLite automatically sets the encoding of the database to UTF16 if called from sqlite3_open16() _sql = new SQLite3_UTF16(dateFormat); else _sql = new SQLite3(dateFormat); |
︙ | |||
2347 2348 2349 2350 2351 2352 2353 | 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | } private void RollbackCallback(IntPtr parg) { _rollbackHandler(this, EventArgs.Empty); } |
︙ | |||
2419 2420 2421 2422 2423 2424 2425 | 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 | - - - - - - + - - - - - - - | internal delegate void SQLiteTraceCallback(IntPtr puser, IntPtr statement); #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif internal delegate void SQLiteRollbackCallback(IntPtr puser); |
︙ | |||
2539 2540 2541 2542 2543 2544 2545 | 2488 2489 2490 2491 2492 2493 2494 2495 | - - - - - - - - - - + - - - - - - - - - - - - - - | internal TraceEventArgs(string statement) { Statement = statement; } } |
Changes to System.Data.SQLite/SQLiteFactory.cs.
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 | 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 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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | /******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Robert Simpson (robert@blackcastlesoft.com) * * Released to the public domain, use at your own risk! ********************************************************/ namespace System.Data.SQLite { using System; using System.Data.Common; /// <summary> /// Passed during an Log callback /// </summary> public class LogEventArgs : EventArgs { /// <summary> /// The error code. /// </summary> public readonly int ErrorCode; /// <summary> /// SQL statement text as the statement first begins executing /// </summary> public readonly string Message; internal LogEventArgs(IntPtr puser, int err_code, string message) { // puser should be NULL ErrorCode = err_code; Message = message; } } /// <summary> /// Raised when a log event occurs. /// </summary> /// <param name="sender">The current connection</param> /// <param name="e">Event arguments of the trace</param> public delegate void SQLiteLogEventHandler(object sender, LogEventArgs e); #if !PLATFORM_COMPACTFRAMEWORK /// <summary> /// SQLite implementation of DbProviderFactory. /// </summary> public sealed partial class SQLiteFactory : DbProviderFactory { /// <summary> /// Member variable to store the application log handler to call. /// </summary> internal event SQLiteLogEventHandler _logHandler; /// <summary> /// The log callback passed to SQLite engine. /// </summary> private SQLiteLogCallback _logCallback; /// <summary> /// The base SQLite object to interop with. /// </summary> internal SQLiteBase _sql; /// <summary> /// This event is raised whenever SQLite raises a logging event. /// Note that this should be set as one of the first things in the /// application. /// </summary> public event SQLiteLogEventHandler Log { add { // Remove any copies of this event handler from registered list. // This essentially means that a handler will be called only once // no matter how many times it is added. _logHandler -= value; // add this to the list of event handlers _logHandler += value; } remove { _logHandler -= value; } } /// <summary> /// Internal proxy function that calls any registered application log /// event handlers. /// </summary> private void LogCallback(IntPtr puser, int err_code, IntPtr message) { // if there are any registered event handlers if (_logHandler != null) // call them _logHandler(this, new LogEventArgs(puser, err_code, SQLiteBase.UTF8ToString(message, -1))); } /// <overloads> /// Constructs a new SQLiteFactory object /// </overloads> /// <summary> /// Default constructor /// </summary> public SQLiteFactory() { if (_sql == null) { _sql = new SQLite3(SQLiteDateFormats.ISO8601); if (_sql != null) { // Create a single "global" callback to register with SQLite. // This callback will pass the event on to any registered // handler. We only want to do this once. if (_logCallback == null) { _logCallback = new SQLiteLogCallback(LogCallback); if (_logCallback != null) { _sql.SetLogCallback(_logCallback); } } } } } /// <summary> /// Static instance member which returns an instanced SQLiteFactory class. /// </summary> public static readonly SQLiteFactory Instance = new SQLiteFactory(); /// <summary> /// Returns a new SQLiteCommand object. |
︙ |
Changes to test/TestCases.cs.
︙ | |||
1590 1591 1592 1593 1594 1595 1596 | 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 | - - + + - + - - - + | [Test] internal void SetLogCallbackTest() { if (_fact.GetType().Name.IndexOf("SQLite", StringComparison.OrdinalIgnoreCase) > -1) { SQLiteConnection cnn = new SQLiteConnection(_cnnstring.ConnectionString); |
︙ |