System.Data.SQLite
Check-in [32459aa7cd]
Not logged in

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

Overview
Comment:Add object disposal diagnostic support for the sqlite3_changes() API.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 32459aa7cd57d616d2463ee3acf56973f6ee9087
User & Date: mistachkin 2012-10-13 19:09:33
Context
2012-10-13
19:11
Prevent stress test from running out of memory due to large result sets. Also, increase several of the default workload argument values. check-in: c2d27a493d user: mistachkin tags: trunk
19:09
Add object disposal diagnostic support for the sqlite3_changes() API. check-in: 32459aa7cd user: mistachkin tags: trunk
17:57
Modify the debug defines in the interop assembly project to include SQLITE_ENABLE_EXPENSIVE_ASSERT. check-in: 232e3ae933 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SQLite.Interop/props/SQLite.Interop.2005.vsprops.

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
	<UserMacro
		Name="INTEROP_RC_VERSION"
		Value="1,0,83,0"
		PerformEnvironmentSet="true"
	/>
	<UserMacro
		Name="INTEROP_DEBUG_DEFINES"
		Value="INTEROP_DEBUG=7;INTEROP_TEST_EXTENSION=1"
		PerformEnvironmentSet="true"
	/>
	<UserMacro
		Name="INTEROP_EXTRA_DEFINES"
		Value="INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1"
		PerformEnvironmentSet="true"
	/>







|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
	<UserMacro
		Name="INTEROP_RC_VERSION"
		Value="1,0,83,0"
		PerformEnvironmentSet="true"
	/>
	<UserMacro
		Name="INTEROP_DEBUG_DEFINES"
		Value="INTEROP_DEBUG=0x307;INTEROP_TEST_EXTENSION=1"
		PerformEnvironmentSet="true"
	/>
	<UserMacro
		Name="INTEROP_EXTRA_DEFINES"
		Value="INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1"
		PerformEnvironmentSet="true"
	/>

Changes to SQLite.Interop/props/SQLite.Interop.2008.vsprops.

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
	<UserMacro
		Name="INTEROP_RC_VERSION"
		Value="1,0,83,0"
		PerformEnvironmentSet="true"
	/>
	<UserMacro
		Name="INTEROP_DEBUG_DEFINES"
		Value="INTEROP_DEBUG=7;INTEROP_TEST_EXTENSION=1"
		PerformEnvironmentSet="true"
	/>
	<UserMacro
		Name="INTEROP_EXTRA_DEFINES"
		Value="INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1"
		PerformEnvironmentSet="true"
	/>







|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
	<UserMacro
		Name="INTEROP_RC_VERSION"
		Value="1,0,83,0"
		PerformEnvironmentSet="true"
	/>
	<UserMacro
		Name="INTEROP_DEBUG_DEFINES"
		Value="INTEROP_DEBUG=0x307;INTEROP_TEST_EXTENSION=1"
		PerformEnvironmentSet="true"
	/>
	<UserMacro
		Name="INTEROP_EXTRA_DEFINES"
		Value="INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1"
		PerformEnvironmentSet="true"
	/>

Changes to SQLite.Interop/props/SQLite.Interop.2010.props.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup Label="UserMacros">
    <ConfigurationYear>2010</ConfigurationYear>
    <INTEROP_BUILD_NUMBER>083</INTEROP_BUILD_NUMBER>
    <INTEROP_LINKER_VERSION>1.0</INTEROP_LINKER_VERSION>
    <INTEROP_MANIFEST_VERSION>1.0.83.0</INTEROP_MANIFEST_VERSION>
    <INTEROP_RC_VERSION>1,0,83,0</INTEROP_RC_VERSION>
    <INTEROP_DEBUG_DEFINES>INTEROP_DEBUG=7;INTEROP_TEST_EXTENSION=1</INTEROP_DEBUG_DEFINES>
    <INTEROP_EXTRA_DEFINES>INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1</INTEROP_EXTRA_DEFINES>
    <INTEROP_ASSEMBLY_RESOURCES>/ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteCommand.bmp,System.Data.SQLite.SQLiteCommand.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteConnection.bmp,System.Data.SQLite.SQLiteConnection.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteDataAdapter.bmp,System.Data.SQLite.SQLiteDataAdapter.bmp</INTEROP_ASSEMBLY_RESOURCES>
    <INTEROP_KEY_FILE>$(ProjectDir)..\System.Data.SQLite\System.Data.SQLite.snk</INTEROP_KEY_FILE>
    <INTEROP_NATIVE_NAME>SQLite.Interop</INTEROP_NATIVE_NAME>
    <INTEROP_MIXED_NAME>System.Data.SQLite</INTEROP_MIXED_NAME>
  </PropertyGroup>
  <ItemGroup>







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup Label="UserMacros">
    <ConfigurationYear>2010</ConfigurationYear>
    <INTEROP_BUILD_NUMBER>083</INTEROP_BUILD_NUMBER>
    <INTEROP_LINKER_VERSION>1.0</INTEROP_LINKER_VERSION>
    <INTEROP_MANIFEST_VERSION>1.0.83.0</INTEROP_MANIFEST_VERSION>
    <INTEROP_RC_VERSION>1,0,83,0</INTEROP_RC_VERSION>
    <INTEROP_DEBUG_DEFINES>INTEROP_DEBUG=0x307;INTEROP_TEST_EXTENSION=1</INTEROP_DEBUG_DEFINES>
    <INTEROP_EXTRA_DEFINES>INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1</INTEROP_EXTRA_DEFINES>
    <INTEROP_ASSEMBLY_RESOURCES>/ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteCommand.bmp,System.Data.SQLite.SQLiteCommand.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteConnection.bmp,System.Data.SQLite.SQLiteConnection.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteDataAdapter.bmp,System.Data.SQLite.SQLiteDataAdapter.bmp</INTEROP_ASSEMBLY_RESOURCES>
    <INTEROP_KEY_FILE>$(ProjectDir)..\System.Data.SQLite\System.Data.SQLite.snk</INTEROP_KEY_FILE>
    <INTEROP_NATIVE_NAME>SQLite.Interop</INTEROP_NATIVE_NAME>
    <INTEROP_MIXED_NAME>System.Data.SQLite</INTEROP_MIXED_NAME>
  </PropertyGroup>
  <ItemGroup>

Changes to SQLite.Interop/props/SQLite.Interop.2012.props.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup Label="UserMacros">
    <ConfigurationYear>2012</ConfigurationYear>
    <INTEROP_BUILD_NUMBER>083</INTEROP_BUILD_NUMBER>
    <INTEROP_LINKER_VERSION>1.0</INTEROP_LINKER_VERSION>
    <INTEROP_MANIFEST_VERSION>1.0.83.0</INTEROP_MANIFEST_VERSION>
    <INTEROP_RC_VERSION>1,0,83,0</INTEROP_RC_VERSION>
    <INTEROP_DEBUG_DEFINES>INTEROP_DEBUG=7;INTEROP_TEST_EXTENSION=1</INTEROP_DEBUG_DEFINES>
    <INTEROP_EXTRA_DEFINES>INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1</INTEROP_EXTRA_DEFINES>
    <INTEROP_ASSEMBLY_RESOURCES>/ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteCommand.bmp,System.Data.SQLite.SQLiteCommand.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteConnection.bmp,System.Data.SQLite.SQLiteConnection.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteDataAdapter.bmp,System.Data.SQLite.SQLiteDataAdapter.bmp</INTEROP_ASSEMBLY_RESOURCES>
    <INTEROP_KEY_FILE>$(ProjectDir)..\System.Data.SQLite\System.Data.SQLite.snk</INTEROP_KEY_FILE>
    <INTEROP_NATIVE_NAME>SQLite.Interop</INTEROP_NATIVE_NAME>
    <INTEROP_MIXED_NAME>System.Data.SQLite</INTEROP_MIXED_NAME>
  </PropertyGroup>
  <ItemGroup>







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup Label="UserMacros">
    <ConfigurationYear>2012</ConfigurationYear>
    <INTEROP_BUILD_NUMBER>083</INTEROP_BUILD_NUMBER>
    <INTEROP_LINKER_VERSION>1.0</INTEROP_LINKER_VERSION>
    <INTEROP_MANIFEST_VERSION>1.0.83.0</INTEROP_MANIFEST_VERSION>
    <INTEROP_RC_VERSION>1,0,83,0</INTEROP_RC_VERSION>
    <INTEROP_DEBUG_DEFINES>INTEROP_DEBUG=0x307;INTEROP_TEST_EXTENSION=1</INTEROP_DEBUG_DEFINES>
    <INTEROP_EXTRA_DEFINES>INTEROP_EXTENSION_FUNCTIONS=1;INTEROP_CODEC=1</INTEROP_EXTRA_DEFINES>
    <INTEROP_ASSEMBLY_RESOURCES>/ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteCommand.bmp,System.Data.SQLite.SQLiteCommand.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteConnection.bmp,System.Data.SQLite.SQLiteConnection.bmp /ASSEMBLYRESOURCE:..\System.Data.SQLite\SQLiteDataAdapter.bmp,System.Data.SQLite.SQLiteDataAdapter.bmp</INTEROP_ASSEMBLY_RESOURCES>
    <INTEROP_KEY_FILE>$(ProjectDir)..\System.Data.SQLite\System.Data.SQLite.snk</INTEROP_KEY_FILE>
    <INTEROP_NATIVE_NAME>SQLite.Interop</INTEROP_NATIVE_NAME>
    <INTEROP_MIXED_NAME>System.Data.SQLite</INTEROP_MIXED_NAME>
  </PropertyGroup>
  <ItemGroup>

Changes to SQLite.Interop/src/win/interop.c.

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30









31
32
33
34
35
36
37
...
218
219
220
221
222
223
224

























225
226
227
228
229
230
231
#endif

#ifdef SQLITE_OS_WIN
#if defined(INTEROP_CODEC)
#include "crypt.c"
#endif

#define INTEROP_DEBUG_NONE           (0x00)
#define INTEROP_DEBUG_CLOSE          (0x01)
#define INTEROP_DEBUG_FINALIZE       (0x02)
#define INTEROP_DEBUG_BACKUP_FINISH  (0x04)
#define INTEROP_DEBUG_OPEN           (0x08)
#define INTEROP_DEBUG_OPEN16         (0x10)
#define INTEROP_DEBUG_PREPARE        (0x20)
#define INTEROP_DEBUG_PREPARE16      (0x40)
#define INTEROP_DEBUG_RESET          (0x80)










typedef void (*SQLITEUSERFUNC)(sqlite3_context *, int, sqlite3_value **);
typedef void (*SQLITEFUNCFINAL)(sqlite3_context *);

#if defined(INTEROP_DEBUG)
SQLITE_PRIVATE void sqlite3InteropDebug(const char *zFormat, ...){
  va_list ap;                         /* Vararg list */
................................................................................

SQLITE_API const char * WINAPI sqlite3_errmsg_interop(sqlite3 *db, int *plen)
{
  const char *pval = sqlite3_errmsg(db);
  *plen = (pval != 0) ? strlen(pval) : 0;
  return pval;
}


























SQLITE_API int WINAPI sqlite3_prepare_interop(sqlite3 *db, const char *sql, int nbytes, sqlite3_stmt **ppstmt, const char **pztail, int *plen)
{
  int n;

#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_PREPARE)
  sqlite3InteropDebug("sqlite3_prepare_interop(): calling sqlite3_prepare(%p, \"%s\", %d, %p)...\n", db, sql, nbytes, ppstmt);







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







 







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







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
...
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#endif

#ifdef SQLITE_OS_WIN
#if defined(INTEROP_CODEC)
#include "crypt.c"
#endif

#define INTEROP_DEBUG_NONE           (0x0000)
#define INTEROP_DEBUG_CLOSE          (0x0001)
#define INTEROP_DEBUG_FINALIZE       (0x0002)
#define INTEROP_DEBUG_BACKUP_FINISH  (0x0004)
#define INTEROP_DEBUG_OPEN           (0x0008)
#define INTEROP_DEBUG_OPEN16         (0x0010)
#define INTEROP_DEBUG_PREPARE        (0x0020)
#define INTEROP_DEBUG_PREPARE16      (0x0040)
#define INTEROP_DEBUG_RESET          (0x0080)
#define INTEROP_DEBUG_CHANGES        (0x0100)
#define INTEROP_DEBUG_BREAK          (0x0200)

#if defined(_MSC_VER) && defined(INTEROP_DEBUG) && \
    (INTEROP_DEBUG & INTEROP_DEBUG_BREAK)
#define sqlite3InteropBreak(a) { sqlite3InteropDebug("%s\n", (a)); __debugbreak(); }
#else
#define sqlite3InteropBreak(a)
#endif

typedef void (*SQLITEUSERFUNC)(sqlite3_context *, int, sqlite3_value **);
typedef void (*SQLITEFUNCFINAL)(sqlite3_context *);

#if defined(INTEROP_DEBUG)
SQLITE_PRIVATE void sqlite3InteropDebug(const char *zFormat, ...){
  va_list ap;                         /* Vararg list */
................................................................................

SQLITE_API const char * WINAPI sqlite3_errmsg_interop(sqlite3 *db, int *plen)
{
  const char *pval = sqlite3_errmsg(db);
  *plen = (pval != 0) ? strlen(pval) : 0;
  return pval;
}

SQLITE_API int WINAPI sqlite3_changes_interop(sqlite3 *db)
{
  int result;

#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_CHANGES)
  sqlite3InteropDebug("sqlite3_changes_interop(): calling sqlite3_changes(%p)...\n", db);
#endif

#ifndef NDEBUG
  if (!db)
      sqlite3InteropBreak("null database handle for sqlite3_changes()");

  if (!sqlite3SafetyCheckOk(db))
      sqlite3InteropBreak("bad database handle for sqlite3_changes()");
#endif

  result = sqlite3_changes(db);

#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_CHANGES)
  sqlite3InteropDebug("sqlite3_changes_interop(): sqlite3_changes(%p) returned %d.\n", db, result);
#endif

  return result;
}

SQLITE_API int WINAPI sqlite3_prepare_interop(sqlite3 *db, const char *sql, int nbytes, sqlite3_stmt **ppstmt, const char **pztail, int *plen)
{
  int n;

#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_PREPARE)
  sqlite3InteropDebug("sqlite3_prepare_interop(): calling sqlite3_prepare(%p, \"%s\", %d, %p)...\n", db, sql, nbytes, ppstmt);

Changes to SQLite.NET.Settings.targets.

222
223
224
225
226
227
228
229
230

231
232
233
234
235


236
237
238
239
240
241
242
                  "SQLite.Interop\props\SQLite.Interop.20YY.[vs]props"

              for the corresponding version(s) of Visual Studio where the XX is
              an integer value that represents a combination of one or more of
              the following bit flags values (i.e. to enable extra diagnostics
              for a particular native function call):

                  INTEROP_DEBUG_CLOSE      (0x01)
                  INTEROP_DEBUG_FINALIZE   (0x02)

                  INTEROP_DEBUG_OPEN       (0x04)
                  INTEROP_DEBUG_OPEN16     (0x08)
                  INTEROP_DEBUG_PREPARE    (0x10)
                  INTEROP_DEBUG_PREPARE16  (0x20)
                  INTEROP_DEBUG_RESET      (0x40)


    -->
    <InteropDebug Condition="'$(InteropDebug)' == '' And '$(Configuration)' == 'Debug'">true</InteropDebug>
    <InteropDebug Condition="'$(InteropDebug)' == '' And '$(Configuration)' != 'Debug'">false</InteropDebug>

    <!--
        NOTE: Enable the use of native Windows APIs, when available?  By
              default, this is enabled.  If this is disabled, all features







|
|
>
|
|
|
|
|
>
>







222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
                  "SQLite.Interop\props\SQLite.Interop.20YY.[vs]props"

              for the corresponding version(s) of Visual Studio where the XX is
              an integer value that represents a combination of one or more of
              the following bit flags values (i.e. to enable extra diagnostics
              for a particular native function call):

                  INTEROP_DEBUG_CLOSE          (0x0001)
                  INTEROP_DEBUG_FINALIZE       (0x0002)
                  INTEROP_DEBUG_BACKUP_FINISH  (0x0004)
                  INTEROP_DEBUG_OPEN           (0x0008)
                  INTEROP_DEBUG_OPEN16         (0x0010)
                  INTEROP_DEBUG_PREPARE        (0x0020)
                  INTEROP_DEBUG_PREPARE16      (0x0040)
                  INTEROP_DEBUG_RESET          (0x0080)
                  INTEROP_DEBUG_CHANGES        (0x0100)
                  INTEROP_DEBUG_BREAK          (0x0200)
    -->
    <InteropDebug Condition="'$(InteropDebug)' == '' And '$(Configuration)' == 'Debug'">true</InteropDebug>
    <InteropDebug Condition="'$(InteropDebug)' == '' And '$(Configuration)' != 'Debug'">false</InteropDebug>

    <!--
        NOTE: Enable the use of native Windows APIs, when available?  By
              default, this is enabled.  If this is disabled, all features

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

238
239
240
241
242
243
244



245

246
247
248
249
250
251
252
      }
    }

    internal override int Changes
    {
      get
      {



        return UnsafeNativeMethods.sqlite3_changes(_sql);

      }
    }

    internal override long MemoryUsed
    {
      get
      {







>
>
>

>







238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
      }
    }

    internal override int Changes
    {
      get
      {
#if !SQLITE_STANDARD
        return UnsafeNativeMethods.sqlite3_changes_interop(_sql);
#else
        return UnsafeNativeMethods.sqlite3_changes(_sql);
#endif
      }
    }

    internal override long MemoryUsed
    {
      get
      {

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

597
598
599
600
601
602
603


604
605
606
607
608
609
610

    [DllImport(SQLITE_DLL)]
    internal static extern SQLiteErrorCode sqlite3_open16_interop(byte[] utf8Filename, SQLiteOpenFlagsEnum flags, out IntPtr db);

    [DllImport(SQLITE_DLL)]
    internal static extern SQLiteErrorCode 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







>
>







597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612

    [DllImport(SQLITE_DLL)]
    internal static extern SQLiteErrorCode sqlite3_open16_interop(byte[] utf8Filename, SQLiteOpenFlagsEnum flags, out IntPtr db);

    [DllImport(SQLITE_DLL)]
    internal static extern SQLiteErrorCode sqlite3_reset_interop(IntPtr stmt);

    [DllImport(SQLITE_DLL)]
    internal static extern int sqlite3_changes_interop(IntPtr db);
#endif
// !SQLITE_STANDARD

    #endregion

    // The standard api call equivalents of the above interop calls
    #region standard versions of interop functions