Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Refactor how logging flags and exception handling are performed. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
6fbb8f60e9f1d27b5ec83d1cfa7c209c |
User & Date: | mistachkin 2017-10-10 21:40:50.281 |
Context
2017-10-10
| ||
21:45 | Use the 'getTemporaryDirectory' helper procedure in the test suite. check-in: f4e188e696 user: mistachkin tags: trunk | |
21:41 | Merge updates from trunk. check-in: 0b70bd2e0e user: mistachkin tags: sessions | |
21:40 | Refactor how logging flags and exception handling are performed. check-in: 6fbb8f60e9 user: mistachkin tags: trunk | |
05:53 | Pickup further release archive verification tool changes from upstream. check-in: 2ada6a698f user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLite3.cs.
︙ | |||
1340 1341 1342 1343 1344 1345 1346 | 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 | - + | SQLiteConnectionFlags flags = (cnn != null) ? cnn.Flags : SQLiteConnectionFlags.Default; if ( #if !PLATFORM_COMPACTFRAMEWORK ForceLogPrepare() || #endif |
︙ | |||
1608 1609 1610 1611 1612 1613 1614 | 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 | - + - + - + | handleIntPtr, index, typeof(Byte[]), (value != null) ? ToHexadecimalString(value) : "<null>")); } internal override void Bind_Double(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, double value) { SQLiteStatementHandle handle = stmt._sqlite_stmt; |
︙ | |||
1671 1672 1673 1674 1675 1676 1677 | 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 | - + - + - + - + - + - + | if (n != SQLiteErrorCode.Ok) throw new SQLiteException(n, GetLastError()); } internal override void Bind_Int64(SQLiteStatement stmt, SQLiteConnectionFlags flags, int index, long value) { SQLiteStatementHandle handle = stmt._sqlite_stmt; |
︙ | |||
1770 1771 1772 1773 1774 1775 1776 | 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 | - + - + - + - + - + - + - + | switch (_datetimeFormat) { case SQLiteDateFormats.Ticks: { long value = dt.Ticks; |
︙ | |||
1901 1902 1903 1904 1905 1906 1907 | 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 | - + - + | #if !SQLITE_STANDARD int len = 0; name = UTF8ToString(UnsafeNativeMethods.sqlite3_bind_parameter_name_interop(handle, index, ref len), len); #else name = UTF8ToString(UnsafeNativeMethods.sqlite3_bind_parameter_name(handle, index), -1); #endif |
︙ | |||
2535 2536 2537 2538 2539 2540 2541 | 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 | - + - - + + | /// The flags for the associated <see cref="SQLiteConnection" /> object instance. /// </param> internal override void CreateModule(SQLiteModule module, SQLiteConnectionFlags flags) { if (module == null) throw new ArgumentNullException("module"); |
︙ |
Changes to System.Data.SQLite/SQLite3_UTF16.cs.
︙ | |||
256 257 258 259 260 261 262 | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | - + - + | { base.Bind_DateTime(stmt, flags, index, dt); break; } default: { #if !PLATFORM_COMPACTFRAMEWORK |
︙ |
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | |||
1976 1977 1978 1979 1980 1981 1982 | 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 | - + | // if (pages == 0) break; } } catch (Exception e) { |
︙ | |||
6307 6308 6309 6310 6311 6312 6313 | 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 | - - + - - + + | return eventArgs.ReturnCode; } catch (Exception e) /* NOTE: Must catch ALL. */ { try { |
︙ | |||
6360 6361 6362 6363 6364 6365 6366 | 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 | - - + - - + + | return eventArgs.ReturnCode; } catch (Exception e) /* NOTE: Must catch ALL. */ { try { |
︙ | |||
6409 6410 6411 6412 6413 6414 6415 | 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 | - - + - - + + | (UpdateEventType)type, rowid)); } catch (Exception e) /* NOTE: Must catch ALL. */ { try { |
︙ | |||
6500 6501 6502 6503 6504 6505 6506 | 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 | - - + - - + + | _traceHandler(this, new TraceEventArgs( SQLiteBase.UTF8ToString(statement, -1))); } catch (Exception e) /* NOTE: Must catch ALL. */ { try { |
︙ | |||
6562 6563 6564 6565 6566 6567 6568 | 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 | - - + - - + + | return (e.AbortTransaction == true) ? 1 : 0; } catch (Exception e) /* NOTE: Must catch ALL. */ { try { |
︙ | |||
6604 6605 6606 6607 6608 6609 6610 | 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 | - - + - - + + | if (_rollbackHandler != null) _rollbackHandler(this, EventArgs.Empty); } catch (Exception e) /* NOTE: Must catch ALL. */ { try { |
︙ |
Changes to System.Data.SQLite/SQLiteFunction.cs.
︙ | |||
412 413 414 415 416 417 418 | 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | - - + - - + + | SetReturnValue(context, Invoke(ConvertParams(nArgs, argsptr))); /* throw */ } catch (Exception e) /* NOTE: Must catch ALL. */ { try { |
︙ | |||
450 451 452 453 454 455 456 | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | - - + - - + + | return Compare(SQLiteConvert.UTF8ToString(ptr1, len1), SQLiteConvert.UTF8ToString(ptr2, len2)); /* throw */ } catch (Exception e) /* NOTE: Must catch ALL. */ { try { |
︙ | |||
497 498 499 500 501 502 503 | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | - - + - - + + | return Compare(SQLite3_UTF16.UTF16ToString(ptr1, len1), SQLite3_UTF16.UTF16ToString(ptr2, len2)); /* throw */ } catch (Exception e) /* NOTE: Must catch ALL. */ { try { |
︙ | |||
570 571 572 573 574 575 576 | 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | - - + - - + + | data._count++; } } catch (Exception e) /* NOTE: Must catch ALL. */ { try { |
︙ | |||
625 626 627 628 629 630 631 | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | - - + - - + + | if (disp != null) disp.Dispose(); /* throw */ } } catch (Exception e) /* NOTE: Must catch ALL. */ { try { |
︙ |
Changes to System.Data.SQLite/SQLiteModule.cs.
︙ | |||
5585 5586 5587 5588 5589 5590 5591 | 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 | - + | { if (LogExceptionsNoThrow) { /* throw */ SQLiteLog.LogMessage(SQLiteBase.COR_E_EXCEPTION, HelperMethods.StringFormat( CultureInfo.CurrentCulture, |
︙ | |||
5693 5694 5695 5696 5697 5698 5699 | 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 | - - + + | try { if (logExceptions) { SQLiteLog.LogMessage(SQLiteBase.COR_E_EXCEPTION, HelperMethods.StringFormat( CultureInfo.CurrentCulture, |
︙ | |||
8149 8150 8151 8152 8153 8154 8155 | 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 | - - + + | try { if (LogExceptionsNoThrow) { SQLiteLog.LogMessage(SQLiteBase.COR_E_EXCEPTION, HelperMethods.StringFormat( CultureInfo.CurrentCulture, |
︙ |
Changes to System.Data.SQLite/SQLiteStatement.cs.
︙ | |||
395 396 397 398 399 400 401 | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | - + | object obj = param.Value; DbType objType = param.DbType; if ((obj != null) && (objType == DbType.Object)) objType = SQLiteConvert.TypeToDbType(obj.GetType()); |
︙ |
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
︙ | |||
281 282 283 284 285 286 287 288 289 290 291 292 293 294 | 281 282 283 284 285 286 287 288 289 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 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 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } #endregion ///////////////////////////////////////////////////////////////////////// #region Internal Methods /// <summary> /// Determines if preparing a query should be logged. /// </summary> /// <param name="flags"> /// The flags associated with the parent connection object. /// </param> /// <returns> /// Non-zero if the query preparation should be logged; otherwise, zero. /// </returns> internal static bool LogPrepare( SQLiteConnectionFlags flags ) { flags &= SQLiteConnectionFlags.LogPrepare; return (flags == SQLiteConnectionFlags.LogPrepare); } ///////////////////////////////////////////////////////////////////////// /// <summary> /// Determines if pre-parameter binding should be logged. /// </summary> /// <param name="flags"> /// The flags associated with the parent connection object. /// </param> /// <returns> /// Non-zero if the pre-parameter binding should be logged; otherwise, /// zero. /// </returns> internal static bool LogPreBind( SQLiteConnectionFlags flags ) { flags &= SQLiteConnectionFlags.LogPreBind; return (flags == SQLiteConnectionFlags.LogPreBind); } ///////////////////////////////////////////////////////////////////////// /// <summary> /// Determines if parameter binding should be logged. /// </summary> /// <param name="flags"> /// The flags associated with the parent connection object. /// </param> /// <returns> /// Non-zero if the parameter binding should be logged; otherwise, zero. /// </returns> internal static bool LogBind( SQLiteConnectionFlags flags ) { flags &= SQLiteConnectionFlags.LogBind; return (flags == SQLiteConnectionFlags.LogBind); } ///////////////////////////////////////////////////////////////////////// /// <summary> /// Determines if an exception in a native callback should be logged. /// </summary> /// <param name="flags"> /// The flags associated with the parent connection object. /// </param> /// <returns> /// Non-zero if the exception should be logged; otherwise, zero. /// </returns> internal static bool LogCallbackExceptions( SQLiteConnectionFlags flags ) { flags &= SQLiteConnectionFlags.LogCallbackException; return (flags == SQLiteConnectionFlags.LogCallbackException); } ///////////////////////////////////////////////////////////////////////// /// <summary> /// Determines if backup API errors should be logged. /// </summary> /// <param name="flags"> /// The flags associated with the parent connection object. /// </param> /// <returns> /// Non-zero if the backup API error should be logged; otherwise, zero. /// </returns> internal static bool LogBackup( SQLiteConnectionFlags flags ) { flags &= SQLiteConnectionFlags.LogBackup; return (flags == SQLiteConnectionFlags.LogBackup); } #if INTEROP_VIRTUAL_TABLE ///////////////////////////////////////////////////////////////////////// /// <summary> /// Determines if logging for the <see cref="SQLiteModule" /> class is /// disabled. /// </summary> /// <param name="flags"> /// The flags associated with the parent connection object. /// </param> /// <returns> /// Non-zero if logging for the <see cref="SQLiteModule" /> class is /// disabled; otherwise, zero. /// </returns> internal static bool NoLogModule( SQLiteConnectionFlags flags ) { flags &= SQLiteConnectionFlags.NoLogModule; return (flags == SQLiteConnectionFlags.NoLogModule); } ///////////////////////////////////////////////////////////////////////// /// <summary> /// Determines if <see cref="SQLiteModule" /> errors should be logged. /// </summary> /// <param name="flags"> /// The flags associated with the parent connection object. /// </param> /// <returns> /// Non-zero if the <see cref="SQLiteModule" /> error should be logged; /// otherwise, zero. /// </returns> internal static bool LogModuleError( SQLiteConnectionFlags flags ) { flags &= SQLiteConnectionFlags.LogModuleError; return (flags == SQLiteConnectionFlags.LogModuleError); } ///////////////////////////////////////////////////////////////////////// /// <summary> /// Determines if <see cref="SQLiteModule" /> exceptions should be /// logged. /// </summary> /// <param name="flags"> /// The flags associated with the parent connection object. /// </param> /// <returns> /// Non-zero if the <see cref="SQLiteModule" /> exception should be /// logged; otherwise, zero. /// </returns> internal static bool LogModuleException( SQLiteConnectionFlags flags ) { flags &= SQLiteConnectionFlags.LogModuleException; return (flags == SQLiteConnectionFlags.LogModuleException); } #endif ///////////////////////////////////////////////////////////////////////// /// <summary> /// Determines if the current process is running on one of the Windows /// [sub-]platforms. /// </summary> /// <returns> /// Non-zero when running on Windows; otherwise, zero. /// </returns> internal static bool IsWindows() |
︙ | |||
604 605 606 607 608 609 610 611 612 613 614 615 616 617 | 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 | + + + + + | /// This class declares P/Invoke methods to call native SQLite APIs. /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [SuppressUnmanagedCodeSecurity] #endif internal static class UnsafeNativeMethods { public const string ExceptionMessageFormat = "Caught exception in \"{0}\" method: {1}"; ///////////////////////////////////////////////////////////////////////// #region Shared Native SQLite Library Pre-Loading Code #region Private Constants /// <summary> /// The file extension used for dynamic link libraries. /// </summary> private static readonly string DllFileExtension = ".dll"; |
︙ |