Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add ext/misc/vfslog.c, a VFS shim for unix that keeps a log of method calls made by SQLite. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
24a827b87666670c56d68a18685f4f71 |
User & Date: | dan 2013-10-10 13:04:46.705 |
Context
2013-10-10
| ||
13:38 | Fix the hash signature algorithm in vfslog.c. Add a utility program to show the hash signatures for every page of a database file. (check-in: eaf4de13a6 user: drh tags: trunk) | |
13:04 | Add ext/misc/vfslog.c, a VFS shim for unix that keeps a log of method calls made by SQLite. (check-in: 24a827b876 user: dan tags: trunk) | |
12:38 | Estimate row sizes for tables and indices and use those estimates during query planning. Enhance the index_info pragma to show the estimated row sizes and to show the estimated row size for the main table as well. Allow an alternative row size estimate to be specified in the sqlite_stat1 table. (check-in: d27b88b8c2 user: drh tags: trunk) | |
Changes
Added ext/misc/vfslog.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 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 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 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 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 | /* ** 2013-10-09 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains the implementation of an SQLite vfs wrapper for ** unix that generates per-database log files of all disk activity. */ /* ** This module contains code for a wrapper VFS that causes a log of ** most VFS calls to be written into a file on disk. The log ** is stored as comma-separated variables. ** ** All calls on sqlite3_file objects are logged. ** Additionally, calls to the xAccess(), xOpen(), and xDelete() ** methods are logged. The other sqlite3_vfs object methods (xDlXXX, ** xRandomness, xSleep, xCurrentTime, xGetLastError and xCurrentTimeInt64) ** are not logged. */ #include "sqlite3.h" #include <string.h> #include <assert.h> #include <stdio.h> /* ** Forward declaration of objects used by this utility */ typedef struct VLogLog VLogLog; typedef struct VLogVfs VLogVfs; typedef struct VLogFile VLogFile; /* There is a pair (an array of size 2) of the following objects for ** each database file being logged. The first contains the filename ** and is used to log I/O with the main database. The second has ** a NULL filename and is used to log I/O for the journal. Both ** out pointers are the same. */ struct VLogLog { VLogLog *pNext; /* Next in a list of all active logs */ VLogLog **ppPrev; /* Pointer to this in the list */ int nRef; /* Number of references to this object */ int nFilename; /* Length of zFilename in bytes */ char *zFilename; /* Name of database file. NULL for journal */ FILE *out; /* Write information here */ }; struct VLogVfs { sqlite3_vfs base; /* VFS methods */ sqlite3_vfs *pVfs; /* Parent VFS */ }; struct VLogFile { sqlite3_file base; /* IO methods */ sqlite3_file *pReal; /* Underlying file handle */ VLogLog *pLog; /* The log file for this file */ }; #define REALVFS(p) (((VLogVfs*)(p))->pVfs) /* ** Methods for VLogFile */ static int vlogClose(sqlite3_file*); static int vlogRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); static int vlogWrite(sqlite3_file*,const void*,int iAmt, sqlite3_int64 iOfst); static int vlogTruncate(sqlite3_file*, sqlite3_int64 size); static int vlogSync(sqlite3_file*, int flags); static int vlogFileSize(sqlite3_file*, sqlite3_int64 *pSize); static int vlogLock(sqlite3_file*, int); static int vlogUnlock(sqlite3_file*, int); static int vlogCheckReservedLock(sqlite3_file*, int *pResOut); static int vlogFileControl(sqlite3_file*, int op, void *pArg); static int vlogSectorSize(sqlite3_file*); static int vlogDeviceCharacteristics(sqlite3_file*); /* ** Methods for VLogVfs */ static int vlogOpen(sqlite3_vfs*, const char *, sqlite3_file*, int , int *); static int vlogDelete(sqlite3_vfs*, const char *zName, int syncDir); static int vlogAccess(sqlite3_vfs*, const char *zName, int flags, int *); static int vlogFullPathname(sqlite3_vfs*, const char *zName, int, char *zOut); static void *vlogDlOpen(sqlite3_vfs*, const char *zFilename); static void vlogDlError(sqlite3_vfs*, int nByte, char *zErrMsg); static void (*vlogDlSym(sqlite3_vfs *pVfs, void *p, const char*zSym))(void); static void vlogDlClose(sqlite3_vfs*, void*); static int vlogRandomness(sqlite3_vfs*, int nByte, char *zOut); static int vlogSleep(sqlite3_vfs*, int microseconds); static int vlogCurrentTime(sqlite3_vfs*, double*); static int vlogGetLastError(sqlite3_vfs*, int, char *); static int vlogCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*); static VLogVfs vlog_vfs = { { 1, /* iVersion */ 0, /* szOsFile (set by register_vlog()) */ 1024, /* mxPathname */ 0, /* pNext */ "vfslog", /* zName */ 0, /* pAppData */ vlogOpen, /* xOpen */ vlogDelete, /* xDelete */ vlogAccess, /* xAccess */ vlogFullPathname, /* xFullPathname */ vlogDlOpen, /* xDlOpen */ vlogDlError, /* xDlError */ vlogDlSym, /* xDlSym */ vlogDlClose, /* xDlClose */ vlogRandomness, /* xRandomness */ vlogSleep, /* xSleep */ vlogCurrentTime, /* xCurrentTime */ vlogGetLastError, /* xGetLastError */ vlogCurrentTimeInt64 /* xCurrentTimeInt64 */ }, 0 }; static sqlite3_io_methods vlog_io_methods = { 1, /* iVersion */ vlogClose, /* xClose */ vlogRead, /* xRead */ vlogWrite, /* xWrite */ vlogTruncate, /* xTruncate */ vlogSync, /* xSync */ vlogFileSize, /* xFileSize */ vlogLock, /* xLock */ vlogUnlock, /* xUnlock */ vlogCheckReservedLock, /* xCheckReservedLock */ vlogFileControl, /* xFileControl */ vlogSectorSize, /* xSectorSize */ vlogDeviceCharacteristics, /* xDeviceCharacteristics */ 0, /* xShmMap */ 0, /* xShmLock */ 0, /* xShmBarrier */ 0 /* xShmUnmap */ }; #if SQLITE_OS_UNIX && !defined(NO_GETTOD) #include <sys/time.h> static sqlite3_uint64 vlog_time(){ struct timeval sTime; gettimeofday(&sTime, 0); return sTime.tv_usec + (sqlite3_uint64)sTime.tv_sec * 1000000; } #elif SQLITE_OS_WIN #include <windows.h> #include <time.h> static sqlite3_uint64 vlog_time(){ FILETIME ft; sqlite3_uint64 u64time = 0; GetSystemTimeAsFileTime(&ft); u64time |= ft.dwHighDateTime; u64time <<= 32; u64time |= ft.dwLowDateTime; /* ft is 100-nanosecond intervals, we want microseconds */ return u64time /(sqlite3_uint64)10; } #else static sqlite3_uint64 vlog_time(){ return 0; } #endif /* ** Write a message to the log file */ static void vlogLogPrint( VLogLog *pLog, /* The log file to write into */ sqlite3_int64 tStart, /* Start time of system call */ sqlite3_int64 tElapse, /* Elapse time of system call */ const char *zOp, /* Type of system call */ sqlite3_int64 iArg1, /* First argument */ sqlite3_int64 iArg2, /* Second argument */ const char *zArg3, /* Third argument */ int iRes /* Result */ ){ char z1[40], z2[40], z3[70]; if( pLog==0 ) return; if( iArg1>=0 ){ sqlite3_snprintf(sizeof(z1), z1, "%lld", iArg1); }else{ z1[0] = 0; } if( iArg2>=0 ){ sqlite3_snprintf(sizeof(z2), z2, "%lld", iArg2); }else{ z2[0] = 0; } if( zArg3 ){ sqlite3_snprintf(sizeof(z3), z3, "\"%s\"", zArg3); }else{ z3[0] = 0; } fprintf(pLog->out,"%lld,%lld,%s,%d,%s,%s,%s,%d\n", tStart, tElapse, zOp, pLog->zFilename==0, z1, z2, z3, iRes); } /* ** List of all active log connections. Protected by the master mutex. */ static VLogLog *allLogs = 0; /* ** Close a VLogLog object */ static void vlogLogClose(VLogLog *p){ if( p ){ sqlite3_mutex *pMutex; p->nRef--; if( p->nRef>0 || p->zFilename==0 ) return; pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); sqlite3_mutex_enter(pMutex); *p->ppPrev = p->pNext; if( p->pNext ) p->pNext->ppPrev = p->ppPrev; sqlite3_mutex_leave(pMutex); fclose(p->out); sqlite3_free(p); } } /* ** Open a VLogLog object on the given file */ static VLogLog *vlogLogOpen(const char *zFilename){ int nName = (int)strlen(zFilename); int isJournal = 0; sqlite3_mutex *pMutex; VLogLog *pLog, *pTemp; if( nName>4 && strcmp(zFilename+nName-4,"-wal")==0 ){ return 0; /* Do not log wal files */ }else if( nName>8 && strcmp(zFilename+nName-8,"-journal")==0 ){ nName -= 8; isJournal = 1; }else if( nName>12 && sqlite3_strglob("-mj??????9??", zFilename+nName-12)==0 ){ return 0; /* Do not log master journal files */ } pTemp = sqlite3_malloc( sizeof(*pLog)*2 + nName + 60 ); if( pTemp==0 ) return 0; pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); sqlite3_mutex_enter(pMutex); for(pLog=allLogs; pLog; pLog=pLog->pNext){ if( pLog->nFilename==nName && !memcmp(pLog->zFilename, zFilename, nName) ){ break; } } if( pLog==0 ){ pLog = pTemp; pTemp = 0; memset(pLog, 0, sizeof(*pLog)*2); pLog->zFilename = (char*)&pLog[2]; sqlite3_snprintf(nName+60, pLog->zFilename, "%.*s-debuglog-%lld", nName, zFilename, vlog_time()); pLog->out = fopen(pLog->zFilename, "a"); if( pLog->out==0 ){ sqlite3_mutex_leave(pMutex); sqlite3_free(pLog); return 0; } pLog->nFilename = nName; pLog[1].out = pLog[0].out; pLog->ppPrev = &allLogs; if( allLogs ) allLogs->ppPrev = &pLog->pNext; pLog->pNext = allLogs; allLogs = pLog; } sqlite3_mutex_leave(pMutex); sqlite3_free(pTemp); if( pLog && isJournal ) pLog++; pLog->nRef++; return pLog; } /* ** Close an vlog-file. */ static int vlogClose(sqlite3_file *pFile){ sqlite3_uint64 tStart, tElapse; int rc = SQLITE_OK; VLogFile *p = (VLogFile *)pFile; tStart = vlog_time(); if( p->pReal->pMethods ){ rc = p->pReal->pMethods->xClose(p->pReal); } tElapse = vlog_time() - tStart; vlogLogPrint(p->pLog, tStart, tElapse, "CLOSE", -1, -1, 0, rc); vlogLogClose(p->pLog); return rc; } /* ** Compute signature for a block of content. ** ** The signature is a hex dump of the first 8 bytes of the block ** followed by a 64bit hash (expressed in hex) of the entire content. */ static void vlogSignature(unsigned char *p, int n, char *zCksum){ unsigned int s0 = 0, s1 = 0; unsigned int *pI; int i; pI = (unsigned int*)p; for(i=0; i<n-7; i+=8){ s0 += pI[0] + s1; s1 += pI[1] + s0; pI += 2; } for(i=0; i<8 && i<n; i++) sqlite3_snprintf(3, zCksum+i, "%02x", p[i]); if( n>8 ) sqlite3_snprintf(18, zCksum+i, "-%08x08x", s0, s1); } /* ** Read data from an vlog-file. */ static int vlogRead( sqlite3_file *pFile, void *zBuf, int iAmt, sqlite_int64 iOfst ){ int rc; sqlite3_uint64 tStart, tElapse; VLogFile *p = (VLogFile *)pFile; char zSig[40]; tStart = vlog_time(); rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst); tElapse = vlog_time() - tStart; if( rc==SQLITE_OK ){ vlogSignature(zBuf, iAmt, zSig); }else{ zSig[0] = 0; } vlogLogPrint(p->pLog, tStart, tElapse, "READ", iAmt, iOfst, zSig, rc); return rc; } /* ** Write data to an vlog-file. */ static int vlogWrite( sqlite3_file *pFile, const void *z, int iAmt, sqlite_int64 iOfst ){ int rc; sqlite3_uint64 tStart, tElapse; VLogFile *p = (VLogFile *)pFile; char zSig[40]; tStart = vlog_time(); vlogSignature((unsigned char*)z, iAmt, zSig); rc = p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst); tElapse = vlog_time() - tStart; vlogLogPrint(p->pLog, tStart, tElapse, "WRITE", iAmt, iOfst, zSig, rc); return rc; } /* ** Truncate an vlog-file. */ static int vlogTruncate(sqlite3_file *pFile, sqlite_int64 size){ int rc; sqlite3_uint64 tStart, tElapse; VLogFile *p = (VLogFile *)pFile; tStart = vlog_time(); rc = p->pReal->pMethods->xTruncate(p->pReal, size); tElapse = vlog_time() - tStart; vlogLogPrint(p->pLog, tStart, tElapse, "TRUNCATE", size, -1, 0, rc); return rc; } /* ** Sync an vlog-file. */ static int vlogSync(sqlite3_file *pFile, int flags){ int rc; sqlite3_uint64 tStart, tElapse; VLogFile *p = (VLogFile *)pFile; tStart = vlog_time(); rc = p->pReal->pMethods->xSync(p->pReal, flags); tElapse = vlog_time() - tStart; vlogLogPrint(p->pLog, tStart, tElapse, "SYNC", flags, -1, 0, rc); return rc; } /* ** Return the current file-size of an vlog-file. */ static int vlogFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ int rc; sqlite3_uint64 tStart, tElapse; VLogFile *p = (VLogFile *)pFile; tStart = vlog_time(); rc = p->pReal->pMethods->xFileSize(p->pReal, pSize); tElapse = vlog_time() - tStart; vlogLogPrint(p->pLog, tStart, tElapse, "FILESIZE", *pSize, -1, 0, rc); return rc; } /* ** Lock an vlog-file. */ static int vlogLock(sqlite3_file *pFile, int eLock){ int rc; sqlite3_uint64 tStart, tElapse; VLogFile *p = (VLogFile *)pFile; tStart = vlog_time(); rc = p->pReal->pMethods->xLock(p->pReal, eLock); tElapse = vlog_time() - tStart; vlogLogPrint(p->pLog, tStart, tElapse, "LOCK", eLock, -1, 0, rc); return rc; } /* ** Unlock an vlog-file. */ static int vlogUnlock(sqlite3_file *pFile, int eLock){ int rc; sqlite3_uint64 tStart, tElapse; VLogFile *p = (VLogFile *)pFile; tStart = vlog_time(); rc = p->pReal->pMethods->xUnlock(p->pReal, eLock); tElapse = vlog_time() - tStart; vlogLogPrint(p->pLog, tStart, tElapse, "UNLOCK", eLock, -1, 0, rc); return rc; } /* ** Check if another file-handle holds a RESERVED lock on an vlog-file. */ static int vlogCheckReservedLock(sqlite3_file *pFile, int *pResOut){ int rc; sqlite3_uint64 tStart, tElapse; VLogFile *p = (VLogFile *)pFile; tStart = vlog_time(); rc = p->pReal->pMethods->xCheckReservedLock(p->pReal, pResOut); tElapse = vlog_time() - tStart; vlogLogPrint(p->pLog, tStart, tElapse, "CHECKRESERVEDLOCK", *pResOut, -1, "", rc); return rc; } /* ** File control method. For custom operations on an vlog-file. */ static int vlogFileControl(sqlite3_file *pFile, int op, void *pArg){ VLogFile *p = (VLogFile *)pFile; sqlite3_uint64 tStart, tElapse; int rc; tStart = vlog_time(); rc = p->pReal->pMethods->xFileControl(p->pReal, op, pArg); if( op==SQLITE_FCNTL_VFSNAME && rc==SQLITE_OK ){ *(char**)pArg = sqlite3_mprintf("vlog/%z", *(char**)pArg); } tElapse = vlog_time() - tStart; vlogLogPrint(p->pLog, tStart, tElapse, "FILECONTROL", op, -1, 0, rc); return rc; } /* ** Return the sector-size in bytes for an vlog-file. */ static int vlogSectorSize(sqlite3_file *pFile){ int rc; sqlite3_uint64 tStart, tElapse; VLogFile *p = (VLogFile *)pFile; tStart = vlog_time(); rc = p->pReal->pMethods->xSectorSize(p->pReal); tElapse = vlog_time() - tStart; vlogLogPrint(p->pLog, tStart, tElapse, "SECTORSIZE", -1, -1, 0, rc); return rc; } /* ** Return the device characteristic flags supported by an vlog-file. */ static int vlogDeviceCharacteristics(sqlite3_file *pFile){ int rc; sqlite3_uint64 tStart, tElapse; VLogFile *p = (VLogFile *)pFile; tStart = vlog_time(); rc = p->pReal->pMethods->xDeviceCharacteristics(p->pReal); tElapse = vlog_time() - tStart; vlogLogPrint(p->pLog, tStart, tElapse, "DEVCHAR", -1, -1, 0, rc); return rc; } /* ** Open an vlog file handle. */ static int vlogOpen( sqlite3_vfs *pVfs, const char *zName, sqlite3_file *pFile, int flags, int *pOutFlags ){ int rc; sqlite3_uint64 tStart, tElapse; sqlite3_int64 iArg2; VLogFile *p = (VLogFile*)pFile; p->pReal = (sqlite3_file*)&p[1]; if( (flags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_MAIN_JOURNAL))!=0 ){ p->pLog = vlogLogOpen(zName); }else{ p->pLog = 0; } tStart = vlog_time(); rc = REALVFS(pVfs)->xOpen(REALVFS(pVfs), zName, p->pReal, flags, pOutFlags); tElapse = vlog_time() - tStart; iArg2 = pOutFlags ? *pOutFlags : -1; vlogLogPrint(p->pLog, tStart, tElapse, "OPEN", flags, iArg2, 0, rc); if( rc==SQLITE_OK ){ pFile->pMethods = &vlog_io_methods; }else{ if( p->pLog ) vlogLogClose(p->pLog); p->pLog = 0; } return rc; } /* ** Delete the file located at zPath. If the dirSync argument is true, ** ensure the file-system modifications are synced to disk before ** returning. */ static int vlogDelete(sqlite3_vfs *pVfs, const char *zPath, int dirSync){ int rc; sqlite3_uint64 tStart, tElapse; VLogLog *pLog; tStart = vlog_time(); rc = REALVFS(pVfs)->xDelete(REALVFS(pVfs), zPath, dirSync); tElapse = vlog_time() - tStart; pLog = vlogLogOpen(zPath); vlogLogPrint(pLog, tStart, tElapse, "DELETE", dirSync, -1, 0, rc); vlogLogClose(pLog); return rc; } /* ** Test for access permissions. Return true if the requested permission ** is available, or false otherwise. */ static int vlogAccess( sqlite3_vfs *pVfs, const char *zPath, int flags, int *pResOut ){ int rc; sqlite3_uint64 tStart, tElapse; VLogLog *pLog; tStart = vlog_time(); rc = REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags, pResOut); tElapse = vlog_time() - tStart; pLog = vlogLogOpen(zPath); vlogLogPrint(pLog, tStart, tElapse, "ACCESS", flags, *pResOut, 0, rc); vlogLogClose(pLog); return rc; } /* ** Populate buffer zOut with the full canonical pathname corresponding ** to the pathname in zPath. zOut is guaranteed to point to a buffer ** of at least (INST_MAX_PATHNAME+1) bytes. */ static int vlogFullPathname( sqlite3_vfs *pVfs, const char *zPath, int nOut, char *zOut ){ return REALVFS(pVfs)->xFullPathname(REALVFS(pVfs), zPath, nOut, zOut); } /* ** Open the dynamic library located at zPath and return a handle. */ static void *vlogDlOpen(sqlite3_vfs *pVfs, const char *zPath){ return REALVFS(pVfs)->xDlOpen(REALVFS(pVfs), zPath); } /* ** Populate the buffer zErrMsg (size nByte bytes) with a human readable ** utf-8 string describing the most recent error encountered associated ** with dynamic libraries. */ static void vlogDlError(sqlite3_vfs *pVfs, int nByte, char *zErrMsg){ REALVFS(pVfs)->xDlError(REALVFS(pVfs), nByte, zErrMsg); } /* ** Return a pointer to the symbol zSymbol in the dynamic library pHandle. */ static void (*vlogDlSym(sqlite3_vfs *pVfs, void *p, const char *zSym))(void){ return REALVFS(pVfs)->xDlSym(REALVFS(pVfs), p, zSym); } /* ** Close the dynamic library handle pHandle. */ static void vlogDlClose(sqlite3_vfs *pVfs, void *pHandle){ REALVFS(pVfs)->xDlClose(REALVFS(pVfs), pHandle); } /* ** Populate the buffer pointed to by zBufOut with nByte bytes of ** random data. */ static int vlogRandomness(sqlite3_vfs *pVfs, int nByte, char *zBufOut){ return REALVFS(pVfs)->xRandomness(REALVFS(pVfs), nByte, zBufOut); } /* ** Sleep for nMicro microseconds. Return the number of microseconds ** actually slept. */ static int vlogSleep(sqlite3_vfs *pVfs, int nMicro){ return REALVFS(pVfs)->xSleep(REALVFS(pVfs), nMicro); } /* ** Return the current time as a Julian Day number in *pTimeOut. */ static int vlogCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ return REALVFS(pVfs)->xCurrentTime(REALVFS(pVfs), pTimeOut); } static int vlogGetLastError(sqlite3_vfs *pVfs, int a, char *b){ return REALVFS(pVfs)->xGetLastError(REALVFS(pVfs), a, b); } static int vlogCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *p){ return REALVFS(pVfs)->xCurrentTimeInt64(REALVFS(pVfs), p); } /* ** Register debugvfs as the default VFS for this process. */ int sqlite3_register_vfslog(const char *zArg){ vlog_vfs.pVfs = sqlite3_vfs_find(0); vlog_vfs.base.szOsFile = sizeof(VLogFile) + vlog_vfs.pVfs->szOsFile; return sqlite3_vfs_register(&vlog_vfs.base, 1); } |
Changes to main.mk.
︙ | ︙ | |||
275 276 277 278 279 280 281 | $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/fuzzer.c \ $(TOP)/ext/misc/ieee754.c \ $(TOP)/ext/misc/nextchar.c \ $(TOP)/ext/misc/percentile.c \ $(TOP)/ext/misc/regexp.c \ $(TOP)/ext/misc/spellfix.c \ | | > | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | $(TOP)/ext/misc/closure.c \ $(TOP)/ext/misc/fuzzer.c \ $(TOP)/ext/misc/ieee754.c \ $(TOP)/ext/misc/nextchar.c \ $(TOP)/ext/misc/percentile.c \ $(TOP)/ext/misc/regexp.c \ $(TOP)/ext/misc/spellfix.c \ $(TOP)/ext/misc/wholenumber.c \ $(TOP)/ext/misc/vfslog.c #TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c #TESTSRC += $(TOP)/ext/fts3/fts3_tokenizer.c TESTSRC2 = \ $(TOP)/src/attach.c \ |
︙ | ︙ |
Changes to test/permutations.test.
︙ | ︙ | |||
284 285 286 287 288 289 290 291 292 293 294 295 296 297 | vtab5.test vtab6.test vtab7.test vtab8.test vtab9.test vtab_alter.test vtabA.test vtabB.test vtabC.test vtabD.test vtabE.test vtabF.test where2.test where3.test where4.test where5.test where6.test where7.test where8m.test where8.test where9.test whereA.test whereB.test whereC.test whereD.test whereE.test whereF.test wherelimit.test where.test } lappend ::testsuitelist xxx #------------------------------------------------------------------------- # Define the coverage related test suites: # # coverage-wal # | > > > > > > > > > > > | 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 | vtab5.test vtab6.test vtab7.test vtab8.test vtab9.test vtab_alter.test vtabA.test vtabB.test vtabC.test vtabD.test vtabE.test vtabF.test where2.test where3.test where4.test where5.test where6.test where7.test where8m.test where8.test where9.test whereA.test whereB.test whereC.test whereD.test whereE.test whereF.test wherelimit.test where.test } test_suite "vfslog" -prefix "" -description { "Vfslog" quick test suite. Like "veryquick" except does not omits a few tests that do not work with a version 1 VFS. And the quota* tests, which do not work with a VFS that uses the pVfs argument passed to sqlite3_vfs methods. } -files [ test_set $allquicktests -exclude *malloc* *ioerr* *fault* oserror.test \ pager1.test syscall.test sysfault.test tkt3457.test quota* superlock* \ wal* mmap* ] lappend ::testsuitelist xxx #------------------------------------------------------------------------- # Define the coverage related test suites: # # coverage-wal # |
︙ | ︙ |