Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | In the showdb.exe utility, for the "NNNbd" command, also show data fields in addition to header fields on each record decoded. Improvements to formatting. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
b451fe0cb92278deb7724e7995c1bd46 |
User & Date: | drh 2014-06-20 01:32:42.411 |
Context
2014-06-20
| ||
13:55 | Improved display of record data in the "NNNbd" output of the showdb.exe utility program. (check-in: f735c2497e user: drh tags: trunk) | |
01:32 | In the showdb.exe utility, for the "NNNbd" command, also show data fields in addition to header fields on each record decoded. Improvements to formatting. (check-in: b451fe0cb9 user: drh tags: trunk) | |
2014-06-19
| ||
23:38 | Add the ability to decode the headers of individual cells, byte-by-byte, in the "showdb.exe" utility. (check-in: 306b461d7c user: drh tags: trunk) | |
Changes
Changes to tool/showdb.c.
︙ | ︙ | |||
379 380 381 382 383 384 385 386 | i64 rowid; i64 nHdr; i64 iType; int nLocal; unsigned char *x = a + ofst; unsigned char *end; unsigned char cType = a[0]; | > > > > | < > > > > | > | | > | | 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 | i64 rowid; i64 nHdr; i64 iType; int nLocal; unsigned char *x = a + ofst; unsigned char *end; unsigned char cType = a[0]; int nCol = 0; int szCol[2000]; int ofstCol[2000]; int typeCol[2000]; printf("Cell[%d]:\n", iCell); if( cType<=5 ){ leftChild = ((x[0]*256 + x[1])*256 + x[2])*256 + x[3]; printBytes(a, x, 4); printf("left child page:: %d\n", leftChild); x += 4; } if( cType!=5 ){ i = decodeVarint(x, &nPayload); printBytes(a, x, i); nLocal = localPayload(nPayload, cType); if( nLocal==nPayload ){ printf("payload-size: %d\n", (int)nPayload); }else{ printf("payload-size: %d (%d local, %d overflow)\n", (int)nPayload, nLocal, (int)(nPayload-nLocal)); } x += i; }else{ nPayload = nLocal = 0; } end = x + nLocal; if( cType==5 || cType==13 ){ i = decodeVarint(x, &rowid); printBytes(a, x, i); printf("rowid: %lld\n", rowid); x += i; } if( nLocal>0 ){ i = decodeVarint(x, &nHdr); printBytes(a, x, i); printf("record-header-size: %d\n", (int)nHdr); j = i; nCol = 0; k = nHdr; while( x+j<end && j<nHdr ){ const char *zTypeName; int sz = 0; char zNm[30]; i = decodeVarint(x+j, &iType); printBytes(a, x+j, i); printf("typecode[%d]: %d - ", nCol, (int)iType); switch( iType ){ case 0: zTypeName = "NULL"; sz = 0; break; case 1: zTypeName = "int8"; sz = 1; break; case 2: zTypeName = "int16"; sz = 2; break; case 3: zTypeName = "int24"; sz = 3; break; case 4: zTypeName = "int32"; sz = 4; break; case 5: zTypeName = "int48"; sz = 6; break; |
︙ | ︙ | |||
438 439 440 441 442 443 444 445 446 447 448 449 | sz = (int)(iType-12)/2; sprintf(zNm, (iType&1)==0 ? "blob(%d)" : "text(%d)", sz); zTypeName = zNm; break; } } printf("%s\n", zTypeName); j += i; } } if( j<nLocal ){ printBytes(a, x+j, 0); | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | 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 | sz = (int)(iType-12)/2; sprintf(zNm, (iType&1)==0 ? "blob(%d)" : "text(%d)", sz); zTypeName = zNm; break; } } printf("%s\n", zTypeName); szCol[nCol] = sz; ofstCol[nCol] = k; typeCol[nCol] = (int)iType; k += sz; nCol++; j += i; } for(i=0; i<nCol && ofstCol[i]+szCol[i]<=nLocal; i++){ int s = ofstCol[i]; i64 v; const unsigned char *pData; if( szCol[i]==0 ) continue; printBytes(a, x+s, szCol[i]); printf("data[%d]: ", i); pData = x+s; if( typeCol[i]<=7 ){ v = (signed char)pData[0]; for(k=1; k<szCol[i]; k++){ v = (v<<8) + pData[k]; } if( typeCol[i]==7 ){ double r; memcpy(&r, &v, sizeof(r)); printf("%#g\n", r); }else{ printf("%lld\n", v); } }else{ printf("%d bytes of %s\n", szCol[i], (typeCol[i]&1)==0 ? "BLOB" : "TEXT"); } j = ofstCol[i] + szCol[i]; } } if( j<nLocal ){ printBytes(a, x+j, 0); printf("... %d bytes of content ...\n", nLocal-j); } if( nLocal<nPayload ){ printBytes(a, x+nLocal, 4); printf("overflow-page: %d\n", decodeInt32(x+nLocal)); } } /* ** Decode a btree page */ |
︙ | ︙ | |||
496 497 498 499 500 501 502 | break; } } zArgs++; } nCell = a[3]*256 + a[4]; iCellPtr = (a[0]==2 || a[0]==5) ? 12 : 8; | | > > > | | | | | | | | | | | | < < < < | 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 | break; } } zArgs++; } nCell = a[3]*256 + a[4]; iCellPtr = (a[0]==2 || a[0]==5) ? 12 : 8; if( cellToDecode>=nCell ){ printf("Page %d has only %d cells\n", pgno, nCell); return; } printf("Header on btree page %d:\n", pgno); print_decode_line(a, 0, 1, zType); print_decode_line(a, 1, 2, "Offset to first freeblock"); print_decode_line(a, 3, 2, "Number of cells on this page"); print_decode_line(a, 5, 2, "Offset to cell content area"); print_decode_line(a, 7, 1, "Fragmented byte count"); if( a[0]==2 || a[0]==5 ){ print_decode_line(a, 8, 4, "Right child"); } if( cellToDecode==(-2) && nCell>0 ){ printf(" key: lx=left-child n=payload-size r=rowid\n"); } if( showMap ){ zMap = malloc(pagesize); memset(zMap, '.', pagesize); memset(zMap, '1', hdrSize); memset(&zMap[hdrSize], 'H', iCellPtr); memset(&zMap[hdrSize+iCellPtr], 'P', 2*nCell); } |
︙ | ︙ | |||
543 544 545 546 547 548 549 550 551 552 553 554 555 556 | if( cellToDecode==(-2) ){ printf(" %03x: cell[%d] %s\n", cofst, i, zDesc); }else if( cellToDecode==(-1) || cellToDecode==i ){ decodeCell(a, pgno, i, hdrSize, cofst-hdrSize); } } if( showMap ){ for(i=0; i<pagesize; i+=64){ printf(" %03x: %.64s\n", i, &zMap[i]); } free(zMap); } } | > | 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | if( cellToDecode==(-2) ){ printf(" %03x: cell[%d] %s\n", cofst, i, zDesc); }else if( cellToDecode==(-1) || cellToDecode==i ){ decodeCell(a, pgno, i, hdrSize, cofst-hdrSize); } } if( showMap ){ printf("Page map: (H=header P=cell-index 1=page-1-header .=free-space)\n"); for(i=0; i<pagesize; i+=64){ printf(" %03x: %.64s\n", i, &zMap[i]); } free(zMap); } } |
︙ | ︙ |