interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / session / session6.test

91 lines · 2076 bytes Raw Blame History
1# 2011 July 11
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 sessions extension.
12# Specifically, it tests that sessions work when the database is modified
13# using incremental blob handles.
14#
15
16if {![info exists testdir]} {
17 set testdir [file join [file dirname [info script]] .. .. test]
18}
19source [file join [file dirname [info script]] session_common.tcl]
20source $testdir/tester.tcl
21ifcapable !session {finish_test; return}
22ifcapable !incrblob {finish_test; return}
23
24set testprefix session6
25
26proc do_then_apply_tcl {tcl {dbname main}} {
27 proc xConflict args { return "OMIT" }
28 set rc [catch {
29 sqlite3session S db $dbname
30 db eval "SELECT name FROM $dbname.sqlite_master WHERE type = 'table'" {
31 S attach $name
32 }
33 eval $tcl
34 sqlite3changeset_apply db2 [S changeset] xConflict
35 } msg]
36
37 catch { S delete }
38 if {$rc} {error $msg}
39}
40
41test_sqlite3_log x
42proc x {args} {puts $args}
43
44forcedelete test.db2
45sqlite3 db2 test.db2
46
47do_common_sql {
48 CREATE TABLE t1(a PRIMARY KEY, b);
49 CREATE TABLE t2(c PRIMARY KEY, d);
50}
51
52# Test a blob update.
53#
54do_test 1.1 {
55 do_then_apply_tcl {
56 db eval { INSERT INTO t1 VALUES(1, 'helloworld') }
57 db eval { INSERT INTO t2 VALUES(2, 'onetwothree') }
58 }
59 compare_db db db2
60} {}
61do_test 1.2 {
62 do_then_apply_tcl {
63 set fd [db incrblob t1 b 1]
64 puts -nonewline $fd 1234567890
65 close $fd
66 }
67 compare_db db db2
68} {}
69
70# Test an attached database.
71#
72do_test 2.1 {
73 forcedelete test.db3
74 file copy test.db2 test.db3
75 execsql { ATTACH 'test.db3' AS aux; }
76
77 do_then_apply_tcl {
78 set fd [db incrblob aux t2 d 1]
79 puts -nonewline $fd fourfivesix
80 close $fd
81 } aux
82
83 sqlite3 db3 test.db3
84 compare_db db2 db3
85} {}
86
87
88db3 close
89db2 close
90
91finish_test