1
1
/******************************************************************************
2
2
** This file is an amalgamation of many separate C source files from SQLite
3
- ** version 3.8.10. By combining all the individual C code files into this
3
+ ** version 3.8.10.2. By combining all the individual C code files into this
4
4
** single large file, the entire code can be compiled as a single translation
5
5
** unit. This allows many compilers to do optimizations that would not be
6
6
** possible if the files were compiled separately. Performance improvements
@@ -318,9 +318,9 @@ extern "C" {
318
318
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
319
319
** [sqlite_version()] and [sqlite_source_id()].
320
320
*/
321
- #define SQLITE_VERSION "3.8.10"
321
+ #define SQLITE_VERSION "3.8.10.2 "
322
322
#define SQLITE_VERSION_NUMBER 3008010
323
- #define SQLITE_SOURCE_ID "2015-05-04 19:13:25 850c11866686a7b39d7b163fb60898c11283688e "
323
+ #define SQLITE_SOURCE_ID "2015-05-20 18:17:19 2ef4f3a5b1d1d0c4338f8243d40a2452cc1f7fe4 "
324
324
325
325
/*
326
326
** CAPI3REF: Run-Time Library Version Numbers
@@ -14126,6 +14126,9 @@ static const char * const azCompileOpt[] = {
14126
14126
#if SQLITE_ENABLE_COLUMN_METADATA
14127
14127
"ENABLE_COLUMN_METADATA",
14128
14128
#endif
14129
+ #if SQLITE_ENABLE_DBSTAT_VTAB
14130
+ "ENABLE_DBSTAT_VTAB",
14131
+ #endif
14129
14132
#if SQLITE_ENABLE_EXPENSIVE_ASSERT
14130
14133
"ENABLE_EXPENSIVE_ASSERT",
14131
14134
#endif
@@ -21592,7 +21595,6 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
21592
21595
}
21593
21596
}while( !done && (c=(*++fmt))!=0 );
21594
21597
/* Get the field width */
21595
- width = 0;
21596
21598
if( c=='*' ){
21597
21599
if( bArgList ){
21598
21600
width = (int)getIntArg(pArgList);
@@ -21616,7 +21618,6 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
21616
21618
21617
21619
/* Get the precision */
21618
21620
if( c=='.' ){
21619
- precision = 0;
21620
21621
c = *++fmt;
21621
21622
if( c=='*' ){
21622
21623
if( bArgList ){
@@ -55479,7 +55480,7 @@ SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve,
55479
55480
if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE &&
55480
55481
((pageSize-1)&pageSize)==0 ){
55481
55482
assert( (pageSize & 7)==0 );
55482
- assert( !pBt->pPage1 && !pBt-> pCursor );
55483
+ assert( !pBt->pCursor );
55483
55484
pBt->pageSize = (u32)pageSize;
55484
55485
freeTempSpace(pBt);
55485
55486
}
@@ -71038,6 +71039,7 @@ static void applyAffinity(
71038
71039
if( 0==(pRec->flags&MEM_Str) && (pRec->flags&(MEM_Real|MEM_Int)) ){
71039
71040
sqlite3VdbeMemStringify(pRec, enc, 1);
71040
71041
}
71042
+ pRec->flags &= ~(MEM_Real|MEM_Int);
71041
71043
}
71042
71044
}
71043
71045
@@ -71816,7 +71818,6 @@ case OP_Halt: {
71816
71818
assert( rc==SQLITE_OK || db->nDeferredCons>0 || db->nDeferredImmCons>0 );
71817
71819
rc = p->rc ? SQLITE_ERROR : SQLITE_DONE;
71818
71820
}
71819
- pOp = &aOp[pcx];
71820
71821
goto vdbe_return;
71821
71822
}
71822
71823
@@ -76744,7 +76745,6 @@ case OP_JournalMode: { /* out2 */
76744
76745
}
76745
76746
eNew = sqlite3PagerSetJournalMode(pPager, eNew);
76746
76747
76747
- pOut = &aMem[pOp->p2];
76748
76748
pOut->flags = MEM_Str|MEM_Static|MEM_Term;
76749
76749
pOut->z = (char *)sqlite3JournalModename(eNew);
76750
76750
pOut->n = sqlite3Strlen30(pOut->z);
@@ -81395,7 +81395,6 @@ static void resolveAlias(
81395
81395
assert( iCol>=0 && iCol<pEList->nExpr );
81396
81396
pOrig = pEList->a[iCol].pExpr;
81397
81397
assert( pOrig!=0 );
81398
- assert( (pOrig->flags & EP_Resolved)!=0 || zType[0]==0 );
81399
81398
db = pParse->db;
81400
81399
pDup = sqlite3ExprDup(db, pOrig, 0);
81401
81400
if( pDup==0 ) return;
@@ -84056,7 +84055,7 @@ SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList *pList){
84056
84055
if( pList ){
84057
84056
for(i=0; i<pList->nExpr; i++){
84058
84057
Expr *pExpr = pList->a[i].pExpr;
84059
- if( ALWAYS(pExpr) ) m |= pList->a[i]. pExpr->flags;
84058
+ if( ALWAYS(pExpr) ) m |= pExpr->flags;
84060
84059
}
84061
84060
}
84062
84061
return m;
@@ -130868,6 +130867,13 @@ static int openDatabase(
130868
130867
}
130869
130868
#endif
130870
130869
130870
+ #ifdef SQLITE_ENABLE_DBSTAT_VTAB
130871
+ if( !db->mallocFailed && rc==SQLITE_OK){
130872
+ int sqlite3_dbstat_register(sqlite3*);
130873
+ rc = sqlite3_dbstat_register(db);
130874
+ }
130875
+ #endif
130876
+
130871
130877
/* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
130872
130878
** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
130873
130879
** mode. Doing nothing at all also makes NORMAL the default.
@@ -155229,7 +155235,7 @@ SQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(
155229
155235
*/
155230
155236
155231
155237
#if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \
155232
- && !defined(SQLITE_OMIT_VIRTUAL_TABLE )
155238
+ && !defined(SQLITE_OMIT_VIRTUALTABLE )
155233
155239
155234
155240
/*
155235
155241
** Page paths:
@@ -155331,6 +155337,7 @@ struct StatCursor {
155331
155337
struct StatTable {
155332
155338
sqlite3_vtab base;
155333
155339
sqlite3 *db;
155340
+ int iDb; /* Index of database to analyze */
155334
155341
};
155335
155342
155336
155343
#ifndef get2byte
@@ -155349,7 +155356,17 @@ static int statConnect(
155349
155356
){
155350
155357
StatTable *pTab = 0;
155351
155358
int rc = SQLITE_OK;
155359
+ int iDb;
155352
155360
155361
+ if( argc>=4 ){
155362
+ iDb = sqlite3FindDbName(db, argv[3]);
155363
+ if( iDb<0 ){
155364
+ *pzErr = sqlite3_mprintf("no such database: %s", argv[3]);
155365
+ return SQLITE_ERROR;
155366
+ }
155367
+ }else{
155368
+ iDb = 0;
155369
+ }
155353
155370
rc = sqlite3_declare_vtab(db, VTAB_SCHEMA);
155354
155371
if( rc==SQLITE_OK ){
155355
155372
pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable));
@@ -155360,6 +155377,7 @@ static int statConnect(
155360
155377
if( rc==SQLITE_OK ){
155361
155378
memset(pTab, 0, sizeof(StatTable));
155362
155379
pTab->db = db;
155380
+ pTab->iDb = iDb;
155363
155381
}
155364
155382
155365
155383
*ppVtab = (sqlite3_vtab*)pTab;
@@ -155414,16 +155432,22 @@ static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
155414
155432
if( pCsr==0 ){
155415
155433
rc = SQLITE_NOMEM;
155416
155434
}else{
155435
+ char *zSql;
155417
155436
memset(pCsr, 0, sizeof(StatCursor));
155418
155437
pCsr->base.pVtab = pVTab;
155419
155438
155420
- rc = sqlite3_prepare_v2(pTab->db,
155439
+ zSql = sqlite3_mprintf(
155421
155440
"SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type"
155422
155441
" UNION ALL "
155423
- "SELECT name, rootpage, type FROM sqlite_master WHERE rootpage!=0"
155424
- " ORDER BY name", -1,
155425
- &pCsr->pStmt, 0
155426
- );
155442
+ "SELECT name, rootpage, type"
155443
+ " FROM \"%w\".sqlite_master WHERE rootpage!=0"
155444
+ " ORDER BY name", pTab->db->aDb[pTab->iDb].zName);
155445
+ if( zSql==0 ){
155446
+ rc = SQLITE_NOMEM;
155447
+ }else{
155448
+ rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);
155449
+ sqlite3_free(zSql);
155450
+ }
155427
155451
if( rc!=SQLITE_OK ){
155428
155452
sqlite3_free(pCsr);
155429
155453
pCsr = 0;
@@ -155589,7 +155613,7 @@ static int statDecodePage(Btree *pBt, StatPage *p){
155589
155613
*/
155590
155614
static void statSizeAndOffset(StatCursor *pCsr){
155591
155615
StatTable *pTab = (StatTable *)((sqlite3_vtab_cursor *)pCsr)->pVtab;
155592
- Btree *pBt = pTab->db->aDb[0 ].pBt;
155616
+ Btree *pBt = pTab->db->aDb[pTab->iDb ].pBt;
155593
155617
Pager *pPager = sqlite3BtreePager(pBt);
155594
155618
sqlite3_file *fd;
155595
155619
sqlite3_int64 x[2];
@@ -155603,7 +155627,7 @@ static void statSizeAndOffset(StatCursor *pCsr){
155603
155627
*/
155604
155628
fd = sqlite3PagerFile(pPager);
155605
155629
x[0] = pCsr->iPageno;
155606
- if( sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){
155630
+ if( fd->pMethods!=0 && sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){
155607
155631
pCsr->iOffset = x[0];
155608
155632
pCsr->szPage = (int)x[1];
155609
155633
}
@@ -155615,9 +155639,10 @@ static void statSizeAndOffset(StatCursor *pCsr){
155615
155639
static int statNext(sqlite3_vtab_cursor *pCursor){
155616
155640
int rc;
155617
155641
int nPayload;
155642
+ char *z;
155618
155643
StatCursor *pCsr = (StatCursor *)pCursor;
155619
155644
StatTable *pTab = (StatTable *)pCursor->pVtab;
155620
- Btree *pBt = pTab->db->aDb[0 ].pBt;
155645
+ Btree *pBt = pTab->db->aDb[pTab->iDb ].pBt;
155621
155646
Pager *pPager = sqlite3BtreePager(pBt);
155622
155647
155623
155648
sqlite3_free(pCsr->zPath);
@@ -155637,8 +155662,9 @@ static int statNext(sqlite3_vtab_cursor *pCursor){
155637
155662
rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg);
155638
155663
pCsr->aPage[0].iPgno = iRoot;
155639
155664
pCsr->aPage[0].iCell = 0;
155640
- pCsr->aPage[0].zPath = sqlite3_mprintf("/");
155665
+ pCsr->aPage[0].zPath = z = sqlite3_mprintf("/");
155641
155666
pCsr->iPage = 0;
155667
+ if( z==0 ) rc = SQLITE_NOMEM;
155642
155668
}else{
155643
155669
pCsr->isEof = 1;
155644
155670
return sqlite3_reset(pCsr->pStmt);
@@ -155661,7 +155687,7 @@ static int statNext(sqlite3_vtab_cursor *pCursor){
155661
155687
pCsr->zPagetype = "overflow";
155662
155688
pCsr->nCell = 0;
155663
155689
pCsr->nMxPayload = 0;
155664
- pCsr->zPath = sqlite3_mprintf(
155690
+ pCsr->zPath = z = sqlite3_mprintf(
155665
155691
"%s%.3x+%.6x", p->zPath, p->iCell, pCell->iOvfl
155666
155692
);
155667
155693
if( pCell->iOvfl<pCell->nOvfl-1 ){
@@ -155673,7 +155699,7 @@ static int statNext(sqlite3_vtab_cursor *pCursor){
155673
155699
}
155674
155700
pCell->iOvfl++;
155675
155701
statSizeAndOffset(pCsr);
155676
- return SQLITE_OK;
155702
+ return z==0 ? SQLITE_NOMEM : SQLITE_OK;
155677
155703
}
155678
155704
if( p->iRightChildPg ) break;
155679
155705
p->iCell++;
@@ -155695,8 +155721,9 @@ static int statNext(sqlite3_vtab_cursor *pCursor){
155695
155721
}
155696
155722
rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg);
155697
155723
p[1].iCell = 0;
155698
- p[1].zPath = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell);
155724
+ p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell);
155699
155725
p->iCell++;
155726
+ if( z==0 ) rc = SQLITE_NOMEM;
155700
155727
}
155701
155728
155702
155729
@@ -155729,7 +155756,8 @@ static int statNext(sqlite3_vtab_cursor *pCursor){
155729
155756
pCsr->nCell = p->nCell;
155730
155757
pCsr->nUnused = p->nUnused;
155731
155758
pCsr->nMxPayload = p->nMxPayload;
155732
- pCsr->zPath = sqlite3_mprintf("%s", p->zPath);
155759
+ pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath);
155760
+ if( z==0 ) rc = SQLITE_NOMEM;
155733
155761
nPayload = 0;
155734
155762
for(i=0; i<p->nCell; i++){
155735
155763
nPayload += p->aCell[i].nLocal;
@@ -155765,7 +155793,7 @@ static int statColumn(
155765
155793
StatCursor *pCsr = (StatCursor *)pCursor;
155766
155794
switch( i ){
155767
155795
case 0: /* name */
155768
- sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_STATIC );
155796
+ sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_TRANSIENT );
155769
155797
break;
155770
155798
case 1: /* path */
155771
155799
sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT);
@@ -155791,7 +155819,8 @@ static int statColumn(
155791
155819
case 8: /* pgoffset */
155792
155820
sqlite3_result_int64(ctx, pCsr->iOffset);
155793
155821
break;
155794
- case 9: /* pgsize */
155822
+ default: /* pgsize */
155823
+ assert( i==9 );
155795
155824
sqlite3_result_int(ctx, pCsr->szPage);
155796
155825
break;
155797
155826
}
0 commit comments