-C Fix\sa\spair\sof\sassert()s\sin\s"PRAGMA\sforeign_key_check"\sthat\smight\shave\sgiven\na\sfalse-positive\sfollowing\san\sOOM.
-D 2020-09-16T19:48:23.775
+C DISTINCT\smay\snot\sbe\signored\sinside\sa\sUNION\sALL\scommon\stable\sexpression.\nFix\sfor\sticket\s[c51489c3b8f919c5]
+D 2020-09-17T00:46:09.055
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c 97b91fb25d86881ff20c9ad2ad98412c6c1bb5f7d6c9bb044db250cbc9cfcd4b
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
-F src/select.c 233e884d7da6601486c7b93aedb97fd29302ae5c03742d0e0eccb4790638bb77
+F src/select.c 6c3f7d60295f06ce7fa128bb23b1159648f0aa96a78c257af35dfef727ac63f1
F src/shell.c.in 0fd9eca42731d94a293d7b12a76c6614976f8bdbb2874768ad2e6ddbb86dffd8
F src/sqlite.h.in 11896ccb28f85b0aa52f0d4169aaca0ed7cf3f9b3e0c544aecee0032ae2b3c2e
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 2d1af80082edffd71c6f96f70ad1ce6a4fb46615ad10291fc77fe0dea9ff0197
-F src/sqliteInt.h d8d69318b1ba3906d4860da1cd1c6b3650b81c9595e5bc360c6469a1e54e09e1
+F src/sqliteInt.h 34319c13e900063b267052168b277c7bc1e124a1ceef457e450d53ce618bb96e
F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657
F src/status.c 4b8bc2a6905163a38b739854a35b826c737333fab5b1f8e03fa7eb9a4799c4c1
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
F test/windowerr.tcl f5acd6fbc210d7b5546c0e879d157888455cd4a17a1d3f28f07c1c8a387019e0
F test/windowerr.test a8b752402109c15aa1c5efe1b93ccb0ce1ef84fa964ae1cd6684dd0b3cc1819b
F test/windowfault.test 72375ae71031eabf96bc88d0af128c8628a091ddc99b5a394e848b3df5fc17ad
-F test/with1.test 584580a5ae79868a91873863f8cb2d00040006dc1e4c332ef1d8642f2815dc6e
+F test/with1.test 323659eaf309787add657d05e5943e437a7a3494f2b6602a0deb18fdebc1ab4c
F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1ab
F test/with3.test 13b3336739da648a9e4dfa11bb04e73a920c97620041007c5f75d5d14084c346
F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 6c94ba4b1c16b676978808dcb24f63c2f22915af5dcfe9f635c037011affcf4b
-R 38e8b34a5e2ff3cf94eaf76807abdad3
+P 9ea3039b538ffd0f348c8fbc9452af1fbf899a1f668af9a2404bdd0f8dd21351
+R 5bf1eaed1b0f62e19f1e327d7467bbe1
U drh
-Z 188d1d8f2a6059fab39eb41cb4a67396
+Z 6e1d5387493b3a726ae70a6af2467d64
-9ea3039b538ffd0f348c8fbc9452af1fbf899a1f668af9a2404bdd0f8dd21351
\ No newline at end of file
+7d2b590d3abd66a7e6ae9046198eb669e0fd2f223f7691281e9ad795a12b8903
\ No newline at end of file
assert( p->pOrderBy==0 || pDest->eDest!=SRT_Fifo );
assert( p->pOrderBy==0 || pDest->eDest!=SRT_DistQueue );
assert( p->pOrderBy==0 || pDest->eDest!=SRT_Queue );
- if( IgnorableOrderby(pDest) ){
- assert(pDest->eDest==SRT_Exists || pDest->eDest==SRT_Union ||
- pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard ||
- pDest->eDest==SRT_Queue || pDest->eDest==SRT_DistFifo ||
- pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_Fifo);
- /* If ORDER BY makes no difference in the output then neither does
- ** DISTINCT so it can be removed too. */
+ if( IgnorableDistinct(pDest) ){
+ assert(pDest->eDest==SRT_Exists || pDest->eDest==SRT_Union ||
+ pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard ||
+ pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_DistFifo );
+ /* All of these destinations are also able to ignore the ORDER BY clause */
sqlite3ExprListDelete(db, p->pOrderBy);
p->pOrderBy = 0;
p->selFlags &= ~SF_Distinct;
** statements within triggers whose only purpose is
** the side-effects of functions.
**
-** All of the above are free to ignore their ORDER BY clause. Those that
-** follow must honor the ORDER BY clause.
-**
** SRT_Output Generate a row of output (using the OP_ResultRow
** opcode) for each row in the result set.
**
#define SRT_Except 2 /* Remove result from a UNION index */
#define SRT_Exists 3 /* Store 1 if the result is not empty */
#define SRT_Discard 4 /* Do not save the results anywhere */
-#define SRT_Fifo 5 /* Store result as data with an automatic rowid */
-#define SRT_DistFifo 6 /* Like SRT_Fifo, but unique results only */
+#define SRT_DistFifo 5 /* Like SRT_Fifo, but unique results only */
+#define SRT_DistQueue 6 /* Like SRT_Queue, but unique results only */
+
+/* The DISTINCT clause is ignored for all of the above. Not that
+** IgnorableDistinct() implies IgnorableOrderby() */
+#define IgnorableDistinct(X) ((X->eDest)<=SRT_DistQueue)
+
#define SRT_Queue 7 /* Store result in an queue */
-#define SRT_DistQueue 8 /* Like SRT_Queue, but unique results only */
+#define SRT_Fifo 8 /* Store result as data with an automatic rowid */
/* The ORDER BY clause is ignored for all of the above */
-#define IgnorableOrderby(X) ((X->eDest)<=SRT_DistQueue)
+#define IgnorableOrderby(X) ((X->eDest)<=SRT_Fifo)
#define SRT_Output 9 /* Output each row of result */
#define SRT_Mem 10 /* Store result in a memory cell */
SELECT x,O. * O FROM i ¬I,I? 10;
} {1 {near "O": syntax error}}
+# 2020-09-17 ticket c51489c3b8f919c5
+# DISTINCT cannot be ignored in a UNION ALL recursive CTE
+#
+reset_db
+do_execsql_test 26.1 {
+ CREATE TABLE t (label VARCHAR(10), step INTEGER);
+ INSERT INTO T VALUES('a', 1);
+ INSERT INTO T VALUES('a', 1);
+ INSERT INTO T VALUES('b', 1);
+ WITH RECURSIVE cte(label, step) AS (
+ SELECT DISTINCT * FROM t
+ UNION ALL
+ SELECT label, step + 1 FROM cte WHERE step < 3
+ )
+ SELECT * FROM cte ORDER BY +label, +step;
+} {a 1 a 2 a 3 b 1 b 2 b 3}
+do_execsql_test 26.2 {
+ WITH RECURSIVE cte(label, step) AS (
+ SELECT * FROM t
+ UNION
+ SELECT label, step + 1 FROM cte WHERE step < 3
+ )
+ SELECT * FROM cte ORDER BY +label, +step;
+} {a 1 a 2 a 3 b 1 b 2 b 3}
+do_execsql_test 26.3 {
+ CREATE TABLE tworow(x);
+ INSERT INTO tworow(x) VALUES(1),(2);
+ DELETE FROM t WHERE rowid=2;
+ WITH RECURSIVE cte(label, step) AS (
+ SELECT * FROM t
+ UNION ALL
+ SELECT DISTINCT label, step + 1 FROM cte, tworow WHERE step < 3
+ )
+ SELECT * FROM cte ORDER BY +label, +step;
+} {a 1 a 2 a 3 b 1 b 2 b 3}
+
finish_test