| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2010 July 12 | 2 ** 2010 July 12 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 ** '/1c2/000+000002' // Third page in overflow chain | 51 ** '/1c2/000+000002' // Third page in overflow chain |
| 52 ** | 52 ** |
| 53 ** If the paths are sorted using the BINARY collation sequence, then | 53 ** If the paths are sorted using the BINARY collation sequence, then |
| 54 ** the overflow pages associated with a cell will appear earlier in the | 54 ** the overflow pages associated with a cell will appear earlier in the |
| 55 ** sort-order than its child page: | 55 ** sort-order than its child page: |
| 56 ** | 56 ** |
| 57 ** '/1c2/000/' // Left-most child of 451st child of root | 57 ** '/1c2/000/' // Left-most child of 451st child of root |
| 58 */ | 58 */ |
| 59 #define VTAB_SCHEMA \ | 59 #define VTAB_SCHEMA \ |
| 60 "CREATE TABLE xx( " \ | 60 "CREATE TABLE xx( " \ |
| 61 " name STRING, /* Name of table or index */" \ | 61 " name TEXT, /* Name of table or index */" \ |
| 62 " path INTEGER, /* Path to page from root */" \ | 62 " path TEXT, /* Path to page from root */" \ |
| 63 " pageno INTEGER, /* Page number */" \ | 63 " pageno INTEGER, /* Page number */" \ |
| 64 " pagetype STRING, /* 'internal', 'leaf' or 'overflow' */" \ | 64 " pagetype TEXT, /* 'internal', 'leaf' or 'overflow' */" \ |
| 65 " ncell INTEGER, /* Cells on page (0 for overflow) */" \ | 65 " ncell INTEGER, /* Cells on page (0 for overflow) */" \ |
| 66 " payload INTEGER, /* Bytes of payload on this page */" \ | 66 " payload INTEGER, /* Bytes of payload on this page */" \ |
| 67 " unused INTEGER, /* Bytes of unused space on this page */" \ | 67 " unused INTEGER, /* Bytes of unused space on this page */" \ |
| 68 " mx_payload INTEGER, /* Largest payload size of all cells */" \ | 68 " mx_payload INTEGER, /* Largest payload size of all cells */" \ |
| 69 " pgoffset INTEGER, /* Offset of page in file */" \ | 69 " pgoffset INTEGER, /* Offset of page in file */" \ |
| 70 " pgsize INTEGER, /* Size of the page */" \ | 70 " pgsize INTEGER, /* Size of the page */" \ |
| 71 " schema TEXT HIDDEN /* Database schema being analyzed */" \ | 71 " schema TEXT HIDDEN /* Database schema being analyzed */" \ |
| 72 ");" | 72 ");" |
| 73 | 73 |
| 74 | 74 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 void *pAux, | 142 void *pAux, |
| 143 int argc, const char *const*argv, | 143 int argc, const char *const*argv, |
| 144 sqlite3_vtab **ppVtab, | 144 sqlite3_vtab **ppVtab, |
| 145 char **pzErr | 145 char **pzErr |
| 146 ){ | 146 ){ |
| 147 StatTable *pTab = 0; | 147 StatTable *pTab = 0; |
| 148 int rc = SQLITE_OK; | 148 int rc = SQLITE_OK; |
| 149 int iDb; | 149 int iDb; |
| 150 | 150 |
| 151 if( argc>=4 ){ | 151 if( argc>=4 ){ |
| 152 iDb = sqlite3FindDbName(db, argv[3]); | 152 Token nm; |
| 153 sqlite3TokenInit(&nm, (char*)argv[3]); |
| 154 iDb = sqlite3FindDb(db, &nm); |
| 153 if( iDb<0 ){ | 155 if( iDb<0 ){ |
| 154 *pzErr = sqlite3_mprintf("no such database: %s", argv[3]); | 156 *pzErr = sqlite3_mprintf("no such database: %s", argv[3]); |
| 155 return SQLITE_ERROR; | 157 return SQLITE_ERROR; |
| 156 } | 158 } |
| 157 }else{ | 159 }else{ |
| 158 iDb = 0; | 160 iDb = 0; |
| 159 } | 161 } |
| 160 rc = sqlite3_declare_vtab(db, VTAB_SCHEMA); | 162 rc = sqlite3_declare_vtab(db, VTAB_SCHEMA); |
| 161 if( rc==SQLITE_OK ){ | 163 if( rc==SQLITE_OK ){ |
| 162 pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable)); | 164 pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable)); |
| 163 if( pTab==0 ) rc = SQLITE_NOMEM; | 165 if( pTab==0 ) rc = SQLITE_NOMEM_BKPT; |
| 164 } | 166 } |
| 165 | 167 |
| 166 assert( rc==SQLITE_OK || pTab==0 ); | 168 assert( rc==SQLITE_OK || pTab==0 ); |
| 167 if( rc==SQLITE_OK ){ | 169 if( rc==SQLITE_OK ){ |
| 168 memset(pTab, 0, sizeof(StatTable)); | 170 memset(pTab, 0, sizeof(StatTable)); |
| 169 pTab->db = db; | 171 pTab->db = db; |
| 170 pTab->iDb = iDb; | 172 pTab->iDb = iDb; |
| 171 } | 173 } |
| 172 | 174 |
| 173 *ppVtab = (sqlite3_vtab*)pTab; | 175 *ppVtab = (sqlite3_vtab*)pTab; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 236 |
| 235 /* | 237 /* |
| 236 ** Open a new statvfs cursor. | 238 ** Open a new statvfs cursor. |
| 237 */ | 239 */ |
| 238 static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ | 240 static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ |
| 239 StatTable *pTab = (StatTable *)pVTab; | 241 StatTable *pTab = (StatTable *)pVTab; |
| 240 StatCursor *pCsr; | 242 StatCursor *pCsr; |
| 241 | 243 |
| 242 pCsr = (StatCursor *)sqlite3_malloc64(sizeof(StatCursor)); | 244 pCsr = (StatCursor *)sqlite3_malloc64(sizeof(StatCursor)); |
| 243 if( pCsr==0 ){ | 245 if( pCsr==0 ){ |
| 244 return SQLITE_NOMEM; | 246 return SQLITE_NOMEM_BKPT; |
| 245 }else{ | 247 }else{ |
| 246 memset(pCsr, 0, sizeof(StatCursor)); | 248 memset(pCsr, 0, sizeof(StatCursor)); |
| 247 pCsr->base.pVtab = pVTab; | 249 pCsr->base.pVtab = pVTab; |
| 248 pCsr->iDb = pTab->iDb; | 250 pCsr->iDb = pTab->iDb; |
| 249 } | 251 } |
| 250 | 252 |
| 251 *ppCursor = (sqlite3_vtab_cursor *)pCsr; | 253 *ppCursor = (sqlite3_vtab_cursor *)pCsr; |
| 252 return SQLITE_OK; | 254 return SQLITE_OK; |
| 253 } | 255 } |
| 254 | 256 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 szPage = sqlite3BtreeGetPageSize(pBt); | 342 szPage = sqlite3BtreeGetPageSize(pBt); |
| 341 | 343 |
| 342 if( p->nCell ){ | 344 if( p->nCell ){ |
| 343 int i; /* Used to iterate through cells */ | 345 int i; /* Used to iterate through cells */ |
| 344 int nUsable; /* Usable bytes per page */ | 346 int nUsable; /* Usable bytes per page */ |
| 345 | 347 |
| 346 sqlite3BtreeEnter(pBt); | 348 sqlite3BtreeEnter(pBt); |
| 347 nUsable = szPage - sqlite3BtreeGetReserveNoMutex(pBt); | 349 nUsable = szPage - sqlite3BtreeGetReserveNoMutex(pBt); |
| 348 sqlite3BtreeLeave(pBt); | 350 sqlite3BtreeLeave(pBt); |
| 349 p->aCell = sqlite3_malloc64((p->nCell+1) * sizeof(StatCell)); | 351 p->aCell = sqlite3_malloc64((p->nCell+1) * sizeof(StatCell)); |
| 350 if( p->aCell==0 ) return SQLITE_NOMEM; | 352 if( p->aCell==0 ) return SQLITE_NOMEM_BKPT; |
| 351 memset(p->aCell, 0, (p->nCell+1) * sizeof(StatCell)); | 353 memset(p->aCell, 0, (p->nCell+1) * sizeof(StatCell)); |
| 352 | 354 |
| 353 for(i=0; i<p->nCell; i++){ | 355 for(i=0; i<p->nCell; i++){ |
| 354 StatCell *pCell = &p->aCell[i]; | 356 StatCell *pCell = &p->aCell[i]; |
| 355 | 357 |
| 356 iOff = get2byte(&aData[nHdr+i*2]); | 358 iOff = get2byte(&aData[nHdr+i*2]); |
| 357 if( !isLeaf ){ | 359 if( !isLeaf ){ |
| 358 pCell->iChildPg = sqlite3Get4byte(&aData[iOff]); | 360 pCell->iChildPg = sqlite3Get4byte(&aData[iOff]); |
| 359 iOff += 4; | 361 iOff += 4; |
| 360 } | 362 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 373 pCell->nLocal = nLocal; | 375 pCell->nLocal = nLocal; |
| 374 assert( nLocal>=0 ); | 376 assert( nLocal>=0 ); |
| 375 assert( nPayload>=(u32)nLocal ); | 377 assert( nPayload>=(u32)nLocal ); |
| 376 assert( nLocal<=(nUsable-35) ); | 378 assert( nLocal<=(nUsable-35) ); |
| 377 if( nPayload>(u32)nLocal ){ | 379 if( nPayload>(u32)nLocal ){ |
| 378 int j; | 380 int j; |
| 379 int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4); | 381 int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4); |
| 380 pCell->nLastOvfl = (nPayload-nLocal) - (nOvfl-1) * (nUsable-4); | 382 pCell->nLastOvfl = (nPayload-nLocal) - (nOvfl-1) * (nUsable-4); |
| 381 pCell->nOvfl = nOvfl; | 383 pCell->nOvfl = nOvfl; |
| 382 pCell->aOvfl = sqlite3_malloc64(sizeof(u32)*nOvfl); | 384 pCell->aOvfl = sqlite3_malloc64(sizeof(u32)*nOvfl); |
| 383 if( pCell->aOvfl==0 ) return SQLITE_NOMEM; | 385 if( pCell->aOvfl==0 ) return SQLITE_NOMEM_BKPT; |
| 384 pCell->aOvfl[0] = sqlite3Get4byte(&aData[iOff+nLocal]); | 386 pCell->aOvfl[0] = sqlite3Get4byte(&aData[iOff+nLocal]); |
| 385 for(j=1; j<nOvfl; j++){ | 387 for(j=1; j<nOvfl; j++){ |
| 386 int rc; | 388 int rc; |
| 387 u32 iPrev = pCell->aOvfl[j-1]; | 389 u32 iPrev = pCell->aOvfl[j-1]; |
| 388 DbPage *pPg = 0; | 390 DbPage *pPg = 0; |
| 389 rc = sqlite3PagerGet(sqlite3BtreePager(pBt), iPrev, &pPg, 0); | 391 rc = sqlite3PagerGet(sqlite3BtreePager(pBt), iPrev, &pPg, 0); |
| 390 if( rc!=SQLITE_OK ){ | 392 if( rc!=SQLITE_OK ){ |
| 391 assert( pPg==0 ); | 393 assert( pPg==0 ); |
| 392 return rc; | 394 return rc; |
| 393 } | 395 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 sqlite3PagerPagecount(pPager, &nPage); | 454 sqlite3PagerPagecount(pPager, &nPage); |
| 453 if( nPage==0 ){ | 455 if( nPage==0 ){ |
| 454 pCsr->isEof = 1; | 456 pCsr->isEof = 1; |
| 455 return sqlite3_reset(pCsr->pStmt); | 457 return sqlite3_reset(pCsr->pStmt); |
| 456 } | 458 } |
| 457 rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg, 0); | 459 rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg, 0); |
| 458 pCsr->aPage[0].iPgno = iRoot; | 460 pCsr->aPage[0].iPgno = iRoot; |
| 459 pCsr->aPage[0].iCell = 0; | 461 pCsr->aPage[0].iCell = 0; |
| 460 pCsr->aPage[0].zPath = z = sqlite3_mprintf("/"); | 462 pCsr->aPage[0].zPath = z = sqlite3_mprintf("/"); |
| 461 pCsr->iPage = 0; | 463 pCsr->iPage = 0; |
| 462 if( z==0 ) rc = SQLITE_NOMEM; | 464 if( z==0 ) rc = SQLITE_NOMEM_BKPT; |
| 463 }else{ | 465 }else{ |
| 464 pCsr->isEof = 1; | 466 pCsr->isEof = 1; |
| 465 return sqlite3_reset(pCsr->pStmt); | 467 return sqlite3_reset(pCsr->pStmt); |
| 466 } | 468 } |
| 467 }else{ | 469 }else{ |
| 468 | 470 |
| 469 /* Page p itself has already been visited. */ | 471 /* Page p itself has already been visited. */ |
| 470 StatPage *p = &pCsr->aPage[pCsr->iPage]; | 472 StatPage *p = &pCsr->aPage[pCsr->iPage]; |
| 471 | 473 |
| 472 while( p->iCell<p->nCell ){ | 474 while( p->iCell<p->nCell ){ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 487 ); | 489 ); |
| 488 if( pCell->iOvfl<pCell->nOvfl-1 ){ | 490 if( pCell->iOvfl<pCell->nOvfl-1 ){ |
| 489 pCsr->nUnused = 0; | 491 pCsr->nUnused = 0; |
| 490 pCsr->nPayload = nUsable - 4; | 492 pCsr->nPayload = nUsable - 4; |
| 491 }else{ | 493 }else{ |
| 492 pCsr->nPayload = pCell->nLastOvfl; | 494 pCsr->nPayload = pCell->nLastOvfl; |
| 493 pCsr->nUnused = nUsable - 4 - pCsr->nPayload; | 495 pCsr->nUnused = nUsable - 4 - pCsr->nPayload; |
| 494 } | 496 } |
| 495 pCell->iOvfl++; | 497 pCell->iOvfl++; |
| 496 statSizeAndOffset(pCsr); | 498 statSizeAndOffset(pCsr); |
| 497 return z==0 ? SQLITE_NOMEM : SQLITE_OK; | 499 return z==0 ? SQLITE_NOMEM_BKPT : SQLITE_OK; |
| 498 } | 500 } |
| 499 if( p->iRightChildPg ) break; | 501 if( p->iRightChildPg ) break; |
| 500 p->iCell++; | 502 p->iCell++; |
| 501 } | 503 } |
| 502 | 504 |
| 503 if( !p->iRightChildPg || p->iCell>p->nCell ){ | 505 if( !p->iRightChildPg || p->iCell>p->nCell ){ |
| 504 statClearPage(p); | 506 statClearPage(p); |
| 505 if( pCsr->iPage==0 ) return statNext(pCursor); | 507 if( pCsr->iPage==0 ) return statNext(pCursor); |
| 506 pCsr->iPage--; | 508 pCsr->iPage--; |
| 507 goto statNextRestart; /* Tail recursion */ | 509 goto statNextRestart; /* Tail recursion */ |
| 508 } | 510 } |
| 509 pCsr->iPage++; | 511 pCsr->iPage++; |
| 510 assert( p==&pCsr->aPage[pCsr->iPage-1] ); | 512 assert( p==&pCsr->aPage[pCsr->iPage-1] ); |
| 511 | 513 |
| 512 if( p->iCell==p->nCell ){ | 514 if( p->iCell==p->nCell ){ |
| 513 p[1].iPgno = p->iRightChildPg; | 515 p[1].iPgno = p->iRightChildPg; |
| 514 }else{ | 516 }else{ |
| 515 p[1].iPgno = p->aCell[p->iCell].iChildPg; | 517 p[1].iPgno = p->aCell[p->iCell].iChildPg; |
| 516 } | 518 } |
| 517 rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg, 0); | 519 rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg, 0); |
| 518 p[1].iCell = 0; | 520 p[1].iCell = 0; |
| 519 p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell); | 521 p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell); |
| 520 p->iCell++; | 522 p->iCell++; |
| 521 if( z==0 ) rc = SQLITE_NOMEM; | 523 if( z==0 ) rc = SQLITE_NOMEM_BKPT; |
| 522 } | 524 } |
| 523 | 525 |
| 524 | 526 |
| 525 /* Populate the StatCursor fields with the values to be returned | 527 /* Populate the StatCursor fields with the values to be returned |
| 526 ** by the xColumn() and xRowid() methods. | 528 ** by the xColumn() and xRowid() methods. |
| 527 */ | 529 */ |
| 528 if( rc==SQLITE_OK ){ | 530 if( rc==SQLITE_OK ){ |
| 529 int i; | 531 int i; |
| 530 StatPage *p = &pCsr->aPage[pCsr->iPage]; | 532 StatPage *p = &pCsr->aPage[pCsr->iPage]; |
| 531 pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0); | 533 pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 545 pCsr->zPagetype = "leaf"; | 547 pCsr->zPagetype = "leaf"; |
| 546 break; | 548 break; |
| 547 default: | 549 default: |
| 548 pCsr->zPagetype = "corrupted"; | 550 pCsr->zPagetype = "corrupted"; |
| 549 break; | 551 break; |
| 550 } | 552 } |
| 551 pCsr->nCell = p->nCell; | 553 pCsr->nCell = p->nCell; |
| 552 pCsr->nUnused = p->nUnused; | 554 pCsr->nUnused = p->nUnused; |
| 553 pCsr->nMxPayload = p->nMxPayload; | 555 pCsr->nMxPayload = p->nMxPayload; |
| 554 pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath); | 556 pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath); |
| 555 if( z==0 ) rc = SQLITE_NOMEM; | 557 if( z==0 ) rc = SQLITE_NOMEM_BKPT; |
| 556 nPayload = 0; | 558 nPayload = 0; |
| 557 for(i=0; i<p->nCell; i++){ | 559 for(i=0; i<p->nCell; i++){ |
| 558 nPayload += p->aCell[i].nLocal; | 560 nPayload += p->aCell[i].nLocal; |
| 559 } | 561 } |
| 560 pCsr->nPayload = nPayload; | 562 pCsr->nPayload = nPayload; |
| 561 } | 563 } |
| 562 } | 564 } |
| 563 | 565 |
| 564 return rc; | 566 return rc; |
| 565 } | 567 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 579 char *zSql; | 581 char *zSql; |
| 580 int rc = SQLITE_OK; | 582 int rc = SQLITE_OK; |
| 581 char *zMaster; | 583 char *zMaster; |
| 582 | 584 |
| 583 if( idxNum==1 ){ | 585 if( idxNum==1 ){ |
| 584 const char *zDbase = (const char*)sqlite3_value_text(argv[0]); | 586 const char *zDbase = (const char*)sqlite3_value_text(argv[0]); |
| 585 pCsr->iDb = sqlite3FindDbName(pTab->db, zDbase); | 587 pCsr->iDb = sqlite3FindDbName(pTab->db, zDbase); |
| 586 if( pCsr->iDb<0 ){ | 588 if( pCsr->iDb<0 ){ |
| 587 sqlite3_free(pCursor->pVtab->zErrMsg); | 589 sqlite3_free(pCursor->pVtab->zErrMsg); |
| 588 pCursor->pVtab->zErrMsg = sqlite3_mprintf("no such schema: %s", zDbase); | 590 pCursor->pVtab->zErrMsg = sqlite3_mprintf("no such schema: %s", zDbase); |
| 589 return pCursor->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM; | 591 return pCursor->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM_BKPT; |
| 590 } | 592 } |
| 591 }else{ | 593 }else{ |
| 592 pCsr->iDb = pTab->iDb; | 594 pCsr->iDb = pTab->iDb; |
| 593 } | 595 } |
| 594 statResetCsr(pCsr); | 596 statResetCsr(pCsr); |
| 595 sqlite3_finalize(pCsr->pStmt); | 597 sqlite3_finalize(pCsr->pStmt); |
| 596 pCsr->pStmt = 0; | 598 pCsr->pStmt = 0; |
| 597 zMaster = pCsr->iDb==1 ? "sqlite_temp_master" : "sqlite_master"; | 599 zMaster = pCsr->iDb==1 ? "sqlite_temp_master" : "sqlite_master"; |
| 598 zSql = sqlite3_mprintf( | 600 zSql = sqlite3_mprintf( |
| 599 "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type" | 601 "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type" |
| 600 " UNION ALL " | 602 " UNION ALL " |
| 601 "SELECT name, rootpage, type" | 603 "SELECT name, rootpage, type" |
| 602 " FROM \"%w\".%s WHERE rootpage!=0" | 604 " FROM \"%w\".%s WHERE rootpage!=0" |
| 603 " ORDER BY name", pTab->db->aDb[pCsr->iDb].zName, zMaster); | 605 " ORDER BY name", pTab->db->aDb[pCsr->iDb].zDbSName, zMaster); |
| 604 if( zSql==0 ){ | 606 if( zSql==0 ){ |
| 605 return SQLITE_NOMEM; | 607 return SQLITE_NOMEM_BKPT; |
| 606 }else{ | 608 }else{ |
| 607 rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0); | 609 rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0); |
| 608 sqlite3_free(zSql); | 610 sqlite3_free(zSql); |
| 609 } | 611 } |
| 610 | 612 |
| 611 if( rc==SQLITE_OK ){ | 613 if( rc==SQLITE_OK ){ |
| 612 rc = statNext(pCursor); | 614 rc = statNext(pCursor); |
| 613 } | 615 } |
| 614 return rc; | 616 return rc; |
| 615 } | 617 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 break; | 649 break; |
| 648 case 8: /* pgoffset */ | 650 case 8: /* pgoffset */ |
| 649 sqlite3_result_int64(ctx, pCsr->iOffset); | 651 sqlite3_result_int64(ctx, pCsr->iOffset); |
| 650 break; | 652 break; |
| 651 case 9: /* pgsize */ | 653 case 9: /* pgsize */ |
| 652 sqlite3_result_int(ctx, pCsr->szPage); | 654 sqlite3_result_int(ctx, pCsr->szPage); |
| 653 break; | 655 break; |
| 654 default: { /* schema */ | 656 default: { /* schema */ |
| 655 sqlite3 *db = sqlite3_context_db_handle(ctx); | 657 sqlite3 *db = sqlite3_context_db_handle(ctx); |
| 656 int iDb = pCsr->iDb; | 658 int iDb = pCsr->iDb; |
| 657 sqlite3_result_text(ctx, db->aDb[iDb].zName, -1, SQLITE_STATIC); | 659 sqlite3_result_text(ctx, db->aDb[iDb].zDbSName, -1, SQLITE_STATIC); |
| 658 break; | 660 break; |
| 659 } | 661 } |
| 660 } | 662 } |
| 661 return SQLITE_OK; | 663 return SQLITE_OK; |
| 662 } | 664 } |
| 663 | 665 |
| 664 static int statRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ | 666 static int statRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ |
| 665 StatCursor *pCsr = (StatCursor *)pCursor; | 667 StatCursor *pCsr = (StatCursor *)pCursor; |
| 666 *pRowid = pCsr->iPageno; | 668 *pRowid = pCsr->iPageno; |
| 667 return SQLITE_OK; | 669 return SQLITE_OK; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 691 0, /* xCommit */ | 693 0, /* xCommit */ |
| 692 0, /* xRollback */ | 694 0, /* xRollback */ |
| 693 0, /* xFindMethod */ | 695 0, /* xFindMethod */ |
| 694 0, /* xRename */ | 696 0, /* xRename */ |
| 695 }; | 697 }; |
| 696 return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); | 698 return sqlite3_create_module(db, "dbstat", &dbstat_module, 0); |
| 697 } | 699 } |
| 698 #elif defined(SQLITE_ENABLE_DBSTAT_VTAB) | 700 #elif defined(SQLITE_ENABLE_DBSTAT_VTAB) |
| 699 int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; } | 701 int sqlite3DbstatRegister(sqlite3 *db){ return SQLITE_OK; } |
| 700 #endif /* SQLITE_ENABLE_DBSTAT_VTAB */ | 702 #endif /* SQLITE_ENABLE_DBSTAT_VTAB */ |
| OLD | NEW |