Compare commits

...

7 Commits

Author SHA1 Message Date
dan 7d818c8f9d Before beginning an incremental checkpoint in RBU, sync the directory
containing the target database file. This ensures that the new directory entry
created by renaming the *-oal file to *-wal is synced to disk. Cherrypick of
[915a9a28].

FossilOrigin-Name: 694fe0b22bfa13d91f5fcdbe0562cb31334ce017
2017-03-07 14:47:02 +00:00
dan 22685281e1 Fix another RBU case similar to the previous. This one for systems where the
sector-size is larger than the page-size. Cherrypick of [4012bb3a].

FossilOrigin-Name: 59a11b7f1f4aeefec7102b4859deda70b0b934b9
2017-03-07 14:46:25 +00:00
dan e5d128a1f0 When saving the state of an RBU update in the incremental-checkpoint phase,
sync the database file. Otherwise, if a power failure occurs and the RBU
update resumed following system recovery, the database may become corrupt.
Cherrypick of [edee6a80].

FossilOrigin-Name: 811a559967d886239fc0b16fac08707c78e60988
2017-03-07 14:45:52 +00:00
drh 64b7a31a0c Version 3.17.0
FossilOrigin-Name: ada05cfa86ad7f5645450ac7a2a21c9aa6e57d2c
2017-02-13 16:02:40 +00:00
drh 86aac2020e Fix typos in using the MSVC_VERSION macro.
FossilOrigin-Name: 25ebadd096ce98fd0f9fab809969d34b958794f6
2017-02-13 11:35:38 +00:00
drh cefca47ab5 Ensure that indexed expressions with collating sequences are handled
correctly.  Fix for ticket [eb703ba7b50c1a5] backported from trunk.

FossilOrigin-Name: b2e49ae36bfd00a1d0b70a9de9d23d2e16d1c7ca
2017-02-11 15:02:23 +00:00
drh 191bc61af2 Version 3.17.0 release candidate
FossilOrigin-Name: ad867e8701a5ee17a98a5444da8be6fb1ef7247a
2017-02-10 17:38:00 +00:00
12 changed files with 205 additions and 30 deletions
+106
View File
@@ -0,0 +1,106 @@
# 2017 March 02
#
# 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.
#
#***********************************************************************
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source $testdir/tester.tcl
set ::testprefix rbucrash2
db close
forcedelete test.db-oal rbu.db
sqlite3_shutdown
sqlite3_config_uri 1
reset_db
# Set up a target database and an rbu update database. The target
# db is the usual "test.db", the rbu db is "test.db2".
#
forcedelete test.db2
do_execsql_test 1.0 {
CREATE TABLE t1(a, b, c, PRIMARY KEY(a), UNIQUE(b));
INSERT INTO t1 VALUES(1, 2, 3);
INSERT INTO t1 VALUES(4, 5, 6);
INSERT INTO t1 VALUES(7, 8, 9);
ATTACH 'test.db2' AS rbu;
CREATE TABLE rbu.data_t1(a, b, c, rbu_control);
INSERT INTO data_t1 VALUES('one', randomblob(3500), NULL, 0);
INSERT INTO data_t1 VALUES('two', randomblob(3500), NULL, 0);
INSERT INTO data_t1 VALUES('three', randomblob(3500), NULL, 0);
INSERT INTO data_t1 VALUES('four', randomblob(3500), NULL, 0);
INSERT INTO data_t1 VALUES('five', randomblob(3500), NULL, 0);
INSERT INTO data_t1 VALUES('six', randomblob(3500), NULL, 0);
}
db_save_and_close
proc do_rbu_crash_test2 {tn script} {
foreach {f blksz} {
test.db 512
test.db2 512
test.db 4096
test.db2 4096
} {
set bDone 0
for {set iDelay 1} {$bDone==0} {incr iDelay} {
forcedelete test.db2 test.db2-journal test.db test.db-oal test.db-wal
db_restore
set res [
crashsql -file $f -delay $iDelay -tclbody $script -dflt 1 -opendb {} \
-blocksize $blksz {}
]
set bDone 1
if {$res == "1 {child process exited abnormally}"} {
set bDone 0
} elseif {$res != "0 {}"} {
error "unexected catchsql result: $res"
}
sqlite3rbu rbu test.db test.db2
while {[rbu step]=="SQLITE_OK"} {}
rbu close
sqlite3 db test.db
do_execsql_test $tn.delay=$iDelay.f=$f.blksz=$blksz {
PRAGMA integrity_check;
} {ok}
db close
}
}
}
for {set x 1} {$x < 10} {incr x} {
do_rbu_crash_test2 1.$x {
sqlite3rbu rbu test.db test.db2
while {[rbu step]=="SQLITE_OK"} {
rbu savestate
}
rbu close
}
}
for {set x 1} {$x < 2} {incr x} {
do_rbu_crash_test2 2.$x {
sqlite3rbu rbu test.db test.db2
while {[rbu step]=="SQLITE_OK"} {
rbu close
sqlite3rbu rbu test.db test.db2
}
rbu close
}
}
finish_test
+2
View File
@@ -40,6 +40,7 @@ proc create_rbu1 {filename} {
do_execsql_test 1.0 {
PRAGMA page_size = 4096;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
}
@@ -266,6 +267,7 @@ foreach bReopen {0 1} {
do_test 3.$bReopen.1.0 {
reset_db
execsql {
PRAGMA page_size = 4096;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
+50 -3
View File
@@ -356,6 +356,7 @@ struct sqlite3rbu {
RbuObjIter objiter; /* Iterator for skipping through tbl/idx */
const char *zVfsName; /* Name of automatically created rbu vfs */
rbu_file *pTargetFd; /* File handle open on target db */
int nPagePerSector; /* Pages per sector for pTargetFd */
i64 iOalSz;
i64 nPhaseOneStep;
@@ -2620,6 +2621,23 @@ static void rbuSetupCheckpoint(sqlite3rbu *p, RbuState *pState){
if( p->nFrame==0 || (pState && pState->iWalCksum!=p->iWalCksum) ){
p->rc = SQLITE_DONE;
p->eStage = RBU_STAGE_DONE;
}else{
int nSectorSize;
sqlite3_file *pDb = p->pTargetFd->pReal;
sqlite3_file *pWal = p->pTargetFd->pWalFd->pReal;
assert( p->nPagePerSector==0 );
nSectorSize = pDb->pMethods->xSectorSize(pDb);
if( nSectorSize>p->pgsz ){
p->nPagePerSector = nSectorSize / p->pgsz;
}else{
p->nPagePerSector = 1;
}
/* Call xSync() on the wal file. This causes SQLite to sync the
** directory in which the target database and the wal file reside, in
** case it has not been synced since the rename() call in
** rbuMoveOalFile(). */
p->rc = pWal->pMethods->xSync(pWal, SQLITE_SYNC_NORMAL);
}
}
}
@@ -3275,9 +3293,26 @@ int sqlite3rbu_step(sqlite3rbu *p){
p->rc = SQLITE_DONE;
}
}else{
RbuFrame *pFrame = &p->aFrame[p->nStep];
rbuCheckpointFrame(p, pFrame);
p->nStep++;
/* At one point the following block copied a single frame from the
** wal file to the database file. So that one call to sqlite3rbu_step()
** checkpointed a single frame.
**
** However, if the sector-size is larger than the page-size, and the
** application calls sqlite3rbu_savestate() or close() immediately
** after this step, then rbu_step() again, then a power failure occurs,
** then the database page written here may be damaged. Work around
** this by checkpointing frames until the next page in the aFrame[]
** lies on a different disk sector to the current one. */
u32 iSector;
do{
RbuFrame *pFrame = &p->aFrame[p->nStep];
iSector = (pFrame->iDbPage-1) / p->nPagePerSector;
rbuCheckpointFrame(p, pFrame);
p->nStep++;
}while( p->nStep<p->nFrame
&& iSector==((p->aFrame[p->nStep].iDbPage-1) / p->nPagePerSector)
&& p->rc==SQLITE_OK
);
}
p->nProgress++;
}
@@ -3718,6 +3753,12 @@ int sqlite3rbu_close(sqlite3rbu *p, char **pzErrmsg){
p->rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, &p->zErrmsg);
}
/* Sync the db file if currently doing an incremental checkpoint */
if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){
sqlite3_file *pDb = p->pTargetFd->pReal;
p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);
}
rbuSaveState(p, p->eStage);
if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){
@@ -3842,6 +3883,12 @@ int sqlite3rbu_savestate(sqlite3rbu *p){
if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, 0);
}
/* Sync the db file */
if( rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){
sqlite3_file *pDb = p->pTargetFd->pReal;
rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);
}
p->rc = rc;
rbuSaveState(p, p->eStage);
rc = p->rc;
+17 -15
View File
@@ -1,5 +1,5 @@
C Cleanup\sthe\susage\sof\sthe\sSQLITE_DISABLE_INTRINSIC\scompile-time\soption.\nRemove\sthe\sSQLITE_RUNTIME_BYTEORDER\scompile-time\soption.\s\sUse\n-DSQLITE_BYTEORDER=0\sinstead.\s\sFix\sa\sbug\sin\sR-Tree\sthat\soccurs\swhen\scompiling\non\sa\sknown\slittle-endian\smachine\swithout\sthe\suse\sof\sintrinsic\sbyteswapping\nfunctions.
D 2017-02-09T17:12:22.122
C Before\sbeginning\san\sincremental\scheckpoint\sin\sRBU,\ssync\sthe\sdirectory\ncontaining\sthe\starget\sdatabase\sfile.\sThis\sensures\sthat\sthe\snew\sdirectory\sentry\ncreated\sby\srenaming\sthe\s*-oal\sfile\sto\s*-wal\sis\ssynced\sto\sdisk.\sCherrypick\sof\n[915a9a28].
D 2017-03-07T14:47:02.385
F Makefile.in edb6bcdd37748d2b1c3422ff727c748df7ffe918
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 067a6766f800cc8d72845ab61f8de4ffe8f3fc99
@@ -248,6 +248,7 @@ F ext/rbu/rbuB.test c25bc325b8072a766e56bb76c001866b405925c2
F ext/rbu/rbuC.test efe47db508a0269b683cb2a1913a425ffd39a831
F ext/rbu/rbu_common.tcl a38e8e2d4a50fd6aaf151633714c1b1d2fae3ead
F ext/rbu/rbucrash.test 8d2ed5d4b05fef6c00c2a6b5f7ead71fa172a695
F ext/rbu/rbucrash2.test b2ecbdd7bb72c88bd217c65bd00dafa07f7f2d4d
F ext/rbu/rbudiff.test 3e605cf624d00d04d0fb1316a3acec4fbe3b3ac5
F ext/rbu/rbudor.test 99b05cc0df613e962c2c8085cfb05686a09cf315
F ext/rbu/rbufault.test cc0be8d5d392d98b0c2d6a51be377ea989250a89
@@ -255,12 +256,12 @@ F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06
F ext/rbu/rbufault3.test 54a399888ac4af44c68f9f58afbed23149428bca
F ext/rbu/rbufault4.test 34e70701cbec51571ffbd9fbf9d4e0f2ec495ca7
F ext/rbu/rbufts.test 828cd689da825f0a7b7c53ffc1f6f7fdb6fa5bda
F ext/rbu/rbuprogress.test e3e25fb7622641b8f2df7c6b7a7eb6fddfc46a4b
F ext/rbu/rbuprogress.test 1849d4e0e50616edf5ce75ce7db86622e656b5cf
F ext/rbu/rburesume.test 8acb77f4a422ff55acfcfc9cc15a5cb210b1de83
F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48
F ext/rbu/rbuvacuum.test 4a977447c15c2581ab668781d9ef4294382530e0
F ext/rbu/rbuvacuum2.test 2074ab14fe66e1c7e7210c62562650dcd215bbaa
F ext/rbu/sqlite3rbu.c bb0de6cdbdb14a7d55a097238a434b7e99caf318
F ext/rbu/sqlite3rbu.c 2a89efba9eeba8e6c89a498dc195e8efbdde2694
F ext/rbu/sqlite3rbu.h 6fb6294c34a9ca93b5894a33bca530c6f08decba
F ext/rbu/test_rbu.c 5aa22616afac6f71ebd3d9bc9bf1006cfabcca88
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
@@ -339,7 +340,7 @@ F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca
F src/btree.c 9fe65ab418d99e80289f024016b5e5e74c3059dd
F src/btree.h e6d352808956ec163a17f832193a3e198b3fb0ac
F src/btreeInt.h 429bbfebae05ab3beb1c4508ba94c292036c660f
F src/btreeInt.h cd55d39d9916270837a88c12e701047cba0729b0
F src/build.c 9e799f1edd910dfa8a0bc29bd390d35d310596af
F src/callback.c 2e76147783386374bf01b227f752c81ec872d730
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
@@ -347,7 +348,7 @@ F src/ctime.c 9f2296a4e5d26ebf0e0d95a0af4628f1ea694e7a
F src/date.c dc3f1391d9297f8c748132813aaffcb117090d6e
F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d
F src/delete.c 0d9d5549d42e79ce4d82ff1db1e6c81e36d2f67c
F src/expr.c d29114e9b709eaeaaa18553a5bbe60a19302aeef
F src/expr.c c218ec8cfc12b2c5b354660ce7285dfaf43305e9
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae
F src/func.c c67273e1ec08abbdcc14c189892a3ff6eeece86b
@@ -372,7 +373,7 @@ F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c
F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85
F src/mutex_noop.c 9d4309c075ba9cc7249e19412d3d62f7f94839c4
F src/mutex_unix.c 27bb6cc49485ee46711a6580ab7b3f1402211d23
F src/mutex_w32.c 00bbf37d80fb763a8159b83cc3cbde0f91d37f7b
F src/mutex_w32.c 3631e57d056062807ae2c92b79f3d1c05f04ecfe
F src/notify.c 9711a7575036f0d3040ba61bc6e217f13a9888e7
F src/os.c add02933b1dce7a39a005b00a2f5364b763e9a24
F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343
@@ -409,7 +410,7 @@ F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
F src/test3.c d03f5b5da9a2410b7a91c64b0d3306ed28ab6fee
F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6
F src/test5.c 328aae2c010c57a9829d255dc099d6899311672d
F src/test6.c 55aa2775c154415dcf4ed7cd1e19a193122b3a02
F src/test6.c e2ed878f1bc7f45d0e441928c3a02788cf73aa1c
F src/test7.c 5612e9aecf934d6df7bba6ce861fdf5ba5456010
F src/test8.c 4f4904721167b32f7a4fa8c7b32a07a673d6cc86
F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5
@@ -475,7 +476,7 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c 40c543f0a2195d1b0dc88ef12142bea690009344
F src/wal.h 06b2a0b599cc0f53ea97f497cf8c6b758c999f71
F src/walker.c 91a6df7435827e41cff6bb7df50ea00934ee78b0
F src/where.c bc71775e23d23334e8f449aa31012d692dc09cb2
F src/where.c b0d81c6f24ea6aebb249c92c5d78ec8ab1452523
F src/whereInt.h 2bcc3d176e6091cb8f50a30b65c006e88a73614d
F src/wherecode.c 99a8ced164c75edf41b3a865a75381c9adb38b28
F src/whereexpr.c 35ad025389a632a3987a35617c878be3b3d70dc6
@@ -867,7 +868,7 @@ F test/index6.test b4fc812290067a578b98bb2667b676db89e202a7
F test/index7.test 7feababe16f2091b229c22aff2bcc1d4d6b9d2bb
F test/index8.test bc2e3db70e8e62459aaa1bd7e4a9b39664f8f9d7
F test/indexedby.test 9c4cd331224e57f79fbf411ae245e6272d415985
F test/indexexpr1.test 7d243fac508b4a99fb900ffe34eb488312cfce84
F test/indexexpr1.test 038b3befa74e5a75126b6e9dd2ae5df61c1c7cf7
F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d
F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
F test/insert.test 38742b5e9601c8f8d76e9b7555f7270288c2d371
@@ -1169,7 +1170,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e
F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637
F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc
F test/tester.tcl 67835ac17e90055f24a9cf52e5c5bce0dd511c74
F test/tester.tcl 581f0185434daf7026ccede4c07e8d1479186ec5
F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
@@ -1555,7 +1556,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 1afec5758b624e6a066d4e7ef50695095e9d7ff1
R d99a1e96a3817ca7543fc882a1f70881
U drh
Z 871c0b5ab0829dba2d37da91622734c8
P 59a11b7f1f4aeefec7102b4859deda70b0b934b9
Q +915a9a28783fbb2f4c0794eb4264ce8c0b9d42f7
R 1d86992c5b1ed821d31ab7205d9b0768
U dan
Z c76854f4a10706e6a8874036088648ec
+1 -1
View File
@@ -1 +1 @@
798fb9d70d2e5f95e64237b04d6692360133381a
694fe0b22bfa13d91f5fcdbe0562cb31334ce017
+1 -1
View File
@@ -694,7 +694,7 @@ struct IntegrityCk {
# define get2byteAligned(x) (*(u16*)(x))
#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4008000
# define get2byteAligned(x) __builtin_bswap16(*(u16*)(x))
#elif SQLITE_BYTEORDER==1234 && MSCV_VERSION>=1300
#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300
# define get2byteAligned(x) _byteswap_ushort(*(u16*)(x))
#else
# define get2byteAligned(x) ((x)[0]<<8 | (x)[1])
+1 -1
View File
@@ -231,7 +231,7 @@ static char comparisonAffinity(Expr *pExpr){
aff = sqlite3CompareAffinity(pExpr->pRight, aff);
}else if( ExprHasProperty(pExpr, EP_xIsSelect) ){
aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff);
}else if( NEVER(aff==0) ){
}else if( aff==0 ){
aff = SQLITE_AFF_BLOB;
}
return aff;
+1 -1
View File
@@ -87,7 +87,7 @@ void sqlite3MemoryBarrier(void){
SQLITE_MEMORY_BARRIER;
#elif defined(__GNUC__)
__sync_synchronize();
#elif MSCV_VERSION>=1300
#elif MSVC_VERSION>=1300
_ReadWriteBarrier();
#elif defined(MemoryBarrier)
MemoryBarrier();
+11 -6
View File
@@ -315,8 +315,9 @@ static int writeListSync(CrashFile *pFile, int isCrash){
assert(pWrite->zBuf);
#ifdef TRACE_CRASHTEST
printf("Trashing %d sectors @ %lld (sector %d) (%s)\n",
1+iLast-iFirst, pWrite->iOffset, iFirst, pWrite->pFile->zName
printf("Trashing %d sectors (%d bytes) @ %lld (sector %d) (%s)\n",
1+iLast-iFirst, (1+iLast-iFirst)*g.iSectorSize,
pWrite->iOffset, iFirst, pWrite->pFile->zName
);
#endif
@@ -827,7 +828,7 @@ static int SQLITE_TCLAPI crashNowCmd(
}
/*
** tclcmd: sqlite_crash_enable ENABLE
** tclcmd: sqlite_crash_enable ENABLE ?DEFAULT?
**
** Parameter ENABLE must be a boolean value. If true, then the "crash"
** vfs is added to the system. If false, it is removed.
@@ -839,6 +840,7 @@ static int SQLITE_TCLAPI crashEnableCmd(
Tcl_Obj *CONST objv[]
){
int isEnable;
int isDefault = 0;
static sqlite3_vfs crashVfs = {
2, /* iVersion */
0, /* szOsFile */
@@ -862,14 +864,17 @@ static int SQLITE_TCLAPI crashEnableCmd(
0, /* xCurrentTimeInt64 */
};
if( objc!=2 ){
Tcl_WrongNumArgs(interp, 1, objv, "ENABLE");
if( objc!=2 && objc!=3 ){
Tcl_WrongNumArgs(interp, 1, objv, "ENABLE ?DEFAULT?");
return TCL_ERROR;
}
if( Tcl_GetBooleanFromObj(interp, objv[1], &isEnable) ){
return TCL_ERROR;
}
if( objc==3 && Tcl_GetBooleanFromObj(interp, objv[2], &isDefault) ){
return TCL_ERROR;
}
if( (isEnable && crashVfs.pAppData) || (!isEnable && !crashVfs.pAppData) ){
return TCL_OK;
@@ -880,7 +885,7 @@ static int SQLITE_TCLAPI crashEnableCmd(
crashVfs.mxPathname = pOriginalVfs->mxPathname;
crashVfs.pAppData = (void *)pOriginalVfs;
crashVfs.szOsFile = sizeof(CrashFile) + pOriginalVfs->szOsFile;
sqlite3_vfs_register(&crashVfs, 0);
sqlite3_vfs_register(&crashVfs, isDefault);
}else{
crashVfs.pAppData = 0;
sqlite3_vfs_unregister(&crashVfs);
+1
View File
@@ -308,6 +308,7 @@ static WhereTerm *whereScanInit(
iColumn = pIdx->aiColumn[j];
if( iColumn==XN_EXPR ){
pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
pScan->zCollName = pIdx->azColl[j];
}else if( iColumn==pIdx->pTable->iPKey ){
iColumn = XN_ROWID;
}else if( iColumn>=0 ){
+10
View File
@@ -370,4 +370,14 @@ do_execsql_test indexexpr1-1200.4 {
0 0 0 2 0 4 2 0 2 2 4 0
}
# Ticket https://www.sqlite.org/src/tktview/eb703ba7b50c1a
# Incorrect result using an index on an expression with a collating function
#
do_execsql_test indexexpr1-1300.1 {
CREATE TABLE t1300(a INTEGER PRIMARY KEY, b);
INSERT INTO t1300 VALUES(1,'coffee'),(2,'COFFEE'),(3,'stress'),(4,'STRESS');
CREATE INDEX t1300bexpr ON t1300( substr(b,4) );
SELECT a FROM t1300 WHERE substr(b,4)='ess' COLLATE nocase ORDER BY +a;
} {3 4}
finish_test
+4 -2
View File
@@ -1533,6 +1533,7 @@ proc crashsql {args} {
set tclbody {}
set crashfile ""
set dc ""
set dfltvfs 0
set sql [lindex $args end]
for {set ii 0} {$ii < [llength $args]-1} {incr ii 2} {
@@ -1546,7 +1547,8 @@ proc crashsql {args} {
elseif {$n>1 && [string first $z -file]==0} {set crashfile $z2} \
elseif {$n>1 && [string first $z -tclbody]==0} {set tclbody $z2} \
elseif {$n>1 && [string first $z -blocksize]==0} {set blocksize "-s $z2" } \
elseif {$n>1 && [string first $z -characteristics]==0} {set dc "-c {$z2}" } \
elseif {$n>1 && [string first $z -characteristics]==0} {set dc "-c {$z2}" }\
elseif {$n>1 && [string first $z -dfltvfs]==0} {set dfltvfs $z2 }\
else { error "Unrecognized option: $z" }
}
@@ -1560,7 +1562,7 @@ proc crashsql {args} {
set cfile [string map {\\ \\\\} [file nativename [file join [get_pwd] $crashfile]]]
set f [open crash.tcl w]
puts $f "sqlite3_crash_enable 1"
puts $f "sqlite3_crash_enable 1 $dfltvfs"
puts $f "sqlite3_crashparams $blocksize $dc $crashdelay $cfile"
puts $f "sqlite3_test_control_pending_byte $::sqlite_pending_byte"