Minor bugfixes and test case adjustments for version 2 test cases to work
with version 3. (CVS 1598) FossilOrigin-Name: e21a181376d4115c7dbe614f3f8a1fbf82d77c75
This commit is contained in:
parent
fbcd585fe6
commit
369f27eb51
39
manifest
39
manifest
@ -1,5 +1,5 @@
|
||||
C (1)\sVdbe\smakes\sa\scopy\sof\scolumn\stypes.\s(2)\sDon't\sinvalidate\sother\scursors\nwhen\sa\sstatement\sor\stransaction\sis\srolled\sback.\s(3)\sUpdate\scapi2.test\sfor\nthe\snew\sAPI.\s(CVS\s1597)
|
||||
D 2004-06-15T02:44:19
|
||||
C Minor\sbugfixes\sand\stest\scase\sadjustments\sfor\sversion\s2\stest\scases\sto\swork\nwith\sversion\s3.\s(CVS\s1598)
|
||||
D 2004-06-15T11:40:04
|
||||
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
|
||||
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@ -26,7 +26,7 @@ F sqlite.def fc4f5734786fe4743cfe2aa98eb2da4b089edb5f
|
||||
F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
|
||||
F src/attach.c 93b8ecec4a8d7b4e9f2479e2327d90c9d01765e8
|
||||
F src/auth.c 204e1e9c45e64315589bc8b62cba5d9de29b6a3c
|
||||
F src/btree.c 3c59f64c92d5e9e87ebbd1450329697202031d33
|
||||
F src/btree.c 2852932e900b1b82e105fd651807f199a1d86f12
|
||||
F src/btree.h 32f96abef464cf8765b23ca669acfe90d191fcc5
|
||||
F src/build.c 916a84fa5f8bfd44dbe14c3d7c923dd07ee7373f
|
||||
F src/date.c 65b483caeb0e4dd663667d2f927caa058168ebff
|
||||
@ -42,13 +42,13 @@ F src/main.c a62c08c9d315c3ebc58bfb6b52ab5953ee8a3089
|
||||
F src/md5.c d77a389955759c8329bb357e3d71bac3d6eb710b
|
||||
F src/os.h 1cb5f0293a30288451fe3c0c73815cf208212ed1
|
||||
F src/os_common.h ba1b7306e16e2091718f2c48db0fe6c1d7a31bb8
|
||||
F src/os_mac.c 129029f9faecf1133edcf72eaedd54c1c838b140
|
||||
F src/os_mac.c 3d31e26be1411acfb7961033098631b4f3486fdf
|
||||
F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4
|
||||
F src/os_unix.c 7eac2e840300848818f53e6e78cd19d128e936bd
|
||||
F src/os_unix.c 8832c78dd95c115b1690054354d90321a791950d
|
||||
F src/os_unix.h 1cd6133cf66dea704b8646b70b2dfdcbdd9b3738
|
||||
F src/os_win.c a60f9ebfb0ce3e5b2ce259f981af59a50b24fc8d
|
||||
F src/os_win.c 337e973ee77797aaab4787e3477a5945fcd97266
|
||||
F src/os_win.h 004eec47b1780fcaf07420ddc2072294b698d48c
|
||||
F src/pager.c bf81f3c8105f8b257ee07575d0040ee2c3822a51
|
||||
F src/pager.c 8e26112df058f73e718938ed07bdbf10ab942c0f
|
||||
F src/pager.h bc58d32a9dee464f7268fb68652c130a4216e438
|
||||
F src/parse.y 097438674976355a10cf177bd97326c548820b86
|
||||
F src/pragma.c e288bd122d3ca41ec2032475abde1ff5fa3095f4
|
||||
@ -61,7 +61,7 @@ F src/sqliteInt.h 924f0bcb493722c90cec7b19a240a37a4f01bbe7
|
||||
F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
|
||||
F src/tclsqlite.c 6f88be282a3617c6739c043fd13571b5f2fe9922
|
||||
F src/test1.c 49c69d360ce09f8ecf56ec5e55fba625703d8b21
|
||||
F src/test2.c 05f810c90cf6262d5f352860e87d41a3f34207f9
|
||||
F src/test2.c db0a0c30b59f1639cb8c2572be06439402833cc8
|
||||
F src/test3.c beafd0ccf7b9ae784744be1b1e66ffe8f64c25da
|
||||
F src/test4.c a921a69821fd30209589228e64f94e9f715b6fe2
|
||||
F src/test5.c 13ac1db35b03acbc197ceb245fe862da5ebf2369
|
||||
@ -70,13 +70,13 @@ F src/trigger.c 3ff6f24e5273767117126b712eaae24c3d6466aa
|
||||
F src/update.c 6133c876aa126e1771cda165fd992bb0d2f8eb38
|
||||
F src/utf.c e16737b3fc4201bf7ce9bd8ced5250596aa31b76
|
||||
F src/util.c 90375fa253137562d536ccdd40b297f0fd7413fc
|
||||
F src/vacuum.c b921eb778842592e1fb48a9d4cef7e861103878f
|
||||
F src/vdbe.c afbffe8d238004cf940f8844ecbec921fbeb2996
|
||||
F src/vacuum.c f9561c8095407a970af4e6a304b77c4083433d3e
|
||||
F src/vdbe.c adf618cd90b41ad473aadc165554896968988b02
|
||||
F src/vdbe.h 46f74444a213129bc4b5ce40124dd8ed613b0cde
|
||||
F src/vdbeInt.h ffc7b8ed911c5bf804796a768fdb6f0568010fa2
|
||||
F src/vdbeInt.h 0aabcc77523f0885c3e710fae58c8ec6e3ef0753
|
||||
F src/vdbeapi.c ee350b552fc4c1c695b760f914f69e9c5556e829
|
||||
F src/vdbeaux.c 9484c890b9dab6ee94705d1ca8072b33c202e3ca
|
||||
F src/vdbemem.c 34f59988831ea032b7f526c2c73175f9f4c0f3ad
|
||||
F src/vdbeaux.c 765ffa64365c61c0d5b91dba33b35cadddadf52a
|
||||
F src/vdbemem.c 1e7df5ed53bc05433c7d3fb28899cf2c82bd16ac
|
||||
F src/where.c 7fee7aeb9278f27324f228c55ab453b5f183b486
|
||||
F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
|
||||
F test/attach.test aed659e52635662bcd5069599aaca823533edf5a
|
||||
@ -117,7 +117,7 @@ F test/insert.test 6ec324659656f4a86e4abfcf1a1fd2795ba6b603
|
||||
F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f
|
||||
F test/interrupt.test 9142ce4448605127640eda5e283952f75f67ed91
|
||||
F test/intpkey.test e6e0d7cca0e64ec09cbf683a4712ed2196073742
|
||||
F test/ioerr.test 5dbaf09f96b56ee01cf3edd762b96eb4ad2c9ca4
|
||||
F test/ioerr.test ab1319619f4d90a0f5c0f9835dff48ac30e9c3dc
|
||||
F test/join.test 9ef6aabaac9de51d5fc41e68d1f4355da05a84cd
|
||||
F test/join2.test c97e4c5aa65dea462145529e58212a709b4722b8
|
||||
F test/lastinsert.test 31382f88b9b0270333ac9e4a17f2c2f4732da718
|
||||
@ -126,7 +126,7 @@ F test/limit.test 60d7f856ee7846f7130dee67f10f0e726cd70b5d
|
||||
F test/lock.test 3dca2c865d83fd1ab5730e8ad2fa69f81e0079e0
|
||||
F test/main.test 6a851b5992c4881a725a3d9647e629199df8de9d
|
||||
F test/malloc.test 4e19b96d9cd7d61f4826e6fce03849ad5ad526dd
|
||||
F test/memdb.test befe8f26d430d07ba65692243a893a0e82a0b866
|
||||
F test/memdb.test ec2abdcf03c3497236d499b289c4b7eacde8c336
|
||||
F test/memleak.test 4d5d374c8ea1fc5ac634aed58cac1047848ce65e
|
||||
F test/minmax.test 9dcf52f713b1b9e61d0a88a51eb8bb2e3c52d0ab
|
||||
F test/misc1.test 8472d2133c33efa29d514b464c4129f638b9cd31
|
||||
@ -140,7 +140,7 @@ F test/pager2.test 55469c7c1c1a54d6b32d7b3cc99001e90101a1ce
|
||||
F test/pragma.test 1b6792d4af550ca4973096d77fc278dd6c32c4dd
|
||||
F test/printf.test 31ac25b4f85fbc7fb507be34c6c0731adbefcf80
|
||||
F test/progress.test 7542a6ac7894a1b7730c1f9a27f3f8b9388a4d25 x
|
||||
F test/quick.test a519fa2a7bf0bd1b91fc642b83d765d0dc197a9f
|
||||
F test/quick.test 32f64124a83c2a3b1de1444e253bc95e51e14048
|
||||
F test/quote.test 08f23385c685d3dc7914ec760d492cacea7f6e3d
|
||||
F test/rowid.test 863e6e75878cccf03d166fe52023f20e09508683
|
||||
F test/select1.test 2f161f9cdf9fb577336bc8c930edade538567123
|
||||
@ -170,7 +170,6 @@ F test/unique.test 0e38d4cc7affeef2527720d1dafd1f6870f02f2b
|
||||
F test/update.test b29bd9061a1150426dab6959806fcc73a41b1217
|
||||
F test/vacuum.test c11b73769bf1d6d607acf0227c3ce925dd20e41d
|
||||
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
|
||||
F test/version.test 2ba212ba06380e65e476bdf2fcd390e8b05af5a0
|
||||
F test/view.test 1ee12c6f8f4791a2c0655120d5562a49400cfe53
|
||||
F test/where.test 9c5752b807b78078fab8da6f52e689832579ca20
|
||||
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
|
||||
@ -223,7 +222,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248
|
||||
F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
|
||||
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||
P 1c6a0706359c21e3b04e9097837a297d1d7714c3
|
||||
R bc3395ed5c26800ea674afecaa20429f
|
||||
P 4f5e2530829ef91753b083b5f2a1d7332e311cb6
|
||||
R e12d307f558ec5df80a17da54f5ce817
|
||||
U danielk1977
|
||||
Z 85a63d429d1d5d2f9e9b5bd0015dc827
|
||||
Z f98acef0e3dddb395ad5120c2ae73489
|
||||
|
@ -1 +1 @@
|
||||
4f5e2530829ef91753b083b5f2a1d7332e311cb6
|
||||
e21a181376d4115c7dbe614f3f8a1fbf82d77c75
|
@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.169 2004/06/15 02:44:19 danielk1977 Exp $
|
||||
** $Id: btree.c,v 1.170 2004/06/15 11:40:04 danielk1977 Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** For a detailed discussion of BTrees, refer to
|
||||
@ -1514,6 +1514,7 @@ int sqlite3BtreeCursor(
|
||||
pCur->pPage = 0;
|
||||
goto create_cursor_exception;
|
||||
}
|
||||
pCur->pPage = 0; /* For exit-handler, in case getAndInitPage() fails. */
|
||||
rc = getAndInitPage(pBt, pCur->pgnoRoot, &pCur->pPage, 0);
|
||||
if( rc!=SQLITE_OK ){
|
||||
goto create_cursor_exception;
|
||||
@ -4252,11 +4253,9 @@ int sqlite3BtreeCopyFile(Btree *pBtTo, Btree *pBtFrom){
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
if( pBtTo->pCursor ) return SQLITE_BUSY;
|
||||
memcpy(pBtTo->pPage1->aData, pBtFrom->pPage1->aData, pBtFrom->usableSize);
|
||||
rc = sqlite3pager_overwrite(pBtTo->pPager, 1, pBtFrom->pPage1->aData);
|
||||
nToPage = sqlite3pager_pagecount(pBtTo->pPager);
|
||||
nPage = sqlite3pager_pagecount(pBtFrom->pPager);
|
||||
for(i=2; rc==SQLITE_OK && i<=nPage; i++){
|
||||
for(i=1; rc==SQLITE_OK && i<=nPage; i++){
|
||||
void *pPage;
|
||||
rc = sqlite3pager_get(pBtFrom->pPager, i, &pPage);
|
||||
if( rc ) break;
|
||||
|
@ -397,6 +397,7 @@ int sqlite3OsSync(OsFile *id){
|
||||
** than UNIX.
|
||||
*/
|
||||
int sqlite3OsSyncDirectory(const char *zDirname){
|
||||
SimulateIOError(SQLITE_IOERR);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
|
@ -627,7 +627,9 @@ int sqlite3OsSync(OsFile *id){
|
||||
int sqlite3OsSyncDirectory(const char *zDirname){
|
||||
int fd;
|
||||
int r;
|
||||
SimulateIOError(SQLITE_IOERR);
|
||||
fd = open(zDirname, O_RDONLY|O_BINARY, 0644);
|
||||
TRACE3("DIRSYNC %-3d (%s)\n", fd, zDirname);
|
||||
if( fd<0 ){
|
||||
return SQLITE_CANTOPEN;
|
||||
}
|
||||
|
@ -295,6 +295,7 @@ int sqlite3OsSync(OsFile *id){
|
||||
** than UNIX.
|
||||
*/
|
||||
int sqlite3OsSyncDirectory(const char *zDirname){
|
||||
SimulateIOError(SQLITE_IOERR);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
|
16
src/pager.c
16
src/pager.c
@ -18,7 +18,7 @@
|
||||
** file simultaneously, or one process from reading the database while
|
||||
** another is writing.
|
||||
**
|
||||
** @(#) $Id: pager.c,v 1.127 2004/06/15 01:40:29 drh Exp $
|
||||
** @(#) $Id: pager.c,v 1.128 2004/06/15 11:40:09 danielk1977 Exp $
|
||||
*/
|
||||
#include "os.h" /* Must be first to enable large file support */
|
||||
#include "sqliteInt.h"
|
||||
@ -1265,7 +1265,7 @@ static void unlinkPage(PgHdr *pPg){
|
||||
|
||||
/*
|
||||
** This routine is used to truncate an in-memory database. Delete
|
||||
** every pages whose pgno is larger than pPager->dbSize and is unreferenced.
|
||||
** all pages whose pgno is larger than pPager->dbSize and is unreferenced.
|
||||
** Referenced pages larger than pPager->dbSize are zeroed.
|
||||
*/
|
||||
static void memoryTruncate(Pager *pPager){
|
||||
@ -1309,7 +1309,10 @@ int sqlite3pager_truncate(Pager *pPager, Pgno nPage){
|
||||
memoryTruncate(pPager);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
syncJournal(pPager, 0);
|
||||
rc = syncJournal(pPager, 0);
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
rc = sqlite3OsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)nPage);
|
||||
if( rc==SQLITE_OK ){
|
||||
pPager->dbSize = nPage;
|
||||
@ -2434,7 +2437,7 @@ int sqlite3pager_rollback(Pager *pPager){
|
||||
PgHdr *p;
|
||||
for(p=pPager->pAll; p; p=p->pNextAll){
|
||||
PgHistory *pHist;
|
||||
if( !p->dirty ) continue;
|
||||
if( !p->alwaysRollback && !p->dirty ) continue;
|
||||
pHist = PGHDR_TO_HIST(p, pPager);
|
||||
if( pHist->pOrig ){
|
||||
memcpy(PGHDR_TO_DATA(p), pHist->pOrig, pPager->pageSize);
|
||||
@ -2447,6 +2450,11 @@ int sqlite3pager_rollback(Pager *pPager){
|
||||
p->inJournal = 0;
|
||||
p->inStmt = 0;
|
||||
p->pPrevStmt = p->pNextStmt = 0;
|
||||
|
||||
if( pPager->xReiniter ){
|
||||
pPager->xReiniter(PGHDR_TO_DATA(p), pPager->pageSize);
|
||||
}
|
||||
|
||||
}
|
||||
pPager->pStmt = 0;
|
||||
pPager->dbSize = pPager->origDbSize;
|
||||
|
@ -13,7 +13,7 @@
|
||||
** is not included in the SQLite library. It is used for automated
|
||||
** testing of the SQLite library.
|
||||
**
|
||||
** $Id: test2.c,v 1.21 2004/06/09 19:03:55 drh Exp $
|
||||
** $Id: test2.c,v 1.22 2004/06/15 11:40:09 danielk1977 Exp $
|
||||
*/
|
||||
#include "os.h"
|
||||
#include "sqliteInt.h"
|
||||
@ -551,7 +551,7 @@ int Sqlitetest2_Init(Tcl_Interp *interp){
|
||||
for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
|
||||
Tcl_CreateCommand(interp, aCmd[i].zName, aCmd[i].xProc, 0, 0);
|
||||
}
|
||||
Tcl_LinkVar(interp, "sqlite3_io_error_pending",
|
||||
Tcl_LinkVar(interp, "sqlite_io_error_pending",
|
||||
(char*)&sqlite3_io_error_pending, TCL_LINK_INT);
|
||||
sprintf(zBuf, "%d", SQLITE_PAGE_SIZE);
|
||||
Tcl_SetVar(interp, "SQLITE_PAGE_SIZE", zBuf, TCL_GLOBAL_ONLY);
|
||||
|
@ -14,7 +14,7 @@
|
||||
** Most of the code in this file may be omitted by defining the
|
||||
** SQLITE_OMIT_VACUUM macro.
|
||||
**
|
||||
** $Id: vacuum.c,v 1.21 2004/06/03 16:08:42 danielk1977 Exp $
|
||||
** $Id: vacuum.c,v 1.22 2004/06/15 11:40:09 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@ -196,7 +196,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
|
||||
u32 meta;
|
||||
|
||||
assert( 0==sqlite3BtreeIsInTrans(pMain) );
|
||||
rc = sqlite3BtreeBeginTrans(db->aDb[0].pBt, 1, 0);
|
||||
rc = sqlite3BtreeBeginTrans(pMain, 1, 0);
|
||||
if( rc!=SQLITE_OK ) goto end_of_vacuum;
|
||||
|
||||
/* Copy Btree meta values 3 and 4. These correspond to SQL layer meta
|
||||
@ -212,6 +212,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
|
||||
if( rc!=SQLITE_OK ) goto end_of_vacuum;
|
||||
|
||||
rc = sqlite3BtreeCopyFile(pMain, pTemp);
|
||||
if( rc!=SQLITE_OK ) goto end_of_vacuum;
|
||||
rc = sqlite3BtreeCommit(pMain);
|
||||
}
|
||||
|
||||
|
20
src/vdbe.c
20
src/vdbe.c
@ -43,7 +43,7 @@
|
||||
** in this file for details. If in doubt, do not deviate from existing
|
||||
** commenting and indentation practices when changing or adding code.
|
||||
**
|
||||
** $Id: vdbe.c,v 1.372 2004/06/14 13:14:59 danielk1977 Exp $
|
||||
** $Id: vdbe.c,v 1.373 2004/06/15 11:40:09 danielk1977 Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@ -4144,8 +4144,7 @@ case OP_SortPut: {
|
||||
Mem *pNos = &pTos[-1];
|
||||
Sorter *pSorter;
|
||||
assert( pNos>=p->aStack );
|
||||
Stringify(pNos, db->enc);
|
||||
if( Dynamicify(pTos, db->enc) || Dynamicify(pNos, db->enc) ) goto no_mem;
|
||||
if( Dynamicify(pTos, db->enc) ) goto no_mem;
|
||||
pSorter = sqliteMallocRaw( sizeof(Sorter) );
|
||||
if( pSorter==0 ) goto no_mem;
|
||||
pSorter->pNext = p->pSort;
|
||||
@ -4153,9 +4152,10 @@ case OP_SortPut: {
|
||||
assert( pTos->flags & MEM_Dyn );
|
||||
pSorter->nKey = pTos->n;
|
||||
pSorter->zKey = pTos->z;
|
||||
assert( pNos->flags & MEM_Dyn );
|
||||
pSorter->nData = pNos->n;
|
||||
pSorter->pData = pNos->z;
|
||||
pSorter->data.flags = MEM_Null;
|
||||
rc = sqlite3VdbeMemMove(&pSorter->data, pNos);
|
||||
if( rc!=SQLITE_OK ) goto abort_due_to_error;
|
||||
Deephemeralize(&pSorter->data);
|
||||
pTos -= 2;
|
||||
break;
|
||||
}
|
||||
@ -4213,11 +4213,9 @@ case OP_SortNext: {
|
||||
if( pSorter!=0 ){
|
||||
p->pSort = pSorter->pNext;
|
||||
pTos++;
|
||||
pTos->z = pSorter->pData;
|
||||
pTos->n = pSorter->nData;
|
||||
pTos->flags = MEM_Blob|MEM_Dyn|MEM_Term;
|
||||
pTos->xDel = 0;
|
||||
pTos->enc = 0;
|
||||
pTos->flags = MEM_Null;
|
||||
rc = sqlite3VdbeMemMove(pTos, &pSorter->data);
|
||||
assert( rc==SQLITE_OK );
|
||||
sqliteFree(pSorter->zKey);
|
||||
sqliteFree(pSorter);
|
||||
}else{
|
||||
|
@ -95,24 +95,6 @@ struct Cursor {
|
||||
};
|
||||
typedef struct Cursor Cursor;
|
||||
|
||||
/*
|
||||
** A sorter builds a list of elements to be sorted. Each element of
|
||||
** the list is an instance of the following structure.
|
||||
*/
|
||||
typedef struct Sorter Sorter;
|
||||
struct Sorter {
|
||||
int nKey; /* Number of bytes in the key */
|
||||
char *zKey; /* The key by which we will sort */
|
||||
int nData; /* Number of bytes in the data */
|
||||
char *pData; /* The data associated with this key */
|
||||
Sorter *pNext; /* Next in the list */
|
||||
};
|
||||
|
||||
/*
|
||||
** Number of buckets used for merge-sort.
|
||||
*/
|
||||
#define NSORT 30
|
||||
|
||||
/*
|
||||
** Number of bytes of string storage space available to each stack
|
||||
** layer without having to malloc. NBFS is short for Number of Bytes
|
||||
@ -144,6 +126,23 @@ struct Mem {
|
||||
};
|
||||
typedef struct Mem Mem;
|
||||
|
||||
/*
|
||||
** A sorter builds a list of elements to be sorted. Each element of
|
||||
** the list is an instance of the following structure.
|
||||
*/
|
||||
typedef struct Sorter Sorter;
|
||||
struct Sorter {
|
||||
int nKey; /* Number of bytes in the key */
|
||||
char *zKey; /* The key by which we will sort */
|
||||
Mem data;
|
||||
Sorter *pNext; /* Next in the list */
|
||||
};
|
||||
|
||||
/*
|
||||
** Number of buckets used for merge-sort.
|
||||
*/
|
||||
#define NSORT 30
|
||||
|
||||
/* One or more of the following flags are set to indicate the validOK
|
||||
** representations of the value stored in the Mem struct.
|
||||
**
|
||||
@ -377,6 +376,7 @@ int sqlite3VdbeExec(Vdbe*);
|
||||
int sqlite3VdbeList(Vdbe*);
|
||||
int sqlite3VdbeChangeEncoding(Mem *, int);
|
||||
int sqlite3VdbeMemCopy(Mem*, const Mem*);
|
||||
int sqlite3VdbeMemMove(Mem*, Mem*);
|
||||
int sqlite3VdbeMemNulTerminate(Mem*);
|
||||
int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));
|
||||
void sqlite3VdbeMemSetInt64(Mem*, long long int);
|
||||
|
@ -693,7 +693,7 @@ void sqlite3VdbeSorterReset(Vdbe *p){
|
||||
Sorter *pSorter = p->pSort;
|
||||
p->pSort = pSorter->pNext;
|
||||
sqliteFree(pSorter->zKey);
|
||||
sqliteFree(pSorter->pData);
|
||||
sqlite3VdbeMemRelease(&pSorter->data);
|
||||
sqliteFree(pSorter);
|
||||
}
|
||||
}
|
||||
|
@ -311,6 +311,24 @@ int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Transfer the contents of pFrom to pTo. Any existing value in pTo is
|
||||
** deleted. pFrom contains an SQL NULL when this routine returns.
|
||||
*/
|
||||
int sqlite3VdbeMemMove(Mem *pTo, Mem *pFrom){
|
||||
int rc = SQLITE_OK;
|
||||
if( !(pFrom->flags&MEM_Dyn && pFrom->xDel) ){
|
||||
memcpy(pTo, pFrom, sizeof(Mem));
|
||||
if( pFrom->flags & MEM_Short ){
|
||||
pTo->z = pTo->zShort;
|
||||
}
|
||||
}else{
|
||||
rc = sqlite3VdbeMemCopy(pTo, pFrom);
|
||||
sqlite3VdbeMemRelease(pFrom);
|
||||
}
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Change the value of a Mem to be a string or a BLOB.
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@
|
||||
# The tests in this file use special facilities that are only
|
||||
# available in the SQLite test fixture.
|
||||
#
|
||||
# $Id: ioerr.test,v 1.3 2003/04/25 15:37:59 drh Exp $
|
||||
# $Id: ioerr.test,v 1.4 2004/06/15 11:40:10 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -57,8 +57,12 @@ for {set n 1} {$go} {incr n} {
|
||||
set ::sqlite_io_error_pending 0
|
||||
|
||||
proc cksum {{db db}} {
|
||||
set txt [$db eval {SELECT name, type, sql FROM sqlite_master}]\n
|
||||
foreach tbl [$db eval {SELECT name FROM sqlite_master WHERE type='table'}] {
|
||||
set txt [$db eval {
|
||||
SELECT name, type, sql FROM sqlite_master order by name
|
||||
}]\n
|
||||
foreach tbl [$db eval {
|
||||
SELECT name FROM sqlite_master WHERE type='table' order by name
|
||||
}] {
|
||||
append txt [$db eval "SELECT * FROM $tbl"]\n
|
||||
}
|
||||
foreach prag {default_synchronous default_cache_size} {
|
||||
@ -102,11 +106,16 @@ for {set n 1} {$go} {incr n} {
|
||||
set ::sqlite_io_error_pending $n
|
||||
}] $n
|
||||
do_test ioerr-2.$n.3 {
|
||||
if {$n==41} {
|
||||
# set sqlite_os_trace 1
|
||||
breakpoint
|
||||
}
|
||||
set r [catch {db eval {
|
||||
VACUUM;
|
||||
}} msg]
|
||||
# puts "error_pending=$::sqlite_io_error_pending"
|
||||
# if {$r} {puts $msg}
|
||||
set sqlite_os_trace 0
|
||||
set ::go [expr {$::sqlite_io_error_pending<=0}]
|
||||
expr {$::sqlite_io_error_pending>0 || $r!=0}
|
||||
set ::sqlite_io_error_pending 0
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is in-memory database backend.
|
||||
#
|
||||
# $Id: memdb.test,v 1.7 2004/06/09 19:03:55 drh Exp $
|
||||
# $Id: memdb.test,v 1.8 2004/06/15 11:40:10 danielk1977 Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -170,17 +170,6 @@ foreach {i conf cmd t0 t1 t2} {
|
||||
5 {} {INSERT OR FAIL} 1 {} 1
|
||||
6 {} {INSERT OR ABORT} 1 {} 1
|
||||
7 {} {INSERT OR ROLLBACK} 1 {} {}
|
||||
8 IGNORE INSERT 0 3 1
|
||||
9 IGNORE {INSERT OR IGNORE} 0 3 1
|
||||
10 IGNORE {INSERT OR REPLACE} 0 4 1
|
||||
11 IGNORE REPLACE 0 4 1
|
||||
12 IGNORE {INSERT OR FAIL} 1 {} 1
|
||||
13 IGNORE {INSERT OR ABORT} 1 {} 1
|
||||
14 IGNORE {INSERT OR ROLLBACK} 1 {} {}
|
||||
15 REPLACE INSERT 0 4 1
|
||||
16 FAIL INSERT 1 {} 1
|
||||
17 ABORT INSERT 1 {} 1
|
||||
18 ROLLBACK INSERT 1 {} {}
|
||||
} {
|
||||
do_test memdb-4.$i {
|
||||
if {$conf!=""} {set conf "ON CONFLICT $conf"}
|
||||
@ -241,16 +230,6 @@ foreach {i conf1 conf2 cmd t0 t1 t2} {
|
||||
14 {} {} {UPDATE OR FAIL} 1 {6 7 3 4} 1
|
||||
15 {} {} {UPDATE OR ABORT} 1 {1 2 3 4} 1
|
||||
16 {} {} {UPDATE OR ROLLBACK} 1 {1 2 3 4} 0
|
||||
17 {} IGNORE UPDATE 0 {6 7 3 9} 1
|
||||
18 {} REPLACE UPDATE 0 {7 6 9} 1
|
||||
19 {} FAIL UPDATE 1 {6 7 3 4} 1
|
||||
20 {} ABORT UPDATE 1 {1 2 3 4} 1
|
||||
21 {} ROLLBACK UPDATE 1 {1 2 3 4} 0
|
||||
22 REPLACE IGNORE UPDATE 0 {6 7 3 9} 1
|
||||
23 IGNORE REPLACE UPDATE 0 {7 6 9} 1
|
||||
24 REPLACE FAIL UPDATE 1 {6 7 3 4} 1
|
||||
25 IGNORE ABORT UPDATE 1 {1 2 3 4} 1
|
||||
26 REPLACE ROLLBACK UPDATE 1 {1 2 3 4} 0
|
||||
} {
|
||||
if {$t0} {set t1 {column a is not unique}}
|
||||
do_test memdb-5.$i {
|
||||
|
@ -10,7 +10,7 @@
|
||||
#***********************************************************************
|
||||
# This file runs all tests.
|
||||
#
|
||||
# $Id: quick.test,v 1.22 2004/06/15 02:44:20 danielk1977 Exp $
|
||||
# $Id: quick.test,v 1.23 2004/06/15 11:40:10 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -28,10 +28,6 @@ set EXCLUDE {
|
||||
format3.test
|
||||
}
|
||||
|
||||
lappend EXCLUDE ioerr.test ;# seg-faults (?)
|
||||
lappend EXCLUDE memdb.test ;# fails - malformed database
|
||||
lappend EXCLUDE version.test ;# This is obsolete.
|
||||
|
||||
if {[sqlite -has-codec]} {
|
||||
lappend EXCLUDE \
|
||||
attach.test \
|
||||
|
@ -1,198 +0,0 @@
|
||||
# 2002 July 17
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the ability of the library to detect
|
||||
# past or future file format version numbers and respond appropriately.
|
||||
#
|
||||
# $Id: version.test,v 1.10 2004/05/13 11:34:17 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
# Current file format version
|
||||
set VX 4
|
||||
|
||||
# Create a new database
|
||||
#
|
||||
do_test version-1.1 {
|
||||
execsql {
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(1);
|
||||
INSERT INTO t1 SELECT x+1 FROM t1;
|
||||
INSERT INTO t1 SELECT x+2 FROM t1;
|
||||
INSERT INTO t1 SELECT x+4 FROM t1;
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {1 2 3 4 5 6 7 8}
|
||||
|
||||
# Make sure the version number is set correctly
|
||||
#
|
||||
do_test version-1.2 {
|
||||
db close
|
||||
set ::bt [btree_open test.db 100 0]
|
||||
btree_begin_transaction $::bt
|
||||
set ::meta [btree_get_meta $::bt]
|
||||
btree_rollback $::bt
|
||||
lindex $::meta 2
|
||||
} $VX
|
||||
|
||||
# Increase the file_format number by one. Verify that the
|
||||
# file will refuse to open.
|
||||
#
|
||||
do_test version-1.3 {
|
||||
set m2 [lreplace $::meta 2 2 [expr {$::VX+1}]]
|
||||
btree_begin_transaction $::bt
|
||||
eval btree_update_meta $::bt $m2
|
||||
btree_commit $::bt
|
||||
set rc [catch {sqlite db test.db} msg]
|
||||
lappend rc $msg
|
||||
} {1 {unsupported file format}}
|
||||
|
||||
# Decrease the file_format number by one. Verify that the
|
||||
# file will open correctly.
|
||||
#
|
||||
do_test version-1.4 {
|
||||
set m2 [lreplace $::meta 2 2 [expr {$::VX-1}]]
|
||||
btree_begin_transaction $::bt
|
||||
eval btree_update_meta $::bt $m2
|
||||
btree_commit $::bt
|
||||
sqlite db test.db
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {1 2 3 4 5 6 7 8}
|
||||
|
||||
# Set the file_format number to 2. This should cause the automatic
|
||||
# upgrade processing to run.
|
||||
#
|
||||
do_test version-1.5 {
|
||||
set m2 [lreplace $::meta 2 2 2]
|
||||
btree_begin_transaction $::bt
|
||||
eval btree_update_meta $::bt $m2
|
||||
btree_commit $::bt
|
||||
sqlite db test.db
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {1 2 3 4 5 6 7 8}
|
||||
do_test version-1.6 {
|
||||
set ::meta [btree_get_meta $::bt]
|
||||
lindex $::meta 2
|
||||
} $VX
|
||||
|
||||
# Add some triggers, views, and indices to the schema and make sure the
|
||||
# automatic upgrade still works.
|
||||
#
|
||||
do_test version-1.7 {
|
||||
execsql {
|
||||
CREATE INDEX i1 ON t1(x);
|
||||
DELETE FROM t1;
|
||||
CREATE TABLE t2(a INTEGER PRIMARY KEY, b UNIQUE, c);
|
||||
CREATE TABLE cnt(name,ins, del);
|
||||
INSERT INTO cnt VALUES('t1',0,0);
|
||||
INSERT INTO cnt VALUES('t2',0,0);
|
||||
CREATE TRIGGER r1 AFTER INSERT ON t1 FOR EACH ROW BEGIN
|
||||
UPDATE cnt SET ins=ins+1 WHERE name='t1';
|
||||
END;
|
||||
CREATE TRIGGER r2 AFTER DELETE ON t1 FOR EACH ROW BEGIN
|
||||
UPDATE cnt SET del=del+1 WHERE name='t1';
|
||||
END;
|
||||
CREATE TRIGGER r3 AFTER INSERT ON t2 FOR EACH ROW BEGIN
|
||||
UPDATE cnt SET ins=ins+1 WHERE name='t2';
|
||||
END;
|
||||
CREATE TRIGGER r4 AFTER DELETE ON t2 FOR EACH ROW BEGIN
|
||||
UPDATE cnt SET del=del+1 WHERE name='t2';
|
||||
END;
|
||||
CREATE VIEW v1 AS SELECT x+100 FROM t1;
|
||||
CREATE VIEW v2 AS SELECT sum(ins), sum(del) FROM cnt;
|
||||
INSERT INTO t1 VALUES(1);
|
||||
INSERT INTO t1 SELECT x+1 FROM t1;
|
||||
INSERT INTO t1 SELECT x+2 FROM t1;
|
||||
INSERT INTO t1 SELECT x+4 FROM t1;
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
} {1 2 3 4 5 6 7 8}
|
||||
do_test version-1.8 {
|
||||
execsql {
|
||||
SELECT * FROM v2;
|
||||
}
|
||||
} {8 0}
|
||||
do_test version-1.9 {
|
||||
execsql {
|
||||
SELECT * FROM cnt;
|
||||
}
|
||||
} {t1 8 0 t2 0 0}
|
||||
do_test version-1.10 {
|
||||
execsql {
|
||||
INSERT INTO t2 SELECT x*3, x*2, x FROM t1;
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} {3 2 1 6 4 2 9 6 3 12 8 4 15 10 5 18 12 6 21 14 7 24 16 8}
|
||||
do_test version-1.11 {
|
||||
execsql {
|
||||
SELECT * FROM cnt;
|
||||
}
|
||||
} {t1 8 0 t2 8 0}
|
||||
|
||||
# Here we do the upgrade test.
|
||||
#
|
||||
do_test version-1.12 {
|
||||
db close
|
||||
set m2 [lreplace $::meta 2 2 2]
|
||||
btree_begin_transaction $::bt
|
||||
eval btree_update_meta $::bt $m2
|
||||
btree_commit $::bt
|
||||
sqlite db test.db
|
||||
execsql {
|
||||
SELECT * FROM cnt;
|
||||
}
|
||||
} {t1 8 0 t2 8 0}
|
||||
do_test version-1.13 {
|
||||
execsql {
|
||||
SELECT * FROM v1;
|
||||
}
|
||||
} {101 102 103 104 105 106 107 108}
|
||||
do_test version-1.14 {
|
||||
execsql {
|
||||
SELECT * FROM v2;
|
||||
}
|
||||
} {16 0}
|
||||
|
||||
# Try to do an upgrade where the database file is read-only
|
||||
#
|
||||
do_test version-2.1 {
|
||||
db close
|
||||
set m2 [lreplace $::meta 2 2 2]
|
||||
btree_begin_transaction $::bt
|
||||
eval btree_update_meta $::bt $m2
|
||||
btree_commit $::bt
|
||||
btree_close $::bt
|
||||
catch {file attributes test.db -permissions 0444}
|
||||
catch {file attributes test.db -readonly 1}
|
||||
if {[file writable test.db]} {
|
||||
error "Unable to make the database file test.db readonly - rerun this test as an unprivileged user"
|
||||
}
|
||||
set rc [catch {sqlite db test.db} msg]
|
||||
lappend rc $msg
|
||||
} {1 {unable to upgrade database to the version 2.6 format: attempt to write a readonly database}}
|
||||
do_test version-2.2 {
|
||||
file delete -force test.db
|
||||
set fd [open test.db w]
|
||||
set txt "This is not a valid database file\n"
|
||||
while {[string length $txt]<4092} {append txt $txt}
|
||||
puts $fd $txt
|
||||
close $fd
|
||||
set rc [catch {sqlite db test.db} msg]
|
||||
lappend rc $msg
|
||||
} {1 {file is encrypted or is not a database}}
|
||||
|
||||
|
||||
finish_test
|
Loading…
Reference in New Issue
Block a user