Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add tests to improve code coverage of the RBU module. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ecb56b75a0e66462acdcce285b93f9fc |
User & Date: | dan 2019-05-08 18:49:51.870 |
Context
2019-05-08
| ||
19:06 | Avoid an excess register allocation in UPDATE, when possible. This improves speed (slightly) and reduces the code footprint. (check-in: 8658574e3f user: drh tags: trunk) | |
18:49 | Add tests to improve code coverage of the RBU module. (check-in: ecb56b75a0 user: dan tags: trunk) | |
17:27 | Provide the SQLITE_OMIT_CASE_SENSITIVE_LIKE_PRAGMA compile-time option to omit the case_sensitive_like pragma. This change, in combination with documentation changes, is the current solution to ticket [a340eef47b0cad5]. (check-in: eabe7f2d4f user: drh tags: trunk) | |
Changes
Changes to ext/rbu/rbufault3.test.
︙ | ︙ | |||
79 80 81 82 83 84 85 | sqlite3rbu_vacuum rbu test.db test.db2 rbu step rbu close faultsim_save_and_close do_faultsim_test 3 -faults $fault -prep { faultsim_restore_and_reopen | < < | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | sqlite3rbu_vacuum rbu test.db test.db2 rbu step rbu close faultsim_save_and_close do_faultsim_test 3 -faults $fault -prep { faultsim_restore_and_reopen } -body { sqlite3rbu_vacuum rbu test.db test.db2 rbu step rbu close } -test { eval [list faultsim_test_result {0 SQLITE_OK} {*}$::errlist] } } finish_test |
Added ext/rbu/rbumisc.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | # 2014 August 30 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # source [file join [file dirname [info script]] rbu_common.tcl] set ::testprefix rbumisc db close sqlite3_shutdown sqlite3_config_uri 1 reset_db #------------------------------------------------------------------------- # Ensure that RBU is not confused by oddly named tables in an RBU # database. # do_execsql_test 1.0 { CREATE TABLE x1(a, b, c INTEGER PRIMARY KEY); } do_test 1.1 { forcedelete rbu.db sqlite3 rbu rbu.db rbu eval { CREATE TABLE data_x1(a, b, c, rbu_control); INSERT INTO data_x1 VALUES(1, 1, 1, 0); INSERT INTO data_x1 VALUES(2, 2, 2, 0); CREATE TABLE dat(a, b, c, rbu_control); CREATE TABLE "data x1"(a, b, c, rbu_control); CREATE TABLE datax1(a, b, c, rbu_control); CREATE TABLE data_(a, b, c, rbu_control); INSERT INTO "data x1" VALUES(3, 3, 3, 0); INSERT INTO datax1 VALUES(3, 3, 3, 0); INSERT INTO data_ VALUES(3, 3, 3, 0); INSERT INTO dat VALUES(3, 3, 3, 0); } } {} do_test 1.2 { step_rbu test.db rbu.db db eval { SELECT * FROM x1 } } {1 1 1 2 2 2} finish_test |
Changes to ext/rbu/rbutemplimit.test.
︙ | ︙ | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 74 | } proc step_rbu_cachesize {target rbu stepsize cachesize temp_limit} { set res "" while 1 { sqlite3rbu rbu $target $rbu rbu temp_size_limit $temp_limit sqlite3_exec_nr [rbu db 1] "PRAGMA cache_size = $cachesize" for {set i 0} {$i < $stepsize} {incr i} { set rc [rbu step] set ::A([rbu temp_size]) 1 if {$rc!="SQLITE_OK"} break } set res [list [catch {rbu close} msg] $msg] | > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | } proc step_rbu_cachesize {target rbu stepsize cachesize temp_limit} { set res "" while 1 { sqlite3rbu rbu $target $rbu rbu temp_size_limit $temp_limit if { [rbu temp_size_limit -1]!=$temp_limit } { error "round trip problem!" } sqlite3_exec_nr [rbu db 1] "PRAGMA cache_size = $cachesize" for {set i 0} {$i < $stepsize} {incr i} { set rc [rbu step] set ::A([rbu temp_size]) 1 if {$rc!="SQLITE_OK"} break } set res [list [catch {rbu close} msg] $msg] |
︙ | ︙ |
Changes to ext/rbu/rbuvacuum4.test.
︙ | ︙ | |||
46 47 48 49 50 51 52 53 54 55 56 57 58 | do_execsql_test 3.0 { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); CREATE INDEX i1 oN t1(b, c); INSERT INTO t1 VALUES(1, 2, 3); INSERT INTO t1 VALUES(4, 5, 6); INSERT INTO t1 VALUES(7, 8, 9); } do_rbu_vacuum_test 3.1 1 do_execsql_test 3.2 { SELECT * FROM t1; | > > > > > > > | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | do_execsql_test 3.0 { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); CREATE INDEX i1 oN t1(b, c); INSERT INTO t1 VALUES(1, 2, 3); INSERT INTO t1 VALUES(4, 5, 6); INSERT INTO t1 VALUES(7, 8, 9); CREATE TABLE t2(a, b, c INTEGER, PRIMARY KEY(c)); CREATE INDEX i2 oN t2(b, a); INSERT INTO t2 VALUES('a', 'b', -1); INSERT INTO t2 VALUES('c', 'd', -2); INSERT INTO t2 VALUES('e', 'f', -3); } do_rbu_vacuum_test 3.1 1 do_execsql_test 3.2 { SELECT * FROM t1; SELECT * FROM t2; } {1 2 3 4 5 6 7 8 9 e f -3 c d -2 a b -1} #------------------------------------------------------------------------- reset_db do_execsql_test 4.0 { CREATE TABLE x1(a, b, c, d, PRIMARY KEY(c, b)) WITHOUT ROWID; INSERT INTO x1 VALUES(1, 1, 1, 1); INSERT INTO x1 VALUES(1, 1, 2, 1); |
︙ | ︙ | |||
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | INSERT INTO "a b c" VALUES(NULL, 'a', NULL); INSERT INTO "a b c" VALUES(NULL, 'b', NULL); INSERT INTO "a b c" VALUES(NULL, 'c', NULL); INSERT INTO "a b c" VALUES(1, 2, 3); INSERT INTO "a b c" VALUES(3, 9, 1); INSERT INTO "a b c" VALUES('aaa', 'bbb', 'ccc'); CREATE TABLE x(a); INSERT INTO x VALUES('a'), ('b'), ('d'); CREATE UNIQUE INDEX y ON x(a); } do_rbu_vacuum_test 5.1 1 finish_test | > > | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | INSERT INTO "a b c" VALUES(NULL, 'a', NULL); INSERT INTO "a b c" VALUES(NULL, 'b', NULL); INSERT INTO "a b c" VALUES(NULL, 'c', NULL); INSERT INTO "a b c" VALUES(1, 2, 3); INSERT INTO "a b c" VALUES(3, 9, 1); INSERT INTO "a b c" VALUES('aaa', 'bbb', 'ccc'); CREATE INDEX abc2 ON "a b c"("c c" DESC, a); CREATE TABLE x(a); INSERT INTO x VALUES('a'), ('b'), ('d'); CREATE UNIQUE INDEX y ON x(a); } do_rbu_vacuum_test 5.1 1 finish_test |
Changes to ext/rbu/sqlite3rbu.c.
︙ | ︙ | |||
1542 1543 1544 1545 1546 1547 1548 | ){ char *zOrder = 0; char *zLhs = 0; char *zSelect = 0; char *zVector = 0; char *zRet = 0; int bFailed = 0; | < < | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < | | | | | < | | 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 | ){ char *zOrder = 0; char *zLhs = 0; char *zSelect = 0; char *zVector = 0; char *zRet = 0; int bFailed = 0; const char *zSep = ""; int iCol = 0; sqlite3_stmt *pXInfo = 0; p->rc = prepareFreeAndCollectError(p->dbMain, &pXInfo, &p->zErrmsg, sqlite3_mprintf("PRAGMA main.index_xinfo = %Q", pIter->zIdx) ); while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){ int iCid = sqlite3_column_int(pXInfo, 1); const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4); const char *zCol; if( sqlite3_column_int(pXInfo, 3) ){ bFailed = 1; break; } if( iCid<0 ){ if( pIter->eType==RBU_PK_IPK ){ int i; for(i=0; pIter->abTblPk[i]==0; i++); assert( i<pIter->nTblCol ); zCol = pIter->azTblCol[i]; }else{ zCol = "_rowid_"; } }else{ zCol = pIter->azTblCol[iCid]; } zLhs = rbuMPrintf(p, "%z%s \"%w\" COLLATE %Q", zLhs, zSep, zCol, zCollate ); zOrder = rbuMPrintf(p, "%z%s \"rbu_imp_%d%w\" COLLATE %Q DESC", zOrder, zSep, iCol, zCol, zCollate ); zSelect = rbuMPrintf(p, "%z%s quote(\"rbu_imp_%d%w\")", zSelect, zSep, iCol, zCol ); zSep = ", "; iCol++; } rbuFinalize(p, pXInfo); if( bFailed ) goto index_start_out; if( p->rc==SQLITE_OK ){ sqlite3_stmt *pSel = 0; p->rc = prepareFreeAndCollectError(p->dbMain, &pSel, &p->zErrmsg, sqlite3_mprintf("SELECT %s FROM \"rbu_imp_%w\" ORDER BY %s LIMIT 1", zSelect, pIter->zTbl, zOrder ) ); if( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSel) ){ zSep = ""; for(iCol=0; iCol<pIter->nCol; iCol++){ const char *zQuoted = (const char*)sqlite3_column_text(pSel, iCol); if( zQuoted[0]=='N' ){ bFailed = 1; break; } zVector = rbuMPrintf(p, "%z%s%s", zVector, zSep, zQuoted); |
︙ | ︙ |