Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Initial implementation of SQLITE_CONFIG_LOG interface. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
fc3e41ac858848624097eacec25c8c1a |
User & Date: | shaneh 2011-04-22 18:08:43.571 |
Context
2011-04-22
| ||
18:54 | Revert path setting again, still fails on 64-bit systems. check-in: ef25334cf7 user: shaneh tags: trunk | |
18:08 | Initial implementation of SQLITE_CONFIG_LOG interface. check-in: fc3e41ac85 user: shaneh tags: trunk | |
2011-04-15
| ||
17:33 | Added support for sqlite3_extended_result_codes(), sqlite3_errcode(), and sqlite3_extended_errcode(). check-in: 41ad3433f5 user: shaneh tags: trunk | |
Changes
Changes to SQLite.Interop/src/win/interop.c.
︙ | ︙ | |||
92 93 94 95 96 97 98 | { if(!DbHasProperty(*ppdb, 0, DB_SchemaLoaded)) ENC(*ppdb) = SQLITE_UTF16NATIVE; } return ret; } | < < < < < < < < < < < < < < < < < < | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | { if(!DbHasProperty(*ppdb, 0, DB_SchemaLoaded)) ENC(*ppdb) = SQLITE_UTF16NATIVE; } return ret; } __declspec(dllexport) const char * WINAPI sqlite3_errmsg_interop(sqlite3 *db, int *plen) { const char *pval = sqlite3_errmsg(db); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } |
︙ | ︙ |
Changes to System.Data.SQLite/SQLite3.cs.
︙ | ︙ | |||
96 97 98 99 100 101 102 103 104 105 106 107 108 109 | internal override int Changes { get { return UnsafeNativeMethods.sqlite3_changes(_sql); } } internal override void Open(string strFilename, SQLiteOpenFlagsEnum flags, int maxPoolSize, bool usePool) { if (_sql != null) return; _usePool = usePool; if (usePool) | > > > > > > > > > > > | 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 | internal override int Changes { get { return UnsafeNativeMethods.sqlite3_changes(_sql); } } /// <summary> /// Shutdown the SQLite engine so that it can be restarted with different config options. /// We depend on auto initialization to recover. /// </summary> /// <returns>Returns a result code</returns> internal override int Shutdown() { int rc = UnsafeNativeMethods.sqlite3_shutdown(); return rc; } internal override void Open(string strFilename, SQLiteOpenFlagsEnum flags, int maxPoolSize, bool usePool) { if (_sql != null) return; _usePool = usePool; if (usePool) |
︙ | ︙ | |||
849 850 851 852 853 854 855 | { return UnsafeNativeMethods.sqlite3_aggregate_context(context, 1); } /// Enables or disabled extended result codes returned by SQLite internal override void SetExtendedResultCodes(bool bOnOff) { | < < < < < < < < < < < < | 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 | { return UnsafeNativeMethods.sqlite3_aggregate_context(context, 1); } /// Enables or disabled extended result codes returned by SQLite internal override void SetExtendedResultCodes(bool bOnOff) { UnsafeNativeMethods.sqlite3_extended_result_codes(_sql, (bOnOff ? -1 : 0)); } /// Gets the last SQLite error code internal override int ResultCode() { return UnsafeNativeMethods.sqlite3_errcode(_sql); } /// Gets the last SQLite extended error code internal override int ExtendedResultCode() { return UnsafeNativeMethods.sqlite3_extended_errcode(_sql); } internal override void SetPassword(byte[] passwordBytes) { int n = UnsafeNativeMethods.sqlite3_key(_sql, passwordBytes, passwordBytes.Length); if (n > 0) throw new SQLiteException(n, SQLiteLastError()); } |
︙ | ︙ | |||
905 906 907 908 909 910 911 912 913 914 915 916 917 918 | UnsafeNativeMethods.sqlite3_trace(_sql, func, IntPtr.Zero); } internal override void SetRollbackHook(SQLiteRollbackCallback func) { UnsafeNativeMethods.sqlite3_rollback_hook(_sql, func, IntPtr.Zero); } /// <summary> /// Helper function to retrieve a column of data from an active statement. /// </summary> /// <param name="stmt">The statement being step()'d through</param> /// <param name="index">The column index to retrieve</param> /// <param name="typ">The type of data contained in the column. If Uninitialized, this function will retrieve the datatype information.</param> | > > > > > > > > > > > > > | 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 | UnsafeNativeMethods.sqlite3_trace(_sql, func, IntPtr.Zero); } internal override void SetRollbackHook(SQLiteRollbackCallback func) { UnsafeNativeMethods.sqlite3_rollback_hook(_sql, func, IntPtr.Zero); } /// <summary> /// Allows the setting of a logging callback invoked by SQLite when a /// log event occurs. Only one callback may be set. If NULL is passed, /// the logging callback is unregistered. /// </summary> /// <param name="func">The callback function to invoke.</param> /// <returns>Returns a result code</returns> internal override int SetLogCallback(SQLiteLogCallback func) { int rc = UnsafeNativeMethods.sqlite3_config((int)SQLiteConfigOpsEnum.SQLITE_CONFIG_LOG, func, (IntPtr)0); return rc; } /// <summary> /// Helper function to retrieve a column of data from an active statement. /// </summary> /// <param name="stmt">The statement being step()'d through</param> /// <param name="index">The column index to retrieve</param> /// <param name="typ">The type of data contained in the column. If Uninitialized, this function will retrieve the datatype information.</param> |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteBase.cs.
︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /// </summary> internal abstract string Version { get; } /// <summary> /// Returns the number of changes the last executing insert/update caused. /// </summary> internal abstract int Changes { get; } /// <summary> /// Opens a database. /// </summary> /// <remarks> /// Implementers should call SQLiteFunction.BindFunctions() and save the array after opening a connection /// to bind all attributed user-defined functions and collating sequences to the new connection. /// </remarks> /// <param name="strFilename">The filename of the database to open. SQLite automatically creates it if it doesn't exist.</param> | > > > > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /// </summary> internal abstract string Version { get; } /// <summary> /// Returns the number of changes the last executing insert/update caused. /// </summary> internal abstract int Changes { get; } /// <summary> /// Shutdown the SQLite engine so that it can be restarted with different config options. /// We depend on auto initialization to recover. /// </summary> internal abstract int Shutdown(); /// <summary> /// Opens a database. /// </summary> /// <remarks> /// Implementers should call SQLiteFunction.BindFunctions() and save the array after opening a connection /// to bind all attributed user-defined functions and collating sequences to the new connection. /// </remarks> /// <param name="strFilename">The filename of the database to open. SQLite automatically creates it if it doesn't exist.</param> |
︙ | ︙ | |||
172 173 174 175 176 177 178 179 180 181 182 183 184 185 | internal abstract void SetPassword(byte[] passwordBytes); internal abstract void ChangePassword(byte[] newPasswordBytes); 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 int GetCursorForTable(SQLiteStatement stmt, int database, int rootPage); internal abstract long GetRowIdForCursor(SQLiteStatement stmt, int cursor); internal abstract object GetValue(SQLiteStatement stmt, int index, SQLiteType typ); internal abstract bool AutoCommit | > | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | internal abstract void SetPassword(byte[] passwordBytes); internal abstract void ChangePassword(byte[] newPasswordBytes); 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 int SetLogCallback(SQLiteLogCallback func); internal abstract int GetCursorForTable(SQLiteStatement stmt, int database, int rootPage); internal abstract long GetRowIdForCursor(SQLiteStatement stmt, int cursor); internal abstract object GetValue(SQLiteStatement stmt, int index, SQLiteType typ); internal abstract bool AutoCommit |
︙ | ︙ | |||
284 285 286 287 288 289 290 | None = 0, ReadOnly = 0x01, ReadWrite = 0x02, Create = 0x04, SharedCache = 0x01000000, Default = 0x06, } | | > > > > > > > > > > > > > > > > > > > > > > | 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | None = 0, ReadOnly = 0x01, ReadWrite = 0x02, Create = 0x04, SharedCache = 0x01000000, Default = 0x06, } // These are the options to the internal sqlite3_config call. internal enum SQLiteConfigOpsEnum { SQLITE_CONFIG_SINGLETHREAD = 1, // nil SQLITE_CONFIG_MULTITHREAD = 2, // nil SQLITE_CONFIG_SERIALIZED = 3, // nil SQLITE_CONFIG_MALLOC = 4, // sqlite3_mem_methods* SQLITE_CONFIG_GETMALLOC = 5, // sqlite3_mem_methods* SQLITE_CONFIG_SCRATCH = 6, // void*, int sz, int N SQLITE_CONFIG_PAGECACHE = 7, // void*, int sz, int N SQLITE_CONFIG_HEAP = 8, // void*, int nByte, int min SQLITE_CONFIG_MEMSTATUS = 9, // boolean SQLITE_CONFIG_MUTEX = 10, // sqlite3_mutex_methods* SQLITE_CONFIG_GETMUTEX = 11, // sqlite3_mutex_methods* // previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused SQLITE_CONFIG_LOOKASIDE = 13, // int int SQLITE_CONFIG_PCACHE = 14, // sqlite3_pcache_methods* SQLITE_CONFIG_GETPCACHE = 15, // sqlite3_pcache_methods* SQLITE_CONFIG_LOG = 16, // xFunc, void* } } |
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | ︙ | |||
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; private SQLiteUpdateCallback _updateCallback; private SQLiteCommitCallback _commitCallback; private SQLiteTraceCallback _traceCallback; private SQLiteRollbackCallback _rollbackCallback; /// <summary> /// This event is raised whenever the database is opened or closed. /// </summary> public override event StateChangeEventHandler StateChange; ///<overloads> | > > | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | internal long _version; private event SQLiteUpdateEventHandler _updateHandler; private event SQLiteCommitHandler _commitHandler; private event SQLiteTraceEventHandler _traceHandler; private event EventHandler _rollbackHandler; private event SQLiteLogEventHandler _logHandler; private SQLiteUpdateCallback _updateCallback; private SQLiteCommitCallback _commitCallback; private SQLiteTraceCallback _traceCallback; private SQLiteRollbackCallback _rollbackCallback; private SQLiteLogCallback _logCallback; /// <summary> /// This event is raised whenever the database is opened or closed. /// </summary> public override event StateChangeEventHandler StateChange; ///<overloads> |
︙ | ︙ | |||
440 441 442 443 444 445 446 447 448 449 450 451 452 453 | cnn._transactionLevel = _transactionLevel; cnn._enlistment = _enlistment; cnn._connectionState = _connectionState; cnn._version = _version; cnn._enlistment._transaction._cnn = cnn; cnn._enlistment._disposeConnection = true; _sql = null; _enlistment = null; } #endif if (_sql != null) { _sql.Close(); | > | 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | cnn._transactionLevel = _transactionLevel; cnn._enlistment = _enlistment; cnn._connectionState = _connectionState; cnn._version = _version; cnn._enlistment._transaction._cnn = cnn; cnn._enlistment._disposeConnection = true; _sql = null; _enlistment = null; } #endif if (_sql != null) { _sql.Close(); |
︙ | ︙ | |||
785 786 787 788 789 790 791 | fileName = Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().GetName().CodeBase) + fileName.Substring(1); #endif fileName = ExpandFileName(fileName); } try { bool usePooling = (SQLiteConvert.ToBoolean(FindKey(opts, "Pooling", Boolean.FalseString)) == true); | < < > > > > > > > > > > > > > > | 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 | fileName = Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().GetName().CodeBase) + fileName.Substring(1); #endif fileName = ExpandFileName(fileName); } try { bool usePooling = (SQLiteConvert.ToBoolean(FindKey(opts, "Pooling", Boolean.FalseString)) == true); int maxPoolSize = Convert.ToInt32(FindKey(opts, "Max Pool Size", "100"), CultureInfo.InvariantCulture); _defaultTimeout = Convert.ToInt32(FindKey(opts, "Default Timeout", "30"), CultureInfo.CurrentCulture); _defaultIsolation = (IsolationLevel)Enum.Parse(typeof(IsolationLevel), FindKey(opts, "Default IsolationLevel", "Serializable"), true); if (_defaultIsolation != IsolationLevel.Serializable && _defaultIsolation != IsolationLevel.ReadCommitted) throw new NotSupportedException("Invalid Default IsolationLevel specified"); //string temp = FindKey(opts, "DateTimeFormat", "ISO8601"); //if (String.Compare(temp, "ticks", StringComparison.OrdinalIgnoreCase) == 0) dateFormat = SQLiteDateFormats.Ticks; //else if (String.Compare(temp, "julianday", StringComparison.OrdinalIgnoreCase) == 0) dateFormat = SQLiteDateFormats.JulianDay; if (_sql == null) { bool bUTF16 = (SQLiteConvert.ToBoolean(FindKey(opts, "UseUTF16Encoding", Boolean.FalseString)) == true); SQLiteDateFormats dateFormat = (SQLiteDateFormats)Enum.Parse(typeof(SQLiteDateFormats), 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); if (_sql != null && _logHandler != null) { if (_logCallback == null) _logCallback = new SQLiteLogCallback(LogCallback); if (_logCallback != null) _sql.SetLogCallback(_logCallback); } } SQLiteOpenFlagsEnum flags = SQLiteOpenFlagsEnum.None; if (SQLiteConvert.ToBoolean(FindKey(opts, "FailIfMissing", Boolean.FalseString)) == false) flags |= SQLiteOpenFlagsEnum.Create; if (SQLiteConvert.ToBoolean(FindKey(opts, "Read Only", Boolean.FalseString)) == true) |
︙ | ︙ | |||
971 972 973 974 975 976 977 978 979 980 981 982 983 984 | public override ConnectionState State { get { return _connectionState; } } /// Enables or disabled extended result codes returned by SQLite public void SetExtendedResultCodes(bool bOnOff) { if (_sql != null) _sql.SetExtendedResultCodes(bOnOff); } /// Enables or disabled extended result codes returned by SQLite | > > > > > > > > > > > > > > > > > > > > > > | 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 | public override ConnectionState State { get { return _connectionState; } } /// Passes a shutdown request off to SQLite. public int Shutdown() { // make sure we have an instance of the base class if (_sql == null) { SortedList<string, string> opts = ParseConnectionString(_connectionString); bool bUTF16 = (SQLiteConvert.ToBoolean(FindKey(opts, "UseUTF16Encoding", Boolean.FalseString)) == true); SQLiteDateFormats dateFormat = (SQLiteDateFormats)Enum.Parse(typeof(SQLiteDateFormats), 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); } if (_sql != null) return _sql.Shutdown(); throw new InvalidOperationException("Database connection not active."); } /// Enables or disabled extended result codes returned by SQLite public void SetExtendedResultCodes(bool bOnOff) { if (_sql != null) _sql.SetExtendedResultCodes(bOnOff); } /// Enables or disabled extended result codes returned by SQLite |
︙ | ︙ | |||
2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 | return (e.AbortTransaction == true) ? 1 : 0; } private void RollbackCallback(IntPtr parg) { _rollbackHandler(this, EventArgs.Empty); } } /// <summary> /// The I/O file cache flushing behavior for the connection /// </summary> public enum SynchronizationModes { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 | return (e.AbortTransaction == true) ? 1 : 0; } private void RollbackCallback(IntPtr parg) { _rollbackHandler(this, EventArgs.Empty); } /// <summary> /// This event is raised whenever SQLite raises a logging event. /// </summary> public event SQLiteLogEventHandler Log { add { _logHandler += value; // callback handler will be set/removed at open/close } remove { _logHandler -= value; if (_logHandler==null) { _sql.SetLogCallback(null); _logCallback = null; } } } private void LogCallback(IntPtr puser, int err_code, IntPtr message) { if (_logHandler != null) _logHandler(this, new LogEventArgs(puser, err_code, SQLiteBase.UTF8ToString(message, -1))); } } /// <summary> /// The I/O file cache flushing behavior for the connection /// </summary> public enum SynchronizationModes { |
︙ | ︙ | |||
2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 | Off = 2, } #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif internal delegate void SQLiteUpdateCallback(IntPtr puser, int type, IntPtr database, IntPtr table, Int64 rowid); #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif 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 when a transaction is about to be committed. To roll back a transaction, set the /// rollbackTrans boolean value to true. /// </summary> /// <param name="sender">The connection committing the transaction</param> /// <param name="e">Event arguments on the transaction</param> public delegate void SQLiteCommitHandler(object sender, CommitEventArgs e); | > > > > > > > > | 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 | Off = 2, } #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif internal delegate void SQLiteUpdateCallback(IntPtr puser, int type, IntPtr database, IntPtr table, Int64 rowid); #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif 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); #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif internal delegate void SQLiteLogCallback(IntPtr puser, int err_code, IntPtr message); /// <summary> /// Raised when a transaction is about to be committed. To roll back a transaction, set the /// rollbackTrans boolean value to true. /// </summary> /// <param name="sender">The connection committing the transaction</param> /// <param name="e">Event arguments on the transaction</param> public delegate void SQLiteCommitHandler(object sender, CommitEventArgs e); |
︙ | ︙ | |||
2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 | /// <summary> /// Raised when a statement first begins executing on a given connection /// </summary> /// <param name="sender">The connection executing the statement</param> /// <param name="e">Event arguments on the trace</param> public delegate void SQLiteTraceEventHandler(object sender, TraceEventArgs e); /// <summary> /// Whenever an update event is triggered on a connection, this enum will indicate /// exactly what type of operation is being performed. /// </summary> public enum UpdateEventType { /// <summary> | > > > > > > > | 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 | /// <summary> /// Raised when a statement first begins executing on a given connection /// </summary> /// <param name="sender">The connection executing the statement</param> /// <param name="e">Event arguments on the trace</param> public delegate void SQLiteTraceEventHandler(object sender, TraceEventArgs e); /// <summary> /// Raised when a log event occurs. /// </summary> /// <param name="sender">The current connection</param> /// <param name="e">Event arguments on the trace</param> public delegate void SQLiteLogEventHandler(object sender, LogEventArgs e); /// <summary> /// Whenever an update event is triggered on a connection, this enum will indicate /// exactly what type of operation is being performed. /// </summary> public enum UpdateEventType { /// <summary> |
︙ | ︙ | |||
2448 2449 2450 2451 2452 2453 2454 2455 | public readonly string Statement; internal TraceEventArgs(string statement) { Statement = statement; } } | > > > > > > > > > | > > > > > > > > > > > > > > | 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 | public readonly string Statement; internal TraceEventArgs(string statement) { Statement = statement; } } /// <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; } } } |
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
︙ | ︙ | |||
31 32 33 34 35 36 37 | #endif // USE_INTEROP_DLL #else private const string SQLITE_DLL = "sqlite3"; #endif // This section uses interop calls that also fetch text length to optimize conversion. | | > > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #endif // USE_INTEROP_DLL #else private const string SQLITE_DLL = "sqlite3"; #endif // This section uses interop calls that also fetch text length to optimize conversion. // When using the standard dll, we can replace these calls with normal sqlite calls and // do unoptimized conversions instead afterwards #region interop added textlength calls #if !SQLITE_STANDARD [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_bind_parameter_name_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_database_name_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] |
︙ | ︙ | |||
74 75 76 77 78 79 80 | [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_text_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_text16_interop(IntPtr stmt, int index, out int len); | < < < < < < < < < > > > > > | 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 135 136 137 138 139 140 141 142 143 | [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_text_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_column_text16_interop(IntPtr stmt, int index, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_errmsg_interop(IntPtr db, out int len); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_prepare_interop(IntPtr db, IntPtr pSql, int nBytes, out IntPtr stmt, out IntPtr ptrRemain, out int nRemain); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_table_column_metadata_interop(IntPtr db, byte[] dbName, byte[] tblName, byte[] colName, out IntPtr ptrDataType, out IntPtr ptrCollSeq, out int notNull, out int primaryKey, out int autoInc, out int dtLen, out int csLen); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_value_text_interop(IntPtr p, out int len); [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_value_text16_interop(IntPtr p, out int len); #endif // !SQLITE_STANDARD #endregion // These functions add existing functionality on top of SQLite and require a little effort to // get working when using the standard SQLite library. #region interop added functionality #if !SQLITE_STANDARD [DllImport(SQLITE_DLL)] internal static extern int sqlite3_close_interop(IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_create_function_interop(IntPtr db, byte[] strName, int nArgs, int nType, IntPtr pvUser, SQLiteCallback func, SQLiteCallback fstep, SQLiteFinalCallback ffinal, int needCollSeq); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_finalize_interop(IntPtr stmt); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_open_interop(byte[] utf8Filename, int flags, out IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_open16_interop(byte[] utf8Filename, int flags, out IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_reset_interop(IntPtr stmt); #endif // !SQLITE_STANDARD #endregion // The standard api call equivalents of the above interop calls #region standard versions of interop functions #if SQLITE_STANDARD #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_close(IntPtr db); |
︙ | ︙ | |||
268 269 270 271 272 273 274 | [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_text16(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else | < < < < < < < < < < < < < < < < < < < < < | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_column_text16(IntPtr stmt, int index); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_errmsg(IntPtr db); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else |
︙ | ︙ | |||
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_value_text16(IntPtr p); #endif #endregion // These functions are custom and have no equivalent standard library method. // All of them are "nice to haves" and not necessarily "need to haves". #region no equivalent standard method #if !SQLITE_STANDARD [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_context_collseq(IntPtr context, out int type, out int enc, out int len); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_context_collcompare(IntPtr context, byte[] p1, int p1len, byte[] p2, int p2len); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_cursor_rowid(IntPtr stmt, int cursor, out long rowid); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_index_column_info_interop(IntPtr db, byte[] catalog, byte[] IndexName, byte[] ColumnName, out int sortOrder, out int onError, out IntPtr Collation, out int colllen); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_resetall_interop(IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_table_cursor(IntPtr stmt, int db, int tableRootPage); #endif #endregion // Standard API calls global across versions. There are a few instances of interop calls // scattered in here, but they are only active when PLATFORM_COMPACTFRAMEWORK is declared. #region standard sqlite api calls | > > > > > | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_value_text16(IntPtr p); #endif // SQLITE_STANDARD #endregion // These functions are custom and have no equivalent standard library method. // All of them are "nice to haves" and not necessarily "need to haves". #region no equivalent standard method #if !SQLITE_STANDARD [DllImport(SQLITE_DLL)] internal static extern IntPtr sqlite3_context_collseq(IntPtr context, out int type, out int enc, out int len); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_context_collcompare(IntPtr context, byte[] p1, int p1len, byte[] p2, int p2len); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_cursor_rowid(IntPtr stmt, int cursor, out long rowid); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_index_column_info_interop(IntPtr db, byte[] catalog, byte[] IndexName, byte[] ColumnName, out int sortOrder, out int onError, out IntPtr Collation, out int colllen); [DllImport(SQLITE_DLL)] internal static extern void sqlite3_resetall_interop(IntPtr db); [DllImport(SQLITE_DLL)] internal static extern int sqlite3_table_cursor(IntPtr stmt, int db, int tableRootPage); #endif // !SQLITE_STANDARD #endregion // Standard API calls global across versions. There are a few instances of interop calls // scattered in here, but they are only active when PLATFORM_COMPACTFRAMEWORK is declared. #region standard sqlite api calls |
︙ | ︙ | |||
375 376 377 378 379 380 381 382 383 384 385 386 387 388 | #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_changes(IntPtr db); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_busy_timeout(IntPtr db, int ms); | > > > > > > > | 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_changes(IntPtr db); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_shutdown(); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_busy_timeout(IntPtr db, int ms); |
︙ | ︙ | |||
670 671 672 673 674 675 676 677 678 679 680 681 682 683 | #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_rollback_hook(IntPtr db, SQLiteRollbackCallback func, IntPtr pvUser); | > > > > > > > > > | 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 | #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. For now, we are only exposing the SQLITE_CONFIG_LOG call. #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_config(int op, SQLiteLogCallback func, IntPtr pvUser); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern IntPtr sqlite3_rollback_hook(IntPtr db, SQLiteRollbackCallback func, IntPtr pvUser); |
︙ | ︙ | |||
704 705 706 707 708 709 710 711 712 713 714 715 716 717 | #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_get_autocommit(IntPtr db); #endregion } #if PLATFORM_COMPACTFRAMEWORK internal abstract class CriticalHandle : IDisposable { | > > > > > > > > > > > > > > > > > > > > > > | 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 | #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_get_autocommit(IntPtr db); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_extended_result_codes(IntPtr db, int onoff); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_errcode(IntPtr db); #if !PLATFORM_COMPACTFRAMEWORK [DllImport(SQLITE_DLL, CallingConvention = CallingConvention.Cdecl)] #else [DllImport(SQLITE_DLL)] #endif internal static extern int sqlite3_extended_errcode(IntPtr db); #endregion } #if PLATFORM_COMPACTFRAMEWORK internal abstract class CriticalHandle : IDisposable { |
︙ | ︙ |
Changes to test/TestCases.cs.
︙ | ︙ | |||
1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 | // Turn on extended result codes cnn.SetExtendedResultCodes(true); int rc = cnn.ResultCode(); int xrc = cnn.ExtendedResultCode(); cnn.Close(); } } /// <summary> /// Open a reader and then attempt to write to test the writer's command timeout property /// SQLite doesn't allow a write when a reader is active. /// *** NOTE AS OF 3.3.8 this test no longer blocks because SQLite now allows you to update table(s) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 | // Turn on extended result codes cnn.SetExtendedResultCodes(true); int rc = cnn.ResultCode(); int xrc = cnn.ExtendedResultCode(); cnn.Close(); } } //Applying EventHandler public void OnLogEvent(object sender, LogEventArgs logEvent) { int err_code = logEvent.ErrorCode; string err_msg = logEvent.Message; } /// <summary> /// Tests SQLITE_CONFIG_LOG support. /// </summary> [Test] internal void SetLogCallbackTest() { if (_factstring.ToLower().Contains("sqlite")) { SQLiteConnection cnn = new SQLiteConnection(_cnnstring.ConnectionString); cnn.Shutdown(); // we need to shutdown so that we can change config options SQLiteLogEventHandler logHandler = new SQLiteLogEventHandler(OnLogEvent); cnn.Log += logHandler; cnn.Open(); maydroptable.Add("LogCallbackTest"); if (cnn.State != ConnectionState.Open) cnn.Open(); using (DbCommand cmd = cnn.CreateCommand()) { cmd.CommandText = "CREATE TABLE LogCallbackTest(ID int primary key)"; cmd.ExecuteNonQuery(); } cnn.Close(); cnn.Shutdown(); // we need to shutdown so that we can change config options // remove the log handler before the connection is closed. cnn.Log -= logHandler; } } /// <summary> /// Open a reader and then attempt to write to test the writer's command timeout property /// SQLite doesn't allow a write when a reader is active. /// *** NOTE AS OF 3.3.8 this test no longer blocks because SQLite now allows you to update table(s) |
︙ | ︙ |