From: dan Date: Tue, 2 Aug 2016 18:50:15 +0000 (+0000) Subject: Add tests and fixes for vector operations that use sub-queries with different combina... X-Git-Tag: version-3.15.0~110^2~88 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=51d82d1d2443c55669c60630ed28d55ae03a57b0;p=thirdparty%2Fsqlite.git Add tests and fixes for vector operations that use sub-queries with different combinations of LIMIT, OFFSET and ORDER BY clauses. FossilOrigin-Name: 092b1c5ff53c9f3cfed079c46e3353d93f99303e --- diff --git a/manifest b/manifest index c6971b1622..b7b01adb06 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sSQLITE_OMIT_SUBQUERY\sbuilds. -D 2016-08-02T17:45:00.556 +C Add\stests\sand\sfixes\sfor\svector\soperations\sthat\suse\ssub-queries\swith\sdifferent\scombinations\sof\sLIMIT,\sOFFSET\sand\sORDER\sBY\sclauses. +D 2016-08-02T18:50:15.542 F Makefile.in 6c20d44f72d4564f11652b26291a214c8367e5db F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 3340e479e5221f06c3d61726f8f7efff885e4233 @@ -383,7 +383,7 @@ F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c cca3aa77b95706df5d635a2141a4d1de60ae6598 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac -F src/select.c 952aa1b4148ed4c0024586e9049b8742a765c6f9 +F src/select.c 228eec644a778a31763b3d384d1ee1a5e3cf2349 F src/shell.c 79dda477be6c96eba6e952a934957ad36f87acc7 F src/sqlite.h.in e011dcc3942e6ddc8dd7b894e9e6702e4269161e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -1021,7 +1021,7 @@ F test/rowid.test 5b7509f384f4f6fae1af3c8c104c8ca299fea18d F test/rowvalue.test 56b34d31d91340a6e922e753b798880170cc1aa7 F test/rowvalue2.test 8d5dfe75b8f4d1868a2f91f0356f20d36cba64ff F test/rowvalue3.test dbe935260851b197dfbbbcb0ac2a15cb5f324fd4 -F test/rowvalue4.test 9e720652d4db9ef3bea50227c69e33d7e64801c6 +F test/rowvalue4.test 9aa6a5efe6069b34bcbefe004bb481cdaaca0dc5 F test/rtree.test 0c8d9dd458d6824e59683c19ab2ffa9ef946f798 F test/run-wordcount.sh 891e89c4c2d16e629cd45951d4ed899ad12afc09 F test/savepoint.test c671fdbd34cd3bfe1518a777526ada595180cf8d @@ -1513,7 +1513,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e2ad30c8b5366fd8e50f36c62345ed03ec613c47 -R 4d69da3a911755cf5dde753475b8adf2 +P 339f85f414a484e44d2502d1ff7281caf9b7c838 +R c52410c242ecf248d644374975097b8c U dan -Z aa590e568ce86faba8eaef4a3eef0582 +Z 38a047c096aac032ca966b61ad2f4616 diff --git a/manifest.uuid b/manifest.uuid index fc2a84a3ab..eacf0abe20 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -339f85f414a484e44d2502d1ff7281caf9b7c838 \ No newline at end of file +092b1c5ff53c9f3cfed079c46e3353d93f99303e \ No newline at end of file diff --git a/src/select.c b/src/select.c index 6aba96730a..7bcf3eca16 100644 --- a/src/select.c +++ b/src/select.c @@ -873,7 +873,8 @@ static void selectInnerLoop( ** ORDER BY in this case since the order of entries in the set ** does not matter. But there might be a LIMIT clause, in which ** case the order does matter */ - pushOntoSorter(pParse, pSort, p, regResult, regResult, 1, nPrefixReg); + pushOntoSorter( + pParse, pSort, p, regResult, regResult, nResultCol, nPrefixReg); }else{ int r1 = sqlite3GetTempReg(pParse); assert( sqlite3Strlen30(pDest->zAffSdst)==nResultCol ); @@ -1221,6 +1222,10 @@ static void generateSortTail( regRowid = 0; regRow = pDest->iSdst; nSortData = nColumn; + }else if( eDest==SRT_Set ){ + regRowid = sqlite3GetTempReg(pParse); + regRow = sqlite3GetTempRange(pParse, nColumn); + nSortData = nColumn; }else{ regRowid = sqlite3GetTempReg(pParse); regRow = sqlite3GetTempReg(pParse); @@ -1285,7 +1290,11 @@ static void generateSortTail( } } if( regRowid ){ - sqlite3ReleaseTempReg(pParse, regRow); + if( eDest==SRT_Set ){ + sqlite3ReleaseTempRange(pParse, regRow, nColumn); + }else{ + sqlite3ReleaseTempReg(pParse, regRow); + } sqlite3ReleaseTempReg(pParse, regRowid); } /* The bottom of the loop diff --git a/test/rowvalue4.test b/test/rowvalue4.test index ccae0498e1..c0e0933ebd 100644 --- a/test/rowvalue4.test +++ b/test/rowvalue4.test @@ -92,6 +92,9 @@ foreach {nm idx} { idx4 { CREATE INDEX t2abc ON t2(a DESC, b DESC, c DESC); } idx5 { CREATE INDEX t2abc ON t2(a ASC, b ASC, c ASC); } idx6 { CREATE INDEX t2abc ON t2(a DESC, b, c); } + idx7 { CREATE INDEX t2abc ON t2(a DESC, b DESC) } + idx8 { CREATE INDEX t2abc ON t2(c, b, a); } + idx9 { CREATE INDEX t2d ON t2(d); } } { drop_all_indexes execsql $idx @@ -101,10 +104,45 @@ foreach {nm idx} { 2 "(a, b, c) <= (2, 2, 2)" {1 2 3 4 5 6 7 8 9 10 11 12 13 14} 3 "(a, b, c) > (2, 2, 2)" {15 16 17 18 19 20 21 22 23 24 25 26 27} 4 "(a, b, c) >= (2, 2, 2)" {14 15 16 17 18 19 20 21 22 23 24 25 26 27} + 5 "(a, b, c) >= (2, 2, NULL)" {16 17 18 19 20 21 22 23 24 25 26 27} + 6 "(a, b, c) <= (2, 2, NULL)" {1 2 3 4 5 6 7 8 9 10 11 12} + 7 "(a, b, c) >= (2, NULL, NULL)" {19 20 21 22 23 24 25 26 27} + 8 "(a, b, c) <= (2, NULL, NULL)" {1 2 3 4 5 6 7 8 9} + + 9 "(a, b, c) < (SELECT a, b, c FROM t2 WHERE d=14)" + {1 2 3 4 5 6 7 8 9 10 11 12 13} + + 10 "(a, b, c) = (SELECT a, b, c FROM t2 WHERE d=14)" 14 } { set result [db eval "SELECT d FROM t2 WHERE $where"] - do_test 2.$nm.$tn { lsort -integer $result } $res + do_test 2.1.$nm.$tn { lsort -integer $result } $res + } + + foreach {tn e res} { + 1 "(2, 1) IN (SELECT a, b FROM t2)" 1 + 2 "(2, 1) IN (SELECT a, b FROM t2 ORDER BY d)" 1 + 3 "(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 9)" 0 + 4 "(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 10)" 1 + + 5 "(3, 3) = (SELECT a, b FROM t2 ORDER BY d DESC LIMIT 1)" 1 + 6 "(3, 3) = (SELECT a, b FROM t2 ORDER BY d ASC LIMIT 1)" 0 + 7 "(1, NULL) = (SELECT a, b FROM t2 ORDER BY d ASC LIMIT 1)" {{}} + + 8 "(3, 1) = (SELECT b, c FROM t2 ORDER BY d DESC LIMIT 1 OFFSET 2)" 1 + 9 "(3, 1) = (SELECT b, c FROM t2 ORDER BY d ASC LIMIT 1 OFFSET 2)" 0 + 10 "(1, NULL) = (SELECT b, c FROM t2 ORDER BY d ASC LIMIT 1 OFFSET 2)" {{}} + + 11 "(3, 3) = (SELECT max(a), max(b) FROM t2)" 1 + 12 "(3, 1) = (SELECT max(a), min(b) FROM t2)" 1 + 13 "(NULL, NULL) = (SELECT max(a), min(b) FROM t2)" {{}} + + 14 "(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 5 OFFSET 11)" 1 + 15 "(2, 1) IN (SELECT a, b FROM t2 ORDER BY d LIMIT 5 OFFSET 12)" 0 + } { + do_execsql_test 2.2.$nm.$tn "SELECT $e" $res } } + + finish_test