mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Coverage tests for vacuum.c (CVS 1776)
FossilOrigin-Name: 152e9940b919a53fcd0da4091dbf75ab8ef15b38
This commit is contained in:
28
manifest
28
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Fixes\sfor\scompiler\swarnings.\sAlso\smore\scoverage.\s(CVS\s1775)
|
C Coverage\stests\sfor\svacuum.c\s(CVS\s1776)
|
||||||
D 2004-06-30T08:20:16
|
D 2004-06-30T09:49:23
|
||||||
F Makefile.in cb7a9889c38723f72b2506c4236ff30a05ff172b
|
F Makefile.in cb7a9889c38723f72b2506c4236ff30a05ff172b
|
||||||
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
||||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||||
@@ -24,7 +24,7 @@ F spec.template a38492f1c1dd349fc24cb0565e08afc53045304b
|
|||||||
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
|
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
|
||||||
F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
|
F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
|
||||||
F sqlite3.def 26f4e7b0a3fbaa55701e020fdec429f1594e2866
|
F sqlite3.def 26f4e7b0a3fbaa55701e020fdec429f1594e2866
|
||||||
F src/attach.c 678ded370e4b4d5bf03e9566404a42a8dcf5eef9
|
F src/attach.c 132498271187144919de139673ad648b8e82c77e
|
||||||
F src/auth.c 60db23b98bb94c8b0178180faaf49dc116674217
|
F src/auth.c 60db23b98bb94c8b0178180faaf49dc116674217
|
||||||
F src/btree.c 3ed3c19e43bb243f502ee614f6ad0a52e53362a7
|
F src/btree.c 3ed3c19e43bb243f502ee614f6ad0a52e53362a7
|
||||||
F src/btree.h 934d0ad30b5b419e9291a11da878be349df2277e
|
F src/btree.h 934d0ad30b5b419e9291a11da878be349df2277e
|
||||||
@@ -38,7 +38,7 @@ F src/hash.c 148e3512f1b4e90f8477f852c70b36a137b116a7
|
|||||||
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
|
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
|
||||||
F src/insert.c d99ffe87e1e1397f4233afcd06841d52d6b17b18
|
F src/insert.c d99ffe87e1e1397f4233afcd06841d52d6b17b18
|
||||||
F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
|
F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
|
||||||
F src/main.c 95a915b2fe9bd879aa47f80472654f11e033b7a6
|
F src/main.c adb17bee0606a685d8872bdac9f23464e2c6a748
|
||||||
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
|
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
|
||||||
F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345
|
F src/os.h d1780e0db95cad01f213d48da22ab490eb4fd345
|
||||||
F src/os_common.h fe9604754116bd2f2702d58f82d2d8b89998cb21
|
F src/os_common.h fe9604754116bd2f2702d58f82d2d8b89998cb21
|
||||||
@@ -50,10 +50,10 @@ F src/os_unix.c 7df6ae05faa5b84164193d3694cb71b66661bbf3
|
|||||||
F src/os_unix.h 00c1f82b526ab2fb7ee5ddd555ea4ed68363c93a
|
F src/os_unix.h 00c1f82b526ab2fb7ee5ddd555ea4ed68363c93a
|
||||||
F src/os_win.c 84549f6cc815237533c5d0eb3697352b03478d96
|
F src/os_win.c 84549f6cc815237533c5d0eb3697352b03478d96
|
||||||
F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44
|
F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44
|
||||||
F src/pager.c c1d5212e7cac86bc1a29d01a30d9dbbdb545dfd8
|
F src/pager.c 7f30e724959a04011dd077a923ea16b53561ee6c
|
||||||
F src/pager.h 269b6cfc114dba0148203446e41dd19f9647dd53
|
F src/pager.h 269b6cfc114dba0148203446e41dd19f9647dd53
|
||||||
F src/parse.y e19e066e726a31d7b2d3e6475bdf55f7e339f8a3
|
F src/parse.y 51c8e696276c409618e66a4ccf316fcff245506e
|
||||||
F src/pragma.c 0ecbe7ccf78ad893f5011516845c9e2f74faa21a
|
F src/pragma.c 8326df8c400f573eb43004dfb8e53e5102acb3e4
|
||||||
F src/printf.c 3090c8ff397d549bc0de09b16d8ab7fd37a0c3f7
|
F src/printf.c 3090c8ff397d549bc0de09b16d8ab7fd37a0c3f7
|
||||||
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
|
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
|
||||||
F src/select.c f02a65af34231031896e8442161cb5251e191e75
|
F src/select.c f02a65af34231031896e8442161cb5251e191e75
|
||||||
@@ -72,8 +72,8 @@ F src/trigger.c 6aaf6d79cc2157c70a06031dd1531707d644cfb4
|
|||||||
F src/update.c b66b1896c9da54678ba3eff2bf0b4d291a95986a
|
F src/update.c b66b1896c9da54678ba3eff2bf0b4d291a95986a
|
||||||
F src/utf.c f03535db72bfa09e24202ccdd245f21d2fc65f0a
|
F src/utf.c f03535db72bfa09e24202ccdd245f21d2fc65f0a
|
||||||
F src/util.c b267d0fe10cffa3301fe9fab6592a6808a38bce6
|
F src/util.c b267d0fe10cffa3301fe9fab6592a6808a38bce6
|
||||||
F src/vacuum.c 4aede0a7048d8b71a43f45cc15359e16eddc8a2e
|
F src/vacuum.c b8546f4921719458cc537b9e736df52a8256399c
|
||||||
F src/vdbe.c 6950e25d93346b03404d2fc383883ff9fa2e5966
|
F src/vdbe.c 4629151c9995b8b6a895c42de8808df1969bdcc7
|
||||||
F src/vdbe.h 75b241c02431b9c0f16eaa9cdbb34146c6287f52
|
F src/vdbe.h 75b241c02431b9c0f16eaa9cdbb34146c6287f52
|
||||||
F src/vdbeInt.h d83fd7389838453d8392915c21f432014afc99cf
|
F src/vdbeInt.h d83fd7389838453d8392915c21f432014afc99cf
|
||||||
F src/vdbeapi.c ba3722f45db3d3c3509bf5d24f4f868f4c64449d
|
F src/vdbeapi.c ba3722f45db3d3c3509bf5d24f4f868f4c64449d
|
||||||
@@ -130,7 +130,7 @@ F test/limit.test 60d7f856ee7846f7130dee67f10f0e726cd70b5d
|
|||||||
F test/lock.test 1dbf1d06b0a7eb36237b4f107cfb3da9726b449e
|
F test/lock.test 1dbf1d06b0a7eb36237b4f107cfb3da9726b449e
|
||||||
F test/lock2.test 4108cabaa108a142e5eed83de3b13b6e579c12cf
|
F test/lock2.test 4108cabaa108a142e5eed83de3b13b6e579c12cf
|
||||||
F test/main.test e8c4d9ca6d1e5f5e55e6550d31aec488883b2ed9
|
F test/main.test e8c4d9ca6d1e5f5e55e6550d31aec488883b2ed9
|
||||||
F test/malloc.test a78617ce8258388e4835f4834a3a2c0d4282a7ec
|
F test/malloc.test 769b240d89a7ef3320d88919fdb6765f9395a51f
|
||||||
F test/memdb.test b8a13fa79f006bd087bbcf135ce8eb62056a6027
|
F test/memdb.test b8a13fa79f006bd087bbcf135ce8eb62056a6027
|
||||||
F test/memleak.test 26571a04575461f39a7cf97a2ee2f7fb2f519ddb
|
F test/memleak.test 26571a04575461f39a7cf97a2ee2f7fb2f519ddb
|
||||||
F test/minmax.test 3f87d1d49f7e9aa9ae80d35c47a1f5b034557899
|
F test/minmax.test 3f87d1d49f7e9aa9ae80d35c47a1f5b034557899
|
||||||
@@ -175,7 +175,7 @@ F test/types2.test 5d725fcb68dbd032c6d4950d568d75fa33872687
|
|||||||
F test/unique.test 0e38d4cc7affeef2527720d1dafd1f6870f02f2b
|
F test/unique.test 0e38d4cc7affeef2527720d1dafd1f6870f02f2b
|
||||||
F test/update.test b29bd9061a1150426dab6959806fcc73a41b1217
|
F test/update.test b29bd9061a1150426dab6959806fcc73a41b1217
|
||||||
F test/utf16.test 459c2f5ab80c60092c603630a348c32d6e59c558
|
F test/utf16.test 459c2f5ab80c60092c603630a348c32d6e59c558
|
||||||
F test/vacuum.test 3922b97f958986a9ab198c30480f54361087a06f
|
F test/vacuum.test 0416ace6131f3003d1e823f04ac0bb5b53315431
|
||||||
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
|
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
|
||||||
F test/view.test b42c98499ae9fbf578cd7a4b020d23057c8825fb
|
F test/view.test b42c98499ae9fbf578cd7a4b020d23057c8825fb
|
||||||
F test/where.test 9c5752b807b78078fab8da6f52e689832579ca20
|
F test/where.test 9c5752b807b78078fab8da6f52e689832579ca20
|
||||||
@@ -232,7 +232,7 @@ F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
|
|||||||
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
||||||
F www/version3.tcl 563ba3ac02f64da27ab17f3edbe8e56bfd0293fb
|
F www/version3.tcl 563ba3ac02f64da27ab17f3edbe8e56bfd0293fb
|
||||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||||
P d256c14943968e7adf4b73988cac6af941c9b12d
|
P fa19c77bf045787faa4cdc40bcfbd9eeae8594ae
|
||||||
R 4f61ce2de075aff0c8e8c9f0f47fa953
|
R 6e782cee555b8abc4fb19017e23b5110
|
||||||
U danielk1977
|
U danielk1977
|
||||||
Z eeffb6cff58a960d2f9806fbf7046f4d
|
Z 135637c42a81cf49b10a663d51dc227f
|
||||||
|
@@ -1 +1 @@
|
|||||||
fa19c77bf045787faa4cdc40bcfbd9eeae8594ae
|
152e9940b919a53fcd0da4091dbf75ab8ef15b38
|
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file contains code used to implement the ATTACH and DETACH commands.
|
** This file contains code used to implement the ATTACH and DETACH commands.
|
||||||
**
|
**
|
||||||
** $Id: attach.c,v 1.20 2004/06/29 08:59:35 danielk1977 Exp $
|
** $Id: attach.c,v 1.21 2004/06/30 09:49:23 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ void sqlite3Attach(Parse *pParse, Token *pFilename, Token *pDbname, Token *pKey)
|
|||||||
Vdbe *v;
|
Vdbe *v;
|
||||||
|
|
||||||
v = sqlite3GetVdbe(pParse);
|
v = sqlite3GetVdbe(pParse);
|
||||||
|
if( !v ) return;
|
||||||
sqlite3VdbeAddOp(v, OP_Halt, 0, 0);
|
sqlite3VdbeAddOp(v, OP_Halt, 0, 0);
|
||||||
if( pParse->explain ) return;
|
if( pParse->explain ) return;
|
||||||
db = pParse->db;
|
db = pParse->db;
|
||||||
@@ -140,6 +141,7 @@ void sqlite3Detach(Parse *pParse, Token *pDbname){
|
|||||||
Db *pDb = 0;
|
Db *pDb = 0;
|
||||||
|
|
||||||
v = sqlite3GetVdbe(pParse);
|
v = sqlite3GetVdbe(pParse);
|
||||||
|
if( !v ) return;
|
||||||
sqlite3VdbeAddOp(v, OP_Halt, 0, 0);
|
sqlite3VdbeAddOp(v, OP_Halt, 0, 0);
|
||||||
if( pParse->explain ) return;
|
if( pParse->explain ) return;
|
||||||
db = pParse->db;
|
db = pParse->db;
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
** other files are for internal use by SQLite and should not be
|
** other files are for internal use by SQLite and should not be
|
||||||
** accessed by users of the library.
|
** accessed by users of the library.
|
||||||
**
|
**
|
||||||
** $Id: main.c,v 1.242 2004/06/29 13:18:24 danielk1977 Exp $
|
** $Id: main.c,v 1.243 2004/06/30 09:49:24 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@@ -963,6 +963,10 @@ int sqlite3_prepare(
|
|||||||
char *zErrMsg = 0;
|
char *zErrMsg = 0;
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
|
|
||||||
|
if( sqlite3_malloc_failed ){
|
||||||
|
return SQLITE_NOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
assert( ppStmt );
|
assert( ppStmt );
|
||||||
*ppStmt = 0;
|
*ppStmt = 0;
|
||||||
if( sqlite3SafetyOn(db) ){
|
if( sqlite3SafetyOn(db) ){
|
||||||
|
@@ -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.147 2004/06/28 04:52:30 danielk1977 Exp $
|
** @(#) $Id: pager.c,v 1.148 2004/06/30 09:49:24 danielk1977 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"
|
||||||
@@ -2317,7 +2317,7 @@ static int pager_open_journal(Pager *pPager){
|
|||||||
pPager->aInJournal = 0;
|
pPager->aInJournal = 0;
|
||||||
sqlite3OsUnlock(&pPager->fd, SHARED_LOCK);
|
sqlite3OsUnlock(&pPager->fd, SHARED_LOCK);
|
||||||
pPager->state = PAGER_SHARED;
|
pPager->state = PAGER_SHARED;
|
||||||
return SQLITE_CANTOPEN;
|
return rc;
|
||||||
}
|
}
|
||||||
sqlite3OsOpenDirectory(pPager->zDirectory, &pPager->jfd);
|
sqlite3OsOpenDirectory(pPager->zDirectory, &pPager->jfd);
|
||||||
pPager->journalOpen = 1;
|
pPager->journalOpen = 1;
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
** the parser. Lemon will also generate a header file containing
|
** the parser. Lemon will also generate a header file containing
|
||||||
** numeric codes for all of the tokens.
|
** numeric codes for all of the tokens.
|
||||||
**
|
**
|
||||||
** @(#) $Id: parse.y,v 1.128 2004/06/26 06:37:07 danielk1977 Exp $
|
** @(#) $Id: parse.y,v 1.129 2004/06/30 09:49:24 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
%token_prefix TK_
|
%token_prefix TK_
|
||||||
%token_type {Token}
|
%token_type {Token}
|
||||||
@@ -442,7 +442,7 @@ sortlist(A) ::= sortlist(X) COMMA sortitem(Y) collate(C) sortorder(Z). {
|
|||||||
}
|
}
|
||||||
sortlist(A) ::= sortitem(Y) collate(C) sortorder(Z). {
|
sortlist(A) ::= sortitem(Y) collate(C) sortorder(Z). {
|
||||||
A = sqlite3ExprListAppend(0,Y,C.n>0?&C:0);
|
A = sqlite3ExprListAppend(0,Y,C.n>0?&C:0);
|
||||||
if( A ) A->a[0].sortOrder = Z;
|
if( A && A->a ) A->a[0].sortOrder = Z;
|
||||||
}
|
}
|
||||||
sortitem(A) ::= expr(X). {A = X;}
|
sortitem(A) ::= expr(X). {A = X;}
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file contains code used to implement the PRAGMA command.
|
** This file contains code used to implement the PRAGMA command.
|
||||||
**
|
**
|
||||||
** $Id: pragma.c,v 1.56 2004/06/29 08:59:35 danielk1977 Exp $
|
** $Id: pragma.c,v 1.57 2004/06/30 09:49:24 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -148,6 +148,7 @@ void sqlite3Pragma(
|
|||||||
if( iDb<0 ) return;
|
if( iDb<0 ) return;
|
||||||
|
|
||||||
zLeft = sqlite3NameFromToken(pId);
|
zLeft = sqlite3NameFromToken(pId);
|
||||||
|
if( !zLeft ) return;
|
||||||
if( minusFlag ){
|
if( minusFlag ){
|
||||||
zRight = 0;
|
zRight = 0;
|
||||||
sqlite3SetNString(&zRight, "-", 1, pValue->z, pValue->n, 0);
|
sqlite3SetNString(&zRight, "-", 1, pValue->z, pValue->n, 0);
|
||||||
|
26
src/vacuum.c
26
src/vacuum.c
@@ -14,7 +14,7 @@
|
|||||||
** Most of the code in this file may be omitted by defining the
|
** Most of the code in this file may be omitted by defining the
|
||||||
** SQLITE_OMIT_VACUUM macro.
|
** SQLITE_OMIT_VACUUM macro.
|
||||||
**
|
**
|
||||||
** $Id: vacuum.c,v 1.25 2004/06/30 06:30:26 danielk1977 Exp $
|
** $Id: vacuum.c,v 1.26 2004/06/30 09:49:24 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@@ -82,7 +82,9 @@ static int execExecSql(sqlite3 *db, const char *zSql){
|
|||||||
*/
|
*/
|
||||||
void sqlite3Vacuum(Parse *pParse, Token *pTableName){
|
void sqlite3Vacuum(Parse *pParse, Token *pTableName){
|
||||||
Vdbe *v = sqlite3GetVdbe(pParse);
|
Vdbe *v = sqlite3GetVdbe(pParse);
|
||||||
|
if( v ){
|
||||||
sqlite3VdbeAddOp(v, OP_Vacuum, 0, 0);
|
sqlite3VdbeAddOp(v, OP_Vacuum, 0, 0);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,9 +112,13 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
|
|||||||
** temporary filename in the same directory as the original file.
|
** temporary filename in the same directory as the original file.
|
||||||
*/
|
*/
|
||||||
zFilename = sqlite3BtreeGetFilename(db->aDb[0].pBt);
|
zFilename = sqlite3BtreeGetFilename(db->aDb[0].pBt);
|
||||||
if( zFilename==0 ){
|
assert( zFilename );
|
||||||
/* The in-memory database. Do nothing. */
|
if( zFilename[0]=='\0' ){
|
||||||
goto end_of_vacuum;
|
/* The in-memory database. Do nothing. Return directly to avoid causing
|
||||||
|
** an error trying to DETACH the vacuum_db (which never got attached)
|
||||||
|
** in the exit-handler.
|
||||||
|
*/
|
||||||
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
nFilename = strlen(zFilename);
|
nFilename = strlen(zFilename);
|
||||||
zTemp = sqliteMalloc( nFilename+100 );
|
zTemp = sqliteMalloc( nFilename+100 );
|
||||||
@@ -121,11 +127,11 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
|
|||||||
goto end_of_vacuum;
|
goto end_of_vacuum;
|
||||||
}
|
}
|
||||||
strcpy(zTemp, zFilename);
|
strcpy(zTemp, zFilename);
|
||||||
for(i=0; i<10; i++){
|
i = 0;
|
||||||
|
do {
|
||||||
zTemp[nFilename] = '-';
|
zTemp[nFilename] = '-';
|
||||||
randomName((unsigned char*)&zTemp[nFilename+1]);
|
randomName((unsigned char*)&zTemp[nFilename+1]);
|
||||||
if( !sqlite3OsFileExists(zTemp) ) break;
|
} while( i<10 && sqlite3OsFileExists(zTemp) );
|
||||||
}
|
|
||||||
|
|
||||||
/* Attach the temporary database as 'vacuum_db'. The synchronous pragma
|
/* Attach the temporary database as 'vacuum_db'. The synchronous pragma
|
||||||
** can be set to 'off' for this file, as it is not recovered if a crash
|
** can be set to 'off' for this file, as it is not recovered if a crash
|
||||||
@@ -136,7 +142,6 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
|
|||||||
** An optimisation would be to use a non-journaled pager.
|
** An optimisation would be to use a non-journaled pager.
|
||||||
*/
|
*/
|
||||||
zSql = sqlite3MPrintf("ATTACH '%s' AS vacuum_db;", zTemp);
|
zSql = sqlite3MPrintf("ATTACH '%s' AS vacuum_db;", zTemp);
|
||||||
execSql(db, "PRAGMA vacuum_db.synchronous = off;");
|
|
||||||
if( !zSql ){
|
if( !zSql ){
|
||||||
rc = SQLITE_NOMEM;
|
rc = SQLITE_NOMEM;
|
||||||
goto end_of_vacuum;
|
goto end_of_vacuum;
|
||||||
@@ -145,6 +150,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite *db){
|
|||||||
sqliteFree(zSql);
|
sqliteFree(zSql);
|
||||||
zSql = 0;
|
zSql = 0;
|
||||||
if( rc!=SQLITE_OK ) goto end_of_vacuum;
|
if( rc!=SQLITE_OK ) goto end_of_vacuum;
|
||||||
|
execSql(db, "PRAGMA vacuum_db.synchronous = off;");
|
||||||
|
|
||||||
/* Begin a transaction */
|
/* Begin a transaction */
|
||||||
rc = execSql(db, "BEGIN;");
|
rc = execSql(db, "BEGIN;");
|
||||||
@@ -231,7 +237,11 @@ end_of_vacuum:
|
|||||||
** is closed by the DETACH.
|
** is closed by the DETACH.
|
||||||
*/
|
*/
|
||||||
db->autoCommit = 1;
|
db->autoCommit = 1;
|
||||||
|
if( rc==SQLITE_OK ){
|
||||||
|
rc = execSql(db, "DETACH vacuum_db;");
|
||||||
|
}else{
|
||||||
execSql(db, "DETACH vacuum_db;");
|
execSql(db, "DETACH vacuum_db;");
|
||||||
|
}
|
||||||
if( zTemp ){
|
if( zTemp ){
|
||||||
sqlite3OsDelete(zTemp);
|
sqlite3OsDelete(zTemp);
|
||||||
sqliteFree(zTemp);
|
sqliteFree(zTemp);
|
||||||
|
@@ -43,7 +43,7 @@
|
|||||||
** in this file for details. If in doubt, do not deviate from existing
|
** in this file for details. If in doubt, do not deviate from existing
|
||||||
** commenting and indentation practices when changing or adding code.
|
** commenting and indentation practices when changing or adding code.
|
||||||
**
|
**
|
||||||
** $Id: vdbe.c,v 1.397 2004/06/30 06:30:26 danielk1977 Exp $
|
** $Id: vdbe.c,v 1.398 2004/06/30 09:49:24 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@@ -1248,6 +1248,7 @@ case OP_Function: {
|
|||||||
if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
|
if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse;
|
||||||
(*ctx.pFunc->xFunc)(&ctx, n, apVal);
|
(*ctx.pFunc->xFunc)(&ctx, n, apVal);
|
||||||
if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
|
if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse;
|
||||||
|
if( sqlite3_malloc_failed ) goto no_mem;
|
||||||
popStack(&pTos, n);
|
popStack(&pTos, n);
|
||||||
|
|
||||||
/* If any auxilary data functions have been called by this user function,
|
/* If any auxilary data functions have been called by this user function,
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
# special feature is used to see what happens in the library if a malloc
|
# special feature is used to see what happens in the library if a malloc
|
||||||
# were to really fail due to an out-of-memory situation.
|
# were to really fail due to an out-of-memory situation.
|
||||||
#
|
#
|
||||||
# $Id: malloc.test,v 1.9 2004/06/26 13:51:34 danielk1977 Exp $
|
# $Id: malloc.test,v 1.10 2004/06/30 09:49:24 danielk1977 Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@@ -263,5 +263,52 @@ do_test malloc-5.X {
|
|||||||
set sqlite_open_file_count
|
set sqlite_open_file_count
|
||||||
} {0}
|
} {0}
|
||||||
|
|
||||||
|
for {set go 1; set i 1} {$go} {incr i} {
|
||||||
|
do_test malloc-6.$i {
|
||||||
|
sqlite_malloc_fail 0
|
||||||
|
catch {db close}
|
||||||
|
catch {file delete -force test.db}
|
||||||
|
catch {file delete -force test.db-journal}
|
||||||
|
sqlite3 db test.db
|
||||||
|
execsql {
|
||||||
|
BEGIN TRANSACTION;
|
||||||
|
CREATE TABLE t1(a);
|
||||||
|
INSERT INTO t1 VALUES(1);
|
||||||
|
INSERT INTO t1 SELECT a*2 FROM t1;
|
||||||
|
INSERT INTO t1 SELECT a*2 FROM t1;
|
||||||
|
INSERT INTO t1 SELECT a*2 FROM t1;
|
||||||
|
INSERT INTO t1 SELECT a*2 FROM t1;
|
||||||
|
INSERT INTO t1 SELECT a*2 FROM t1;
|
||||||
|
INSERT INTO t1 SELECT a*2 FROM t1;
|
||||||
|
INSERT INTO t1 SELECT a*2 FROM t1;
|
||||||
|
INSERT INTO t1 SELECT a*2 FROM t1;
|
||||||
|
INSERT INTO t1 SELECT a*2 FROM t1;
|
||||||
|
INSERT INTO t1 SELECT a*2 FROM t1;
|
||||||
|
DELETE FROM t1 where rowid%5 = 0;
|
||||||
|
COMMIT;
|
||||||
|
}
|
||||||
|
sqlite_malloc_fail $i
|
||||||
|
set v [catch {execsql {
|
||||||
|
VACUUM;
|
||||||
|
}} msg]
|
||||||
|
set leftover [lindex [sqlite_malloc_stat] 2]
|
||||||
|
if {$leftover>0} {
|
||||||
|
if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"}
|
||||||
|
set ::go 0
|
||||||
|
set v {1 1}
|
||||||
|
} else {
|
||||||
|
set v2 [expr {$msg=="" || $msg=="out of memory"}]
|
||||||
|
if {!$v2} {puts "\nError message returned: $msg"}
|
||||||
|
lappend v $v2
|
||||||
|
}
|
||||||
|
} {1 1}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ensure that no file descriptors were leaked.
|
||||||
|
do_test malloc-6.X {
|
||||||
|
catch {db close}
|
||||||
|
set sqlite_open_file_count
|
||||||
|
} {0}
|
||||||
|
|
||||||
sqlite_malloc_fail 0
|
sqlite_malloc_fail 0
|
||||||
finish_test
|
finish_test
|
||||||
|
@@ -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 file is testing the VACUUM statement.
|
# focus of this file is testing the VACUUM statement.
|
||||||
#
|
#
|
||||||
# $Id: vacuum.test,v 1.21 2004/06/19 00:16:32 drh Exp $
|
# $Id: vacuum.test,v 1.22 2004/06/30 09:49:24 danielk1977 Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@@ -200,4 +200,13 @@ do_test vacuum-6.4 {
|
|||||||
}
|
}
|
||||||
} {1}
|
} {1}
|
||||||
|
|
||||||
|
# Check what happens when an in-memory database is vacuumed.
|
||||||
|
do_test vacuum-7.0 {
|
||||||
|
sqlite3 db2 :memory:
|
||||||
|
execsql {
|
||||||
|
CREATE TABLE t1(t);
|
||||||
|
VACUUM;
|
||||||
|
} db2
|
||||||
|
} {}
|
||||||
|
|
||||||
# finish_test
|
# finish_test
|
||||||
|
Reference in New Issue
Block a user