Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Additional interpretation of flags and constants in the VFS trace output. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
3e984195f1f6d28734456dd726d226ce |
User & Date: | drh 2011-03-16 18:54:23.037 |
Context
2011-03-17
| ||
01:34 | Enhances to the query planner such that "x IS NULL" constraints take the STAT2 statistics into account, just like "x=VALUE" constraints. (check-in: 2353176811 user: drh tags: trunk) | |
2011-03-16
| ||
18:54 | Additional interpretation of flags and constants in the VFS trace output. (check-in: 3e984195f1 user: drh tags: trunk) | |
17:05 | Add the -vfstrace option to the usage error message in the shell. (check-in: baca45c549 user: drh tags: trunk) | |
Changes
Changes to src/test_vfstrace.c.
︙ | ︙ | |||
171 172 173 174 175 176 177 178 179 180 181 182 183 184 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", rc); zVal = zBuf; break; } } vfstrace_printf(pInfo, zFormat, zVal); } /* ** Close an vfstrace-file. */ static int vfstraceClose(sqlite3_file *pFile){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; | > > > > > > > > > > | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", rc); zVal = zBuf; break; } } vfstrace_printf(pInfo, zFormat, zVal); } /* ** Append to a buffer. */ static void strappend(char *z, int *pI, const char *zAppend){ int i = *pI; while( zAppend[0] ){ z[i++] = *(zAppend++); } z[i] = 0; *pI = i; } /* ** Close an vfstrace-file. */ static int vfstraceClose(sqlite3_file *pFile){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; |
︙ | ︙ | |||
201 202 203 204 205 206 207 | void *zBuf, int iAmt, sqlite_int64 iOfst ){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; | | | | | | 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 | void *zBuf, int iAmt, sqlite_int64 iOfst ){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; vfstrace_printf(pInfo, "%s.xRead(%s,n=%d,ofst=%lld)", pInfo->zVfsName, p->zFName, iAmt, iOfst); rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst); vfstrace_print_errcode(pInfo, " -> %s\n", rc); return rc; } /* ** Write data to an vfstrace-file. */ static int vfstraceWrite( sqlite3_file *pFile, const void *zBuf, int iAmt, sqlite_int64 iOfst ){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; vfstrace_printf(pInfo, "%s.xWrite(%s,n=%d,ofst=%lld)", pInfo->zVfsName, p->zFName, iAmt, iOfst); rc = p->pReal->pMethods->xWrite(p->pReal, zBuf, iAmt, iOfst); vfstrace_print_errcode(pInfo, " -> %s\n", rc); return rc; } /* ** Truncate an vfstrace-file. |
︙ | ︙ | |||
248 249 250 251 252 253 254 | /* ** Sync an vfstrace-file. */ static int vfstraceSync(sqlite3_file *pFile, int flags){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; | > > > > > > > > > > | > > > > > > > > > > > > > > > | > | > | 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 | /* ** Sync an vfstrace-file. */ static int vfstraceSync(sqlite3_file *pFile, int flags){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; int i; char zBuf[100]; memcpy(zBuf, "|0", 3); i = 0; if( flags & SQLITE_SYNC_FULL ) strappend(zBuf, &i, "|FULL"); else if( flags & SQLITE_SYNC_NORMAL ) strappend(zBuf, &i, "|NORMAL"); if( flags & SQLITE_SYNC_DATAONLY ) strappend(zBuf, &i, "|DATAONLY"); if( flags & ~(SQLITE_SYNC_FULL|SQLITE_SYNC_DATAONLY) ){ sqlite3_snprintf(sizeof(zBuf)-i, &zBuf[i], "|0x%x", flags); } vfstrace_printf(pInfo, "%s.xSync(%s,%s)", pInfo->zVfsName, p->zFName, &zBuf[1]); rc = p->pReal->pMethods->xSync(p->pReal, flags); vfstrace_printf(pInfo, " -> %d\n", rc); return rc; } /* ** Return the current file-size of an vfstrace-file. */ static int vfstraceFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; vfstrace_printf(pInfo, "%s.xFileSize(%s)", pInfo->zVfsName, p->zFName); rc = p->pReal->pMethods->xFileSize(p->pReal, pSize); vfstrace_print_errcode(pInfo, " -> %s,", rc); vfstrace_printf(pInfo, " size=%lld\n", *pSize); return rc; } /* ** Return the name of a lock. */ static const char *lockName(int eLock){ const char *azLockNames[] = { "NONE", "SHARED", "RESERVED", "PENDING", "EXCLUSIVE" }; if( eLock<0 || eLock>=sizeof(azLockNames)/sizeof(azLockNames[0]) ){ return "???"; }else{ return azLockNames[eLock]; } } /* ** Lock an vfstrace-file. */ static int vfstraceLock(sqlite3_file *pFile, int eLock){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; vfstrace_printf(pInfo, "%s.xLock(%s,%s)", pInfo->zVfsName, p->zFName, lockName(eLock)); rc = p->pReal->pMethods->xLock(p->pReal, eLock); vfstrace_print_errcode(pInfo, " -> %s\n", rc); return rc; } /* ** Unlock an vfstrace-file. */ static int vfstraceUnlock(sqlite3_file *pFile, int eLock){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; vfstrace_printf(pInfo, "%s.xUnlock(%s,%s)", pInfo->zVfsName, p->zFName, lockName(eLock)); rc = p->pReal->pMethods->xUnlock(p->pReal, eLock); vfstrace_print_errcode(pInfo, " -> %s\n", rc); return rc; } /* ** Check if another file-handle holds a RESERVED lock on an vfstrace-file. |
︙ | ︙ | |||
316 317 318 319 320 321 322 | /* ** File control method. For custom operations on an vfstrace-file. */ static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; | > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | 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 | /* ** File control method. For custom operations on an vfstrace-file. */ static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; char zBuf[100]; char *zOp; switch( op ){ case SQLITE_FCNTL_LOCKSTATE: zOp = "LOCKSTATE"; break; case SQLITE_GET_LOCKPROXYFILE: zOp = "GET_LOCKPROXYFILE"; break; case SQLITE_SET_LOCKPROXYFILE: zOp = "SET_LOCKPROXYFILE"; break; case SQLITE_LAST_ERRNO: zOp = "LAST_ERRNO"; break; case SQLITE_FCNTL_SIZE_HINT: { sqlite3_snprintf(sizeof(zBuf), zBuf, "SIZE_HINT,%lld", *(sqlite3_int64*)pArg); zOp = zBuf; break; } case SQLITE_FCNTL_CHUNK_SIZE: { sqlite3_snprintf(sizeof(zBuf), zBuf, "CHUNK_SIZE,%d", *(int*)pArg); zOp = zBuf; break; } case SQLITE_FCNTL_FILE_POINTER: zOp = "FILE_POINTER"; break; case SQLITE_FCNTL_SYNC_OMITTED: zOp = "SYNC_OMITTED"; break; case 0xca093fa0: zOp = "DB_UNCHANGED"; break; default: { sqlite3_snprintf(sizeof zBuf, zBuf, "%d", op); zOp = zBuf; break; } } vfstrace_printf(pInfo, "%s.xFileControl(%s,%s)", pInfo->zVfsName, p->zFName, zOp); rc = p->pReal->pMethods->xFileControl(p->pReal, op, pArg); vfstrace_print_errcode(pInfo, " -> %s\n", rc); return rc; } /* ** Return the sector-size in bytes for an vfstrace-file. |
︙ | ︙ | |||
357 358 359 360 361 362 363 | /* ** Shared-memory operations. */ static int vfstraceShmLock(sqlite3_file *pFile, int ofst, int n, int flags){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; | > > > > > > > > > > | | | 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 | /* ** Shared-memory operations. */ static int vfstraceShmLock(sqlite3_file *pFile, int ofst, int n, int flags){ vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = p->pInfo; int rc; char zLck[100]; int i = 0; memcpy(zLck, "|0", 3); if( flags & SQLITE_SHM_UNLOCK ) strappend(zLck, &i, "|UNLOCK"); if( flags & SQLITE_SHM_LOCK ) strappend(zLck, &i, "|LOCK"); if( flags & SQLITE_SHM_SHARED ) strappend(zLck, &i, "|SHARED"); if( flags & SQLITE_SHM_EXCLUSIVE ) strappend(zLck, &i, "|EXCLUSIVE"); if( flags & ~(0xf) ){ sqlite3_snprintf(sizeof(zLck)-i, &zLck[i], "|0x%x", flags); } vfstrace_printf(pInfo, "%s.xShmLock(%s,ofst=%d,n=%d,%s)", pInfo->zVfsName, p->zFName, ofst, n, &zLck[1]); rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags); vfstrace_print_errcode(pInfo, " -> %s\n", rc); return rc; } static int vfstraceShmMap( sqlite3_file *pFile, int iRegion, |
︙ | ︙ | |||
413 414 415 416 417 418 419 | int *pOutFlags ){ int rc; vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData; sqlite3_vfs *pRoot = pInfo->pRootVfs; p->pInfo = pInfo; | | | 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | int *pOutFlags ){ int rc; vfstrace_file *p = (vfstrace_file *)pFile; vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData; sqlite3_vfs *pRoot = pInfo->pRootVfs; p->pInfo = pInfo; p->zFName = zName ? fileTail(zName) : "<temp>"; p->pReal = (sqlite3_file *)&p[1]; rc = pRoot->xOpen(pRoot, zName, p->pReal, flags, pOutFlags); vfstrace_printf(pInfo, "%s.xOpen(%s,flags=0x%x)", pInfo->zVfsName, p->zFName, flags); if( p->pReal->pMethods ){ sqlite3_io_methods *pNew = sqlite3_malloc( sizeof(*pNew) ); const sqlite3_io_methods *pSub = p->pReal->pMethods; |
︙ | ︙ | |||
444 445 446 447 448 449 450 | pNew->xShmLock = pSub->xShmLock ? vfstraceShmLock : 0; pNew->xShmBarrier = pSub->xShmBarrier ? vfstraceShmBarrier : 0; pNew->xShmUnmap = pSub->xShmUnmap ? vfstraceShmUnmap : 0; } pFile->pMethods = pNew; } vfstrace_print_errcode(pInfo, " -> %s", rc); | > | > > > | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | pNew->xShmLock = pSub->xShmLock ? vfstraceShmLock : 0; pNew->xShmBarrier = pSub->xShmBarrier ? vfstraceShmBarrier : 0; pNew->xShmUnmap = pSub->xShmUnmap ? vfstraceShmUnmap : 0; } pFile->pMethods = pNew; } vfstrace_print_errcode(pInfo, " -> %s", rc); if( pOutFlags ){ vfstrace_printf(pInfo, ", outFlags=0x%x\n", *pOutFlags); }else{ vfstrace_printf(pInfo, "\n"); } 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. |
︙ | ︙ |