Skip to content

Commit 281c6a8

Browse files
authored
Set correct upper page size from source DB and do some page size checking (#5)
1 parent bed0dad commit 281c6a8

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,14 @@ If you are using CEVFS, chances are that you are _not_ currently making use of t
122122
- Free nodes are not managed which could result in wasted space. Not an issue if the database you create with `cevfs_build()` is intended to be used as a read-only database.
123123
- VACUUM not yet implemented to recover lost space.
124124

125-
## Knows Issues
126-
1. Does not work yet with SQLite version 3.13.0.
125+
## Compatible Versions
126+
127+
|Version|Combatibility|
128+
|-|-|
129+
|3.10.2|Most development was originally on this version|
130+
|3.11.x|OK|
131+
|3.12.0 - 3.15.2|CEVFS recently fixed for these versions|
132+
|3.16.0 and higher|Not compatible yet due to API changes|
127133

128134
## Contributing to the project
129135
If you would like to contribute back to the project, please fork the repo and submit pull requests. For more information, please read this [wiki page](https://github.com/ryanhomer/sqlite3-compression-encryption-vfs/wiki/Developing-in-Xcode)

cevfs/cevfs.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ struct cevfs_info {
146146
void *pCtx;
147147
t_xAutoDetect xAutoDetect;
148148

149+
u32 upperPgSize; // Temp storage for upperPgSize
149150
};
150151

151152
/*
@@ -1469,7 +1470,9 @@ static int cevfsOpen(
14691470
p->pReal = (sqlite3_file *)&p[1];
14701471
p->cevfsHeader.schema = CEVFS_FILE_SCHEMA_NO;
14711472
p->cevfsHeader.currPgno = CEVFS_FIRST_MAPPED_PAGE;
1472-
p->cevfsHeader.uppPgSz = SQLITE_DEFAULT_PAGE_SIZE;
1473+
1474+
// Set upper page size from temp storage else use default
1475+
p->cevfsHeader.uppPgSz = pInfo->upperPgSize ? pInfo->upperPgSize : SQLITE_DEFAULT_PAGE_SIZE;
14731476

14741477
// We need this for import
14751478
pInfo->pFile = p;
@@ -1862,9 +1865,12 @@ int cevfs_build(
18621865
// get destination ready to receive data
18631866
sqlite3 *pDb;
18641867

1865-
if( (rc = sqlite3_open_v2(zDestFilename, &pDb, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, vfsName))==SQLITE_OK ){
1866-
cevfs_info *pInfo = (cevfs_info *)pDestVfs->pAppData;
1868+
// Must set upper page size before sqlite3_open_v2
1869+
// as cevfsOpen will be invoked and expecting this value.
1870+
cevfs_info *pInfo = (cevfs_info *)pDestVfs->pAppData;
1871+
pInfo->upperPgSize = pageSize;
18671872

1873+
if( (rc = sqlite3_open_v2(zDestFilename, &pDb, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, vfsName))==SQLITE_OK ){
18681874
DbPage *pPage1 = NULL;
18691875
// import all pages
18701876
for(Pgno pgno=0; pgno<pageCount; pgno++){

0 commit comments

Comments
 (0)