1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Pass all (relevant) regression tests when using the codec. (CVS 1223)

FossilOrigin-Name: 5200e9edc5fdba0285a3cb1cd808cbf66d7a349e
This commit is contained in:
drh
2004-02-11 02:18:05 +00:00
parent d86a39c866
commit 9eb9e26b82
12 changed files with 91 additions and 65 deletions

View File

@ -1,5 +1,5 @@
C Adjustments\sto\sthe\scodec\sin\sthe\spager.\s(CVS\s1222) C Pass\sall\s(relevant)\sregression\stests\swhen\susing\sthe\scodec.\s(CVS\s1223)
D 2004-02-10T23:51:06 D 2004-02-11T02:18:06
F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@ -25,7 +25,7 @@ F src/attach.c 4a0a3c0885fec11a0a199a8031694d08925d0a27
F src/auth.c c59ad0dab501888f8b1fccc25e2f5965d2265116 F src/auth.c c59ad0dab501888f8b1fccc25e2f5965d2265116
F src/btree.c c325d46f0aa815d73358bf2e044dab23f645c214 F src/btree.c c325d46f0aa815d73358bf2e044dab23f645c214
F src/btree.h 41cb3ff6ebc3f6da2d0a074e39ff8c7a2287469f F src/btree.h 41cb3ff6ebc3f6da2d0a074e39ff8c7a2287469f
F src/btree_rb.c 9a22056a94ef3253dbcf58849b05dfc3284d8fac F src/btree_rb.c ed844f9181d08efa4eaca2c157accc27434e345f
F src/build.c 0fdb0ce4bd87419b3930d0279e8277c4f9f69c1f F src/build.c 0fdb0ce4bd87419b3930d0279e8277c4f9f69c1f
F src/copy.c 9e47975ea96751c658bcf1a0c4f0bb7c6ee61e73 F src/copy.c 9e47975ea96751c658bcf1a0c4f0bb7c6ee61e73
F src/date.c c9d2bfd40b1c95f8f97d53a5eba981d7167c7b61 F src/date.c c9d2bfd40b1c95f8f97d53a5eba981d7167c7b61
@ -40,18 +40,18 @@ F src/main.c 6ec57b0f146572033c70493417d251365a7b4fbe
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565 F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
F src/os.c 681ec36217bc7c795d55d9a63ff79a8614ddee8c F src/os.c 681ec36217bc7c795d55d9a63ff79a8614ddee8c
F src/os.h 8d02b622153d2df442da1ec37cdd6b1bd9804a25 F src/os.h 8d02b622153d2df442da1ec37cdd6b1bd9804a25
F src/pager.c 3678afeb3f8ff4af3e4538e4a586b01198458046 F src/pager.c 8b4803d3225dfa15b15cfe6d0f48d8e690238a54
F src/pager.h b618354fa6270a87e0105be8aeaa0a0c7c545ee2 F src/pager.h 82332878799280145639a48d88cdb4058925e3f6
F src/parse.y 7a121554c0c0c0150a77ab05417b01fa44813ac4 F src/parse.y 7a121554c0c0c0150a77ab05417b01fa44813ac4
F src/pragma.c 89d62c31c6f0a43376fe8d20549b87a6d30c467a F src/pragma.c 89d62c31c6f0a43376fe8d20549b87a6d30c467a
F src/printf.c 84e4ea4ba49cbbf930e95e82295127ad5843ae1f F src/printf.c 84e4ea4ba49cbbf930e95e82295127ad5843ae1f
F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
F src/select.c a0211d1a6a94f6c3e611096e77f2d689a641495e F src/select.c a0211d1a6a94f6c3e611096e77f2d689a641495e
F src/shell.c 77b1d34a21b61cb8b0a2efa0152156f805c51897 F src/shell.c 514056d54893e58995ab27237e54c7f057e47597
F src/sqlite.h.in 1798588cab21ebf9fac3aad7fc1539b396c1f91d F src/sqlite.h.in 1798588cab21ebf9fac3aad7fc1539b396c1f91d
F src/sqliteInt.h c5b727d5d07b88654c204c0fc1ae79c9f635a008 F src/sqliteInt.h c5b727d5d07b88654c204c0fc1ae79c9f635a008
F src/table.c d845cb101b5afc1f7fea083c99e3d2fa7998d895 F src/table.c d845cb101b5afc1f7fea083c99e3d2fa7998d895
F src/tclsqlite.c 30afbb2e446d193d867e49fb0ca5ed84f1e0867f F src/tclsqlite.c 735da4580554cd38fc9360fe7d36ceff9574a84e
F src/test1.c 56e9a156df3ad5e4e98df776776e963effc727f7 F src/test1.c 56e9a156df3ad5e4e98df776776e963effc727f7
F src/test2.c 75819b0f2c63c6a0fd6995445881f2eb94036996 F src/test2.c 75819b0f2c63c6a0fd6995445881f2eb94036996
F src/test3.c 30985ebdfaf3ee1462a9b0652d3efbdc8d9798f5 F src/test3.c 30985ebdfaf3ee1462a9b0652d3efbdc8d9798f5
@ -112,10 +112,10 @@ F test/misuse.test 1095f26d1aed406c65e1d2eba651c4bb7c38cbff
F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0 F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
F test/null.test c14d0f4739f21e929b8115b72bf0c765b6bb1721 F test/null.test c14d0f4739f21e929b8115b72bf0c765b6bb1721
F test/pager.test dd31da9bee94a82e2e87e58cf286cfe809f8fc5f F test/pager.test dd31da9bee94a82e2e87e58cf286cfe809f8fc5f
F test/pragma.test 17ff54f4abe187fa1e9dd20afef63d14c650d737 F test/pragma.test 33011f5741cc4952ff8306ead8a1aeb003fb0786
F test/printf.test bdb5f66eb4a63abab9e26ab7277f2f8c886138a5 F test/printf.test bdb5f66eb4a63abab9e26ab7277f2f8c886138a5
F test/progress.test 701b6115c2613128ececdfe1398a1bd0e1a4cfb3 x F test/progress.test 701b6115c2613128ececdfe1398a1bd0e1a4cfb3 x
F test/quick.test c527bdb899b12a8cd8ceecce45f72922099f4095 F test/quick.test 5a6bccf5c02f16841a79fbac7409a02138880c10
F test/quote.test 08f23385c685d3dc7914ec760d492cacea7f6e3d F test/quote.test 08f23385c685d3dc7914ec760d492cacea7f6e3d
F test/rowid.test 77f7e8c7ca626a15ff91a536595b695cfce7c845 F test/rowid.test 77f7e8c7ca626a15ff91a536595b695cfce7c845
F test/select1.test 0d708cec567104653ec9aa49fecf3444a2e7d150 F test/select1.test 0d708cec567104653ec9aa49fecf3444a2e7d150
@ -128,10 +128,10 @@ F test/sort.test ba07b107c16070208e6aab3cadea66ba079d85ba
F test/subselect.test f0fea8cf9f386d416d64d152e3c65f9116d0f50f F test/subselect.test f0fea8cf9f386d416d64d152e3c65f9116d0f50f
F test/table.test 371a1fc1c470982b2f68f9732f903a5d96f949c4 F test/table.test 371a1fc1c470982b2f68f9732f903a5d96f949c4
F test/tableapi.test e0c4cce61e58343caa84dab33fa6823cb35fe1e1 F test/tableapi.test e0c4cce61e58343caa84dab33fa6823cb35fe1e1
F test/tclsqlite.test 97233f45db35a76ceae9e56d244af68fc8061ceb F test/tclsqlite.test 602c73172b46c47221d4e699beaf6684eb120d48
F test/temptable.test c82bd6f800f10e8cf96921af6315e5f1c21e2692 F test/temptable.test c82bd6f800f10e8cf96921af6315e5f1c21e2692
F test/tester.tcl 2671536d3650c29e7c105219f277568b0884cb58 F test/tester.tcl 024e68f66c85f265f4143c4e073939f09710aaf5
F test/thread1.test 0c1fcc2f9bdd887225e56f48db8ddfbb3d0794ba F test/thread1.test 53f050d5be6932d9430df7756edd379366508ff6
F test/threadtest1.c f7f896e62ed46feae1dc411114a48c15a0f82ee2 F test/threadtest1.c f7f896e62ed46feae1dc411114a48c15a0f82ee2
F test/threadtest2.c d94ca4114fd1504f7e0ae724bcd83d4b40931d86 F test/threadtest2.c d94ca4114fd1504f7e0ae724bcd83d4b40931d86
F test/trans.test 75e7a171b5d2d94ee56766459113e2ad0e5f809d F test/trans.test 75e7a171b5d2d94ee56766459113e2ad0e5f809d
@ -183,7 +183,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
P cf1cec74ae039cd7cbc8a1032d29f067dedb4210 P be5122e99caacbeb5e568a2782fe2faf634ad355
R 33a0bad7d3175733647a431c861739f1 R 68916ef0731924b53922877bb802191f
U drh U drh
Z 19f14306e79d3dfba9d27638424ae996 Z 51a413c8556d4e6f634af0189fc8243d

View File

@ -1 +1 @@
be5122e99caacbeb5e568a2782fe2faf634ad355 5200e9edc5fdba0285a3cb1cd808cbf66d7a349e

View File

@ -9,7 +9,7 @@
** May you share freely, never taking more than you give. ** May you share freely, never taking more than you give.
** **
************************************************************************* *************************************************************************
** $Id: btree_rb.c,v 1.21 2004/02/10 02:57:59 drh Exp $ ** $Id: btree_rb.c,v 1.22 2004/02/11 02:18:06 drh Exp $
** **
** This file implements an in-core database using Red-Black balanced ** This file implements an in-core database using Red-Black balanced
** binary trees. ** binary trees.
@ -1425,8 +1425,7 @@ static int memRbtreeCursorDump(RbtCursor* pCur, int* aRes)
static struct Pager *memRbtreePager(Rbtree* tree) static struct Pager *memRbtreePager(Rbtree* tree)
{ {
assert(!"Cannot call sqliteRbtreePager"); return 0;
return SQLITE_OK;
} }
/* /*

View File

@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while ** file simultaneously, or one process from reading the database while
** another is writing. ** another is writing.
** **
** @(#) $Id: pager.c,v 1.98 2004/02/10 23:51:06 drh Exp $ ** @(#) $Id: pager.c,v 1.99 2004/02/11 02:18:07 drh Exp $
*/ */
#include "os.h" /* Must be first to enable large file support */ #include "os.h" /* Must be first to enable large file support */
#include "sqliteInt.h" #include "sqliteInt.h"
@ -117,6 +117,16 @@ struct PgHdr {
/* Pager.nExtra bytes of local data follow the page data */ /* Pager.nExtra bytes of local data follow the page data */
}; };
/*
** A macro used for invoking the codec if there is one
*/
#ifdef SQLITE_HAS_CODEC
# define CODEC(P,D,N,X) if( P->xCodec ){ P->xCodec(P->pCodecArg,D,N,X); }
#else
# define CODEC(P,D,N,X)
#endif
/* /*
** Convert a pointer to a PgHdr into a pointer to its data ** Convert a pointer to a PgHdr into a pointer to its data
** and back again. ** and back again.
@ -158,7 +168,7 @@ struct Pager {
int nRef; /* Number of in-memory pages with PgHdr.nRef>0 */ int nRef; /* Number of in-memory pages with PgHdr.nRef>0 */
int mxPage; /* Maximum number of pages to hold in cache */ int mxPage; /* Maximum number of pages to hold in cache */
int nHit, nMiss, nOvfl; /* Cache hits, missing, and LRU overflows */ int nHit, nMiss, nOvfl; /* Cache hits, missing, and LRU overflows */
void (*xCodec)(void*,void*,int); /* Routine for en/decoding on-disk data */ void (*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */
void *pCodecArg; /* First argument to xCodec() */ void *pCodecArg; /* First argument to xCodec() */
u8 journalOpen; /* True if journal file descriptors is valid */ u8 journalOpen; /* True if journal file descriptors is valid */
u8 journalStarted; /* True if header of journal is synced */ u8 journalStarted; /* True if header of journal is synced */
@ -562,9 +572,7 @@ static int pager_playback_one_page(Pager *pPager, OsFile *jfd, int format){
memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra); memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra);
pPg->dirty = 0; pPg->dirty = 0;
pPg->needSync = 0; pPg->needSync = 0;
if( pPager->xCodec ){ CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3);
pPager->xCodec(pPager->pCodecArg, PGHDR_TO_DATA(pPg), 3);
}
} }
return rc; return rc;
} }
@ -724,10 +732,9 @@ static int pager_playback(Pager *pPager, int useJournalSize){
if( (int)pPg->pgno <= pPager->origDbSize ){ if( (int)pPg->pgno <= pPager->origDbSize ){
sqliteOsSeek(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)(pPg->pgno-1)); sqliteOsSeek(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)(pPg->pgno-1));
rc = sqliteOsRead(&pPager->fd, zBuf, SQLITE_PAGE_SIZE); rc = sqliteOsRead(&pPager->fd, zBuf, SQLITE_PAGE_SIZE);
TRACE2("REFETCH %d\n", pPg->pgno);
CODEC(pPager, zBuf, pPg->pgno, 2);
if( rc ) break; if( rc ) break;
if( pPager->xCodec ){
pPager->xCodec(pPager->pCodecArg, zBuf, 2);
}
}else{ }else{
memset(zBuf, 0, SQLITE_PAGE_SIZE); memset(zBuf, 0, SQLITE_PAGE_SIZE);
} }
@ -1247,13 +1254,10 @@ static int pager_write_pagelist(PgHdr *pList){
while( pList ){ while( pList ){
assert( pList->dirty ); assert( pList->dirty );
sqliteOsSeek(&pPager->fd, (pList->pgno-1)*(off_t)SQLITE_PAGE_SIZE); sqliteOsSeek(&pPager->fd, (pList->pgno-1)*(off_t)SQLITE_PAGE_SIZE);
if( pPager->xCodec ){ CODEC(pPager, PGHDR_TO_DATA(pList), pList->pgno, 6);
pPager->xCodec(pPager->pCodecArg, PGHDR_TO_DATA(pList), 6); TRACE2("STORE %d\n", pList->pgno);
}
rc = sqliteOsWrite(&pPager->fd, PGHDR_TO_DATA(pList), SQLITE_PAGE_SIZE); rc = sqliteOsWrite(&pPager->fd, PGHDR_TO_DATA(pList), SQLITE_PAGE_SIZE);
if( pPager->xCodec ){ CODEC(pPager, PGHDR_TO_DATA(pList), pList->pgno, 0);
pPager->xCodec(pPager->pCodecArg, PGHDR_TO_DATA(pList), 0);
}
if( rc ) return rc; if( rc ) return rc;
pList->dirty = 0; pList->dirty = 0;
pList = pList->pDirty; pList = pList->pDirty;
@ -1514,6 +1518,8 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
int rc; int rc;
sqliteOsSeek(&pPager->fd, (pgno-1)*(off_t)SQLITE_PAGE_SIZE); sqliteOsSeek(&pPager->fd, (pgno-1)*(off_t)SQLITE_PAGE_SIZE);
rc = sqliteOsRead(&pPager->fd, PGHDR_TO_DATA(pPg), SQLITE_PAGE_SIZE); rc = sqliteOsRead(&pPager->fd, PGHDR_TO_DATA(pPg), SQLITE_PAGE_SIZE);
TRACE2("FETCH %d\n", pPg->pgno);
CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3);
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
off_t fileSize; off_t fileSize;
if( sqliteOsFileSize(&pPager->fd,&fileSize)!=SQLITE_OK if( sqliteOsFileSize(&pPager->fd,&fileSize)!=SQLITE_OK
@ -1523,8 +1529,6 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
}else{ }else{
memset(PGHDR_TO_DATA(pPg), 0, SQLITE_PAGE_SIZE); memset(PGHDR_TO_DATA(pPg), 0, SQLITE_PAGE_SIZE);
} }
}else if( pPager->xCodec ){
pPager->xCodec(pPager->pCodecArg, PGHDR_TO_DATA(pPg), 3);
} }
} }
}else{ }else{
@ -1803,13 +1807,10 @@ int sqlitepager_write(void *pData){
szPg = SQLITE_PAGE_SIZE+4; szPg = SQLITE_PAGE_SIZE+4;
} }
store32bits(pPg->pgno, pPg, -4); store32bits(pPg->pgno, pPg, -4);
if( pPager->xCodec ){ CODEC(pPager, pData, pPg->pgno, 7);
pPager->xCodec(pPager->pCodecArg, pData, 3);
}
rc = sqliteOsWrite(&pPager->jfd, &((char*)pData)[-4], szPg); rc = sqliteOsWrite(&pPager->jfd, &((char*)pData)[-4], szPg);
if( pPager->xCodec ){ TRACE3("JOURNAL %d %d\n", pPg->pgno, pPg->needSync);
pPager->xCodec(pPager->pCodecArg, pData, 0); CODEC(pPager, pData, pPg->pgno, 0);
}
if( journal_format>=JOURNAL_FORMAT_3 ){ if( journal_format>=JOURNAL_FORMAT_3 ){
*(u32*)PGHDR_TO_EXTRA(pPg) = saved; *(u32*)PGHDR_TO_EXTRA(pPg) = saved;
} }
@ -1827,7 +1828,6 @@ int sqlitepager_write(void *pData){
pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7); pPager->aInCkpt[pPg->pgno/8] |= 1<<(pPg->pgno&7);
page_add_to_ckpt_list(pPg); page_add_to_ckpt_list(pPg);
} }
TRACE3("JOURNAL %d %d\n", pPg->pgno, pPg->needSync);
}else{ }else{
pPg->needSync = !pPager->journalStarted && !pPager->noSync; pPg->needSync = !pPager->journalStarted && !pPager->noSync;
TRACE3("APPEND %d %d\n", pPg->pgno, pPg->needSync); TRACE3("APPEND %d %d\n", pPg->pgno, pPg->needSync);
@ -1845,7 +1845,10 @@ int sqlitepager_write(void *pData){
if( pPager->ckptInUse && !pPg->inCkpt && (int)pPg->pgno<=pPager->ckptSize ){ if( pPager->ckptInUse && !pPg->inCkpt && (int)pPg->pgno<=pPager->ckptSize ){
assert( pPg->inJournal || (int)pPg->pgno>pPager->origDbSize ); assert( pPg->inJournal || (int)pPg->pgno>pPager->origDbSize );
store32bits(pPg->pgno, pPg, -4); store32bits(pPg->pgno, pPg, -4);
CODEC(pPager, pData, pPg->pgno, 7);
rc = sqliteOsWrite(&pPager->cpfd, &((char*)pData)[-4], SQLITE_PAGE_SIZE+4); rc = sqliteOsWrite(&pPager->cpfd, &((char*)pData)[-4], SQLITE_PAGE_SIZE+4);
TRACE2("CKPT-JOURNAL %d\n", pPg->pgno);
CODEC(pPager, pData, pPg->pgno, 0);
if( rc!=SQLITE_OK ){ if( rc!=SQLITE_OK ){
sqlitepager_rollback(pPager); sqlitepager_rollback(pPager);
pPager->errMask |= PAGER_ERR_FULL; pPager->errMask |= PAGER_ERR_FULL;
@ -2192,7 +2195,7 @@ const char *sqlitepager_filename(Pager *pPager){
*/ */
void sqlitepager_set_codec( void sqlitepager_set_codec(
Pager *pPager, Pager *pPager,
void (*xCodec)(void*,void*,int), void (*xCodec)(void*,void*,Pgno,int),
void *pCodecArg void *pCodecArg
){ ){
pPager->xCodec = xCodec; pPager->xCodec = xCodec;

View File

@ -13,7 +13,7 @@
** subsystem. The page cache subsystem reads and writes a file a page ** subsystem. The page cache subsystem reads and writes a file a page
** at a time and provides a journal for rollback. ** at a time and provides a journal for rollback.
** **
** @(#) $Id: pager.h,v 1.25 2004/02/10 01:54:28 drh Exp $ ** @(#) $Id: pager.h,v 1.26 2004/02/11 02:18:07 drh Exp $
*/ */
/* /*
@ -98,7 +98,7 @@ int *sqlitepager_stats(Pager*);
void sqlitepager_set_safety_level(Pager*,int); void sqlitepager_set_safety_level(Pager*,int);
const char *sqlitepager_filename(Pager*); const char *sqlitepager_filename(Pager*);
int sqlitepager_rename(Pager*, const char *zNewName); int sqlitepager_rename(Pager*, const char *zNewName);
void sqlitepager_set_codec(Pager*,void(*)(void*,void*,int),void*); void sqlitepager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*);
#ifdef SQLITE_TEST #ifdef SQLITE_TEST
void sqlitepager_refdump(Pager*); void sqlitepager_refdump(Pager*);

View File

@ -12,7 +12,7 @@
** This file contains code to implement the "sqlite" command line ** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases. ** utility for accessing SQLite databases.
** **
** $Id: shell.c,v 1.85 2004/02/10 02:57:59 drh Exp $ ** $Id: shell.c,v 1.86 2004/02/11 02:18:07 drh Exp $
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -490,7 +490,7 @@ static char zHelp[] =
".prompt MAIN CONTINUE Replace the standard prompts\n" ".prompt MAIN CONTINUE Replace the standard prompts\n"
".quit Exit this program\n" ".quit Exit this program\n"
".read FILENAME Execute SQL in FILENAME\n" ".read FILENAME Execute SQL in FILENAME\n"
#ifdef SQLITE_HAS_CRYPTO #ifdef SQLITE_HAS_CODEC
".rekey OLD NEW NEW Change the encryption key\n" ".rekey OLD NEW NEW Change the encryption key\n"
#endif #endif
".schema ?TABLE? Show the CREATE statements\n" ".schema ?TABLE? Show the CREATE statements\n"
@ -511,7 +511,7 @@ static void process_input(struct callback_data *p, FILE *in);
static void open_db(struct callback_data *p){ static void open_db(struct callback_data *p){
if( p->db==0 ){ if( p->db==0 ){
char *zErrMsg = 0; char *zErrMsg = 0;
#ifdef SQLITE_HAS_CRYPTO #ifdef SQLITE_HAS_CODEC
if( p->zKey && p->zKey[0] ){ if( p->zKey && p->zKey[0] ){
int n = strlen(p->zKey); int n = strlen(p->zKey);
p->db = sqlite_open_encrypted(p->zDbFilename, p->zKey, n, &zErrMsg); p->db = sqlite_open_encrypted(p->zDbFilename, p->zKey, n, &zErrMsg);
@ -786,7 +786,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
} }
}else }else
#ifdef SQLITE_HAS_CRYPTO #ifdef SQLITE_HAS_CODEC
if( c=='r' && strncmp(azArg[0],"rekey", n)==0 && nArg==4 ){ if( c=='r' && strncmp(azArg[0],"rekey", n)==0 && nArg==4 ){
char *zOld = p->zKey; char *zOld = p->zKey;
if( zOld==0 ) zOld = ""; if( zOld==0 ) zOld = "";
@ -1170,7 +1170,7 @@ static const char zOptions[] =
" -[no]header turn headers on or off\n" " -[no]header turn headers on or off\n"
" -column set output mode to 'column'\n" " -column set output mode to 'column'\n"
" -html set output mode to HTML\n" " -html set output mode to HTML\n"
#ifdef SQLITE_HAS_CRYPTO #ifdef SQLITE_HAS_CODEC
" -key KEY encryption key\n" " -key KEY encryption key\n"
#endif #endif
" -line set output mode to 'line'\n" " -line set output mode to 'line'\n"

View File

@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** A TCL Interface to SQLite ** A TCL Interface to SQLite
** **
** $Id: tclsqlite.c,v 1.55 2004/02/01 01:22:52 drh Exp $ ** $Id: tclsqlite.c,v 1.56 2004/02/11 02:18:07 drh Exp $
*/ */
#ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */
@ -900,7 +900,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
return TCL_ERROR; return TCL_ERROR;
} }
pKey = Tcl_GetByteArrayFromObj(objv[2], &nKey); pKey = Tcl_GetByteArrayFromObj(objv[2], &nKey);
#ifdef SQLITE_HAS_CRYPTO #ifdef SQLITE_HAS_CODEC
rc = sqlite_rekey(pDb->db, pKey, nKey); rc = sqlite_rekey(pDb->db, pKey, nKey);
if( rc ){ if( rc ){
Tcl_AppendResult(interp, sqlite_error_string(rc), 0); Tcl_AppendResult(interp, sqlite_error_string(rc), 0);
@ -1016,8 +1016,8 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
Tcl_AppendResult(interp,sqlite_version,0); Tcl_AppendResult(interp,sqlite_version,0);
return TCL_OK; return TCL_OK;
} }
if( strcmp(zArg,"-has-crypto")==0 ){ if( strcmp(zArg,"-has-codec")==0 ){
#ifdef SQLITE_HAS_CRYPTO #ifdef SQLITE_HAS_CODEC
Tcl_AppendResult(interp,"1",0); Tcl_AppendResult(interp,"1",0);
#else #else
Tcl_AppendResult(interp,"0",0); Tcl_AppendResult(interp,"0",0);
@ -1042,8 +1042,8 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
} }
if( objc!=3 && objc!=4 ){ if( objc!=3 && objc!=4 ){
Tcl_WrongNumArgs(interp, 1, objv, Tcl_WrongNumArgs(interp, 1, objv,
#ifdef SQLITE_HAS_CRYPTO #ifdef SQLITE_HAS_CODEC
"HANDLE FILENAME ?-key CRYPTOKEY?" "HANDLE FILENAME ?-key CODEC-KEY?"
#else #else
"HANDLE FILENAME ?MODE?" "HANDLE FILENAME ?MODE?"
#endif #endif
@ -1063,7 +1063,7 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){
} }
memset(p, 0, sizeof(*p)); memset(p, 0, sizeof(*p));
zFile = Tcl_GetStringFromObj(objv[2], 0); zFile = Tcl_GetStringFromObj(objv[2], 0);
#ifdef SQLITE_HAS_CRYPTO #ifdef SQLITE_HAS_CODEC
if( nKey>0 ){ if( nKey>0 ){
p->db = sqlite_open_encrypted(zFile, pKey, nKey, &zErrMsg); p->db = sqlite_open_encrypted(zFile, pKey, nKey, &zErrMsg);
}else }else

View File

@ -12,7 +12,7 @@
# #
# This file implements tests for the PRAGMA command. # This file implements tests for the PRAGMA command.
# #
# $Id: pragma.test,v 1.7 2003/12/16 03:44:48 drh Exp $ # $Id: pragma.test,v 1.8 2004/02/11 02:18:07 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -243,6 +243,7 @@ do_test pragma-2.10 {
# Construct a corrupted index and make sure the integrity_check # Construct a corrupted index and make sure the integrity_check
# pragma finds it. # pragma finds it.
# #
if {![sqlite -has-codec]} {
do_test pragma-3.1 { do_test pragma-3.1 {
execsql { execsql {
BEGIN; BEGIN;
@ -265,5 +266,6 @@ do_test pragma-3.2 {
btree_close $db btree_close $db
execsql {PRAGMA integrity_check} execsql {PRAGMA integrity_check}
} {{rowid 1 missing from index i2} {wrong # of entries in index i2}} } {{rowid 1 missing from index i2} {wrong # of entries in index i2}}
}; # endif has-codec
finish_test finish_test

View File

@ -10,7 +10,7 @@
#*********************************************************************** #***********************************************************************
# This file runs all tests. # This file runs all tests.
# #
# $Id: quick.test,v 1.5 2003/02/16 22:21:33 drh Exp $ # $Id: quick.test,v 1.6 2004/02/11 02:18:07 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
@ -27,6 +27,15 @@ set EXCLUDE {
misuse.test misuse.test
} }
if {[sqlite -has-codec]} {
lappend EXCLUDE \
attach.test \
attach2.test \
auth.test \
format3.test \
version.test
}
foreach testfile [lsort -dictionary [glob $testdir/*.test]] { foreach testfile [lsort -dictionary [glob $testdir/*.test]] {
set tail [file tail $testfile] set tail [file tail $testfile]
if {[lsearch -exact $EXCLUDE $tail]>=0} continue if {[lsearch -exact $EXCLUDE $tail]>=0} continue

View File

@ -15,15 +15,15 @@
# interface is pretty well tested. This file contains some addition # interface is pretty well tested. This file contains some addition
# tests for fringe issues that the main test suite does not cover. # tests for fringe issues that the main test suite does not cover.
# #
# $Id: tclsqlite.test,v 1.18 2004/02/01 01:22:52 drh Exp $ # $Id: tclsqlite.test,v 1.19 2004/02/11 02:18:07 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
source $testdir/tester.tcl source $testdir/tester.tcl
# Check the error messages generated by tclsqlite # Check the error messages generated by tclsqlite
# #
if {[sqlite -has-crypto]} { if {[sqlite -has-codec]} {
set r "sqlite HANDLE FILENAME ?-key CRYPTOKEY?" set r "sqlite_orig HANDLE FILENAME ?-key CODEC-KEY?"
} else { } else {
set r "sqlite HANDLE FILENAME ?MODE?" set r "sqlite HANDLE FILENAME ?MODE?"
} }

View File

@ -11,7 +11,7 @@
# This file implements some common TCL routines used for regression # This file implements some common TCL routines used for regression
# testing the SQLite library # testing the SQLite library
# #
# $Id: tester.tcl,v 1.26 2003/06/15 23:42:25 drh Exp $ # $Id: tester.tcl,v 1.27 2004/02/11 02:18:07 drh Exp $
# Make sure tclsqlite was compiled correctly. Abort now with an # Make sure tclsqlite was compiled correctly. Abort now with an
# error message if not. # error message if not.
@ -40,6 +40,19 @@ if {[sqlite -tcl-uses-utf]} {
} }
} }
# Use the pager codec if it is available
#
if {[sqlite -has-codec] && [info command sqlite_orig]==""} {
rename sqlite sqlite_orig
proc sqlite {args} {
if {[llength $args]==2 && [string index [lindex $args 0] 0]!="-"} {
lappend args -key {xyzzy}
}
uplevel 1 sqlite_orig $args
}
}
# Create a test database # Create a test database
# #
catch {db close} catch {db close}

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The # This file implements regression tests for SQLite library. The
# focus of this script is multithreading behavior # focus of this script is multithreading behavior
# #
# $Id: thread1.test,v 1.2 2003/12/19 08:40:24 drh Exp $ # $Id: thread1.test,v 1.3 2004/02/11 02:18:07 drh Exp $
set testdir [file dirname $argv0] set testdir [file dirname $argv0]
@ -19,7 +19,7 @@ source $testdir/tester.tcl
# Skip this whole file if the thread testing code is not enabled # Skip this whole file if the thread testing code is not enabled
# #
if {[llength [info command thread_step]]==0} { if {[llength [info command thread_step]]==0 || [sqlite -has-codec]} {
finish_test finish_test
return return
} }