/ Check-in [66f84068]
Login

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

Overview
Comment:Add the first simple tests of server mode. Get the Makefile generated from the configure script working again. (CVS 2898)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 66f84068f3c7c0963ce88f84fc0ba6775f64cd19
User & Date: drh 2006-01-09 23:50:11
Context
2006-01-10
02:30
Enable shared cache on the server demonstration. (CVS 2899) check-in: 8719f880 user: drh tags: trunk
2006-01-09
23:50
Add the first simple tests of server mode. Get the Makefile generated from the configure script working again. (CVS 2898) check-in: 66f84068 user: drh tags: trunk
23:40
Added database server example code (untested). Fixed serveral bugs including the autovacuum compile problem described by ticket #1593. (CVS 2897) check-in: ec332d88 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

   181    181     $(TOP)/src/date.c \
   182    182     $(TOP)/src/func.c \
   183    183     $(TOP)/src/os_unix.c \
   184    184     $(TOP)/src/os_win.c \
   185    185     $(TOP)/src/pager.c \
   186    186     $(TOP)/src/pragma.c \
   187    187     $(TOP)/src/printf.c \
          188  +  $(TOP)/src/server.c \
   188    189     $(TOP)/src/test1.c \
   189    190     $(TOP)/src/test2.c \
   190    191     $(TOP)/src/test3.c \
   191    192     $(TOP)/src/test4.c \
   192    193     $(TOP)/src/test5.c \
   193    194     $(TOP)/src/test6.c \
          195  +  $(TOP)/src/test7.c \
          196  +  $(TOP)/src/test_async.c \
   194    197     $(TOP)/src/utf.c \
   195    198     $(TOP)/src/util.c \
   196    199     $(TOP)/src/vdbe.c \
   197    200     $(TOP)/src/md5.c \
   198    201     $(TOP)/src/where.c
   199    202   
   200    203   # Header files used by all library source files.

Added test/server1.test.

            1  +# 2006 January 09
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.  The
           12  +# focus of this script is testing the server mode of SQLite.
           13  +#
           14  +# This file is derived from thread1.test
           15  +#
           16  +# $Id: server1.test,v 1.1 2006/01/09 23:50:11 drh Exp $
           17  +
           18  +
           19  +set testdir [file dirname $argv0]
           20  +source $testdir/tester.tcl
           21  +
           22  +# Skip this whole file if the server testing code is not enabled
           23  +#
           24  +if {[llength [info command client_step]]==0 || [sqlite3 -has-codec]} {
           25  +  finish_test
           26  +  return
           27  +}
           28  +
           29  +# Create some data to work with
           30  +#
           31  +do_test server1-1.1 {
           32  +  execsql {
           33  +    CREATE TABLE t1(a,b);
           34  +    INSERT INTO t1 VALUES(1,'abcdefgh');
           35  +    INSERT INTO t1 SELECT a+1, b||b FROM t1;
           36  +    INSERT INTO t1 SELECT a+2, b||b FROM t1;
           37  +    INSERT INTO t1 SELECT a+4, b||b FROM t1;
           38  +    SELECT count(*), max(length(b)) FROM t1;
           39  +  }
           40  +} {8 64}
           41  +
           42  +# Interleave two threads on read access.  Then make sure a third
           43  +# thread can write the database.  In other words:
           44  +#
           45  +#    read-lock A
           46  +#    read-lock B
           47  +#    unlock A
           48  +#    unlock B
           49  +#    write-lock C
           50  +#
           51  +do_test server1-1.2 {
           52  +  client_create A test.db
           53  +  client_create B test.db
           54  +  client_create C test.db
           55  +  client_compile A {SELECT a FROM t1}
           56  +  client_step A
           57  +  client_result A
           58  +} SQLITE_ROW
           59  +do_test server1-1.3 {
           60  +  client_argc A
           61  +} 1
           62  +do_test server1-1.4 {
           63  +  client_argv A 0
           64  +} 1
           65  +do_test server1-1.5 {
           66  +  client_compile B {SELECT b FROM t1}
           67  +  client_step B
           68  +  client_result B
           69  +} SQLITE_ROW
           70  +do_test server1-1.6 {
           71  +  client_argc B
           72  +} 1
           73  +do_test server1-1.7 {
           74  +  client_argv B 0
           75  +} abcdefgh
           76  +do_test server1-1.8 {
           77  +  client_finalize A
           78  +  client_result A
           79  +} SQLITE_OK
           80  +do_test server1-1.9 {
           81  +  client_finalize B
           82  +  client_result B
           83  +} SQLITE_OK
           84  +do_test server1-1.10 {
           85  +  client_compile C {CREATE TABLE t2(x,y)}
           86  +  client_step C
           87  +  client_result C
           88  +} SQLITE_DONE
           89  +do_test server1-1.11 {
           90  +  client_finalize C
           91  +  client_result C
           92  +} SQLITE_OK
           93  +do_test server1-1.12 {
           94  +  catchsql {SELECT name FROM sqlite_master}
           95  +  execsql {SELECT name FROM sqlite_master}
           96  +} {t1 t2}
           97  +
           98  +
           99  +#
          100  +# The following tests - server1-2.* - test the following scenario:
          101  +#
          102  +# 1:  Read-lock thread A
          103  +# 2:  Read-lock thread B
          104  +# 3:  Attempt to write in thread C -> SQLITE_BUSY
          105  +# 4:  Check db write failed from main thread.
          106  +# 5:  Unlock from thread A.
          107  +# 6:  Attempt to write in thread C -> SQLITE_BUSY
          108  +# 7:  Check db write failed from main thread.
          109  +# 8:  Unlock from thread B.
          110  +# 9:  Attempt to write in thread C -> SQLITE_DONE
          111  +# 10: Finalize the write from thread C
          112  +# 11: Check db write succeeded from main thread.
          113  +#
          114  +do_test server1-2.1 {
          115  +  client_halt *
          116  +  client_create A test.db
          117  +  client_compile A {SELECT a FROM t1}
          118  +  client_step A
          119  +  client_result A
          120  +} SQLITE_ROW
          121  +do_test server1-2.2 {
          122  +  client_create B test.db
          123  +  client_compile B {SELECT b FROM t1}
          124  +  client_step B
          125  +  client_result B
          126  +} SQLITE_ROW
          127  +do_test server1-2.3 {
          128  +  client_create C test.db
          129  +  client_compile C {INSERT INTO t2 VALUES(98,99)}
          130  +  client_step C
          131  +  client_result C
          132  +  client_finalize C
          133  +  client_result C
          134  +} SQLITE_BUSY
          135  +
          136  +do_test server1-2.4 {
          137  +  execsql {SELECT * FROM t2}
          138  +} {}
          139  +
          140  +do_test server1-2.5 {
          141  +  client_finalize A
          142  +  client_result A
          143  +} SQLITE_OK
          144  +do_test server1-2.6 {
          145  +  client_compile C {INSERT INTO t2 VALUES(98,99)}
          146  +  client_step C
          147  +  client_result C
          148  +  client_finalize C
          149  +  client_result C
          150  +} SQLITE_BUSY
          151  +do_test server1-2.7 {
          152  +  execsql {SELECT * FROM t2}
          153  +} {}
          154  +do_test server1-2.8 {
          155  +  client_finalize B
          156  +  client_result B
          157  +} SQLITE_OK
          158  +do_test server1-2.9 {
          159  +  client_compile C {INSERT INTO t2 VALUES(98,99)}
          160  +  client_step C
          161  +  client_result C
          162  +} SQLITE_DONE
          163  +do_test server1-2.10 {
          164  +  client_finalize C
          165  +  client_result C
          166  +} SQLITE_OK
          167  +do_test server1-2.11 {
          168  +  execsql {SELECT * FROM t2}
          169  +} {98 99}
          170  +
          171  +client_halt *   
          172  +finish_test