-C Fix\sa\spotential\sbuffer\soverrun\sin\sthe\sreplace()\sfunction.\s(CVS\s3947)
-D 2007-05-08T14:39:04
+C Add\sthe\smax_page_count\spragma\sused\sto\slimit\sthe\smaximum\ssize\sof\sa\sdatabase\nfile.\s\sUntested.\s(CVS\s3948)
+D 2007-05-08T14:51:37
F Makefile.in 87b200ad9970907f76df734d29dff3d294c10935
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/analyze.c 4bbf5ddf9680587c6d4917e02e378b6037be3651
F src/attach.c a674f72b5e4a02b81d0ae7e6e14c1a2f48e36491
F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
-F src/btree.c 6d3db6416c71f678a4dd4719ce6d754ad5927c46
-F src/btree.h 845543b5a53d5d8a80ea14aeeb521276602317b7
+F src/btree.c dca996d45f1b8a87c86d0ec22a7ef6ca8c1ab805
+F src/btree.h 8444af0c82c0e878b5ce8a6eb345904830e678a5
F src/btreeInt.h cb3c0e9eb842d06079a62cdf3492c90c5db7ba75
F src/build.c 5a60e2e4a21fa8cbdf9e01a95e6d5ca44ff4a2b9
F src/callback.c 9c12535669a638f90a67e10440b99c7b93c0fbf4
F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
F src/insert.c e595ca26805dfb3a9ebaabc28e7947c479f3b14d
F src/legacy.c 388c71ad7fbcd898ba1bcbfc98a3ac954bfa5d01
-F src/limits.h 7275e16d02c0164177e466a1438e174cc1936f8d
+F src/limits.h e8d89699ff06f1492f5ddcf1ec61eab0df623975
F src/loadext.c afe4f4755dc49c36ef505748bbdddecb9f1d02a2
F src/main.c 35b340716319e88817493172aa63abe8be13b543
F src/malloc.c b89e31258a85158d15795bf87ae3ba007e56329b
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c 3b6169038101d06c54b4f04662bfd44b6cf2f289
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c 9c9a9df78636f4b9c8e18f90e93337a1231aaef7
-F src/pager.h 236e4065b3ca066e8e3edd43fbdd00e2c71a55d5
+F src/pager.c c5b32e741fb73930b6ec3d886ea680a3de3be5f7
+F src/pager.h db31691786504625e7e25c8cde4f40779ba209d9
F src/parse.y efbca804082366871a11f5f272c17672186961d2
-F src/pragma.c f426fef6b045dec23b1cf2f28397122a50fde109
+F src/pragma.c b881b457170d4922893f59b1caaac98f8e4192e2
F src/prepare.c c932f4398c3bf66fa366ad676c6f7e8ac5eaf7f6
F src/printf.c 67de0dcb40ef3297f4a047b434b81585c0f7062d
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
F www/optimizer.tcl d6812a10269bd0d7c488987aac0ad5036cace9dc
F www/optimizing.tcl f0b2538988d1bbad16cbfe63ec6e8f48c9eb04e5
F www/optoverview.tcl 815df406a38c9f69b27d37e8f7ede004c6d9f19e
-F www/pragma.tcl 9e5a48dc564fc2c4a1d38501402e6b45c4d3870b
+F www/pragma.tcl 3655b3fff2f6491768e020f43364288f9e149f79
F www/quickstart.tcl 8708a4ca83fbf55c66af1782992626f20c3df095
F www/shared.gif 265bae80c5b311c5a86e47662821076ffaf5c6ea
F www/sharedcache.tcl 3ebec81110e606af6fd65a3c4c19562cb173b29c
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P c59d436095b5258d7132a432c0cb6cd5a7990d85
-R e45c28784fb5fd22f2c0e733c939e615
-U danielk1977
-Z 3a097658130cbbee5c196715fa819c73
+P b0fb4a3cf6ddbc17ccd0c719b34a720d9090bc93
+R e3726b52936aa8a8c64158a436e46313
+U drh
+Z f695cedfb2999b1238e46a40ecfacacd
-b0fb4a3cf6ddbc17ccd0c719b34a720d9090bc93
\ No newline at end of file
+b1b74f06688fd90fcaf54cf95e2e7beeb5fc1040
\ No newline at end of file
** May you share freely, never taking more than you give.
**
*************************************************************************
-** $Id: btree.c,v 1.377 2007/05/05 18:39:25 drh Exp $
+** $Id: btree.c,v 1.378 2007/05/08 14:51:37 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
int sqlite3BtreeGetReserve(Btree *p){
return p->pBt->pageSize - p->pBt->usableSize;
}
+
+/*
+** Set the maximum page count for a database if mxPage is positive.
+** No changes are made if mxPage is 0 or negative.
+** Regardless of the value of mxPage, return the maximum page count.
+*/
+int sqlite3BtreeMaxPageCount(Btree *p, int mxPage){
+ return sqlite3PagerMaxPageCount(p->pBt->pPager, mxPage);
+}
#endif /* !defined(SQLITE_OMIT_PAGER_PRAGMAS) || !defined(SQLITE_OMIT_VACUUM) */
/*
** subsystem. See comments in the source code for a detailed description
** of what each interface routine does.
**
-** @(#) $Id: btree.h,v 1.80 2007/05/05 18:49:53 drh Exp $
+** @(#) $Id: btree.h,v 1.81 2007/05/08 14:51:37 drh Exp $
*/
#ifndef _BTREE_H_
#define _BTREE_H_
int sqlite3BtreeSyncDisabled(Btree*);
int sqlite3BtreeSetPageSize(Btree*,int,int);
int sqlite3BtreeGetPageSize(Btree*);
+int sqlite3BtreeMaxPageCount(Btree*,int);
int sqlite3BtreeGetReserve(Btree*);
int sqlite3BtreeSetAutoVacuum(Btree *, int);
int sqlite3BtreeGetAutoVacuum(Btree *);
**
** This file defines various limits of what SQLite can process.
**
-** @(#) $Id: limits.h,v 1.2 2007/05/08 13:58:28 drh Exp $
+** @(#) $Id: limits.h,v 1.3 2007/05/08 14:51:37 drh Exp $
*/
/*
/*
** Maximum number of pages in one database file.
+**
+** This is really just the default value for the max_page_count pragma.
+** This value can be lowered (or raised) at run-time using that the
+** max_page_count macro.
*/
#ifndef SQLITE_MAX_PAGE_COUNT
# define SQLITE_MAX_PAGE_COUNT 1073741823
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.336 2007/05/05 11:48:54 drh Exp $
+** @(#) $Id: pager.c,v 1.337 2007/05/08 14:51:37 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
int nExtra; /* Add this many bytes to each in-memory page */
int pageSize; /* Number of bytes in a page */
int nPage; /* Total number of in-memory pages */
- int nMaxPage; /* High water mark of nPage */
int nRef; /* Number of in-memory pages with PgHdr.nRef>0 */
int mxPage; /* Maximum number of pages to hold in cache */
+ Pgno mxPgno; /* Maximum allowed size of the database */
u8 *aInJournal; /* One bit for each page in the database file */
u8 *aInStmt; /* One bit for each page in the database */
char *zFilename; /* Name of the database file */
/* pPager->stmtSize = 0; */
/* pPager->stmtJSize = 0; */
/* pPager->nPage = 0; */
- /* pPager->nMaxPage = 0; */
pPager->mxPage = 100;
+ pPager->mxPgno = SQLITE_MAX_PAGE_COUNT;
assert( PAGER_UNLOCK==0 );
/* pPager->state = PAGER_UNLOCK; */
/* pPager->errMask = 0; */
return pPager->pageSize;
}
+/*
+** Attempt to set the maximum database page count if mxPage is positive.
+** Make no changes if mxPage is zero or negative. And never reduce the
+** maximum page count below the current size of the database.
+**
+** Regardless of mxPage, return the current maximum page count.
+*/
+int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
+ if( mxPage>0 ){
+ pPager->mxPgno = mxPage;
+ }
+ sqlite3PagerPagecount(pPager);
+ return pPager->mxPgno;
+}
+
/*
** The following set of routines are used to disable the simulated
** I/O error mechanism. These routines are used to avoid simulated
if( n==(PENDING_BYTE/pPager->pageSize) ){
n++;
}
+ if( n>pPager->mxPgno ){
+ pPager->mxPgno = n;
+ }
return n;
}
pPg->pNextAll = pPager->pAll;
pPager->pAll = pPg;
pPager->nPage++;
- if( pPager->nPage>pPager->nMaxPage ){
- assert( pPager->nMaxPage==(pPager->nPage-1) );
- pPager->nMaxPage++;
- }
}else{
/* Recycle an existing page with a zero ref-count. */
rc = pager_recycle(pPager, 1, &pPg);
** file, or by setting the entire page to zero.
*/
if( nMax<(int)pgno || MEMDB || (noContent && !pPager->alwaysRollback) ){
+ if( pgno>pPager->mxPgno ){
+ return SQLITE_FULL;
+ }
memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
pPg->needRead = noContent && !pPager->alwaysRollback;
IOTRACE(("ZERO %p %d\n", pPager, pgno));
** subsystem. The page cache subsystem reads and writes a file a page
** at a time and provides a journal for rollback.
**
-** @(#) $Id: pager.h,v 1.59 2007/05/08 01:08:49 drh Exp $
+** @(#) $Id: pager.h,v 1.60 2007/05/08 14:51:37 drh Exp $
*/
#ifndef _PAGER_H_
void sqlite3PagerSetDestructor(Pager*, void(*)(DbPage*,int));
void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*,int));
int sqlite3PagerSetPagesize(Pager*, int);
+int sqlite3PagerMaxPageCount(Pager*, int);
int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
void sqlite3PagerSetCachesize(Pager*, int);
int sqlite3PagerClose(Pager *pPager);
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
-** $Id: pragma.c,v 1.135 2007/05/08 01:08:49 drh Exp $
+** $Id: pragma.c,v 1.136 2007/05/08 14:51:37 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
}
}else
+ /*
+ ** PRAGMA [database.]max_page_count
+ ** PRAGMA [database.]max_page_count=N
+ **
+ ** The first form reports the current setting for the
+ ** maximum number of pages in the database file. The
+ ** second form attempts to change this setting. Both
+ ** forms return the current setting.
+ */
+ if( sqlite3StrICmp(zLeft,"max_page_count")==0 ){
+ Btree *pBt = pDb->pBt;
+ int newMax = 0;
+ if( zRight ){
+ newMax = atoi(zRight);
+ }
+ if( pBt ){
+ newMax = sqlite3BtreeMaxPageCount(pBt, newMax);
+ }
+ returnSingleInt(pParse, "max_page_count", newMax);
+ }else
+
/*
** PRAGMA [database.]locking_mode
** PRAGMA [database.]locking_mode = (normal|exclusive)
#
# Run this Tcl script to generate the pragma.html file.
#
-set rcsid {$Id: pragma.tcl,v 1.23 2007/05/04 19:16:30 drh Exp $}
+set rcsid {$Id: pragma.tcl,v 1.24 2007/05/08 14:51:37 drh Exp $}
source common.tcl
header {Pragma statements supported by SQLite}
</p>
</li>
+<a name="pragma_max_page_count"></a>
+<li><p><b>PRAGMA max_page_count;
+ <br>PRAGMA max_page_count = </b><i>N</i><b>;</b></p>
+ <p>Query or set the maximum number of pages in the database file.
+ Both forms of the pragma return the maximum page count. The second
+ form attempts to modify the maximum page count. The maximum page
+ count cannot be reduced below the current database size.
+ </p>
+</li>
+
<a name="pragma_read_uncommitted"></a>
<li><p><b>PRAGMA read_uncommitted;
<br>PRAGMA read_uncommitted = </b><i>0 | 1</i><b>;</b></p>