SQLite

Check-in [70e708660f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem with journal files being created unnecessarily when doing an atomic write in exclusive access locking mode. Fix a test script problem. (CVS 5075)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 70e708660fec0b6f6c41efc2e29f1d7ae6785b7e
User & Date: drh 2008-05-01 18:01:47.000
Context
2008-05-02
02:00
Add another test case to verify that ticket #3092 has been fixed. (CVS 5076) (check-in: 1906d2dadc user: drh tags: trunk)
2008-05-01
18:01
Fix a problem with journal files being created unnecessarily when doing an atomic write in exclusive access locking mode. Fix a test script problem. (CVS 5075) (check-in: 70e708660f user: drh tags: trunk)
17:16
Fix more compiler warnings. (CVS 5074) (check-in: 59568844e7 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/journal.c.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
** 2007 August 22
**
** 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.
**
*************************************************************************
**
** @(#) $Id: journal.c,v 1.7 2007/09/06 13:49:37 drh Exp $
*/

#ifdef SQLITE_ENABLE_ATOMIC_WRITE

/*
** This file implements a special kind of sqlite3_file object used
** by SQLite to create journal files if the atomic-write optimization












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
** 2007 August 22
**
** 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.
**
*************************************************************************
**
** @(#) $Id: journal.c,v 1.8 2008/05/01 18:01:47 drh Exp $
*/

#ifdef SQLITE_ENABLE_ATOMIC_WRITE

/*
** This file implements a special kind of sqlite3_file object used
** by SQLite to create journal files if the atomic-write optimization
145
146
147
148
149
150
151
152
153
154


155
156
157
158
159
160
161

/*
** Sync the file.
*/
static int jrnlSync(sqlite3_file *pJfd, int flags){
  int rc;
  JournalFile *p = (JournalFile *)pJfd;
  rc = createFile(p);
  if( rc==SQLITE_OK ){
    rc = sqlite3OsSync(p->pReal, flags);


  }
  return rc;
}

/*
** Query the size of the file in bytes.
*/







<
|

>
>







145
146
147
148
149
150
151

152
153
154
155
156
157
158
159
160
161
162

/*
** Sync the file.
*/
static int jrnlSync(sqlite3_file *pJfd, int flags){
  int rc;
  JournalFile *p = (JournalFile *)pJfd;

  if( p->pReal ){
    rc = sqlite3OsSync(p->pReal, flags);
  }else{
    rc = SQLITE_OK;
  }
  return rc;
}

/*
** Query the size of the file in bytes.
*/
Changes to test/io.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
#
# The focus of this file is testing some specific characteristics of the 
# IO traffic generated by SQLite (making sure SQLite is not writing out
# more database pages than it has to, stuff like that).
#
# $Id: io.test,v 1.15 2008/03/28 17:41:14 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

db close
sqlite3_simulate_device
sqlite3 db test.db -vfs devsym







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
#
# The focus of this file is testing some specific characteristics of the 
# IO traffic generated by SQLite (making sure SQLite is not writing out
# more database pages than it has to, stuff like that).
#
# $Id: io.test,v 1.16 2008/05/01 18:01:47 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

db close
sqlite3_simulate_device
sqlite3 db test.db -vfs devsym
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363

do_test io-2.11.0 {
  execsql { 
    PRAGMA locking_mode = exclusive;
    PRAGMA locking_mode;
  }
} {exclusive exclusive}
breakpoint
do_test io-2.11.1 {
  execsql { 
    INSERT INTO abc VALUES(11, 12);
  }
  file exists test.db-journal
} {0}
breakpoint

do_test io-2.11.2 {
  execsql { 
    PRAGMA locking_mode = normal;
    INSERT INTO abc VALUES(13, 14);
  }
  file exists test.db-journal







<






<







342
343
344
345
346
347
348

349
350
351
352
353
354

355
356
357
358
359
360
361

do_test io-2.11.0 {
  execsql { 
    PRAGMA locking_mode = exclusive;
    PRAGMA locking_mode;
  }
} {exclusive exclusive}

do_test io-2.11.1 {
  execsql { 
    INSERT INTO abc VALUES(11, 12);
  }
  file exists test.db-journal
} {0}


do_test io-2.11.2 {
  execsql { 
    PRAGMA locking_mode = normal;
    INSERT INTO abc VALUES(13, 14);
  }
  file exists test.db-journal
Changes to test/nan.test.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36


37
38
39
40
41
42
43
#***********************************************************************
#
# Ticket #3060
#
# Make sure IEEE floating point NaN values are handled properly.
# SQLite should always convert NaN into NULL.
#
# $Id: nan.test,v 1.1 2008/04/29 00:15:21 drh Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# The ascii->float conversion routine in SQLite converts all digits
# of a number to a long long double.  Then it divids by 10**N where
# N is the number of digits to the right of the decimal point.  If
# both the full number and 10**N are +Inf we will get +Inf/+Inf which
# is NaN.
#
unset -nocomplain nan
set nan 9.[string repeat 9 5000]

unset -nocomplain inf
set inf [string repeat 9 5000].0

do_test nan-1.1 {
  db eval {


    CREATE TABLE t1(x FLOAT);
  }
  db eval "INSERT INTO t1 VALUES($nan)"
  db eval {SELECT x, typeof(x) FROM t1}
} {{} null}
do_test nan-1.2 {
  db eval "INSERT INTO t1 VALUES($inf)"







|



















>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#***********************************************************************
#
# Ticket #3060
#
# Make sure IEEE floating point NaN values are handled properly.
# SQLite should always convert NaN into NULL.
#
# $Id: nan.test,v 1.2 2008/05/01 18:01:47 drh Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# The ascii->float conversion routine in SQLite converts all digits
# of a number to a long long double.  Then it divids by 10**N where
# N is the number of digits to the right of the decimal point.  If
# both the full number and 10**N are +Inf we will get +Inf/+Inf which
# is NaN.
#
unset -nocomplain nan
set nan 9.[string repeat 9 5000]

unset -nocomplain inf
set inf [string repeat 9 5000].0

do_test nan-1.1 {
  db eval {
    PRAGMA auto_vacuum=OFF;
    PRAGMA page_size=1024;
    CREATE TABLE t1(x FLOAT);
  }
  db eval "INSERT INTO t1 VALUES($nan)"
  db eval {SELECT x, typeof(x) FROM t1}
} {{} null}
do_test nan-1.2 {
  db eval "INSERT INTO t1 VALUES($inf)"