SQLite

Artifact [51389ac4]
Login

Artifact 51389ac452f6999ef9b033d0d4a0a7ef15c51c15:

Ticket change [51389ac4] - New ticket [0c4df461] Incorrect result with ORDER BY DESC and LIMIT. by drh 2016-09-07 00:42:45.
D 2016-09-07T00:42:45.588
J foundin 3.14.1
J icomment In\sthe\sfollowing\sSQL,\sthe\sfirst\squery\sgives\sthe\scorrect\s3\slines\sof\sresult\r\nin\sthe\scorrect\sorder.\s\sBut\sthe\ssecond\squery\sreturns\sthe\ssecond\sline\sof\sresult,\r\nnot\sthe\sfirst\sline\sas\sit\sshould:\r\n\r\n<blockquote><pre>\r\nCREATE\sTABLE\st1(a,b,c);\r\nCREATE\sINDEX\st1x\sON\st1(a,b,c);\r\nINSERT\sINTO\st1\sVALUES(0,1,99),(0,1,0),(0,0,0);\r\nSELECT\s*\sFROM\st1\sWHERE\sa=0\sAND\s(c=0\sOR\sc=99)\sORDER\sBY\sc\sDESC;\r\nSELECT\s*\sFROM\st1\sWHERE\sa=0\sAND\s(c=0\sOR\sc=99)\sORDER\sBY\sc\sDESC\sLIMIT\s1;\r\n</pre></blockquote>\r\n\r\nThis\sproblem\sseems\sto\shave\sbeen\sintroduced\sby\scheck-in\s[559733b09e96]\r\non\s2016-05-20\sand\swas\sreleased\swith\sversion\s3.14.0.
J login drh
J mimetype text/x-fossil-wiki
J severity Severe
J status Open
J title Incorrect\sresult\swith\sORDER\sBY\sDESC\sand\sLIMIT
J type Code_Defect
K 0c4df46116e90f927a54103c4ed82a825a18763f
U drh
Z ac1ddae2f7ea537ca1978e25c2e2b86f