Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add NuGet package definition file. Make the test for ticket [b4a7ddc83f] work with the mixed-mode assembly. Add filters file for the VS2010 static mixed-mode assembly project. Make use of SQLITE_API macro in interop.c. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
99628f46feb2b261e1293d062c743800 |
User & Date: | mistachkin 2011-09-14 01:52:40.771 |
Context
2011-09-14
| ||
02:02 | Update build docs to include changing the NuSpec file when updating the version. check-in: 052b3a3beb user: mistachkin tags: trunk | |
01:52 | Add NuGet package definition file. Make the test for ticket [b4a7ddc83f] work with the mixed-mode assembly. Add filters file for the VS2010 static mixed-mode assembly project. Make use of SQLITE_API macro in interop.c. check-in: 99628f46fe user: mistachkin tags: trunk | |
2011-09-12
| ||
20:56 | Document recent changes in the version history. check-in: 5994d72daf user: mistachkin tags: trunk | |
Changes
Added SQLite.Interop/SQLite.Interop.Static.2010.vcxproj.filters.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 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 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 | <?xml version="1.0" encoding="utf-8"?> <!-- * * SQLite.Interop.Static.2010.vcxproj.filters - * * Written by Joe Mistachkin. * Released to the public domain, use at your own risk! * --> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <Filter Include="Source Files"> <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> </Filter> <Filter Include="Header Files"> <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> </Filter> <Filter Include="Resource Files"> <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions> </Filter> <Filter Include="Property Files"> <UniqueIdentifier>{d69d5c95-1d03-4325-ad06-fce223ab4e42}</UniqueIdentifier> </Filter> </ItemGroup> <ItemGroup> <ClCompile Include="src\win\AssemblyInfo.cpp"> <Filter>Source Files</Filter> </ClCompile> <ClCompile Include="src\win\crypt.c"> <Filter>Source Files</Filter> </ClCompile> <ClCompile Include="src\contrib\extension-functions.c"> <Filter>Source Files</Filter> </ClCompile> <ClCompile Include="src\win\interop.c"> <Filter>Source Files</Filter> </ClCompile> <ClCompile Include="src\core\sqlite3.c"> <Filter>Source Files</Filter> </ClCompile> </ItemGroup> <ItemGroup> <None Include="props\sqlite3.props"> <Filter>Property Files</Filter> </None> <None Include="props\SQLite.Interop.props"> <Filter>Property Files</Filter> </None> </ItemGroup> <ItemGroup> <ClInclude Include="src\core\sqlite3.h"> <Filter>Header Files</Filter> </ClInclude> <ClInclude Include="src\core\sqlite3ext.h"> <Filter>Header Files</Filter> </ClInclude> <ClInclude Include="src\win\interop.h"> <Filter>Header Files</Filter> </ClInclude> </ItemGroup> <ItemGroup> <ResourceCompile Include="src\win\SQLite.Interop.rc"> <Filter>Resource Files</Filter> </ResourceCompile> <EmbeddedResource Include="..\System.Data.SQLite\SR.resx"> <Filter>Resource Files</Filter> </EmbeddedResource> </ItemGroup> </Project> |
Changes to SQLite.Interop/src/win/interop.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | // Additional open flags, we use this one privately //#define SQLITE_OPEN_SHAREDCACHE 0x01000000 typedef void (*SQLITEUSERFUNC)(sqlite3_context *, int, sqlite3_value **); typedef void (*SQLITEFUNCFINAL)(sqlite3_context *); | | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | // Additional open flags, we use this one privately //#define SQLITE_OPEN_SHAREDCACHE 0x01000000 typedef void (*SQLITEUSERFUNC)(sqlite3_context *, int, sqlite3_value **); typedef void (*SQLITEFUNCFINAL)(sqlite3_context *); SQLITE_PRIVATE void * sqlite3DbMallocZero_interop(sqlite3 *db, int n) { void *p; if (db) { sqlite3_mutex_enter(db->mutex); } p = sqlite3DbMallocZero(db,n); if (db) { sqlite3_mutex_leave(db->mutex); } return p; } SQLITE_PRIVATE void sqlite3DbFree_interop(sqlite3 *db, void *p) { if (db) { sqlite3_mutex_enter(db->mutex); } if (p) { sqlite3MemdebugSetType(p, MEMTYPE_DB|MEMTYPE_HEAP); } |
︙ | ︙ | |||
49 50 51 52 53 54 55 | So, here we have a problem ... .NET has a pointer to any number of sqlite3_stmt objects. We can't call sqlite3_finalize() on these because 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 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 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 GC gets around to calling finalize_interop() on the "bad" statement, we detect that and finish deallocating the pointer. */ | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | So, here we have a problem ... .NET has a pointer to any number of sqlite3_stmt objects. We can't call sqlite3_finalize() on these because 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 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 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 GC gets around to calling finalize_interop() on the "bad" statement, we detect that and finish deallocating the pointer. */ SQLITE_API int WINAPI sqlite3_close_interop(sqlite3 *db) { int ret; ret = sqlite3_close(db); if (ret == SQLITE_BUSY && db->pVdbe) { |
︙ | ︙ | |||
93 94 95 96 97 98 99 | } ret = sqlite3_close(db); } return ret; } | | | | | | | | | | | | | | | | | | | 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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 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 223 224 225 226 227 228 229 230 | } ret = sqlite3_close(db); } return ret; } SQLITE_API int WINAPI sqlite3_open_interop(const char*filename, int flags, sqlite3 **ppdb) { int ret; //int sharedcache = ((flags & SQLITE_OPEN_SHAREDCACHE) != 0); //flags &= ~SQLITE_OPEN_SHAREDCACHE; //sqlite3_enable_shared_cache(sharedcache); ret = sqlite3_open_v2(filename, ppdb, flags, NULL); //sqlite3_enable_shared_cache(0); if (ret == 0) RegisterExtensionFunctions(*ppdb); return ret; } SQLITE_API int WINAPI sqlite3_open16_interop(const char *filename, int flags, sqlite3 **ppdb) { int ret = sqlite3_open_interop(filename, flags, ppdb); if (!ret) { if(!DbHasProperty(*ppdb, 0, DB_SchemaLoaded)) ENC(*ppdb) = SQLITE_UTF16NATIVE; } return ret; } 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; n = sqlite3_prepare(db, sql, nbytes, ppstmt, pztail); *plen = (*pztail != 0) ? strlen(*pztail) : 0; return n; } SQLITE_API int WINAPI sqlite3_prepare16_interop(sqlite3 *db, const void *sql, int nchars, sqlite3_stmt **ppstmt, const void **pztail, int *plen) { int n; n = sqlite3_prepare16(db, sql, nchars * sizeof(wchar_t), ppstmt, pztail); *plen = (*pztail != 0) ? wcslen((wchar_t *)*pztail) * sizeof(wchar_t) : 0; return n; } SQLITE_API int WINAPI sqlite3_bind_double_interop(sqlite3_stmt *stmt, int iCol, double *val) { return sqlite3_bind_double(stmt,iCol,*val); } SQLITE_API int WINAPI sqlite3_bind_int64_interop(sqlite3_stmt *stmt, int iCol, sqlite_int64 *val) { return sqlite3_bind_int64(stmt,iCol,*val); } SQLITE_API const char * WINAPI sqlite3_bind_parameter_name_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_bind_parameter_name(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } SQLITE_API const char * WINAPI sqlite3_column_name_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_column_name(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } SQLITE_API const void * WINAPI sqlite3_column_name16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_name16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } SQLITE_API const char * WINAPI sqlite3_column_decltype_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_column_decltype(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } SQLITE_API const void * WINAPI sqlite3_column_decltype16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_decltype16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } SQLITE_API void WINAPI sqlite3_column_double_interop(sqlite3_stmt *stmt, int iCol, double *val) { *val = sqlite3_column_double(stmt,iCol); } SQLITE_API void WINAPI sqlite3_column_int64_interop(sqlite3_stmt *stmt, int iCol, sqlite_int64 *val) { *val = sqlite3_column_int64(stmt,iCol); } SQLITE_API const unsigned char * WINAPI sqlite3_column_text_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const unsigned char *pval = sqlite3_column_text(stmt, iCol); *plen = (pval != 0) ? strlen((char *)pval) : 0; return pval; } SQLITE_API const void * WINAPI sqlite3_column_text16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_text16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t): 0; return pval; } SQLITE_API int WINAPI sqlite3_finalize_interop(sqlite3_stmt *stmt) { Vdbe *p; sqlite3 *db; int ret; p = (Vdbe *)stmt; if (p && p->magic == VDBE_MAGIC_DEAD) |
︙ | ︙ | |||
238 239 240 241 242 243 244 | } else ret = sqlite3_finalize(stmt); return ret; } | | | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | } else ret = sqlite3_finalize(stmt); return ret; } SQLITE_API int WINAPI sqlite3_reset_interop(sqlite3_stmt *stmt) { int ret; if (((Vdbe *)stmt)->magic == VDBE_MAGIC_DEAD) return SQLITE_SCHEMA; ret = sqlite3_reset(stmt); return ret; } 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) { int n; if (eTextRep == SQLITE_UTF16) eTextRep = SQLITE_UTF16NATIVE; n = sqlite3_create_function(psql, zFunctionName, nArg, eTextRep, 0, func, funcstep, funcfinal); |
︙ | ︙ | |||
270 271 272 273 274 275 276 | } } } return n; } | | | | | | | | | | | | | | | | | | 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | } } } return n; } SQLITE_API void WINAPI sqlite3_value_double_interop(sqlite3_value *pval, double *val) { *val = sqlite3_value_double(pval); } SQLITE_API void WINAPI sqlite3_value_int64_interop(sqlite3_value *pval, sqlite_int64 *val) { *val = sqlite3_value_int64(pval); } SQLITE_API const unsigned char * WINAPI sqlite3_value_text_interop(sqlite3_value *val, int *plen) { const unsigned char *pval = sqlite3_value_text(val); *plen = (pval != 0) ? strlen((char *)pval) : 0; return pval; } SQLITE_API const void * WINAPI sqlite3_value_text16_interop(sqlite3_value *val, int *plen) { const void *pval = sqlite3_value_text16(val); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } SQLITE_API void WINAPI sqlite3_result_double_interop(sqlite3_context *pctx, double *val) { sqlite3_result_double(pctx, *val); } SQLITE_API void WINAPI sqlite3_result_int64_interop(sqlite3_context *pctx, sqlite_int64 *val) { sqlite3_result_int64(pctx, *val); } SQLITE_API int WINAPI sqlite3_context_collcompare(sqlite3_context *ctx, const void *p1, int p1len, const void *p2, int p2len) { if ((ctx->pFunc->flags & SQLITE_FUNC_NEEDCOLL) == 0) return 2; return ctx->pColl->xCmp(ctx->pColl->pUser, p1len, p1, p2len, p2); } SQLITE_API const char * WINAPI sqlite3_context_collseq(sqlite3_context *ctx, int *ptype, int *enc, int *plen) { CollSeq *pColl = ctx->pColl; *ptype = 0; *plen = 0; *enc = 0; if ((ctx->pFunc->flags & SQLITE_FUNC_NEEDCOLL) == 0) return NULL; if (pColl) { *enc = pColl->enc; *ptype = pColl->type; *plen = (pColl->zName != 0) ? strlen(pColl->zName) : 0; return pColl->zName; } return NULL; } SQLITE_API const char * WINAPI sqlite3_column_database_name_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_column_database_name(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } SQLITE_API const void * WINAPI sqlite3_column_database_name16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_database_name16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } SQLITE_API const char * WINAPI sqlite3_column_table_name_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_column_table_name(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } SQLITE_API const void * WINAPI sqlite3_column_table_name16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_table_name16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } SQLITE_API const char * WINAPI sqlite3_column_origin_name_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const char *pval = sqlite3_column_origin_name(stmt, iCol); *plen = (pval != 0) ? strlen(pval) : 0; return pval; } SQLITE_API const void * WINAPI sqlite3_column_origin_name16_interop(sqlite3_stmt *stmt, int iCol, int *plen) { const void *pval = sqlite3_column_origin_name16(stmt, iCol); *plen = (pval != 0) ? wcslen((wchar_t *)pval) * sizeof(wchar_t) : 0; return pval; } SQLITE_API int WINAPI sqlite3_table_column_metadata_interop(sqlite3 *db, const char *zDbName, const char *zTableName, const char *zColumnName, char **pzDataType, char **pzCollSeq, int *pNotNull, int *pPrimaryKey, int *pAutoinc, int *pdtLen, int *pcsLen) { int n; n = sqlite3_table_column_metadata(db, zDbName, zTableName, zColumnName, pzDataType, pzCollSeq, pNotNull, pPrimaryKey, pAutoinc); *pdtLen = (*pzDataType != 0) ? strlen(*pzDataType) : 0; *pcsLen = (*pzCollSeq != 0) ? strlen(*pzCollSeq) : 0; return n; } SQLITE_API int WINAPI sqlite3_index_column_info_interop(sqlite3 *db, const char *zDb, const char *zIndexName, const char *zColumnName, int *sortOrder, int *onError, char **pzColl, int *plen) { Index *pIdx; Table *pTab; int n; sqlite3_mutex_enter(db->mutex); sqlite3BtreeEnterAll(db); |
︙ | ︙ | |||
416 417 418 419 420 421 422 | return SQLITE_OK; } } return SQLITE_ERROR; } | | | 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | return SQLITE_OK; } } return SQLITE_ERROR; } SQLITE_API int WINAPI sqlite3_table_cursor(sqlite3_stmt *pstmt, int iDb, Pgno tableRootPage) { Vdbe *p = (Vdbe *)pstmt; sqlite3 *db = (p == NULL) ? NULL : p->db; int n; int ret = -1; sqlite3_mutex_enter(db->mutex); |
︙ | ︙ | |||
439 440 441 442 443 444 445 | } } sqlite3_mutex_leave(db->mutex); return ret; } | | | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | } } sqlite3_mutex_leave(db->mutex); return ret; } SQLITE_API int WINAPI sqlite3_cursor_rowid(sqlite3_stmt *pstmt, int cursor, sqlite_int64 *prowid) { Vdbe *p = (Vdbe *)pstmt; sqlite3 *db = (p == NULL) ? NULL : p->db; VdbeCursor *pC; int ret = 0; sqlite3_mutex_enter(db->mutex); |
︙ | ︙ | |||
498 499 500 501 502 503 504 | } sqlite3_mutex_leave(db->mutex); return ret; } #endif // SQLITE_OS_WIN | < | 498 499 500 501 502 503 504 | } sqlite3_mutex_leave(db->mutex); return ret; } #endif // SQLITE_OS_WIN |
Added SQLite.nuspec.
> > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <?xml version="1.0" encoding="utf-8"?> <package> <metadata> <id>System.Data.SQLite</id> <version>1.0.75.0</version> <authors>SQLite Development Team</authors> <description>The official SQLite database engine combined with a complete ADO.NET provider all rolled into a single mixed-mode assembly.</description> <language>en-US</language> <projectUrl>http://system.data.sqlite.org/</projectUrl> <iconUrl>http://system.data.sqlite.org/images/sqlite32.png</iconUrl> <licenseUrl>http://www.sqlite.org/copyright.html</licenseUrl> <tags>sqlite database ado.net provider interop</tags> </metadata> <files> <file src="bin\2010\Win32\ReleaseStatic\System.Data.SQLite.dll" target="lib" /> </files> </package> |
Changes to Tests/tkt-b4a7ddc83f.eagle.
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ############################################################################### for {set i 1} {$i < 3} {incr i} { runTest {test tkt-b4a7ddc83f-1.$i {logging shutdown} -setup [subst { set appDomainId(1) [object invoke AppDomain.CurrentDomain Id] set fileName tkt-b4a7ddc83f-1.$i.db set ::path {$::path} set ::test_year [getBuildYear] set ::test_configuration [getBuildConfiguration] }] -body { set appDomainId(2) [object invoke AppDomain.CurrentDomain Id] | > > > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | ############################################################################### for {set i 1} {$i < 3} {incr i} { runTest {test tkt-b4a7ddc83f-1.$i {logging shutdown} -setup [subst { set appDomainId(1) [object invoke AppDomain.CurrentDomain Id] set fileName tkt-b4a7ddc83f-1.$i.db if {[hasRuntimeOption native]} then { object invoke Interpreter.GetActive AddRuntimeOption native } set ::path {$::path} set ::test_year [getBuildYear] set ::test_configuration [getBuildConfiguration] }] -body { set appDomainId(2) [object invoke AppDomain.CurrentDomain Id] |
︙ | ︙ |