System.Data.SQLite
Check-in [e8a0cf1336]
Not logged in

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

Overview
Comment:Add support for extra diagnostics in the native interop assembly when compiled in the debug build configuration. Fix several tests to account for recent changes to the setupDb and cleanupDb test suite infrastructure procedures.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e8a0cf1336929125591fea5a3cb32d935ae53d0b
User & Date: mistachkin 2012-10-08 09:11:50
Context
2012-10-08
12:17
Simplify implementation and usage of the getAppDomainPreamble test suite infrastructure procedure. check-in: a6e4e7b517 user: mistachkin tags: trunk
09:11
Add support for extra diagnostics in the native interop assembly when compiled in the debug build configuration. Fix several tests to account for recent changes to the setupDb and cleanupDb test suite infrastructure procedures. check-in: e8a0cf1336 user: mistachkin tags: trunk
2012-10-07
03:41
Update Eagle in externals to the latest trunk. Always specify the stack size for threads created by the test suite. Allow the SQLite temporary directory used by the test suite to be easily overridden. check-in: bed252ba0c user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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

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

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

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

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

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

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

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

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

    14     14   extern int RegisterExtensionFunctions(sqlite3 *db);
    15     15   #endif
    16     16   
    17     17   #ifdef SQLITE_OS_WIN
    18     18   #if defined(INTEROP_CODEC)
    19     19   #include "crypt.c"
    20     20   #endif
           21  +
           22  +#define INTEROP_DEBUG_NONE       (0x00)
           23  +#define INTEROP_DEBUG_CLOSE      (0x01)
           24  +#define INTEROP_DEBUG_FINALIZE   (0x02)
           25  +#define INTEROP_DEBUG_OPEN       (0x04)
           26  +#define INTEROP_DEBUG_OPEN16     (0x08)
           27  +#define INTEROP_DEBUG_PREPARE    (0x10)
           28  +#define INTEROP_DEBUG_PREPARE16  (0x20)
           29  +#define INTEROP_DEBUG_RESET      (0x40)
    21     30   
    22     31   typedef void (*SQLITEUSERFUNC)(sqlite3_context *, int, sqlite3_value **);
    23     32   typedef void (*SQLITEFUNCFINAL)(sqlite3_context *);
           33  +
           34  +#if defined(INTEROP_DEBUG)
           35  +SQLITE_PRIVATE void sqlite3InteropDebug(const char *zFormat, ...){
           36  +  va_list ap;                         /* Vararg list */
           37  +  StrAccum acc;                       /* String accumulator */
           38  +  char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */
           39  +  va_start(ap, zFormat);
           40  +  sqlite3StrAccumInit(&acc, zMsg, sizeof(zMsg), 0);
           41  +  acc.useMalloc = 0;
           42  +  sqlite3VXPrintf(&acc, 0, zFormat, ap);
           43  +  va_end(ap);
           44  +#if SQLITE_VERSION_NUMBER >= 3007013
           45  +  sqlite3_win32_write_debug(sqlite3StrAccumFinish(&acc), -1);
           46  +#elif defined(SQLITE_WIN32_HAS_ANSI)
           47  +  OutputDebugStringA(sqlite3StrAccumFinish(&acc));
           48  +#elif defined(SQLITE_WIN32_HAS_WIDE)
           49  +  {
           50  +    LPWSTR zWideMsg = utf8ToUnicode(sqlite3StrAccumFinish(&acc));
           51  +    if( zWideMsg ){
           52  +      OutputDebugStringW(zWideMsg);
           53  +      sqlite3_free(zWideMsg);
           54  +    }
           55  +  }
           56  +#else
           57  +  fprintf(stderr, "%s", sqlite3StrAccumFinish(&acc));
           58  +#endif
           59  +}
           60  +#endif
    24     61   
    25     62   #if SQLITE_VERSION_NUMBER < 3007014
    26     63   SQLITE_PRIVATE void * sqlite3DbMallocZero_interop(sqlite3 *db, int n)
    27     64   {
    28     65     void *p;
    29     66     if (db) {
    30     67       sqlite3_mutex_enter(db->mutex);
................................................................................
    62     99       their memory is freed and can be used for something else.  The GC thread could potentially try and call finalize again on the statement after
    63    100       that memory was deallocated.  BAD.  So, what we need to do is make a copy of each statement, and call finalize() on the copy -- so that the original
    64    101       statement's memory is preserved, and marked as BAD, but we can still manage to finalize everything and forcibly close the database.  Later when the 
    65    102       GC gets around to calling finalize_interop() on the "bad" statement, we detect that and finish deallocating the pointer.
    66    103   */
    67    104   SQLITE_API int WINAPI sqlite3_close_interop(sqlite3 *db)
    68    105   {
          106  +  int ret;
    69    107   #if SQLITE_VERSION_NUMBER >= 3007014
    70         -  return sqlite3_close_v2(db);
          108  +
          109  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_CLOSE)
          110  +  sqlite3InteropDebug("sqlite3_close_interop(): calling sqlite3_close_v2(%p)...\n", db);
          111  +#endif
          112  +
          113  +  ret = sqlite3_close_v2(db);
          114  +
          115  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_CLOSE)
          116  +  sqlite3InteropDebug("sqlite3_close_interop(): sqlite3_close_v2(%p) returned %d.\n", db, ret);
          117  +#endif
          118  +
          119  +  return ret;
    71    120   #else
    72         -  int ret = sqlite3_close(db);
          121  +  ret = sqlite3_close(db);
    73    122   
    74    123     if (ret == SQLITE_BUSY)
    75    124     {
    76    125       sqlite3_mutex_enter(db->mutex);
    77    126   
    78    127       if (!db->pVdbe)
    79    128       {
................................................................................
   123    172     return ret;
   124    173   #endif
   125    174   }
   126    175   
   127    176   SQLITE_API int WINAPI sqlite3_open_interop(const char*filename, int flags, sqlite3 **ppdb)
   128    177   {
   129    178     int ret;
          179  +
          180  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_OPEN)
          181  +  sqlite3InteropDebug("sqlite3_open_interop(): calling sqlite3_open_v2(\"%s\", %d, %p)...\n", filename, flags, ppdb);
          182  +#endif
   130    183   
   131    184     ret = sqlite3_open_v2(filename, ppdb, flags, NULL);
          185  +
          186  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_OPEN)
          187  +  sqlite3InteropDebug("sqlite3_open_interop(): sqlite3_open_v2(\"%s\", %d, %p) returned %d.\n", filename, flags, ppdb, ret);
          188  +#endif
   132    189   
   133    190   #if defined(INTEROP_EXTENSION_FUNCTIONS)
   134         -  if (ret == 0)
          191  +  if (ret == SQLITE_OK)
   135    192       RegisterExtensionFunctions(*ppdb);
   136    193   #endif
   137    194   
   138    195     return ret;
   139    196   }
   140    197   
   141    198   SQLITE_API int WINAPI sqlite3_open16_interop(const char *filename, int flags, sqlite3 **ppdb)
   142    199   {
   143         -  int ret = sqlite3_open_interop(filename, flags, ppdb);
   144         -  if (!ret)
   145         -  {
   146         -    if(!DbHasProperty(*ppdb, 0, DB_SchemaLoaded))
   147         -      ENC(*ppdb) = SQLITE_UTF16NATIVE;
   148         -  }
          200  +  int ret;
          201  +
          202  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_OPEN16)
          203  +  sqlite3InteropDebug("sqlite3_open16_interop(): calling sqlite3_open_interop(\"%s\", %d, %p)...\n", filename, flags, ppdb);
          204  +#endif
          205  +
          206  +  ret = sqlite3_open_interop(filename, flags, ppdb);
          207  +
          208  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_OPEN16)
          209  +  sqlite3InteropDebug("sqlite3_open16_interop(): sqlite3_open_interop(\"%s\", %d, %p) returned %d.\n", filename, flags, ppdb, ret);
          210  +#endif
          211  +
          212  +  if ((ret == SQLITE_OK) && !DbHasProperty(*ppdb, 0, DB_SchemaLoaded))
          213  +    ENC(*ppdb) = SQLITE_UTF16NATIVE;
          214  +
   149    215     return ret;
   150    216   }
   151    217   
   152    218   SQLITE_API const char * WINAPI sqlite3_errmsg_interop(sqlite3 *db, int *plen)
   153    219   {
   154    220     const char *pval = sqlite3_errmsg(db);
   155    221     *plen = (pval != 0) ? strlen(pval) : 0;
   156    222     return pval;
   157    223   }
   158    224   
   159    225   SQLITE_API int WINAPI sqlite3_prepare_interop(sqlite3 *db, const char *sql, int nbytes, sqlite3_stmt **ppstmt, const char **pztail, int *plen)
   160    226   {
   161    227     int n;
          228  +
          229  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_PREPARE)
          230  +  sqlite3InteropDebug("sqlite3_prepare_interop(): calling sqlite3_prepare(%p, \"%s\", %d, %p)...\n", db, sql, nbytes, ppstmt);
          231  +#endif
   162    232   
   163    233     n = sqlite3_prepare(db, sql, nbytes, ppstmt, pztail);
          234  +
          235  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_PREPARE)
          236  +  sqlite3InteropDebug("sqlite3_prepare_interop(): sqlite3_prepare(%p, \"%s\", %d, %p) returned %d.\n", db, sql, nbytes, ppstmt, n);
          237  +#endif
          238  +
   164    239     *plen = (*pztail != 0) ? strlen(*pztail) : 0;
   165    240   
   166    241     return n;
   167    242   }
   168    243   
   169    244   SQLITE_API int WINAPI sqlite3_prepare16_interop(sqlite3 *db, const void *sql, int nchars, sqlite3_stmt **ppstmt, const void **pztail, int *plen)
   170    245   {
   171    246     int n;
          247  +
          248  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_PREPARE16)
          249  +  sqlite3InteropDebug("sqlite3_prepare_interop(): calling sqlite3_prepare16(%p, \"%s\", %d, %p)...\n", db, sql, nchars, ppstmt);
          250  +#endif
   172    251   
   173    252     n = sqlite3_prepare16(db, sql, nchars * sizeof(wchar_t), ppstmt, pztail);
          253  +
          254  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_PREPARE16)
          255  +  sqlite3InteropDebug("sqlite3_prepare_interop(): sqlite3_prepare16(%p, \"%s\", %d, %p) returned %d.\n", db, sql, nchars, ppstmt, n);
          256  +#endif
          257  +
   174    258     *plen = (*pztail != 0) ? wcslen((wchar_t *)*pztail) * sizeof(wchar_t) : 0;
   175    259   
   176    260     return n;
   177    261   }
   178    262   
   179    263   SQLITE_API int WINAPI sqlite3_bind_double_interop(sqlite3_stmt *stmt, int iCol, double *val)
   180    264   {
................................................................................
   243    327     const void *pval = sqlite3_column_text16(stmt, iCol);
   244    328     *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t): 0;
   245    329     return pval;
   246    330   }
   247    331   
   248    332   SQLITE_API int WINAPI sqlite3_finalize_interop(sqlite3_stmt *stmt)
   249    333   {
          334  +  int ret;
   250    335   #if SQLITE_VERSION_NUMBER >= 3007014
   251         -  return sqlite3_finalize(stmt);
          336  +
          337  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_FINALIZE)
          338  +  sqlite3InteropDebug("sqlite3_finalize_interop(): calling sqlite3_finalize(%p)...\n", stmt);
          339  +#endif
          340  +
          341  +  ret = sqlite3_finalize(stmt);
          342  +
          343  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_FINALIZE)
          344  +  sqlite3InteropDebug("sqlite3_finalize_interop(): sqlite3_finalize(%p) returned %d.\n", stmt, ret);
          345  +#endif
          346  +
          347  +  return ret;
   252    348   #else
   253    349     Vdbe *p;
   254    350     int ret = SQLITE_OK;
   255    351   
   256    352     p = (Vdbe *)stmt;
   257    353     if (p)
   258    354     {
................................................................................
   276    372   
   277    373     return ret;
   278    374   #endif
   279    375   }
   280    376   
   281    377   SQLITE_API int WINAPI sqlite3_reset_interop(sqlite3_stmt *stmt)
   282    378   {
          379  +  int ret;
   283    380   #if SQLITE_VERSION_NUMBER >= 3007014
   284         -  return sqlite3_reset(stmt);
          381  +
          382  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_RESET)
          383  +  sqlite3InteropDebug("sqlite3_reset_interop(): calling sqlite3_reset(%p)...\n", stmt);
          384  +#endif
          385  +
          386  +  ret = sqlite3_reset(stmt);
          387  +
          388  +#if defined(INTEROP_DEBUG) && (INTEROP_DEBUG & INTEROP_DEBUG_RESET)
          389  +  sqlite3InteropDebug("sqlite3_reset_interop(): sqlite3_reset(%p) returned %d.\n", stmt, ret);
          390  +#endif
          391  +
          392  +  return ret;
   285    393   #else
   286         -  int ret;
   287         -
   288    394     if (((Vdbe *)stmt)->magic == VDBE_MAGIC_DEAD) return SQLITE_SCHEMA;
   289    395     ret = sqlite3_reset(stmt);
   290    396     return ret;
   291    397   #endif
   292    398   }
   293    399   
   294    400   SQLITE_API int WINAPI sqlite3_create_function_interop(sqlite3 *psql, const char *zFunctionName, int nArg, int eTextRep, void *pvUser, SQLITEUSERFUNC func, SQLITEUSERFUNC funcstep, SQLITEFUNCFINAL funcfinal, int needCollSeq)
................................................................................
   295    401   {
   296    402     int n;
   297    403   
   298    404     if (eTextRep == SQLITE_UTF16)
   299    405       eTextRep = SQLITE_UTF16NATIVE;
   300    406   
   301    407     n = sqlite3_create_function(psql, zFunctionName, nArg, eTextRep, 0, func, funcstep, funcfinal);
   302         -  if (n == 0)
          408  +  if (n == SQLITE_OK)
   303    409     {
   304    410       if (needCollSeq)
   305    411       {
   306    412         FuncDef *pFunc = sqlite3FindFunction(psql, zFunctionName, strlen(zFunctionName), nArg, eTextRep, 0);
   307    413         if( pFunc )
   308    414         {
   309    415           pFunc->flags |= SQLITE_FUNC_NEEDCOLL;
................................................................................
   486    592   }
   487    593   
   488    594   SQLITE_API int WINAPI sqlite3_cursor_rowid(sqlite3_stmt *pstmt, int cursor, sqlite_int64 *prowid)
   489    595   {
   490    596     Vdbe *p = (Vdbe *)pstmt;
   491    597     sqlite3 *db = (p == NULL) ? NULL : p->db;
   492    598     VdbeCursor *pC;
   493         -  int ret = 0;
          599  +  int ret = SQLITE_OK;
   494    600   
   495    601     sqlite3_mutex_enter(db->mutex);
   496    602     while (1)
   497    603     {
   498    604       if (cursor < 0 || cursor >= p->nCursor)
   499    605       {
   500    606         ret = SQLITE_ERROR;
................................................................................
   585    691   */
   586    692   SQLITE_API int interop_test_extension_init(
   587    693     sqlite3 *db,
   588    694     char **pzErrMsg,
   589    695     const sqlite3_api_routines *pApi
   590    696   ){
   591    697     SQLITE_EXTENSION_INIT2(pApi)
   592         -  sqlite3_create_function(db, "interopTest", -1, SQLITE_ANY, 0,
          698  +  return sqlite3_create_function(db, "interopTest", -1, SQLITE_ANY, 0,
   593    699         interopTestFunc, 0, 0);
   594         -  return 0;
   595    700   }
   596    701   #endif

Changes to SQLite.NET.Settings.targets.

   166    166                 built interop DLL (i.e. "SQLite.Interop.dll")?  By default, this
   167    167                 is enabled.  If this is disabled, the "well-known" extension
   168    168                 functions will be unavailable.  If this is enabled, it must also
   169    169                 be enabled via the "INTEROP_EXTENSION_FUNCTIONS=1" preprocessor
   170    170                 define being present in the "INTEROP_EXTRA_DEFINES" macro in the
   171    171                 build properties file:
   172    172   
   173         -                  "SQLite.Interop\props\SQLite.Interop.20XX.[vs]props"
          173  +                  "SQLite.Interop\props\SQLite.Interop.20YY.[vs]props"
   174    174   
   175    175                 for the corresponding version(s) of Visual Studio.
   176    176       -->
   177    177       <InteropExtensionFunctions Condition="'$(InteropExtensionFunctions)' == ''">true</InteropExtensionFunctions>
   178    178   
   179    179       <!--
   180    180           NOTE: Enable the test extension from the custom built interop DLL (i.e.
................................................................................
   181    181                 "SQLite.Interop.dll")?  By default, this is enabled only in the
   182    182                 Debug build configuration.  If this is disabled, the test
   183    183                 extension will be unavailable.  If this is enabled, it must also
   184    184                 be enabled via the "INTEROP_TEST_EXTENSION=1" preprocessor define
   185    185                 being present in the "INTEROP_DEBUG_DEFINES" macro in the build
   186    186                 properties file:
   187    187   
   188         -                  "SQLite.Interop\props\SQLite.Interop.20XX.[vs]props"
          188  +                  "SQLite.Interop\props\SQLite.Interop.20YY.[vs]props"
   189    189   
   190    190                 for the corresponding version(s) of Visual Studio.
   191    191       -->
   192    192       <InteropTestExtension Condition="'$(InteropTestExtension)' == '' And '$(Configuration)' == 'Debug'">true</InteropTestExtension>
   193    193       <InteropTestExtension Condition="'$(InteropTestExtension)' == '' And '$(Configuration)' != 'Debug'">false</InteropTestExtension>
   194    194   
   195    195       <!--
................................................................................
   201    201                 the "SQLITE_EXTRA_DEFINES" macro in the build properties file:
   202    202   
   203    203                     "SQLite.Interop\props\sqlite3.[vs]props"
   204    204   
   205    205                 AND via the "INTEROP_CODEC=1" preprocessor define being present in
   206    206                 the "INTEROP_EXTRA_DEFINES" macro in the build properties file:
   207    207   
   208         -                  "SQLite.Interop\props\SQLite.Interop.20XX.[vs]props"
          208  +                  "SQLite.Interop\props\SQLite.Interop.20YY.[vs]props"
   209    209   
   210    210                 both for the corresponding version(s) of Visual Studio.
   211    211       -->
   212    212       <InteropCodec Condition="'$(InteropCodec)' == ''">true</InteropCodec>
   213    213   
          214  +    <!--
          215  +        NOTE: Enable extra diagnostics from the custom built interop DLL (i.e.
          216  +              "SQLite.Interop.dll")?  By default, this is enabled in the Debug
          217  +              build configuration.  If this is disabled, no extra diagnostics
          218  +              will be emitted.  If this is enabled, it must also be enabled via
          219  +              the "INTEROP_DEBUG=XX" preprocessor define being present in the
          220  +              "INTEROP_DEBUG_DEFINES" macro in the build properties file:
          221  +
          222  +                  "SQLite.Interop\props\SQLite.Interop.20YY.[vs]props"
          223  +
          224  +              for the corresponding version(s) of Visual Studio where the XX is
          225  +              an integer value that represents a combination of one or more of
          226  +              the following bit flags values (i.e. to enable extra diagnostics
          227  +              for a particular native function call):
          228  +
          229  +                  INTEROP_DEBUG_CLOSE      (0x01)
          230  +                  INTEROP_DEBUG_FINALIZE   (0x02)
          231  +                  INTEROP_DEBUG_OPEN       (0x04)
          232  +                  INTEROP_DEBUG_OPEN16     (0x08)
          233  +                  INTEROP_DEBUG_PREPARE    (0x10)
          234  +                  INTEROP_DEBUG_PREPARE16  (0x20)
          235  +                  INTEROP_DEBUG_RESET      (0x40)
          236  +    -->
          237  +    <InteropDebug Condition="'$(InteropDebug)' == '' And '$(Configuration)' == 'Debug'">true</InteropDebug>
          238  +    <InteropDebug Condition="'$(InteropDebug)' == '' And '$(Configuration)' != 'Debug'">false</InteropDebug>
          239  +
   214    240       <!--
   215    241           NOTE: Enable the use of native Windows APIs, when available?  By
   216    242                 default, this is enabled.  If this is disabled, all features
   217    243                 that require the use of native Windows APIs will be unavailable.
   218    244       -->
   219    245       <UseWindows Condition="'$(UseWindows)' == ''">true</UseWindows>
   220    246     </PropertyGroup>

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

    19     19   #if DEBUG
    20     20               "DEBUG",
    21     21   #endif
    22     22   
    23     23   #if INTEROP_CODEC
    24     24               "INTEROP_CODEC",
    25     25   #endif
           26  +
           27  +#if INTEROP_DEBUG
           28  +            "INTEROP_DEBUG",
           29  +#endif
    26     30   
    27     31   #if INTEROP_EXTENSION_FUNCTIONS
    28     32               "INTEROP_EXTENSION_FUNCTIONS",
    29     33   #endif
    30     34   
    31     35   #if INTEROP_TEST_EXTENSION
    32     36               "INTEROP_TEST_EXTENSION",

Changes to System.Data.SQLite/System.Data.SQLite.Properties.targets.

   134    134         NOTE: Enable support (in the managed assemblies) for encrypted databases
   135    135               using the CryptoAPI based codec?
   136    136     -->
   137    137     <PropertyGroup Condition="'$(InteropCodec)' != 'false'">
   138    138       <DefineConstants>$(DefineConstants);INTEROP_CODEC</DefineConstants>
   139    139     </PropertyGroup>
   140    140   
          141  +  <!--
          142  +      NOTE: Enable extra diagnostics from the custom built interop DLL (see the
          143  +            "SQLite.NET.Settings.targets" file for more information)?
          144  +  -->
          145  +  <PropertyGroup Condition="'$(InteropDebug)' != 'false'">
          146  +    <DefineConstants>$(DefineConstants);INTEROP_DEBUG</DefineConstants>
          147  +  </PropertyGroup>
          148  +
   141    149     <!--
   142    150         NOTE: Enable various Trace.WriteLine statements included in the code,
   143    151               based on several criteria (see the "SQLite.NET.Settings.targets"
   144         -            file for more information).
          152  +            file for more information)?
   145    153     -->
   146    154     <PropertyGroup Condition="'$(TraceConnection)' != 'false'">
   147    155       <DefineConstants>$(DefineConstants);TRACE_CONNECTION</DefineConstants>
   148    156     </PropertyGroup>
   149    157   
   150    158     <PropertyGroup Condition="'$(TraceHandle)' != 'false'">
   151    159       <DefineConstants>$(DefineConstants);TRACE_HANDLE</DefineConstants>

Changes to Tests/backup.eagle.

    78     78   ###############################################################################
    79     79   
    80     80   for {set i 0} {$i < [llength $params(pages)]} {incr i} {
    81     81     set pages [lindex $params(pages) $i]
    82     82     set callback [lindex $params(callbacks) $i]
    83     83   
    84     84     runTest {test [appendArgs backup-1. $i] {BackupDatabase method} -setup {
    85         -    setupDb [set fileName(1) :memory:] "" "" "" "" "" false false false memDb
           85  +    setupDb [set fileName(1) :memory:] "" "" "" "" "" \
           86  +        false false false true memDb
           87  +
    86     88       setupDb [set fileName(2) [appendArgs backup-1. $i .db]]
    87     89     } -body {
    88     90       set id [object invoke Interpreter.GetActive NextId]
    89     91       set dataSource [file join [getDatabaseDirectory] $fileName(2)]
    90     92   
    91     93       sql execute $memDb {
    92     94         CREATE TABLE t1(x TEXT);

Changes to Tests/basic.eagle.

  1676   1676         System.Data.SQLite.UnsafeNativeMethods sqlite3_win32_set_directory 1 \
  1677   1677         $directory(data)]
  1678   1678   
  1679   1679     lappend result [object invoke -flags +NonPublic \
  1680   1680         System.Data.SQLite.UnsafeNativeMethods sqlite3_win32_set_directory 2 \
  1681   1681         $directory(temp)]
  1682   1682   
  1683         -  setupDb [set fileName data-1.33.db] "" "" "" "" "" false false
         1683  +  setupDb [set fileName data-1.33.db] "" "" "" "" "" false false false false
  1684   1684   
  1685   1685     sql execute $db "CREATE TABLE t1(x NOT NULL);"
  1686   1686   
  1687   1687     for {set i 1} {$i < 100} {incr i} {
  1688   1688       sql execute $db "INSERT INTO t1 (x) VALUES(?);" [list param1 String $i]
  1689   1689     }
  1690   1690   

Changes to Tests/common.eagle.

   353    353         #       the test interpreter created in the isolated application domain.
   354    354         #
   355    355         return [uplevel 1 [list subst [appendArgs $prefix {
   356    356           if {[hasRuntimeOption native]} then {
   357    357             object invoke Interpreter.GetActive AddRuntimeOption native
   358    358           }
   359    359   
          360  +        set ::test_channel {$::test_channel}
   360    361           set ::path {$::path}
   361    362           set ::test_year {[getBuildYear]}
   362    363           set ::test_configuration {[getBuildConfiguration]}
   363    364         } $suffix]]]
   364    365       }
   365    366   
   366    367       proc tryCopyBuildFile { fileName } {
................................................................................
   629    630         #
   630    631         return [expr {$fileName eq ":memory:" || \
   631    632             [string range $fileName 0 12] eq "file::memory:"}]
   632    633       }
   633    634   
   634    635       proc setupDb {
   635    636               fileName {mode ""} {dateTimeFormat ""} {dateTimeKind ""} {flags ""}
   636         -            {extra ""} {qualify true} {delete true} {uri false} {varName db} } {
          637  +            {extra ""} {qualify true} {delete true} {uri false}
          638  +            {temporary true} {varName db} } {
   637    639         #
   638    640         # NOTE: First, see if our caller has requested an in-memory database.
   639    641         #
   640    642         set isMemory [isMemoryDb $fileName]
   641    643   
   642    644         #
   643    645         # NOTE: For now, all test databases used by the test suite are placed into
................................................................................
   760    762         # NOTE: Open the database connection now, placing the opaque handle value
   761    763         #       into the variable specified by our caller.
   762    764         #
   763    765         set db [sql open -type SQLite [subst $connection]]
   764    766   
   765    767         #
   766    768         # NOTE: Configure the temporary directory for the newly opened database
   767         -      #       connection now.
          769  +      #       connection now unless the caller forbids it.
   768    770         #
   769         -      sql execute $db [appendArgs \
   770         -          "PRAGMA temp_store_directory = \"" [getTemporaryDirectory] "\";"]
          771  +      if {$temporary} then {
          772  +        sql execute $db [appendArgs \
          773  +            "PRAGMA temp_store_directory = \"" [getTemporaryDirectory] "\";"]
          774  +      }
          775  +
          776  +      #
          777  +      # NOTE: Always return the connection handle upon success.
          778  +      #
          779  +      return $db
   771    780       }
   772    781   
   773    782       proc getDbConnection { {varName db} } {
   774    783         #
   775    784         # NOTE: Refer to the specified variable (e.g. "db") in the context of our
   776    785         #       caller.  The handle to the database previously opened by [setupDb]
   777    786         #       should be stored there.

Changes to Tests/stress.eagle.

   111    111     #
   112    112     # NOTE: Make sure to remove any stale database from previous test runs.
   113    113     #
   114    114     cleanupFile $fileName(2)
   115    115   
   116    116     #############################################################################
   117    117   
   118         -  setupDb $fileName(1) "" "" "" "" "" false false true srcDb
          118  +  setupDb $fileName(1) "" "" "" "" "" false false true true srcDb
   119    119     setupDb $fileName(2)
   120    120   
   121    121     #############################################################################
   122    122   
   123    123     set workload(1) [list [list srcFileName dstFileName table count] {
   124    124       #
   125    125       # NOTE: Workload #1, CREATE TABLE statements.

Changes to Tests/tkt-2ce0870fad.eagle.

    39     39       set fileName {[appendArgs tkt-2ce0870fad-1. $i .db]}
    40     40   
    41     41       #
    42     42       # NOTE: Keep track of whether or not the global test year and configuration
    43     43       #       variables already exist in the primary application domain before the
    44     44       #       test.  If not, we will need to unset them after the test.
    45     45       #
           46  +    set hadTestChannel {[info exists ::test_channel]}
    46     47       set hadTestYear {[info exists ::test_year]}
    47     48       set hadTestYearClrV2 {[info exists ::test_year_clr_v2]}
    48     49       set hadTestYearClrV4 {[info exists ::test_year_clr_v4]}
    49     50       set hadTestConfiguration {[info exists ::test_configuration]}
    50     51     }] -body {
    51     52       set appDomainId(3) [object invoke AppDomain.CurrentDomain Id]
    52     53   
................................................................................
    77     78         unset -nocomplain ::test_year_clr_v2
    78     79       }
    79     80   
    80     81       if {!$hadTestYear} then {
    81     82         unset -nocomplain ::test_year
    82     83       }
    83     84   
           85  +    if {!$hadTestChannel} then {
           86  +      unset -nocomplain ::test_channel
           87  +    }
           88  +
    84     89       #
    85     90       # NOTE: If this is the primary application domain, skip unsetting the
    86     91       #       loop variable because the surrounding [for] command still needs
    87     92       #       it.
    88     93       #
    89     94       if {$i <= 1} then {
    90     95         unset -nocomplain i
    91     96       }
    92     97   
    93     98       unset -nocomplain assembly appDomainId db fileName hadTestConfiguration \
    94         -        hadTestYearClrV4 hadTestYearClrV2 hadTestYear
           99  +        hadTestYearClrV4 hadTestYearClrV2 hadTestYear hadTestChannel
    95    100     } -constraints {eagle monoBug28 command.sql compile.DATA\
    96    101   compile.ISOLATED_INTERPRETERS SQLite System.Data.SQLite} -isolationLevel \
    97    102   [expr {$i == 1 ? "AppDomain" : "Default"}] -match regexp -result \
    98    103   {^\d+ \d+ True System#Data#SQLite#SQLiteConnection#\d+$}}
    99    104   }
   100    105   
   101    106   ###############################################################################

Changes to Tests/tkt-ac47dd230a.eagle.

    19     19   runSQLiteTestPrologue
    20     20   
    21     21   ###############################################################################
    22     22   
    23     23   runTest {test tkt-ac47dd230a-1.1 {multiple AppDomains} -setup {
    24     24     for {set i 1} {$i < 3} {incr i} {
    25     25       set appDomain($i) [object invoke AppDomain CreateDomain \
    26         -        tkt-ac47dd230a-1.1.$i]
           26  +        [appendArgs tkt-ac47dd230a-1.1. $i]]
    27     27   
    28     28       set result null
    29     29       set interpreterHelper($i) [object invoke -alias InterpreterHelper \
    30     30           Create $appDomain($i) null Default Default null null null result]
    31     31   
    32     32       if {[string length $interpreterHelper($i)] == 0} then {
    33     33         error [object invoke $result ToString]