SQLite

Check-in [5201fa4f83]
Login

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

Overview
Comment:Fix a bug in test_server.c that resulted from the change in semantics of sqlite3_enable_shared_cache(). All quick tests now pass. (CVS 4326)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5201fa4f8310ffc8b6881d96b152581d74e2df6b
User & Date: drh 2007-08-29 18:20:17.000
Context
2007-08-29
19:15
Fix minor problems on various tests. This is a snapshot prior to possible major changes in order to fix the sqlite3AbortOtherActiveVdbes problem. (CVS 4327) (check-in: 35cb63ecfd user: drh tags: trunk)
18:20
Fix a bug in test_server.c that resulted from the change in semantics of sqlite3_enable_shared_cache(). All quick tests now pass. (CVS 4326) (check-in: 5201fa4f83 user: drh tags: trunk)
17:59
Disable tests that require SQLITE_ENABLE_ATOMIC_WRITE if that feature is not enabled. (CVS 4325) (check-in: 4874499377 user: drh tags: trunk)
Changes
Unified Diff Show Whitespace Changes Patch
Changes to src/test_server.c.
382
383
384
385
386
387
388
389
390
391
392
393

394
395
396
397
398
399
400
** This routine implements the server.  To start the server, first
** make sure g.serverHalt is false, then create a new detached thread
** on this procedure.  See the sqlite3_server_start() routine below
** for an example.  This procedure loops until g.serverHalt becomes
** true.
*/
void *sqlite3_server(void *NotUsed){
  sqlite3_enable_shared_cache(1);
  if( pthread_mutex_trylock(&g.serverMutex) ){
    sqlite3_enable_shared_cache(0);
    return 0;  /* Another server is already running */
  }

  while( !g.serverHalt ){
    SqlMessage *pMsg;

    /* Remove the last message from the message queue.
    */
    pthread_mutex_lock(&g.queueMutex);
    while( g.pQueueTail==0 && g.serverHalt==0 ){







<

<


>







382
383
384
385
386
387
388

389

390
391
392
393
394
395
396
397
398
399
** This routine implements the server.  To start the server, first
** make sure g.serverHalt is false, then create a new detached thread
** on this procedure.  See the sqlite3_server_start() routine below
** for an example.  This procedure loops until g.serverHalt becomes
** true.
*/
void *sqlite3_server(void *NotUsed){

  if( pthread_mutex_trylock(&g.serverMutex) ){

    return 0;  /* Another server is already running */
  }
  sqlite3_enable_shared_cache(1);
  while( !g.serverHalt ){
    SqlMessage *pMsg;

    /* Remove the last message from the message queue.
    */
    pthread_mutex_lock(&g.queueMutex);
    while( g.pQueueTail==0 && g.serverHalt==0 ){
Changes to test/server1.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the server mode of SQLite.
#
# This file is derived from thread1.test
#
# $Id: server1.test,v 1.4 2006/01/15 00:13:16 drh Exp $


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

# Skip this whole file if the server testing code is not enabled
#







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script is testing the server mode of SQLite.
#
# This file is derived from thread1.test
#
# $Id: server1.test,v 1.5 2007/08/29 18:20:17 drh Exp $


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

# Skip this whole file if the server testing code is not enabled
#
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  client_create B test.db
  client_compile B {SELECT b FROM t1}
  client_step B
  client_result B
} SQLITE_ROW

# Write to a different table from another thread.  This is allowed
# becaus in server mode with a shared cache we have table-level locking.
#
do_test server1-2.3 {
  client_create C test.db
  client_compile C {INSERT INTO t2 VALUES(98,99)}
  client_step C
  client_result C
  client_finalize C







|







121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  client_create B test.db
  client_compile B {SELECT b FROM t1}
  client_step B
  client_result B
} SQLITE_ROW

# Write to a different table from another thread.  This is allowed
# because in server mode with a shared cache we have table-level locking.
#
do_test server1-2.3 {
  client_create C test.db
  client_compile C {INSERT INTO t2 VALUES(98,99)}
  client_step C
  client_result C
  client_finalize C
163
164
165
166
167
168
169

170
  client_step C
  client_result C
  client_finalize C
  client_result C
} SQLITE_OK

client_halt *   

finish_test







>

163
164
165
166
167
168
169
170
171
  client_step C
  client_result C
  client_finalize C
  client_result C
} SQLITE_OK

client_halt *   
sqlite3_enable_shared_cache 0
finish_test