/ Check-in [71e98d0d]
Login

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

Overview
Comment:Misc fixes for test cases failing due to the new locking model. (CVS 1561)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 71e98d0d089576433c4b06dcba1c57063bd366f5
User & Date: danielk1977 2004-06-10 05:59:25
Context
2004-06-10
10:50
Add the sqlite3_collation_needed() API and fix some error handling cases involving unknown collation sequences. (CVS 1562) check-in: edf069b9 user: danielk1977 tags: trunk
05:59
Misc fixes for test cases failing due to the new locking model. (CVS 1561) check-in: 71e98d0d user: danielk1977 tags: trunk
04:32
When in PAGER_RESERVED state, don't write to the main file when rolling back a statement transaction. (CVS 1560) check-in: adb2bd61 user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/pager.c.

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
...
517
518
519
520
521
522
523
524




525
526
527
528
529
530
531
...
541
542
543
544
545
546
547

548
549


550
551
552
553
554
555
556
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.121 2004/06/10 04:32:17 danielk1977 Exp $
*/
#include "os.h"         /* Must be first to enable large file support */
#include "sqliteInt.h"
#include "pager.h"
#include <assert.h>
#include <string.h>

................................................................................
    }
  }

  assert( pPager->state==PAGER_RESERVED || pPager->state==PAGER_EXCLUSIVE );

  /* If the pager is in RESERVED state, then there must be a copy of this
  ** page in the pager cache. In this case just update the pager cache,
  ** not the database file.




  **
  ** If in EXCLUSIVE state, then we update the pager cache if it exists
  ** and the main file. The page is then marked not dirty.
  */
  pPg = pager_lookup(pPager, pgno);
  assert( pPager->state==PAGER_EXCLUSIVE || pPg );
  TRACE2("PLAYBACK page %d\n", pgno);
................................................................................
    void *pData;
    assert( pPg->nRef==0 || pPg->pgno==1 );
    pData = PGHDR_TO_DATA(pPg);
    memcpy(pData, aData, pPager->pageSize);
    if( pPager->xDestructor ){
      pPager->xDestructor(pData, pPager->pageSize);
    }

    pPg->dirty = 0;
    pPg->needSync = 0;


    CODEC(pPager, pData, pPg->pgno, 3);
  }
  return rc;
}

/*
** Parameter zMaster is the name of a master journal file. A single journal







|







 







|
>
>
>
>







 







>
|
|
>
>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
...
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
...
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.122 2004/06/10 05:59:25 danielk1977 Exp $
*/
#include "os.h"         /* Must be first to enable large file support */
#include "sqliteInt.h"
#include "pager.h"
#include <assert.h>
#include <string.h>

................................................................................
    }
  }

  assert( pPager->state==PAGER_RESERVED || pPager->state==PAGER_EXCLUSIVE );

  /* If the pager is in RESERVED state, then there must be a copy of this
  ** page in the pager cache. In this case just update the pager cache,
  ** not the database file. The page is left marked dirty in this case.
  **
  ** FIX ME: Ideally the page would only be left marked dirty when the
  ** pager is in RESERVED state if it was dirty when this statement
  ** transaction was started. 
  **
  ** If in EXCLUSIVE state, then we update the pager cache if it exists
  ** and the main file. The page is then marked not dirty.
  */
  pPg = pager_lookup(pPager, pgno);
  assert( pPager->state==PAGER_EXCLUSIVE || pPg );
  TRACE2("PLAYBACK page %d\n", pgno);
................................................................................
    void *pData;
    assert( pPg->nRef==0 || pPg->pgno==1 );
    pData = PGHDR_TO_DATA(pPg);
    memcpy(pData, aData, pPager->pageSize);
    if( pPager->xDestructor ){
      pPager->xDestructor(pData, pPager->pageSize);
    }
    if( pPager->state==PAGER_EXCLUSIVE ){
      pPg->dirty = 0;
      pPg->needSync = 0;
    }

    CODEC(pPager, pData, pPg->pgno, 3);
  }
  return rc;
}

/*
** Parameter zMaster is the name of a master journal file. A single journal

Changes to test/delete.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
273
274
275
276
277
278
279




280
281
282
283
284

285
286
287
288
289
290
#    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 DELETE FROM statement.
#
# $Id: delete.test,v 1.14 2004/05/27 17:22:56 drh Exp $

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

# Try to delete from a non-existant table.
#
do_test delete-1.1 {
................................................................................
  catchsql {
    DELETE FROM t3 WHERE 1;
  }
} {1 {attempt to write a readonly database}}
do_test delete-8.4 {
  execsql {SELECT * FROM t3} 
} {123}




do_test delete-8.5 {
  catchsql {
    DELETE FROM t3 WHERE a<100;
  }
} {0 {}}

do_test delete-8.6 {
  execsql {SELECT * FROM t3}
} {123}
integrity_check delete-8.7

finish_test







|







 







>
>
>
>




|
>






7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#    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 DELETE FROM statement.
#
# $Id: delete.test,v 1.15 2004/06/10 05:59:25 danielk1977 Exp $

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

# Try to delete from a non-existant table.
#
do_test delete-1.1 {
................................................................................
  catchsql {
    DELETE FROM t3 WHERE 1;
  }
} {1 {attempt to write a readonly database}}
do_test delete-8.4 {
  execsql {SELECT * FROM t3} 
} {123}

# Update for v3: In v2 the DELETE statement would succeed because no
# database writes actually occur. Version 3 refuses to open a transaction
# on a read-only file, so the statement fails.
do_test delete-8.5 {
  catchsql {
    DELETE FROM t3 WHERE a<100;
  }
# v2 result: {0 {}}
} {1 {attempt to write a readonly database}}
do_test delete-8.6 {
  execsql {SELECT * FROM t3}
} {123}
integrity_check delete-8.7

finish_test

Changes to test/enc2.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
137
138
139
140
141
142
143
144


145
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The focus of
# this file is testing the SQLite routines used for converting between the
# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
# UTF-16be).
#
# $Id: enc2.test,v 1.6 2004/06/09 12:30:06 danielk1977 Exp $

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

db close

# Return the UTF-8 representation of the supplied UTF-16 string $str. 
................................................................................
  db2 eval "CREATE TABLE abc(a, b, c);"
} {}
do_test enc2-4.3 {
  catchsql {
    ATTACH 'test2.db' as aux;
  }
} {1 {attached databases must use the same text encoding as main database}}



finish_test







|







 








>
>

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
137
138
139
140
141
142
143
144
145
146
147
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The focus of
# this file is testing the SQLite routines used for converting between the
# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
# UTF-16be).
#
# $Id: enc2.test,v 1.7 2004/06/10 05:59:25 danielk1977 Exp $

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

db close

# Return the UTF-8 representation of the supplied UTF-16 string $str. 
................................................................................
  db2 eval "CREATE TABLE abc(a, b, c);"
} {}
do_test enc2-4.3 {
  catchsql {
    ATTACH 'test2.db' as aux;
  }
} {1 {attached databases must use the same text encoding as main database}}

db2 close

finish_test

Changes to test/misc1.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
319
320
321
322
323
324
325


326
327
328
329
330
331
332

333
334
335
336
337
338
339
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc1.test,v 1.26 2004/06/09 09:55:20 danielk1977 Exp $

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

# Mimic the SQLite 2 collation type NUMERIC.
db collate numeric numeric_collate
proc numeric_collate {lhs rhs} {
................................................................................
do_test misc1-10.10 {
  execsql {SELECT x1 FROM manycol WHERE x0=100}
} {102}

# Make sure the initialization works even if a database is opened while
# another process has the database locked.
#


do_test misc1-11.1 {
  execsql {BEGIN}
  execsql {UPDATE t1 SET a=0 WHERE 0}
  sqlite db2 test.db
  set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]
  lappend rc $msg
} {1 {database is locked}}

do_test misc1-11.2 {
  execsql {COMMIT}
  set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]
  db2 close
  lappend rc $msg
} {0 3}








|







 







>
>






|
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc1.test,v 1.27 2004/06/10 05:59:25 danielk1977 Exp $

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

# Mimic the SQLite 2 collation type NUMERIC.
db collate numeric numeric_collate
proc numeric_collate {lhs rhs} {
................................................................................
do_test misc1-10.10 {
  execsql {SELECT x1 FROM manycol WHERE x0=100}
} {102}

# Make sure the initialization works even if a database is opened while
# another process has the database locked.
#
# Update for v3: The BEGIN doesn't lock the database so the schema is read
# and the SELECT returns successfully.
do_test misc1-11.1 {
  execsql {BEGIN}
  execsql {UPDATE t1 SET a=0 WHERE 0}
  sqlite db2 test.db
  set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]
  lappend rc $msg
# v2 result: {1 {database is locked}}
} {0 3}
do_test misc1-11.2 {
  execsql {COMMIT}
  set rc [catch {db2 eval {SELECT count(*) FROM t1}} msg]
  db2 close
  lappend rc $msg
} {0 3}

Changes to test/thread1.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
119
120
121
122
123
124
125


126

127
128
129

130
131
132
133
134

135


136
137
138
139
140
141
142
143
144
145

146
147
148
149
150
151
152
153
154
155
156
157
158
#    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 script is multithreading behavior
#
# $Id: thread1.test,v 1.4 2004/06/02 06:30:18 danielk1977 Exp $


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

# Skip this whole file if the thread testing code is not enabled
#
................................................................................
  thread_result B
} SQLITE_ROW
do_test thread1-2.3 {
  thread_create C test.db
  thread_compile C {INSERT INTO t2 VALUES(98,99)}
  thread_step C
  thread_result C


} SQLITE_BUSY

do_test thread1-2.4 {
  execsql {SELECT * FROM t2}
} {}

do_test thread1-2.5 {
  thread_finalize A
  thread_result A
} SQLITE_OK
do_test thread1-2.6 {

  thread_step C


  thread_result C
} SQLITE_BUSY
do_test thread1-2.7 {
  execsql {SELECT * FROM t2}
} {}
do_test thread1-2.8 {
  thread_finalize B
  thread_result B
} SQLITE_OK
do_test thread1-2.9 {

  thread_step C
  thread_result C
} SQLITE_DONE
do_test thread1-2.10 {
  thread_finalize C
  thread_result C
} SQLITE_OK
do_test thread1-2.11 {
  execsql {SELECT * FROM t2}
} {98 99}

thread_halt *   
finish_test







|







 







>
>

>



>





>

>
>










>













7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#    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 script is multithreading behavior
#
# $Id: thread1.test,v 1.5 2004/06/10 05:59:25 danielk1977 Exp $


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

# Skip this whole file if the thread testing code is not enabled
#
................................................................................
  thread_result B
} SQLITE_ROW
do_test thread1-2.3 {
  thread_create C test.db
  thread_compile C {INSERT INTO t2 VALUES(98,99)}
  thread_step C
  thread_result C
  thread_finalize C
  thread_result C
} SQLITE_BUSY

do_test thread1-2.4 {
  execsql {SELECT * FROM t2}
} {}

do_test thread1-2.5 {
  thread_finalize A
  thread_result A
} SQLITE_OK
do_test thread1-2.6 {
  thread_compile C {INSERT INTO t2 VALUES(98,99)}
  thread_step C
  thread_result C
  thread_finalize C
  thread_result C
} SQLITE_BUSY
do_test thread1-2.7 {
  execsql {SELECT * FROM t2}
} {}
do_test thread1-2.8 {
  thread_finalize B
  thread_result B
} SQLITE_OK
do_test thread1-2.9 {
  thread_compile C {INSERT INTO t2 VALUES(98,99)}
  thread_step C
  thread_result C
} SQLITE_DONE
do_test thread1-2.10 {
  thread_finalize C
  thread_result C
} SQLITE_OK
do_test thread1-2.11 {
  execsql {SELECT * FROM t2}
} {98 99}

thread_halt *   
finish_test