Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add tests for the changes on this branch. Fix a problem with calls to the new progress indicator API made after an rbu update has been resumed. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | rbu-percent-progress |
Files: | files | file ages | folders |
SHA1: |
bf82321724d3b0feb51e26d9b76090e0 |
User & Date: | dan 2016-03-18 10:29:47.529 |
Context
2016-03-18
| ||
18:56 | Change the name of the new API on this branch to "sqlite3_bp_progress". Add tests and documentation for the same. (check-in: 1a1b69e87e user: dan tags: rbu-percent-progress) | |
10:29 | Add tests for the changes on this branch. Fix a problem with calls to the new progress indicator API made after an rbu update has been resumed. (check-in: bf82321724 user: dan tags: rbu-percent-progress) | |
2016-03-17
| ||
21:06 | Add an API to indicate the percentage progress of an rbu update. (check-in: ffc58d2c25 user: dan tags: rbu-percent-progress) | |
Changes
Changes to ext/rbu/rbuprogress.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # source [file join [file dirname [info script]] rbu_common.tcl] set ::testprefix rbuprogress | < | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # #*********************************************************************** # source [file join [file dirname [info script]] rbu_common.tcl] set ::testprefix rbuprogress # Create a simple RBU database. That expects to write to a table: # # CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); # proc create_rbu1 {filename} { forcedelete $filename sqlite3 rbu1 $filename |
︙ | ︙ | |||
54 55 56 57 58 59 60 | do_test 1.9 { rbu step ; rbu stage_progress } {10000 10000} do_test 1.10 { rbu close } {SQLITE_DONE} #------------------------------------------------------------------------- | | | | > > | | > > > > > > > > > | > | > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | do_test 1.9 { rbu step ; rbu stage_progress } {10000 10000} do_test 1.10 { rbu close } {SQLITE_DONE} #------------------------------------------------------------------------- # proc do_sp_test {tn bReopen target rbu reslist} { uplevel [list do_test $tn [subst -nocommands { if {$bReopen==0} { sqlite3rbu rbu $target $rbu } set res [list] while 1 { if {$bReopen} { sqlite3rbu rbu $target $rbu } set rc [rbu step] if {[set rc] != "SQLITE_OK"} { error "error 1" } lappend res [lindex [rbu stage_progress] 0] if {[lindex [set res] end]==10000} break if {$bReopen} { rbu close } } if {[set res] != [list $reslist]} { error "1. reslist incorrect (expect=$reslist got=[set res])" } # One step to clean up the temporary tables used to update the only # target table in the rbu database. And one more to move the *-oal # file to *-wal. After each of these steps, the progress remains # at "10000 0". # rbu step set res [rbu stage_progress] if {[set res] != [list 10000 0]} { error "2. reslist incorrect (expect=10000 0 got=[set res])" } rbu step set res [rbu stage_progress] if {[set res] != [list 10000 0]} { error "3. reslist incorrect (expect=10000 0 got=[set res])" } # Do the checkpoint. while {[rbu step]=="SQLITE_OK"} { foreach {a b} [rbu stage_progress] {} if {[set a]!=10000 || [set b]<=0 || [set b]>10000} { error "4. reslist incorrect (expect=10000 1..10000 got=[set a] [set b])" } } set res [rbu stage_progress] if {[set res] != [list 10000 10000]} { error "5. reslist is incorrect (expect=10000 10000 got=[set res])" } rbu close }] {SQLITE_DONE}] } proc create_db_file {filename sql} { forcedelete $filename sqlite3 tmpdb $filename tmpdb eval $sql tmpdb close } foreach {bReopen} { 0 1 } { reset_db do_test 2.$bReopen.1.0 { execsql { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); } create_db_file rbu.db { CREATE TABLE data_t1(a, b, c, rbu_control); INSERT INTO data_t1 VALUES(4, 4, 4, 0); INSERT INTO data_t1 VALUES(5, 5, 5, 0); CREATE TABLE rbu_count(tbl, cnt); INSERT INTO rbu_count VALUES('data_t1', 2); } } {} do_sp_test 2.$bReopen.1.1 $bReopen test.db rbu.db {5000 10000} reset_db do_test 2.$bReopen.2.0 { execsql { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c) } create_rbu1 rbu.db } {rbu.db} do_sp_test 2.$bReopen.2.1 $bReopen test.db rbu.db {3333 6666 10000} reset_db do_test 2.$bReopen.3.0 { execsql { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); CREATE INDEX i1 ON t1(b); INSERT INTO t1 VALUES(1, 1, 1); INSERT INTO t1 VALUES(2, 2, 2); INSERT INTO t1 VALUES(3, 3, 3); } create_db_file rbu.db { CREATE TABLE data_t1(a, b, c, rbu_control); INSERT INTO data_t1 VALUES(4, 4, 4, 0); INSERT INTO data_t1 VALUES(2, NULL, NULL, 1); INSERT INTO data_t1 VALUES(5, NULL, NULL, 1); CREATE TABLE rbu_count(tbl, cnt); INSERT INTO rbu_count VALUES('data_t1', 3); } } {} do_sp_test 2.$bReopen.3.1 $bReopen test.db rbu.db {1666 3333 6000 8000 10000} reset_db do_test 2.$bReopen.4.0 { execsql { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); CREATE INDEX i1 ON t1(b); INSERT INTO t1 VALUES(1, 1, 1); INSERT INTO t1 VALUES(2, 2, 2); INSERT INTO t1 VALUES(3, 3, 3); } create_db_file rbu.db { CREATE TABLE data_t1(a, b, c, rbu_control); INSERT INTO data_t1 VALUES(2, 4, 4, '.xx'); CREATE TABLE rbu_count(tbl, cnt); INSERT INTO rbu_count VALUES('data_t1', 1); } } {} do_sp_test 2.$bReopen.4.1 $bReopen test.db rbu.db {3333 6666 10000} reset_db do_test 2.$bReopen.5.0 { execsql { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); CREATE INDEX i1 ON t1(b); INSERT INTO t1 VALUES(1, 1, 1); INSERT INTO t1 VALUES(2, 2, 2); INSERT INTO t1 VALUES(3, 3, 3); } create_db_file rbu.db { CREATE TABLE data_t1(a, b, c, rbu_control); INSERT INTO data_t1 VALUES(4, NULL, 4, '.xx'); CREATE TABLE rbu_count(tbl, cnt); INSERT INTO rbu_count VALUES('data_t1', 1); } } {} do_sp_test 2.$bReopen.5.1 $bReopen test.db rbu.db {10000} } finish_test |
Changes to ext/rbu/sqlite3rbu.c.
︙ | ︙ | |||
3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 | if( pState->eStage==0 ){ rbuDeleteOalFile(p); rbuInitPhaseOneSteps(p); p->eStage = RBU_STAGE_OAL; }else{ p->eStage = pState->eStage; } p->nProgress = pState->nProgress; p->iOalSz = pState->iOalSz; } } assert( p->rc!=SQLITE_OK || p->eStage!=0 ); | > | 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 | if( pState->eStage==0 ){ rbuDeleteOalFile(p); rbuInitPhaseOneSteps(p); p->eStage = RBU_STAGE_OAL; }else{ p->eStage = pState->eStage; p->nPhaseOneStep = pState->nPhaseOneStep; } p->nProgress = pState->nProgress; p->iOalSz = pState->iOalSz; } } assert( p->rc!=SQLITE_OK || p->eStage!=0 ); |
︙ | ︙ |