Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/ext/session/sessionrebase2.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / ext / session / sessionrebase2.test` 108 lines ยท 3592 bytes Raw Blame History 1 # 2026 July 6 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. 12 # 13 14 if {![info exists testdir]} { 15 set testdir [file join [file dirname [info script]] .. .. test] 16 } 17 source [file join [file dirname [info script]] session_common.tcl] 18 source $testdir/tester.tcl 19 ifcapable !session {finish_test; return} 20 21 set testprefix sessionrebase2 22 23 24 #------------------------------------------------------------------------- 25 # Bug https://sqlite.org/bugs/forumpost/`70e16d367d` 26 # 27 set input "`54280100000000000000000000000000000000000000000000000000000000000000000000000000000074310017000200000000000000070000000000000000000000000000000000000000000000000000000000000000000000000000000002c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c14141414141414102c141414141414141`" 28 29 set rebaser "`5401017431001200020000000000000007`" 30 31 set I [db one {SELECT unhex($input)}] 32 set R [db one {SELECT unhex($rebaser)}] 33 do_test 1.0 { 34 sqlite3rebaser_create R 35 R configure $R 36 set I2 [R rebase $I] 37 R delete 38 } {} 39 40 #------------------------------------------------------------------------- 41 # Ensure that is an error to pass a patchset to sqlite3rebase_configure(). 42 # 43 set input "`0000ff0021`" 44 set rebaser [string map {{ } {}} \ 45 "`5003030000` 7400 0921 `010000000d00490006`" 46 ] 47 48 set I [db one {SELECT unhex($input)}] 49 set R [db one {SELECT unhex($rebaser)}] 50 51 do_test 2.0 { 52 sqlite3rebaser_create R 53 list [catch { R configure $R } msg] $msg 54 } {1 SQLITE_ERROR} 55 56 do_test 2.1 { 57 list [catch { set I2 [R rebase $I] } msg] $msg 58 } {1 SQLITE_CORRUPT} 59 do_test 2.2 { 60 R delete 61 } {} 62 63 #------------------------------------------------------------------------- 64 # 65 reset_db 66 67 proc get_changeset {sql} { 68 execsql BEGIN 69 set cs [changeset_from_sql $sql] 70 execsql ROLLBACK 71 return $cs 72 } 73 74 proc xConflict {args} { 75 set res [lindex $::lConflict 0] 76 set ::lConflict [lrange $::lConflict 1 end] 77 return $res 78 } 79 80 81 proc rebased {blobs cs} { 82 sqlite3rebaser_create R 83 foreach b $blobs { R configure $b } 84 set out [R rebase $cs] 85 R delete 86 changeset_to_list $out 87 } 88 89 do_execsql_test 3.0 { 90 CREATE TABLE t1(a INTEGER PRIMARY KEY, b); 91 INSERT INTO t1 VALUES(1, 'x'); 92 } 93 94 95 set c_peer1 [get_changeset {DELETE FROM t1 WHERE a=1}] 96 set c_peer2 [get_changeset {UPDATE t1 SET b='peer2' WHERE a=1}] 97 set c_local [changeset_from_sql {UPDATE t1 SET b='local' WHERE a=1}] 98 99 set ::lConflict REPLACE 100 set b1 [sqlite3changeset_apply_v2 db $c_peer1 xConflict] 101 set ::lConflict OMIT 102 set b2 [sqlite3changeset_apply_v2 db $c_peer2 xConflict] 103 104 do_test 3.1 { rebased [list $b1] $c_local } {} 105 do_test 3.2 { rebased [list $b2 $b1] $c_local } {} 106 do_test 3.3 { rebased [list $b1 $b2] $c_local } {} 107 108 finish_test