Make sure internal queries are well ordered, even when the

reverse_unordered_selects pragma is in effect.
Ticket [eb942c64a157].

FossilOrigin-Name: 0209f17180065d9c213b6c437be1c3c40660665f
This commit is contained in:
drh 2010-01-12 23:54:14 +00:00
parent 2b1e690ff1
commit 6a9c64b363
7 changed files with 49 additions and 17 deletions

View File

@ -1,8 +1,8 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Fix\sthe\simplementation\sof\sCURRENT_TIMESTAME\sand\sCURRENT_DATE\swhen\s\nSQLITE_OMIT_DATETIME_FUNCS\sis\sdefined.
D 2010-01-12T19:28:20
C Make\ssure\sinternal\squeries\sare\swell\sordered,\seven\swhen\sthe\s\nreverse_unordered_selects\spragma\sis\sin\seffect.\nTicket\s[eb942c64a157].
D 2010-01-12T23:54:15
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -160,7 +160,7 @@ F src/pcache.c 3b079306376e0e04c0d3df40c0a4b750a1839310
F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050
F src/pcache1.c 2bb2261190b42a348038f5b1c285c8cef415fcc8
F src/pragma.c 6936d7df5e04b9f996f8f320d15e65b6944b2caa
F src/prepare.c 170bd953058efe1c46b8ad9020d49cd6f40f0b45
F src/prepare.c d4cd38ccfb51f1424d0e61d4878a810b7e1ebb60
F src/printf.c 644bc7d59df3dc56d6d8b9a510914bfc6b51bc69
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/resolve.c 56ecd50851afa9dbcc1803ef86a9b17b3f3d3b89
@ -211,8 +211,8 @@ F src/trigger.c d46f9389e3bf3dd1cc1d288aba2f289c96b34200
F src/update.c c0dc6b75ad28b76b619042d934f337b02acee208
F src/utf.c dad16adcc0c35ef2437dca125a4b07419d361052
F src/util.c ad4f03079ba0fe83590d1cc9197e8e4844e38592
F src/vacuum.c db6415fd0f1be191e16228457a6deb9f232e6ad6
F src/vdbe.c 9035d0ec1ba8e9268d024c9c08fd258479a7fdb6
F src/vacuum.c 28ee5a4963d16cf2477075d85966c0f461cd79de
F src/vdbe.c 1e2c66f2612275a26e156889ec123e8e13c4821d
F src/vdbe.h bea1f0cd530775bdb58a340265f3cf3ee920e9b2
F src/vdbeInt.h d7ea821ac7813c9bea0fe87558c35e07b2c7c44d
F src/vdbeapi.c fc3787eb2f5487d4cc3444de42d56f2e39d311f5
@ -244,7 +244,7 @@ F test/attach2.test a295d2d7061adcee5884ef4a93c7c96a82765437
F test/attach3.test bd9830bc3a0d22ed1310c9bff6896927937017dc
F test/attachmalloc.test cf8cf17d183de357b1147a9baacbdfc85b940b61
F test/auth.test 8f21c160a4562f54f27618e85bac869efcecbcaf
F test/auth2.test ee3ba272e2b975e913afc9b041ee75706e190005
F test/auth2.test 270baddc8b9c273682760cffba6739d907bd2882
F test/auth3.test a4755e6a2a2fea547ffe63c874eb569e60a28eb5
F test/autoinc.test 85ef3180a737e6580086a018c09c6f1a52759b46
F test/autovacuum.test 25f891bc343a8bf5d9229e2e9ddab9f31a9ab5ec
@ -755,7 +755,7 @@ F test/where7.test fdd58ab9dec9f97679e65d4414bf5e07d725d79f
F test/where8.test 2bb8ea44b745fcc93db150fac9ce33d12e499760
F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739
F test/where9.test be19e1a92f80985c1a121b4678bf7d2123eaa623
F test/whereA.test 1d1674254614147c866ab9b59af6582f454a858c
F test/whereA.test 24c234263c8fe358f079d5e57d884fb569d2da0a
F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5
F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31
F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688
@ -788,14 +788,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P dd9689b7c31861484f8d8062478ae73d3c940902
R e91e57338cb8f293a4bb9b23c125a66b
P eb98265b59db59965b468a7070739921da55efc4
R ed4967f5e7e47f15b9f1daec9413d761
U drh
Z 53dae532f59a801426d68826b9c81461
Z 07b5603b06b78d336c9358d46fc99880
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFLTM1XoxKgR168RlERAjdBAJ9w5UHXdiEuVz7cQHXUtE7S8TVG3gCgiDHp
XJDT0231aWBlk4lbq8Tk25c=
=U05+
iD8DBQFLTQuqoxKgR168RlERAkKNAJ4qC7gYLFTHRR/AwFe8MLPwRiJ4+gCfSKF2
WfQSwlim3QhCopfECpNmEtA=
=Ri4P
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
eb98265b59db59965b468a7070739921da55efc4
0209f17180065d9c213b6c437be1c3c40660665f

View File

@ -315,7 +315,7 @@ static int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg){
{
char *zSql;
zSql = sqlite3MPrintf(db,
"SELECT name, rootpage, sql FROM '%q'.%s",
"SELECT name, rootpage, sql FROM '%q'.%s ORDER BY rowid",
db->aDb[iDb].zName, zMasterName);
(void)sqlite3SafetyOff(db);
#ifndef SQLITE_OMIT_AUTHORIZATION

View File

@ -104,7 +104,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
saved_nTotalChange = db->nTotalChange;
saved_xTrace = db->xTrace;
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
db->flags &= ~SQLITE_ForeignKeys;
db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder);
db->xTrace = 0;
pMain = db->aDb[0].pBt;

View File

@ -4576,7 +4576,7 @@ case OP_ParseSchema: {
initData.iDb = pOp->p1;
initData.pzErrMsg = &p->zErrMsg;
zSql = sqlite3MPrintf(db,
"SELECT name, rootpage, sql FROM '%q'.%s WHERE %s",
"SELECT name, rootpage, sql FROM '%q'.%s WHERE %s ORDER BY rowid",
db->aDb[iDb].zName, zMaster, pOp->p4.z);
if( zSql==0 ){
rc = SQLITE_NOMEM;

View File

@ -102,6 +102,7 @@ SQLITE_READ sqlite_master name main {}
SQLITE_READ sqlite_master rootpage main {}
SQLITE_READ sqlite_master sql main {}
SQLITE_READ sqlite_master tbl_name main {}
SQLITE_READ sqlite_master ROWID main {}
}
do_test auth2-2.2 {
set ::authargs {}
@ -121,6 +122,7 @@ SQLITE_READ sqlite_master name main {}
SQLITE_READ sqlite_master rootpage main {}
SQLITE_READ sqlite_master sql main {}
SQLITE_READ sqlite_master tbl_name main {}
SQLITE_READ sqlite_master ROWID main {}
}
do_test auth2-2.3 {
set ::authargs {}

View File

@ -33,11 +33,41 @@ do_test whereA-1.2 {
} {3 4.53 {} 2 hello world 1 2 3}
do_test whereA-1.3 {
db close
sqlite3 db test.db
db eval {
PRAGMA reverse_unordered_selects=1;
SELECT * FROM t1;
}
} {3 4.53 {} 2 hello world 1 2 3}
do_test whereA-1.4 {
db close
sqlite3 db test.db
db eval {
PRAGMA reverse_unordered_selects=1;
SELECT * FROM t1 ORDER BY rowid;
}
} {1 2 3 2 hello world 3 4.53 {}}
do_test whereA-1.5 {
db eval {
VACUUM;
SELECT * FROM t1 ORDER BY rowid;
}
} {1 2 3 2 hello world 3 4.53 {}}
do_test whereA-1.6 {
db eval {
PRAGMA reverse_unordered_selects;
}
} {1}
do_test whereA-1.7 {
db close
sqlite3 db test.db
db eval {
PRAGMA reverse_unordered_selects=1;
VACUUM;
SELECT * FROM t1;
}
} {3 4.53 {} 2 hello world 1 2 3}
do_test whereA-2.1 {
db eval {