Skip to content

Commit

Permalink
Open windows files in binary mode. (CVS 193)
Browse files Browse the repository at this point in the history
  • Loading branch information
D. Richard Hipp committed Mar 20, 2001
1 parent f3d69df commit ce218a8
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 48 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.25
1.0.26
147 changes: 110 additions & 37 deletions doc/report1.txt
Original file line number Diff line number Diff line change
@@ -1,48 +1,121 @@
The SQL database used for ACD contains 113 tables and indices implemented
The SQL database used for ACD contains 105 tables and indices implemented
in GDBM. The following are statistics on the sizes of keys and data
within these tables and indices.

Entries: 962080
Size: 45573853
Entries: 967089
Size: 45896104
Avg Size: 48
Key Size: 11045299
Key Size: 11112265
Avg Key Size: 12
Max Key Size: 99

0..8 266 0%
9..12 5485 0%
13..16 73633 8%
17..24 180918 27%
25..32 209823 48%
33..40 148995 64%
41..48 76304 72%
49..56 14346 73%
57..64 15725 75%
65..80 44916 80%
81..96 127815 93%
97..112 34769 96%
113..128 13314 98%
129..144 8098 99%
145..160 3355 99%
161..176 1159 99%
177..192 629 99%
193..208 221 99%
209..224 210 99%
225..240 129 99%
241..256 57 99%
257..288 496 99%
289..320 60 99%
321..352 37 99%
353..384 46 99%
385..416 22 99%
0..8 263 0%
9..12 5560 0%
13..16 71394 7%
17..24 180717 26%
25..32 215442 48%
33..40 151118 64%
41..48 77479 72%
49..56 13983 74%
57..64 14481 75%
65..80 41342 79%
81..96 127098 92%
97..112 38054 96%
113..128 14197 98%
129..144 8208 99%
145..160 3326 99%
161..176 1242 99%
177..192 604 99%
193..208 222 99%
209..224 213 99%
225..240 132 99%
241..256 58 99%
257..288 515 99%
289..320 64 99%
321..352 39 99%
353..384 44 99%
385..416 25 99%
417..448 24 99%
449..480 26 99%
481..512 27 99%
513..1024 471 99%
1025..2048 389 99%
2049..4096 182 99%
4097..8192 74 99%
8193..16384 34 99%
513..1024 470 99%
1025..2048 396 99%
2049..4096 187 99%
4097..8192 78 99%
8193..16384 35 99%
16385..32768 17 99%
32769..65536 6 99%
65537..65541 3 100%

If the indices are omitted, the statistics for the 49 tables
become the following:

Entries: 451103
Size: 30930282
Avg Size: 69
Key Size: 1804412
Avg Key Size: 4
Max Key Size: 4

0..24 89 0%
25..32 9417 2%
33..40 119162 28%
41..48 68710 43%
49..56 9539 45%
57..64 12435 48%
65..80 38650 57%
81..96 126877 85%
97..112 38030 93%
113..128 14183 96%
129..144 7668 98%
145..160 3302 99%
161..176 1238 99%
177..192 597 99%
193..208 217 99%
209..224 211 99%
225..240 130 99%
241..256 57 99%
257..288 100 99%
289..320 62 99%
321..352 34 99%
353..384 43 99%
385..416 24 99%
417..448 24 99%
449..480 25 99%
481..512 27 99%
513..1024 153 99%
1025..2048 92 99%
2049..4096 7 100%

The 56 indices have these statistics:

Entries: 512422
Size: 14879828
Avg Size: 30
Key Size: 9253204
Avg Key Size: 19
Max Key Size: 99

0..8 246 0%
9..12 5486 1%
13..16 70717 14%
17..24 178246 49%
25..32 205722 89%
33..40 31951 96%
41..48 8768 97%
49..56 4444 98%
57..64 2046 99%
65..80 2691 99%
81..96 202 99%
97..112 11 99%
113..144 527 99%
145..160 20 99%
161..288 406 99%
289..1024 316 99%
1025..2048 304 99%
2049..4096 180 99%
4097..8192 78 99%
8193..16384 35 99%
16385..32768 17 99%
32769..65536 5 99%
65537..131073 3 100%
32769..65536 6 99%
65537..65541 3 100%
6 changes: 5 additions & 1 deletion src/dbbe.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
** relatively simple to convert to a different database such
** as NDBM, SDBM, or BerkeleyDB.
**
** $Id: dbbe.c,v 1.23 2001/01/15 22:51:10 drh Exp $
** $Id: dbbe.c,v 1.24 2001/03/20 12:55:14 drh Exp $
*/
#include "sqliteInt.h"
#include <unistd.h>
Expand Down Expand Up @@ -98,7 +98,11 @@ int sqliteDbbeOpenTempFile(const char *zDir, Dbbe *pBe, FILE **ppFile){
zFile = 0;
sqliteSetString(&zFile, zDir, zBuf, 0);
}while( access(zFile,0)==0 && limit-- >= 0 );
#if OS_WIN
*ppFile = pBe->apTemp[i] = fopen(zFile, "w+b");
#else
*ppFile = pBe->apTemp[i] = fopen(zFile, "w+");
#endif
if( pBe->apTemp[i]==0 ){
rc = SQLITE_ERROR;
sqliteFree(zFile);
Expand Down
7 changes: 6 additions & 1 deletion src/dbbemem.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
**
** This file uses an in-memory hash table as the database backend.
**
** $Id: dbbemem.c,v 1.8 2001/02/19 23:48:17 drh Exp $
** $Id: dbbemem.c,v 1.9 2001/03/20 12:55:14 drh Exp $
*/
#include "sqliteInt.h"
#include <sys/stat.h>
Expand Down Expand Up @@ -721,7 +721,12 @@ static int sqliteMemDelete(DbbeCursor *pCursr, int nKey, char *pKey){
** directory.
*/
static int sqliteMemOpenTempFile(Dbbe *pDbbe, FILE **ppFile){
#if OS_UNIX
const char *zTemps[] = { "/usr/tmp", "/var/tmp", "/tmp", "/temp", 0};
#endif
#if OS_WIN
const char *zTemps[] = { "c:/temp", "c:", 0};
#endif
const char *zDir;
int i;
struct stat statbuf;
Expand Down
6 changes: 5 additions & 1 deletion test/dbbe.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is exercising the code in dbbe.c.
#
# $Id: dbbe.test,v 1.5 2001/01/31 13:28:09 drh Exp $
# $Id: dbbe.test,v 1.6 2001/03/20 12:55:14 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
Expand Down Expand Up @@ -66,6 +66,8 @@ do_test dbbe-1.4 {
lappend v $msg
} {1 {not a directory: "testdb"}}

if {$::tcl_platform(platform)!="windows"} {

# Access permission denied on the directory.
#
do_test dbbe-1.5 {
Expand Down Expand Up @@ -100,6 +102,8 @@ do_test dbbe-1.6b {
lappend v $msg
} {0 {}}

} ;# End of if( platform!=windows )

# Make sure a table can be accessed by either uppercase or lowercase
# names
#
Expand Down
41 changes: 40 additions & 1 deletion test/delete.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the DELETE FROM statement.
#
# $Id: delete.test,v 1.6 2000/06/21 13:59:13 drh Exp $
# $Id: delete.test,v 1.7 2001/03/20 12:55:14 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
Expand Down Expand Up @@ -79,4 +79,43 @@ do_test delete-4.2 {
lappend v $msg
} {1 {no such function: xyzzy}}

# Lots of deletes
#
do_test delete-5.1 {
execsql {DELETE FROM table1}
execsql {SELECT count(*) FROM table1}
} {}
do_test delete-5.2 {
for {set i 1} {$i<=200} {incr i} {
execsql "INSERT INTO table1 VALUES($i,[expr {$i*$i}])"
}
execsql {SELECT count(*) FROM table1}
} {200}
do_test delete-5.3 {
for {set i 1} {$i<=200} {incr i 4} {
execsql "DELETE FROM table1 WHERE f1==$i"
}
execsql {SELECT count(*) FROM table1}
} {150}
do_test delete-5.4 {
execsql "DELETE FROM table1 WHERE f1>50"
execsql {SELECT count(*) FROM table1}
} {37}
do_test delete-5.5 {
for {set i 1} {$i<=70} {incr i 3} {
execsql "DELETE FROM table1 WHERE f1==$i"
}
execsql {SELECT f1 FROM table1 ORDER BY f1}
} {2 3 6 8 11 12 14 15 18 20 23 24 26 27 30 32 35 36 38 39 42 44 47 48 50}
do_test delete-5.6 {
for {set i 1} {$i<40} {incr i} {
execsql "DELETE FROM table1 WHERE f1==$i"
}
execsql {SELECT f1 FROM table1 ORDER BY f1}
} {42 44 47 48 50}
do_test delete-5.7 {
execsql "DELETE FROM table1 WHERE f1!=48"
execsql {SELECT f1 FROM table1 ORDER BY f1}
} {48}

finish_test
4 changes: 2 additions & 2 deletions test/lock.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
# This file implements regression tests for SQLite library. The
# focus of this script is database locks.
#
# $Id: lock.test,v 1.6 2001/03/15 18:21:22 drh Exp $
# $Id: lock.test,v 1.7 2001/03/20 12:55:14 drh Exp $

if {$dbprefix=="gdbm:"} {
if {$dbprefix=="gdbm:" && $::tcl_platform(platform)!="windows"} {

set testdir [file dirname $argv0]
source $testdir/tester.tcl
Expand Down
7 changes: 6 additions & 1 deletion test/main.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is exercising the code in main.c.
#
# $Id: main.test,v 1.4 2000/12/10 18:23:52 drh Exp $
# $Id: main.test,v 1.5 2001/03/20 12:55:14 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
Expand Down Expand Up @@ -81,6 +81,7 @@ do_test main-1.13 {
#
do_test main-2.0 {
catch {db close}
foreach f [glob -nocomplain testdb/*] {file delete -force $f}
file delete -force testdb
file mkdir testdb
set fd [open testdb/sqlite_master.tbl w]
Expand All @@ -94,20 +95,23 @@ do_test main-2.0 {
#
do_test main-3.1 {
catch {db close}
foreach f [glob -nocomplain testdb/*] {file delete -force $f}
file delete -force testdb
sqlite db testdb
set v [catch {execsql {SELECT * from T1 where x!!5}} msg]
lappend v $msg
} {1 {unrecognized token: "!!"}}
do_test main-3.2 {
catch {db close}
foreach f [glob -nocomplain testdb/*] {file delete -force $f}
file delete -force testdb
sqlite db testdb
set v [catch {execsql {SELECT * from T1 where ~x}} msg]
lappend v $msg
} {1 {unrecognized token: "~"}}
do_test main-3.3 {
catch {db close}
foreach f [glob -nocomplain testdb/*] {file delete -force $f}
file delete -force testdb
sqlite db testdb
set v [catch {execsql {SELECT a|b from T1 where x}} msg]
Expand All @@ -116,6 +120,7 @@ do_test main-3.3 {

do_test main-3.3 {
catch {db close}
foreach f [glob -nocomplain testdb/*] {file delete -force $f}
file delete -force testdb
sqlite db testdb
execsql {
Expand Down
5 changes: 4 additions & 1 deletion test/tester.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# This file implements some common TCL routines used for regression
# testing the SQLite library
#
# $Id: tester.tcl,v 1.11 2001/03/15 18:21:22 drh Exp $
# $Id: tester.tcl,v 1.12 2001/03/20 12:55:14 drh Exp $

# Create a test database
#
Expand All @@ -36,6 +36,9 @@ if {![info exists dbprefix]} {
}
switch $dbprefix {
gdbm: {
foreach f [glob -nocomplain testdb/*] {
catch {file delete -force $f}
}
if {[catch {file delete -force testdb}]} {
exec rm -rf testdb
}
Expand Down
5 changes: 3 additions & 2 deletions test/vacuum.test
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the VACUUM statement.
#
# $Id: vacuum.test,v 1.2 2000/10/19 14:10:10 drh Exp $
# $Id: vacuum.test,v 1.3 2001/03/20 12:55:14 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl
Expand Down Expand Up @@ -65,6 +65,7 @@ do_test vacuum-1.3 {
set a3 [file mtime testdb/index1.tbl]
expr {$a1>$b1 && $a2==$b2 && $a3==$b3}
} {1}
if {$::tcl_platform(platform)!="windows"} {
testif gdbm:
do_test vacuum-1.4 {
set b1 [file mtime testdb/test1.tbl]
Expand All @@ -77,6 +78,6 @@ do_test vacuum-1.4 {
set a3 [file mtime testdb/index1.tbl]
expr {$a1>$b1 && $a2>$b2 && $a3>$b3}
} {1}

} ;# End if( platform!=windows )

finish_test
Loading

0 comments on commit ce218a8

Please sign in to comment.