-C sqlite3_column_int()\sand\ssimilar\sroutines\sreturn\s0\sor\s0.0\son\san\nout-of-memory\scondition,\snot\ssome\smysterious\serror\scode.\s(CVS\s2759)
-D 2005-11-03T14:29:55
+C VACUUM\sworks\seven\son\san\sempty\sdatabase.\s\sTicket\s#1512.\s(CVS\s2760)
+D 2005-11-04T22:03:30
F Makefile.in 12784cdce5ffc8dfb707300c34e4f1eb3b8a14f1
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/main.c 97bb830cdbd378d1f87469618471f52d9d263d09
F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070
F src/os.h c51f2747f7bd1840447e2c7d26db749604626814
-F src/os_common.h 1ff88c7e7e6bd3e5f85443106c91cc26a4f8600b
+F src/os_common.h d74a11728ad2444b6b695b94c28c06881f049e49
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
F src/os_unix.c 2af2d2cea9cc6282c02b48aacf2995193440cf00
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c fbccc85e7011174068c27d54256746321a1f0059
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c adbb27f13ac75cd5bc29a3d84803e0cab1edfa88
+F src/pager.c 0d8dda8bba9efbda30626cdc3c6573fe10adafdc
F src/pager.h e7b41ce8e7b5f629d456708b7ad9a8c8ede37140
F src/parse.y 1d5afb972ed5ef3ec8712a2b5953b48f086091da
F src/pragma.c b40189967155a522433b8470f363192a927ba22c
F src/table.c e03b60eaabaeb54a00d7e931566d77302dfc19b0
F src/tclsqlite.c 4f274fae3d4a1863451a553dd8e5015747a5d91d
F src/test1.c 77506b6b88125c26f00a11bf3ff5c8dc824e837e
-F src/test2.c 4196848c845626e7df894470f27329e80bfe92aa
+F src/test2.c d55861d8ba5a8b434544da366ba6efe206e1ec97
F src/test3.c f4e6a16a602091696619a1171bda25c0e3df49f7
F src/test4.c a8fd681e139e1c61f22a77d07fc3a99cb28fff3f
F src/test5.c 64f08b2a50ef371a1bd68ff206829e7b1b9997f5
F src/update.c ac506fb7400158f826ec6c3a0dbe65e7ed3928d5
F src/utf.c bda5eb85039ef16f2d17004c1e18c96e1ab0a80c
F src/util.c 48fecbbef4391d102a23096d32f0d74173428406
-F src/vacuum.c 2ed18a4e9c894de7239bc1c68fe455fcb39571c6
+F src/vacuum.c baae8681282c7a03900043043dc7ce07d43b5a1e
F src/vdbe.c e83de8a017fe5c495fcef3093dbdca30fa6b1ea4
F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
F src/vdbeInt.h 6eba0b967dc4fc4d5dea6e3bcc66e70a44981cc9
F test/tableapi.test 6a66d58b37d46dc0f2b3c7d4bd2617d209399bd1
F test/tclsqlite.test 2da3e4b3a79b13c1511c9d0cd995e08f8362e782
F test/temptable.test 7927261befdbc7b0a7ffebb85ecc70a74fa7b15b
-F test/tester.tcl 1e75553d320f5d2720613d8483c934488fc2c56f
+F test/tester.tcl bf4e288cd8b968e4514c0bdee27f4f31b21b7271
F test/thread1.test 776c9e459b75ba905193b351926ac4019b049f35
F test/threadtest1.c 6029d9c5567db28e6dc908a0c63099c3ba6c383b
F test/threadtest2.c 97a830d53c24c42290501fdfba4a6e5bdd34748b
F test/tkt1444.test 0f0fc1f277691f904dea2abece6db919dcae2351
F test/tkt1449.test f8de8a84ec12ee805ed80055e1209560f8bee4d8
F test/tkt1473.test e4637c27d606fd002de78113a8e1a142e48ffb18
+F test/tkt1512.test 8efd8d07e27e99d7462f75b5711de65eb7708baf
F test/trace.test 9fd28695c463b90c2d32c387a432e01eb26e8ccf
F test/trans.test 10506dc30305cfb8c4098359f7f6f64786f69c5e
F test/trigger1.test 152aed5a1fa90709fe171f2ca501a6b7f7901479
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e x
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
F tool/report1.txt 9eae07f26a8fc53889b45fc833a66a33daa22816
-F tool/showdb.c 3559eac5a3b46e9b558d50856946b25e77633236
+F tool/showdb.c a086a3d788c7a23cb008317c3180ceb19f20bce0
F tool/showjournal.c ec3b171be148656827c4949fbfb8ab4370822f87
F tool/space_used.tcl f714c41a59e326b8b9042f415b628b561bafa06b
F tool/spaceanal.tcl 5b47b70b9a0d216ec63a5b5547b3642dd308e53a
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P bb94ef64b227839a0ef4156985e2f5a061a78e2c
-R d764f727b04686e2af798ae9ccbcdf15
+P 7780f5e9d504926f11bd0662c03c88c76fb1d416
+R 1a3d1b527330224886b9cff041619a5d
U drh
-Z 6e4bc42bd67b219bb703d08d5d61a498
+Z f1e5a520d02502b659fb8d9e06e8fb3d
-7780f5e9d504926f11bd0662c03c88c76fb1d416
\ No newline at end of file
+1b6bf4188e8ebf55cf1972b7081f6d31bf525555
\ No newline at end of file
** is used for testing the I/O recovery logic.
*/
#ifdef SQLITE_TEST
+int sqlite3_io_error_hit = 0;
int sqlite3_io_error_pending = 0;
int sqlite3_diskfull_pending = 0;
int sqlite3_diskfull = 0;
if( sqlite3_io_error_pending ) \
if( sqlite3_io_error_pending-- == 1 ){ local_ioerr(); return A; }
static void local_ioerr(){
- sqlite3_io_error_pending = 0; /* Really just a place to set a breakpoint */
+ sqlite3_io_error_hit = 1; /* Really just a place to set a breakpoint */
}
#define SimulateDiskfullError \
if( sqlite3_diskfull_pending ){ \
** file simultaneously, or one process from reading the database while
** another is writing.
**
-** @(#) $Id: pager.c,v 1.215 2005/09/17 15:20:27 drh Exp $
+** @(#) $Id: pager.c,v 1.216 2005/11/04 22:03:30 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
return pPager->pageSize;
}
+/*
+** The following set of routines are used to disable the simulated
+** I/O error mechanism. These routines are used to avoid simulated
+** errors in places where we do not care about errors.
+**
+** Unless -DSQLITE_TEST=1 is used, these routines are all no-ops
+** and generate no code.
+*/
+#ifdef SQLITE_TEST
+extern int sqlite3_io_error_pending;
+extern int sqlite3_io_error_hit;
+static int saved_cnt;
+void clear_simulated_io_error(){
+ sqlite3_io_error_hit = 0;
+}
+void disable_simulated_io_errors(void){
+ saved_cnt = sqlite3_io_error_pending;
+ sqlite3_io_error_pending = -1;
+}
+void enable_simulated_io_errors(void){
+ sqlite3_io_error_pending = saved_cnt;
+}
+#else
+# define clear_simulated_io_error(X)
+# define disable_simulated_io_errors(X)
+# define enable_simulated_io_errors(X)
+#endif
+
/*
** Read the first N bytes from the beginning of the file into memory
** that pDest points to. No error checking is done.
if( MEMDB==0 ){
sqlite3OsSeek(&pPager->fd, 0);
sqlite3OsRead(&pPager->fd, pDest, N);
+ clear_simulated_io_error();
}
}
** operation. So disable IO error simulation so that testing
** works more easily.
*/
-#if defined(SQLITE_TEST) && (defined(OS_UNIX) || defined(OS_WIN))
- extern int sqlite3_io_error_pending;
- int ioerr_cnt = sqlite3_io_error_pending;
- sqlite3_io_error_pending = -1;
-#endif
+ disable_simulated_io_errors();
sqlite3pager_rollback(pPager);
-#if defined(SQLITE_TEST) && (defined(OS_UNIX) || defined(OS_WIN))
- sqlite3_io_error_pending = ioerr_cnt;
-#endif
+ enable_simulated_io_errors();
if( !MEMDB ){
sqlite3OsUnlock(&pPager->fd, NO_LOCK);
}
sqlite3pager_unref(PGHDR_TO_DATA(pPg));
return rc;
}else{
+ clear_simulated_io_error();
memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize);
}
}else{
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
-** $Id: test2.c,v 1.34 2005/09/16 10:13:42 danielk1977 Exp $
+** $Id: test2.c,v 1.35 2005/11/04 22:03:30 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
*/
int Sqlitetest2_Init(Tcl_Interp *interp){
extern int sqlite3_io_error_pending;
+ extern int sqlite3_io_error_hit;
extern int sqlite3_diskfull_pending;
extern int sqlite3_diskfull;
static struct {
}
Tcl_LinkVar(interp, "sqlite_io_error_pending",
(char*)&sqlite3_io_error_pending, TCL_LINK_INT);
+ Tcl_LinkVar(interp, "sqlite_io_error_hit",
+ (char*)&sqlite3_io_error_hit, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_diskfull_pending",
(char*)&sqlite3_diskfull_pending, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_diskfull",
** Most of the code in this file may be omitted by defining the
** SQLITE_OMIT_VACUUM macro.
**
-** $Id: vacuum.c,v 1.46 2005/11/03 02:15:04 drh Exp $
+** $Id: vacuum.c,v 1.47 2005/11/04 22:03:30 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
Btree *pMain; /* The database being vacuumed */
Btree *pTemp;
char *zSql = 0;
+ int rc2;
int saved_flags; /* Saved value of the db->flags */
/* Save the current value of the write-schema flag before setting it. */
#endif
/* Begin a transaction */
- rc = execSql(db, "BEGIN;");
+ rc = execSql(db, "BEGIN EXCLUSIVE;");
if( rc!=SQLITE_OK ) goto end_of_vacuum;
/* Query the schema of the main database. Create a mirror schema
** opened for writing. This way, the SQL transaction used to create the
** temporary database never needs to be committed.
*/
- if( sqlite3BtreeIsInTrans(pTemp) ){
+ if( rc==SQLITE_OK ){
u32 meta;
int i;
6, 0, /* Preserve the user version */
};
- assert( 0==sqlite3BtreeIsInTrans(pMain) );
- rc = sqlite3BtreeBeginTrans(pMain, 1);
- if( rc!=SQLITE_OK ) goto end_of_vacuum;
+ assert( 1==sqlite3BtreeIsInTrans(pTemp) );
+ assert( 1==sqlite3BtreeIsInTrans(pMain) );
/* Copy Btree meta values */
for(i=0; i<sizeof(aCopy)/sizeof(aCopy[0]); i+=2){
rc = sqlite3BtreeGetMeta(pMain, aCopy[i], &meta);
if( rc!=SQLITE_OK ) goto end_of_vacuum;
rc = sqlite3BtreeUpdateMeta(pTemp, aCopy[i], meta+aCopy[i+1]);
+ if( rc!=SQLITE_OK ) goto end_of_vacuum;
}
rc = sqlite3BtreeCopyFile(pMain, pTemp);
if( rc!=SQLITE_OK ) goto end_of_vacuum;
+ rc = sqlite3BtreeCommit(pTemp);
+ if( rc!=SQLITE_OK ) goto end_of_vacuum;
rc = sqlite3BtreeCommit(pMain);
}
** is closed by the DETACH.
*/
db->autoCommit = 1;
+ rc2 = execSql(db, "DETACH vacuum_db;");
if( rc==SQLITE_OK ){
- rc = execSql(db, "DETACH vacuum_db;");
- }else{
- execSql(db, "DETACH vacuum_db;");
+ rc = rc2;
}
if( zTemp ){
sqlite3OsDelete(zTemp);
sqliteFree(zTemp);
}
- if( zSql ) sqliteFree( zSql );
+ sqliteFree( zSql );
sqlite3ResetInternalSchema(db, 0);
#endif
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
-# $Id: tester.tcl,v 1.50 2005/09/17 15:20:28 drh Exp $
+# $Id: tester.tcl,v 1.51 2005/11/04 22:03:30 drh Exp $
# Make sure tclsqlite3 was compiled correctly. Abort now with an
# error message if not.
do_test $testname.$n.3 {
set r [catch $::ioerrorbody msg]
set ::go [expr {$::sqlite_io_error_pending<=0}]
- set s [expr $::sqlite_io_error_pending>0]
+ set s [expr $::sqlite_io_error_hit==0]
# puts "$::sqlite_io_error_pending $r $msg"
expr { ($s && !$r) || (!$s && $r) }
# expr {$::sqlite_io_error_pending>0 || $r!=0}
--- /dev/null
+# 2005 September 19
+#
+# 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.
+#
+# This file implements tests to verify that ticket #1512 is
+# fixed.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+do_test tkt1512-1.1 {
+ execsql {
+ CREATE TABLE t1(a,b);
+ INSERT INTO t1 VALUES(1,2);
+ INSERT INTO t1 VALUES(3,4);
+ SELECT * FROM t1
+ }
+} {1 2 3 4}
+do_test tkt1512-1.2 {
+ file size test.db
+} {2048}
+do_test tkt1512-1.3 {
+ execsql {
+ DROP TABLE t1;
+ }
+ file size test.db
+} {2048}
+do_test tkt1512-1.4 {
+ execsql {
+ VACUUM;
+ }
+ file size test.db
+} {1024}
+
+
+finish_test
static int pagesize = 1024;
static int db = -1;
static int mxPage = 0;
+static int perLine = 32;
static void out_of_memory(void){
fprintf(stderr,"Out of memory...\n");
lseek(db, (iPg-1)*pagesize, SEEK_SET);
read(db, aData, pagesize);
fprintf(stdout, "Page %d:\n", iPg);
- for(i=0; i<pagesize; i += 16){
+ for(i=0; i<pagesize; i += perLine){
fprintf(stdout, " %03x: ",i);
- for(j=0; j<16; j++){
+ for(j=0; j<perLine; j++){
fprintf(stdout,"%02x ", aData[i+j]);
}
- for(j=0; j<16; j++){
+ for(j=0; j<perLine; j++){
fprintf(stdout,"%c", isprint(aData[i+j]) ? aData[i+j] : '.');
}
fprintf(stdout,"\n");