Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix vtshim error message handling. Adjust the data-1.28 test to account for the new SQLite3 constructor parameters. Fix delegate declaration for the xFilter method. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | virtualTables |
Files: | files | file ages | folders |
SHA1: |
ee4c57e43536751f87a85c7ee4231205 |
User & Date: | mistachkin 2013-06-21 21:01:03.401 |
Context
2013-06-21
| ||
23:44 | In the SQLite3.Close method, be sure to null out of the _sql field when _ownHandle is false. Centralize the SQLite3 instance creation logic used by the SQLiteConnection class. Restrict the ConnectionStringBuilder test to run only when SQLite is in use. check-in: 67f779810e user: mistachkin tags: virtualTables | |
21:01 | Fix vtshim error message handling. Adjust the data-1.28 test to account for the new SQLite3 constructor parameters. Fix delegate declaration for the xFilter method. check-in: ee4c57e435 user: mistachkin tags: virtualTables | |
18:13 | Correct vtable related maximum memory allocation calculation. Also, always use a lock statement for better portability to the .NET Compact Framework. check-in: 33eaa98450 user: mistachkin tags: virtualTables | |
Changes
Changes to SQLite.Interop/src/ext/vtshim.c.
︙ | ︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | /* A vtshim cursor object */ struct vtshim_cursor { sqlite3_vtab_cursor base; /* Base class - must be first */ sqlite3_vtab_cursor *pChild; /* Cursor generated by the managed subclass */ vtshim_cursor **ppPrev; /* Previous on list of all cursors */ vtshim_cursor *pNext; /* Next on list of all cursors */ }; /* Methods for the vtshim module */ static int vtshimCreate( sqlite3 *db, void *ppAux, int argc, const char *const*argv, sqlite3_vtab **ppVtab, char **pzErr ){ vtshim_aux *pAux = (vtshim_aux*)ppAux; vtshim_vtab *pNew; int rc; assert( db==pAux->db ); pNew = sqlite3_malloc( sizeof(*pNew) ); *ppVtab = (sqlite3_vtab*)pNew; if( pNew==0 ) return SQLITE_NOMEM; memset(pNew, 0, sizeof(*pNew)); rc = pAux->pMod->xCreate(db, pAux->pChildAux, argc, argv, &pNew->pChild, pzErr); if( rc ){ | > > > > > > > > > > > > > > | 53 54 55 56 57 58 59 60 61 62 63 64 65 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 | /* A vtshim cursor object */ struct vtshim_cursor { sqlite3_vtab_cursor base; /* Base class - must be first */ sqlite3_vtab_cursor *pChild; /* Cursor generated by the managed subclass */ vtshim_cursor **ppPrev; /* Previous on list of all cursors */ vtshim_cursor *pNext; /* Next on list of all cursors */ }; /* Macro used to copy the child vtable error message to outer vtable */ #define VTSHIM_COPY_ERRMSG() \ do { \ sqlite3_free(pVtab->base.zErrMsg); \ pVtab->base.zErrMsg = sqlite3_mprintf("%s", pVtab->pChild->zErrMsg); \ } while (0) /* Methods for the vtshim module */ static int vtshimCreate( sqlite3 *db, void *ppAux, int argc, const char *const*argv, sqlite3_vtab **ppVtab, char **pzErr ){ vtshim_aux *pAux = (vtshim_aux*)ppAux; vtshim_vtab *pNew; int rc; assert( db==pAux->db ); if( pAux->bDisposed ){ if( pzErr ){ *pzErr = sqlite3_mprintf("virtual table was disposed: \"%s\"", pAux->zName); } return SQLITE_ERROR; } pNew = sqlite3_malloc( sizeof(*pNew) ); *ppVtab = (sqlite3_vtab*)pNew; if( pNew==0 ) return SQLITE_NOMEM; memset(pNew, 0, sizeof(*pNew)); rc = pAux->pMod->xCreate(db, pAux->pChildAux, argc, argv, &pNew->pChild, pzErr); if( rc ){ |
︙ | ︙ | |||
99 100 101 102 103 104 105 106 107 108 109 110 111 112 | char **pzErr ){ vtshim_aux *pAux = (vtshim_aux*)ppAux; vtshim_vtab *pNew; int rc; assert( db==pAux->db ); pNew = sqlite3_malloc( sizeof(*pNew) ); *ppVtab = (sqlite3_vtab*)pNew; if( pNew==0 ) return SQLITE_NOMEM; memset(pNew, 0, sizeof(*pNew)); rc = pAux->pMod->xConnect(db, pAux->pChildAux, argc, argv, &pNew->pChild, pzErr); if( rc ){ | > > > > > > > | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | char **pzErr ){ vtshim_aux *pAux = (vtshim_aux*)ppAux; vtshim_vtab *pNew; int rc; assert( db==pAux->db ); if( pAux->bDisposed ){ if( pzErr ){ *pzErr = sqlite3_mprintf("virtual table was disposed: \"%s\"", pAux->zName); } return SQLITE_ERROR; } pNew = sqlite3_malloc( sizeof(*pNew) ); *ppVtab = (sqlite3_vtab*)pNew; if( pNew==0 ) return SQLITE_NOMEM; memset(pNew, 0, sizeof(*pNew)); rc = pAux->pMod->xConnect(db, pAux->pChildAux, argc, argv, &pNew->pChild, pzErr); if( rc ){ |
︙ | ︙ | |||
123 124 125 126 127 128 129 130 | static int vtshimBestIndex( sqlite3_vtab *pBase, sqlite3_index_info *pIdxInfo ){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; if( pAux->bDisposed ) return SQLITE_ERROR; | > | > > | > | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | static int vtshimBestIndex( sqlite3_vtab *pBase, sqlite3_index_info *pIdxInfo ){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xBestIndex(pVtab->pChild, pIdxInfo); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimDisconnect(sqlite3_vtab *pBase){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc = SQLITE_OK; if( !pAux->bDisposed ){ rc = pAux->pMod->xDisconnect(pVtab->pChild); |
︙ | ︙ | |||
160 161 162 163 164 165 166 | static int vtshimOpen(sqlite3_vtab *pBase, sqlite3_vtab_cursor **ppCursor){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; vtshim_cursor *pCur; int rc; *ppCursor = 0; | | > > > > > | > > > > > | > > > > > | | > > > | > > > > > | > > > > > | > > > > > | > > > > > | > > > > > | > > > > > | > > > > > | | > > > | > > > > > | > > > > > | > > > > > | > > > > | 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 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 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | static int vtshimOpen(sqlite3_vtab *pBase, sqlite3_vtab_cursor **ppCursor){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; vtshim_cursor *pCur; int rc; *ppCursor = 0; if( pAux->bDisposed ) return SQLITE_ERROR; pCur = sqlite3_malloc( sizeof(*pCur) ); if( pCur==0 ) return SQLITE_NOMEM; memset(pCur, 0, sizeof(*pCur)); rc = pAux->pMod->xOpen(pVtab->pChild, &pCur->pChild); if( rc ){ sqlite3_free(pCur); VTSHIM_COPY_ERRMSG(); return rc; } pCur->pChild->pVtab = pVtab->pChild; *ppCursor = &pCur->base; pCur->ppPrev = &pVtab->pAllCur; if( pVtab->pAllCur ) pVtab->pAllCur->ppPrev = &pCur->pNext; pCur->pNext = pVtab->pAllCur; pVtab->pAllCur = pCur; return SQLITE_OK; } static int vtshimClose(sqlite3_vtab_cursor *pX){ vtshim_cursor *pCur = (vtshim_cursor*)pX; vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab; vtshim_aux *pAux = pVtab->pAux; int rc = SQLITE_OK; if( !pAux->bDisposed ){ rc = pAux->pMod->xClose(pCur->pChild); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } } if( pCur->pNext ) pCur->pNext->ppPrev = pCur->ppPrev; *pCur->ppPrev = pCur->pNext; sqlite3_free(pCur); return rc; } static int vtshimFilter( sqlite3_vtab_cursor *pX, int idxNum, const char *idxStr, int argc, sqlite3_value **argv ){ vtshim_cursor *pCur = (vtshim_cursor*)pX; vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xFilter(pCur->pChild, idxNum, idxStr, argc, argv); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimNext(sqlite3_vtab_cursor *pX){ vtshim_cursor *pCur = (vtshim_cursor*)pX; vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xNext(pCur->pChild); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimEof(sqlite3_vtab_cursor *pX){ vtshim_cursor *pCur = (vtshim_cursor*)pX; vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return 1; rc = pAux->pMod->xEof(pCur->pChild); VTSHIM_COPY_ERRMSG(); return rc; } static int vtshimColumn(sqlite3_vtab_cursor *pX, sqlite3_context *ctx, int i){ vtshim_cursor *pCur = (vtshim_cursor*)pX; vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xColumn(pCur->pChild, ctx, i); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimRowid(sqlite3_vtab_cursor *pX, sqlite3_int64 *pRowid){ vtshim_cursor *pCur = (vtshim_cursor*)pX; vtshim_vtab *pVtab = (vtshim_vtab*)pCur->base.pVtab; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xRowid(pCur->pChild, pRowid); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimUpdate( sqlite3_vtab *pBase, int argc, sqlite3_value **argv, sqlite3_int64 *pRowid ){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xUpdate(pVtab->pChild, argc, argv, pRowid); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimBegin(sqlite3_vtab *pBase){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xBegin(pVtab->pChild); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimSync(sqlite3_vtab *pBase){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xSync(pVtab->pChild); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimCommit(sqlite3_vtab *pBase){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xCommit(pVtab->pChild); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimRollback(sqlite3_vtab *pBase){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xRollback(pVtab->pChild); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimFindFunction( sqlite3_vtab *pBase, int nArg, const char *zName, void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), void **ppArg ){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return 0; rc = pAux->pMod->xFindFunction(pVtab->pChild, nArg, zName, pxFunc, ppArg); VTSHIM_COPY_ERRMSG(); return rc; } static int vtshimRename(sqlite3_vtab *pBase, const char *zNewName){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xRename(pVtab->pChild, zNewName); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimSavepoint(sqlite3_vtab *pBase, int n){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xSavepoint(pVtab->pChild, n); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimRelease(sqlite3_vtab *pBase, int n){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xRelease(pVtab->pChild, n); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } static int vtshimRollbackTo(sqlite3_vtab *pBase, int n){ vtshim_vtab *pVtab = (vtshim_vtab*)pBase; vtshim_aux *pAux = pVtab->pAux; int rc; if( pAux->bDisposed ) return SQLITE_ERROR; rc = pAux->pMod->xRollbackTo(pVtab->pChild, n); if( rc!=SQLITE_OK ){ VTSHIM_COPY_ERRMSG(); } return rc; } /* The destructor function for a disposible module */ static void vtshimAuxDestructor(void *pXAux){ vtshim_aux *pAux = (vtshim_aux*)pXAux; assert( pAux->pAllVtab==0 ); if( !pAux->bDisposed && pAux->xChildDestroy ){ |
︙ | ︙ |
Changes to System.Data.SQLite/UnsafeNativeMethods.cs.
︙ | ︙ | |||
1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif public delegate SQLiteErrorCode xFilter( IntPtr pCursor, int idxNum, IntPtr idxStr, int argc, IntPtr[] argv ); /////////////////////////////////////////////////////////////////////////// #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] | > | 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] #endif public delegate SQLiteErrorCode xFilter( IntPtr pCursor, int idxNum, IntPtr idxStr, int argc, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] IntPtr[] argv ); /////////////////////////////////////////////////////////////////////////// #if !PLATFORM_COMPACTFRAMEWORK [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
︙ | ︙ |
Changes to Tests/basic.eagle.
︙ | ︙ | |||
1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 | runTest {test data-1.28 {SetMemoryStatus method} -setup { # # NOTE: Make sure that SQLite core library is completely shutdown prior to # starting this test. # shutdownSQLite $test_channel # # NOTE: Create an instance of the core SQLite library interop wrapper class. # set sqlite3 [object create -flags +NonPublic System.Data.SQLite.SQLite3 \ | > > > > > | | 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 | runTest {test data-1.28 {SetMemoryStatus method} -setup { # # NOTE: Make sure that SQLite core library is completely shutdown prior to # starting this test. # shutdownSQLite $test_channel # # NOTE: Create an IntPtr instance with a value of zero. # set zero [object invoke -create IntPtr Zero] # # NOTE: Create an instance of the core SQLite library interop wrapper class. # set sqlite3 [object create -flags +NonPublic System.Data.SQLite.SQLite3 \ Default Unspecified null $zero null true] } -body { set result(rc1) [object invoke -flags +NonPublic $sqlite3 SetMemoryStatus \ false] set result(before) [object invoke -flags +NonPublic $sqlite3 MemoryUsed] set result(ptr1) [object invoke -create -flags +NonPublic \ |
︙ | ︙ | |||
1538 1539 1540 1541 1542 1543 1544 | # upon entry into this test (i.e. because the underlying core # library property is currently write-only). # object invoke -flags +NonPublic System.Data.SQLite.UnsafeNativeMethods \ sqlite3_config_int SQLITE_CONFIG_MEMSTATUS 1 } | | | 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 | # upon entry into this test (i.e. because the underlying core # library property is currently write-only). # object invoke -flags +NonPublic System.Data.SQLite.UnsafeNativeMethods \ sqlite3_config_int SQLITE_CONFIG_MEMSTATUS 1 } unset -nocomplain result sqlite3 zero } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \ regexp -result {^Ok Misuse Ok Ok System#IntPtr#\d+ System#IntPtr#\d+ \d+ \d+\ \d+ \d+ \d+ True True True True True True$}} ############################################################################### |
︙ | ︙ |
Changes to Tests/vtab.eagle.
︙ | ︙ | |||
206 207 208 209 210 211 212 | unset -nocomplain result code results errors sql dataSource id db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \ regexp -result [string map [list \n \r\n] {^Ok\ System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{one two three 4 5.0 Error\ \{SQL logic error or missing database | | | 206 207 208 209 210 211 212 213 214 215 216 217 218 | unset -nocomplain result code results errors sql dataSource id db fileName } -constraints \ {eagle monoBug28 command.sql compile.DATA SQLite System.Data.SQLite} -match \ regexp -result [string map [list \n \r\n] {^Ok\ System#CodeDom#Compiler#CompilerResults#\d+ \{\} 0 \{one two three 4 5.0 Error\ \{SQL logic error or missing database virtual table "t\d+" is read-only\}\}$}]} ############################################################################### runSQLiteTestEpilogue runTestEpilogue |