System.Data.SQLite

Check-in [92f1a8d6b9]
Login

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

Overview
Comment:Cache the assembly directory used by the configuration subsystem.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 92f1a8d6b95e5c0da372cd25474c51ba2cbd59f4
User & Date: mistachkin 2017-05-11 01:30:21.614
References
2017-05-11
15:48
Cherrypick of [92f1a8d6b95e5c0d], [2621aa6f2e116d71], [060be3824767ba41], and [4fdd8dee13b40da2], cache the assembly directory and XML configuration file name. check-in: defe7832c2 user: mistachkin tags: branch-1.0.105
Context
2017-05-11
15:48
Cherrypick of [92f1a8d6b95e5c0d], [2621aa6f2e116d71], [060be3824767ba41], and [4fdd8dee13b40da2], cache the assembly directory and XML configuration file name. check-in: defe7832c2 user: mistachkin tags: branch-1.0.105
01:45
Add a missing '#if DEBUG' in the DebugData class. check-in: 2621aa6f2e user: mistachkin tags: trunk
01:30
Cache the assembly directory used by the configuration subsystem. check-in: 92f1a8d6b9 user: mistachkin tags: trunk
01:23
Make sure the 'No_SQLiteConnectionNewParser' and 'DefaultFlags_SQLiteConnection' setting values end up being cached. check-in: cee7126f56 user: mistachkin tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to Doc/Extra/Provider/version.html.
44
45
46
47
48
49
50

51
52
53
54
55
56
57
    <div id="mainBody">
    <h1 class="heading">Version History</h1>
    <p><b>1.0.106.0 - June XX, 2017 <font color="red">(release scheduled)</font></b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/draft/releaselog/3_19_0.html">SQLite 3.19.0</a>.</li>
      <li>Prevent culture settings from negatively impacting integer connection string defaults.</li>
      <li>Make sure the &quot;No_SQLiteConnectionNewParser&quot; and &quot;DefaultFlags_SQLiteConnection&quot; setting values end up being cached.</li>

    </ul>
    <p><b>1.0.105.0 - April 9, 2017</b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_18_0.html">SQLite 3.18.0</a>.</li>
      <li>Add experimental support for native sha1 extension.</li>
    </ul>
    <p><b>1.0.104.0 - December 16, 2016</b></p>







>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    <div id="mainBody">
    <h1 class="heading">Version History</h1>
    <p><b>1.0.106.0 - June XX, 2017 <font color="red">(release scheduled)</font></b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/draft/releaselog/3_19_0.html">SQLite 3.19.0</a>.</li>
      <li>Prevent culture settings from negatively impacting integer connection string defaults.</li>
      <li>Make sure the &quot;No_SQLiteConnectionNewParser&quot; and &quot;DefaultFlags_SQLiteConnection&quot; setting values end up being cached.</li>
      <li>Cache the assembly directory used by the configuration subsystem.</li>
    </ul>
    <p><b>1.0.105.0 - April 9, 2017</b></p>
    <ul>
      <li>Updated to <a href="https://www.sqlite.org/releaselog/3_18_0.html">SQLite 3.18.0</a>.</li>
      <li>Add experimental support for native sha1 extension.</li>
    </ul>
    <p><b>1.0.104.0 - December 16, 2016</b></p>
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
43
44
45
46
47
48
49







50
51
52
53
54
55
56
  /// <summary>
  /// This class encapsulates some tracking data that is used for debugging
  /// and testing purposes.
  /// </summary>
  internal static class DebugData
  {
      #region Private Data







      #region Critical Handle Counts (Debug Build Only)
#if COUNT_HANDLE
      //
      // NOTE: These counts represent the total number of outstanding
      //       (non-disposed) CriticalHandle derived object instances
      //       created by this library and are primarily for use by
      //       the test suite.  These counts are incremented by the







>
>
>
>
>
>
>







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  /// <summary>
  /// This class encapsulates some tracking data that is used for debugging
  /// and testing purposes.
  /// </summary>
  internal static class DebugData
  {
      #region Private Data
      /// <summary>
      /// This lock is used to protect several static fields.
      /// </summary>
      private static readonly object staticSyncRoot = new object();

      /////////////////////////////////////////////////////////////////////////

      #region Critical Handle Counts (Debug Build Only)
#if COUNT_HANDLE
      //
      // NOTE: These counts represent the total number of outstanding
      //       (non-disposed) CriticalHandle derived object instances
      //       created by this library and are primarily for use by
      //       the test suite.  These counts are incremented by the
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
      #endregion

      /////////////////////////////////////////////////////////////////////////

      #region Settings Read Counts (Debug Build Only)
#if DEBUG
      /// <summary>
      /// This lock is used to protect the static
      /// <see cref="settingReadCounts" /> field.
      /// </summary>
      private static readonly object staticSyncRoot = new object();

      /////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// This dictionary stores the read counts for the runtime configuration
      /// settings.  This information is only recorded when compiled in the
      /// "Debug" build configuration.
      /// </summary>
      private static Dictionary<string, int> settingReadCounts;

      /////////////////////////////////////////////////////////////////////////

      /// <summary>
      /// This dictionary stores the read counts for the runtime configuration
      /// settings via the XML configuration file.  This information is only
      /// recorded when compiled in the "Debug" build configuration.
      /// </summary>
      private static Dictionary<string, int> settingFileReadCounts;
#endif
      #endregion













      #endregion

      /////////////////////////////////////////////////////////////////////////

      #region Public Methods
#if DEBUG
      /// <summary>
      /// Creates dictionaries used to store the read counts for each of
      /// the runtime configuration settings.  These numbers are used for
      /// debugging and testing purposes only.
      /// </summary>
      public static void InitializeSettingReadCounts()
      {
          lock (staticSyncRoot)
          {
              //
              // NOTE: Create the dictionaries of statistics that will
              //       contain the number of times each setting value
              //       has been read.
              //
              if (settingReadCounts == null)
                  settingReadCounts = new Dictionary<string, int>();

              if (settingFileReadCounts == null)
                  settingFileReadCounts = new Dictionary<string, int>();



          }
      }

      /////////////////////////////////////////////////////////////////////////

      /// <summary>
      /// Increments the read count for the specified runtime configuration







<
<
<
<
<
<
<
















>
>
>
>
>
>
>
>
>
>
>
>
>











|













>
>
>







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
135
136
137
138
139
140
141
142
143
      #endregion

      /////////////////////////////////////////////////////////////////////////

      #region Settings Read Counts (Debug Build Only)
#if DEBUG
      /// <summary>







      /// This dictionary stores the read counts for the runtime configuration
      /// settings.  This information is only recorded when compiled in the
      /// "Debug" build configuration.
      /// </summary>
      private static Dictionary<string, int> settingReadCounts;

      /////////////////////////////////////////////////////////////////////////

      /// <summary>
      /// This dictionary stores the read counts for the runtime configuration
      /// settings via the XML configuration file.  This information is only
      /// recorded when compiled in the "Debug" build configuration.
      /// </summary>
      private static Dictionary<string, int> settingFileReadCounts;
#endif
      #endregion

      /////////////////////////////////////////////////////////////////////////

      #region Other Counts (Debug Build Only)
#if DEBUG
      /// <summary>
      /// This dictionary stores miscellaneous counts used for debugging
      /// purposes.  This information is only recorded when compiled in the
      /// "Debug" build configuration.
      /// </summary>
      private static Dictionary<string, int> otherCounts;
#endif
      #endregion
      #endregion

      /////////////////////////////////////////////////////////////////////////

      #region Public Methods
#if DEBUG
      /// <summary>
      /// Creates dictionaries used to store the read counts for each of
      /// the runtime configuration settings.  These numbers are used for
      /// debugging and testing purposes only.
      /// </summary>
      public static void Initialize()
      {
          lock (staticSyncRoot)
          {
              //
              // NOTE: Create the dictionaries of statistics that will
              //       contain the number of times each setting value
              //       has been read.
              //
              if (settingReadCounts == null)
                  settingReadCounts = new Dictionary<string, int>();

              if (settingFileReadCounts == null)
                  settingFileReadCounts = new Dictionary<string, int>();

              if (otherCounts == null)
                  otherCounts = new Dictionary<string, int>();
          }
      }

      /////////////////////////////////////////////////////////////////////////

      /// <summary>
      /// Increments the read count for the specified runtime configuration
167
168
169
170
171
172
173


























174
175
176
177
178
179
180
                          settingReadCounts[name] = count + 1;
                      else
                          settingReadCounts.Add(name, 1);
                  }
              }
          }
      }


























#endif
      #endregion
  }
#endif
  #endregion

  /////////////////////////////////////////////////////////////////////////////







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
                          settingReadCounts[name] = count + 1;
                      else
                          settingReadCounts.Add(name, 1);
                  }
              }
          }
      }

      /////////////////////////////////////////////////////////////////////////

      /// <summary>
      /// Increments the specified counter.
      /// </summary>
      /// <param name="name">
      /// The name of the counter being incremented.
      /// </param>
      public static void IncrementOtherCount(
          string name
          )
      {
          lock (staticSyncRoot)
          {
              if (otherCounts != null)
              {
                  int count;

                  if (otherCounts.TryGetValue(name, out count))
                      otherCounts[name] = count + 1;
                  else
                      otherCounts.Add(name, 1);
              }
          }
      }
#endif
      #endregion
  }
#endif
  #endregion

  /////////////////////////////////////////////////////////////////////////////
634
635
636
637
638
639
640








641
642
643
644
645
646
647
      /// purposes.  First, they are used to determine if the assembly code
      /// base should be used instead of the location, based upon whether one
      /// or more of the named sub-directories exist within the assembly code
      /// base.  Second, they are used to assist in loading the appropriate
      /// SQLite interop assembly into the current process.
      /// </summary>
      private static Dictionary<string, string> processorArchitecturePlatforms;








      #endregion

      /////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// For now, this method simply calls the Initialize method.
      /// </summary>
      static UnsafeNativeMethods()







>
>
>
>
>
>
>
>







676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
      /// purposes.  First, they are used to determine if the assembly code
      /// base should be used instead of the location, based upon whether one
      /// or more of the named sub-directories exist within the assembly code
      /// base.  Second, they are used to assist in loading the appropriate
      /// SQLite interop assembly into the current process.
      /// </summary>
      private static Dictionary<string, string> processorArchitecturePlatforms;

      /////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// This is the cached return value from the
      /// <see cref="GetAssemblyDirectory" /> method -OR- null if that method
      /// has never returned a valid value.
      /// </summary>
      private static string cachedAssemblyDirectory;
      #endregion

      /////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// For now, this method simply calls the Initialize method.
      /// </summary>
      static UnsafeNativeMethods()
666
667
668
669
670
671
672
673

674
675
676
677
678
679
680
681
682
683
              return;
#endif
#endif

          #region Debug Build Only
#if DEBUG
          //
          // NOTE: Create the list of statistics that will contain the

          //       number of times each setting value has been read.
          //
          DebugData.InitializeSettingReadCounts();
#endif
          #endregion

          lock (staticSyncRoot)
          {
              //
              // TODO: Make sure this list is updated if the supported







|
>


|







716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
              return;
#endif
#endif

          #region Debug Build Only
#if DEBUG
          //
          // NOTE: Create the lists of statistics that will contain
          //       various counts used in debugging, including the
          //       number of times each setting value has been read.
          //
          DebugData.Initialize();
#endif
          #endregion

          lock (staticSyncRoot)
          {
              //
              // TODO: Make sure this list is updated if the supported
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
          directory = AppDomain.CurrentDomain.BaseDirectory;
          fileName = MaybeCombinePath(directory, XmlConfigFileName);

          if (File.Exists(fileName))
              return fileName;
#endif

          directory = GetAssemblyDirectory();
          fileName = MaybeCombinePath(directory, XmlConfigFileName);

          if (File.Exists(fileName))
              return fileName;

          return null;
      }







|







839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
          directory = AppDomain.CurrentDomain.BaseDirectory;
          fileName = MaybeCombinePath(directory, XmlConfigFileName);

          if (File.Exists(fileName))
              return fileName;
#endif

          directory = GetCachedAssemblyDirectory();
          fileName = MaybeCombinePath(directory, XmlConfigFileName);

          if (File.Exists(fileName))
              return fileName;

          return null;
      }
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
      /// </returns>
      private static string ReplaceEnvironmentVariableTokens(
          string value
          )
      {
          if (!String.IsNullOrEmpty(value))
          {
              string directory = GetAssemblyDirectory();

              if (!String.IsNullOrEmpty(directory))
              {
                  try
                  {
                      value = value.Replace(
                          AssemblyDirectoryToken, directory);







|







1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
      /// </returns>
      private static string ReplaceEnvironmentVariableTokens(
          string value
          )
      {
          if (!String.IsNullOrEmpty(value))
          {
              string directory = GetCachedAssemblyDirectory();

              if (!String.IsNullOrEmpty(directory))
              {
                  try
                  {
                      value = value.Replace(
                          AssemblyDirectoryToken, directory);
1445
1446
1447
1448
1449
1450
1451

















































1452
1453
1454
1455
1456
1457
1458
1459
1460






1461
1462
1463
1464
1465
1466
1467

          return false;
      }
#endif

      /////////////////////////////////////////////////////////////////////////
      /// <summary>

















































      /// Queries and returns the directory for the assembly currently being
      /// executed.
      /// </summary>
      /// <returns>
      /// The directory for the assembly currently being executed -OR- null if
      /// it cannot be determined.
      /// </returns>
      private static string GetAssemblyDirectory()
      {






          try
          {
              Assembly assembly = Assembly.GetExecutingAssembly();

              if (assembly == null)
                  return null;








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









>
>
>
>
>
>







1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
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

          return false;
      }
#endif

      /////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// Resets the cached assembly directory value, thus forcing the next
      /// call to <see cref="GetCachedAssemblyDirectory" /> method to rely
      /// upon the <see cref="GetAssemblyDirectory" /> method to fetch the
      /// assembly directory.
      /// </summary>
      private static void ResetCachedAssemblyDirectory()
      {
          #region Debug Build Only
#if DEBUG
          DebugData.IncrementOtherCount("Method_ResetCachedAssemblyDirectory");
#endif
          #endregion

          lock (staticSyncRoot)
          {
              cachedAssemblyDirectory = null;
          }
      }

      /////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// Queries and returns the cached directory for the assembly currently
      /// being executed, if available.  If the cached assembly directory value
      /// is not available, the <see cref="GetAssemblyDirectory" /> method will
      /// be used to obtain the assembly directory.
      /// </summary>
      /// <returns>
      /// The directory for the assembly currently being executed -OR- null if
      /// it cannot be determined.
      /// </returns>
      private static string GetCachedAssemblyDirectory()
      {
          #region Debug Build Only
#if DEBUG
          DebugData.IncrementOtherCount("Method_GetCachedAssemblyDirectory");
#endif
          #endregion

          lock (staticSyncRoot)
          {
              if (cachedAssemblyDirectory != null)
                  return cachedAssemblyDirectory;
          }

          return GetAssemblyDirectory();
      }

      /////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// Queries and returns the directory for the assembly currently being
      /// executed.
      /// </summary>
      /// <returns>
      /// The directory for the assembly currently being executed -OR- null if
      /// it cannot be determined.
      /// </returns>
      private static string GetAssemblyDirectory()
      {
          #region Debug Build Only
#if DEBUG
          DebugData.IncrementOtherCount("Method_GetAssemblyDirectory");
#endif
          #endregion

          try
          {
              Assembly assembly = Assembly.GetExecutingAssembly();

              if (assembly == null)
                  return null;

1482
1483
1484
1485
1486
1487
1488





1489
1490
1491
1492
1493
1494
1495
              if (String.IsNullOrEmpty(fileName))
                  return null;

              string directory = Path.GetDirectoryName(fileName);

              if (String.IsNullOrEmpty(directory))
                  return null;






              return directory;
          }
#if !NET_COMPACT_20 && TRACE_SHARED
          catch (Exception e)
#else
          catch (Exception)







>
>
>
>
>







1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
              if (String.IsNullOrEmpty(fileName))
                  return null;

              string directory = Path.GetDirectoryName(fileName);

              if (String.IsNullOrEmpty(directory))
                  return null;

              lock (staticSyncRoot)
              {
                  cachedAssemblyDirectory = directory;
              }

              return directory;
          }
#if !NET_COMPACT_20 && TRACE_SHARED
          catch (Exception e)
#else
          catch (Exception)
Changes to Tests/basic.eagle.
4564
4565
4566
4567
4568
4569
4570














































4571
4572
4573
4574
4575
4576
4577

  object unimport -importpattern System.Threading
  object unimport -importpattern System.Globalization
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
defineConstant.System.Data.SQLite.INTEROP_SHA1_EXTENSION System.Data.SQLite\
SQLiteInterop} -match regexp -result \
{^System#Data#SQLite#SQLiteConnection#\d+$}}















































###############################################################################

reportSQLiteResources $test_channel

###############################################################################








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623

  object unimport -importpattern System.Threading
  object unimport -importpattern System.Globalization
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
defineConstant.System.Data.SQLite.INTEROP_SHA1_EXTENSION System.Data.SQLite\
SQLiteInterop} -match regexp -result \
{^System#Data#SQLite#SQLiteConnection#\d+$}}

###############################################################################

reportSQLiteResources $test_channel true

###############################################################################

runTest {test data-1.87 {GetSettingValue cached assembly directory} -setup {
  moveSystemDataSQLiteDllConfig false
} -body {
  object invoke -flags +NonPublic System.Data.SQLite.UnsafeNativeMethods \
      GetSettingValue setting_for_data-1.87 null

  expr {[getOtherCount Method_ResetCachedAssemblyDirectory] == -1 && \
      [getOtherCount Method_GetAssemblyDirectory] == 1 && \
      [getOtherCount Method_GetCachedAssemblyDirectory] >= 1}
} -cleanup {
  moveSystemDataSQLiteDllConfig true
} -constraints {eagle command.object monoBug28 System.Data.SQLite\
buildConfiguration.Debug} -result {True}}

###############################################################################

reportSQLiteResources $test_channel true

###############################################################################

runTest {test data-1.88 {GetSettingValue cached assembly directory} -setup {
  moveSystemDataSQLiteDllConfig false
} -body {
  object invoke -flags +NonPublic System.Data.SQLite.UnsafeNativeMethods \
      GetSettingValue setting_for_data-1.88 null

  object invoke -flags +NonPublic \
      System.Data.SQLite.UnsafeNativeMethods ResetCachedAssemblyDirectory

  object invoke -flags +NonPublic System.Data.SQLite.UnsafeNativeMethods \
      GetSettingValue setting_for_data-1.88 null

  expr {[getOtherCount Method_ResetCachedAssemblyDirectory] == 1 && \
      [getOtherCount Method_GetAssemblyDirectory] == 2 && \
      [getOtherCount Method_GetCachedAssemblyDirectory] >= 2}
} -cleanup {
  moveSystemDataSQLiteDllConfig true
} -constraints {eagle command.object monoBug28 System.Data.SQLite\
buildConfiguration.Debug} -result {True}}

###############################################################################

reportSQLiteResources $test_channel

###############################################################################

Changes to Tests/tkt-58ed318f2f.eagle.
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
###############################################################################

package require System.Data.SQLite.Test
runSQLiteTestPrologue

###############################################################################

proc getSettingReadCount { name {viaFile false} } {
  if {[haveConstraint buildConfiguration.Debug] && [catch {
    object invoke -flags +NonPublic -alias \
        System.Data.SQLite.DebugData [expr {$viaFile ? \
        "settingFileReadCounts" : "settingReadCounts"}]
  } settingReadCounts] == 0} then {
    if {[string length $name] > 0} then {
      if {[$settingReadCounts TryGetValue $name value]} then {
        tputs $::test_channel [appendArgs \
            "---- setting \"" $name "\" was read " $value " times" \
            [expr {$viaFile ? " from the configuration file" : ""}] \n]

        return $value
      }
    } else {
      set nameCount [$settingReadCounts Count]
      set valueCount 0

      object foreach -alias pair $settingReadCounts {
        incr valueCount [$pair Value]

        tputs $::test_channel [appendArgs \
            "---- setting \"" [$pair Key] "\" was read " [$pair Value] \
            " times" [expr {$viaFile ? " from the configuration file" : \
            ""}] \n]
      }

      return [list $nameCount $valueCount]
    }
  }

  if {[string length $name] > 0} then {
    tputs $::test_channel [appendArgs \
        "---- setting \"" $name "\" was not read" [expr {$viaFile ? \
        " from the configuration file" : ""}] \n]
  } else {
    tputs $::test_channel [appendArgs \
        "---- no settings were read" [expr {$viaFile ? \
        " from the configuration file" : ""}] \n]
  }

  return -1
}

###############################################################################

reportSQLiteResources $test_channel true

###############################################################################

runTest {test tkt-58ed318f2f-1.1 {standard GetDefaultDbType usage} -setup {
  setupDb [set fileName tkt-58ed318f2f-1.1.db]
} -body {







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







16
17
18
19
20
21
22














































23
24
25
26
27
28
29
###############################################################################

package require System.Data.SQLite.Test
runSQLiteTestPrologue

###############################################################################















































reportSQLiteResources $test_channel true

###############################################################################

runTest {test tkt-58ed318f2f-1.1 {standard GetDefaultDbType usage} -setup {
  setupDb [set fileName tkt-58ed318f2f-1.1.db]
} -body {
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
  cleanupDb $fileName
  restoreGetSettingValueEnvironment

  unset -nocomplain counts db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite buildConfiguration.Debug} -result {True}}

###############################################################################

rename getSettingReadCount ""

###############################################################################

reportSQLiteResources $test_channel true

###############################################################################

runSQLiteTestEpilogue
runTestEpilogue







<
<
<
<








414
415
416
417
418
419
420




421
422
423
424
425
426
427
428
  cleanupDb $fileName
  restoreGetSettingValueEnvironment

  unset -nocomplain counts db fileName
} -constraints {eagle command.object monoBug28 command.sql compile.DATA SQLite\
System.Data.SQLite buildConfiguration.Debug} -result {True}}





###############################################################################

reportSQLiteResources $test_channel true

###############################################################################

runSQLiteTestEpilogue
runTestEpilogue
Changes to lib/System.Data.SQLite/common.eagle.
3211
3212
3213
3214
3215
3216
3217

3218
3219
3220

3221
3222
3223
3224
3225
3226
3227
        } result] == 0} then {
          if {!$quiet} then {
            tputs $channel [appendArgs \
                "---- memory in use by the CLR before collection... " \
                $result " bytes\n"]
          }
        } else {

          tputs $channel [appendArgs \
              "==== WARNING: failed to get CLR memory usage, error: " \
              \n\t $result \n]

        }
      }

      #########################################################################

      #
      # NOTE: Repeatedly attempt to collect garbage until the allotted number







>
|
|
|
>







3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
        } result] == 0} then {
          if {!$quiet} then {
            tputs $channel [appendArgs \
                "---- memory in use by the CLR before collection... " \
                $result " bytes\n"]
          }
        } else {
          if {!$quiet} then {
            tputs $channel [appendArgs \
                "==== WARNING: failed to get CLR memory usage, error: " \
                \n\t $result \n]
          }
        }
      }

      #########################################################################

      #
      # NOTE: Repeatedly attempt to collect garbage until the allotted number
3236
3237
3238
3239
3240
3241
3242

3243
3244
3245

3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263

3264
3265
3266

3267
3268
3269
3270
3271
3272
3273
          #
          # NOTE: Attempt to force a full garbage collection now.  Report any
          #       error that is encountered if we fail.
          #
          if {[catch {
            object invoke GC GetTotalMemory true
          } error]} then {

            tputs $channel [appendArgs \
                "==== WARNING: failed full garbage collection, error: " \
                \n\t $error \n]

          }

          set now [clock seconds]
        } while {$start <= $now && $now < $stop}
      }

      #########################################################################

      if {[haveSQLiteObjectCommand]} then {
        if {[catch {
          object invoke GC GetTotalMemory false
        } result] == 0} then {
          if {!$quiet} then {
            tputs $channel [appendArgs \
                "---- memory in use by the CLR after collection... " \
                $result " bytes\n"]
          }
        } else {

          tputs $channel [appendArgs \
              "==== WARNING: failed to get CLR memory usage, error: " \
              \n\t $result \n]

        }
      }
    }

    proc getSQLiteHandleCounts { channel {quiet false} } {
      set result [list]








>
|
|
|
>


















>
|
|
|
>







3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
          #
          # NOTE: Attempt to force a full garbage collection now.  Report any
          #       error that is encountered if we fail.
          #
          if {[catch {
            object invoke GC GetTotalMemory true
          } error]} then {
            if {!$quiet} then {
              tputs $channel [appendArgs \
                  "==== WARNING: failed full garbage collection, error: " \
                  \n\t $error \n]
            }
          }

          set now [clock seconds]
        } while {$start <= $now && $now < $stop}
      }

      #########################################################################

      if {[haveSQLiteObjectCommand]} then {
        if {[catch {
          object invoke GC GetTotalMemory false
        } result] == 0} then {
          if {!$quiet} then {
            tputs $channel [appendArgs \
                "---- memory in use by the CLR after collection... " \
                $result " bytes\n"]
          }
        } else {
          if {!$quiet} then {
            tputs $channel [appendArgs \
                "==== WARNING: failed to get CLR memory usage, error: " \
                \n\t $result \n]
          }
        }
      }
    }

    proc getSQLiteHandleCounts { channel {quiet false} } {
      set result [list]

3285
3286
3287
3288
3289
3290
3291

3292
3293
3294

3295
3296
3297
3298
3299
3300
3301
            if {!$quiet} then {
              tputs $channel [appendArgs \
                  "---- critical handle count \"" $name "\" is " $value \n]
            }

            lappend result $value
          } else {

            tputs $channel [appendArgs \
                "==== WARNING: failed to get critical handle count \"" \
                $name "\", error: " \n\t $value \n]

          }
        }
      } elseif {!$quiet} then {
        #
        # NOTE: The actual handle counts are not available; therefore, just
        #       return an empty list.
        #







>
|
|
|
>







3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
            if {!$quiet} then {
              tputs $channel [appendArgs \
                  "---- critical handle count \"" $name "\" is " $value \n]
            }

            lappend result $value
          } else {
            if {!$quiet} then {
              tputs $channel [appendArgs \
                  "==== WARNING: failed to get critical handle count \"" \
                  $name "\", error: " \n\t $value \n]
            }
          }
        }
      } elseif {!$quiet} then {
        #
        # NOTE: The actual handle counts are not available; therefore, just
        #       return an empty list.
        #
3377
3378
3379
3380
3381
3382
3383
3384


















































































3385
3386





















3387
3388
3389
3390
3391
3392
3393
          if {!$quiet} then {
            tputs $channel [appendArgs \
                "---- call sqlite3_shutdown()... error: " \n\t $result \n]
          }
        }
      }
    }



















































































    proc reportSQLiteResources {
            channel {quiet false} {reset true} {collect true} } {





















      #
      # NOTE: If available, report on (and possibly reset) the runtime
      #       configuration statistics.
      #
      if {[haveSQLiteObjectCommand] && \
          [haveConstraint buildConfiguration.Debug]} then {
        if {[catch {








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
          if {!$quiet} then {
            tputs $channel [appendArgs \
                "---- call sqlite3_shutdown()... error: " \n\t $result \n]
          }
        }
      }
    }

    proc getSettingReadCount { name {viaFile false} } {
      if {[haveConstraint buildConfiguration.Debug] && [catch {
        object invoke -flags +NonPublic -alias \
            System.Data.SQLite.DebugData [expr {$viaFile ? \
            "settingFileReadCounts" : "settingReadCounts"}]
      } settingReadCounts] == 0} then {
        if {[string length $name] > 0} then {
          if {[$settingReadCounts TryGetValue $name value]} then {
            tputs $::test_channel [appendArgs \
                "---- setting \"" $name "\" was read " $value " times" \
                [expr {$viaFile ? " from the configuration file" : ""}] \n]

            return $value
          }
        } else {
          set nameCount [$settingReadCounts Count]
          set valueCount 0

          object foreach -alias pair $settingReadCounts {
            incr valueCount [$pair Value]

            tputs $::test_channel [appendArgs \
                "---- setting \"" [$pair Key] "\" was read " [$pair Value] \
                " times" [expr {$viaFile ? " from the configuration file" : \
                ""}] \n]
          }

          return [list $nameCount $valueCount]
        }
      }

      if {[string length $name] > 0} then {
        tputs $::test_channel [appendArgs \
            "---- setting \"" $name "\" was not read" [expr {$viaFile ? \
            " from the configuration file" : ""}] \n]
      } else {
        tputs $::test_channel [appendArgs \
            "---- no settings were read" [expr {$viaFile ? \
            " from the configuration file" : ""}] \n]
      }

      return -1
    }

    proc getOtherCount { name } {
      if {[haveConstraint buildConfiguration.Debug] && [catch {
        object invoke -flags +NonPublic -alias \
            System.Data.SQLite.DebugData otherCounts
      } otherCounts] == 0} then {
        if {[string length $name] > 0} then {
          if {[$otherCounts TryGetValue $name value]} then {
            tputs $::test_channel [appendArgs \
                "---- other counter \"" $name "\" has value " $value \n]

            return $value
          }
        } else {
          set nameCount [$otherCounts Count]
          set valueCount 0

          object foreach -alias pair $otherCounts {
            incr valueCount [$pair Value]

            tputs $::test_channel [appendArgs \
                "---- other counter \"" [$pair Key] "\" has value " \
                [$pair Value] \n]
          }

          return [list $nameCount $valueCount]
        }
      }

      if {[string length $name] > 0} then {
        tputs $::test_channel [appendArgs \
            "---- other counter \"" $name "\" has no value\n"]
      } else {
        tputs $::test_channel "---- there are no other counters\n"
      }

      return -1
    }

    proc reportSQLiteResources {
            channel {quiet false} {reset true} {collect true} } {
      #
      # NOTE: If possible, always reset the cached assembly directory.
      #
      if {[haveSQLiteObjectCommand]} then {
        if {[catch {
          object invoke -flags +NonPublic \
              System.Data.SQLite.UnsafeNativeMethods \
              ResetCachedAssemblyDirectory
        } error] == 0} then {
          if {!$quiet} then {
            tputs $channel "---- reset cached assembly directory"
          }
        } else {
          if {!$quiet} then {
            tputs $channel [appendArgs \
                "==== WARNING: failed to reset cached assembly directory, " \
                "error: " \n\t $error \n]
          }
        }
      }

      #
      # NOTE: If available, report on (and possibly reset) the runtime
      #       configuration statistics.
      #
      if {[haveSQLiteObjectCommand] && \
          [haveConstraint buildConfiguration.Debug]} then {
        if {[catch {
3411
3412
3413
3414
3415
3416
3417

3418
3419
3420
3421

3422
3423
3424
3425
3426
3427
3428
            if {[catch {$settingReadCounts Clear} error] == 0} then {
              if {!$quiet} then {
                tputs $channel [appendArgs \
                    "---- reset setting statistics for the previous " \
                    $nameCount " names and " $valueCount " values read\n"]
              }
            } else {

              tputs $channel [appendArgs \
                  "==== WARNING: failed to reset setting statistics for " \
                  "the previous " $nameCount " names and " $valueCount \
                  " values read, error: " \n\t $error \n]

            }
          }
        }

        if {[catch {
          object invoke -flags +NonPublic -alias \
              System.Data.SQLite.DebugData settingFileReadCounts







>
|
|
|
|
>







3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
            if {[catch {$settingReadCounts Clear} error] == 0} then {
              if {!$quiet} then {
                tputs $channel [appendArgs \
                    "---- reset setting statistics for the previous " \
                    $nameCount " names and " $valueCount " values read\n"]
              }
            } else {
              if {!$quiet} then {
                tputs $channel [appendArgs \
                    "==== WARNING: failed to reset setting statistics for " \
                    "the previous " $nameCount " names and " $valueCount \
                    " values read, error: " \n\t $error \n]
              }
            }
          }
        }

        if {[catch {
          object invoke -flags +NonPublic -alias \
              System.Data.SQLite.DebugData settingFileReadCounts
3445
3446
3447
3448
3449
3450
3451

3452
3453
3454
3455
3456




































3457
3458
3459
3460
3461
3462
3463
              if {!$quiet} then {
                tputs $channel [appendArgs \
                    "---- reset setting statistics for the previous " \
                    $nameCount " names and " $valueCount " values read " \
                    "from the configuration file\n"]
              }
            } else {

              tputs $channel [appendArgs \
                  "==== WARNING: failed to reset setting statistics for " \
                  "the previous " $nameCount " names and " $valueCount \
                  " values read from the configuration file, error: " \n\t \
                  $error \n]




































            }
          }
        }
      }

      if {[haveSQLiteObjectCommand] && \
          [haveSQLiteDefineConstant INTEROP_VIRTUAL_TABLE] && \







>
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
              if {!$quiet} then {
                tputs $channel [appendArgs \
                    "---- reset setting statistics for the previous " \
                    $nameCount " names and " $valueCount " values read " \
                    "from the configuration file\n"]
              }
            } else {
              if {!$quiet} then {
                tputs $channel [appendArgs \
                    "==== WARNING: failed to reset setting statistics for " \
                    "the previous " $nameCount " names and " $valueCount \
                    " values read from the configuration file, error: " \n\t \
                    $error \n]
              }
            }
          }
        }

        if {[catch {
          object invoke -flags +NonPublic -alias \
              System.Data.SQLite.DebugData otherCounts
        } otherCounts] == 0} then {
          set nameCount [$otherCounts Count]
          set valueCount 0

          object foreach -alias pair $otherCounts {
            incr valueCount [$pair Value]

            if {!$quiet} then {
              tputs $channel [appendArgs \
                  "---- other counter \"" [$pair Key] "\" has value " \
                  [$pair Value] \n]
            }
          }

          if {$reset} then {
            if {[catch {$otherCounts Clear} error] == 0} then {
              if {!$quiet} then {
                tputs $channel [appendArgs \
                    "---- reset other counters for the previous " \
                    $nameCount " names and " $valueCount " values\n"]
              }
            } else {
              if {!$quiet} then {
                tputs $channel [appendArgs \
                    "==== WARNING: failed to reset other counters for " \
                    "the previous " $nameCount " names and " $valueCount \
                    " values, error: " \n\t $error \n]
              }
            }
          }
        }
      }

      if {[haveSQLiteObjectCommand] && \
          [haveSQLiteDefineConstant INTEROP_VIRTUAL_TABLE] && \
Changes to readme.htm.
210
211
212
213
214
215
216

217
218
219
220
221
222
223
<p>
    <b>1.0.106.0 - June XX, 2017 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/draft/releaselog/3_19_0.html">SQLite 3.19.0</a>.</li>
    <li>Prevent culture settings from negatively impacting integer connection string defaults.</li>
    <li>Make sure the &quot;No_SQLiteConnectionNewParser&quot; and &quot;DefaultFlags_SQLiteConnection&quot; setting values end up being cached.</li>

</ul>
<p>
    <b>1.0.105.0 - April 9, 2017</b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/releaselog/3_18_0.html">SQLite 3.18.0</a>.</li>
    <li>Add experimental support for native sha1 extension.</li>







>







210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<p>
    <b>1.0.106.0 - June XX, 2017 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/draft/releaselog/3_19_0.html">SQLite 3.19.0</a>.</li>
    <li>Prevent culture settings from negatively impacting integer connection string defaults.</li>
    <li>Make sure the &quot;No_SQLiteConnectionNewParser&quot; and &quot;DefaultFlags_SQLiteConnection&quot; setting values end up being cached.</li>
    <li>Cache the assembly directory used by the configuration subsystem.</li>
</ul>
<p>
    <b>1.0.105.0 - April 9, 2017</b>
</p>
<ul>
    <li>Updated to <a href="https://www.sqlite.org/releaselog/3_18_0.html">SQLite 3.18.0</a>.</li>
    <li>Add experimental support for native sha1 extension.</li>
Changes to www/news.wiki.
47
48
49
50
51
52
53

54
55
56
57
58
59
60
<p>
    <b>1.0.106.0 - June XX, 2017 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/draft/releaselog/3_19_0.html|SQLite 3.19.0].</li>
    <li>Prevent culture settings from negatively impacting integer connection string defaults.</li>
    <li>Make sure the &quot;No_SQLiteConnectionNewParser&quot; and &quot;DefaultFlags_SQLiteConnection&quot; setting values end up being cached.</li>

</ul>
<p>
    <b>1.0.105.0 - April 9, 2017</b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/releaselog/3_18_0.html|SQLite 3.18.0].</li>
    <li>Add experimental support for native sha1 extension.</li>







>







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<p>
    <b>1.0.106.0 - June XX, 2017 <font color="red">(release scheduled)</font></b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/draft/releaselog/3_19_0.html|SQLite 3.19.0].</li>
    <li>Prevent culture settings from negatively impacting integer connection string defaults.</li>
    <li>Make sure the &quot;No_SQLiteConnectionNewParser&quot; and &quot;DefaultFlags_SQLiteConnection&quot; setting values end up being cached.</li>
    <li>Cache the assembly directory used by the configuration subsystem.</li>
</ul>
<p>
    <b>1.0.105.0 - April 9, 2017</b>
</p>
<ul>
    <li>Updated to [https://www.sqlite.org/releaselog/3_18_0.html|SQLite 3.18.0].</li>
    <li>Add experimental support for native sha1 extension.</li>