SQLite

Hex Artifact Content
Login

Artifact 614870a83e6b79cb97462eb5cea293864999a071db7c893a9ffeb07164720b9b:

Ticket change [614870a83e] - New ticket [510cde277783b5fb|510cde2777] <i>Endless loop on a query with window functions, ORDER BY, and LIMIT</i>. by drh 2018-09-17 14:28:12.
0000: 44 20 32 30 31 38 2d 30 39 2d 31 37 54 31 34 3a  D 2018-09-17T14:
0010: 32 38 3a 31 32 2e 34 36 31 0a 4a 20 66 6f 75 6e  28:12.461.J foun
0020: 64 69 6e 20 33 2e 32 35 2e 30 0a 4a 20 69 63 6f  din 3.25.0.J ico
0030: 6d 6d 65 6e 74 20 54 68 65 5c 73 66 6f 6c 6c 6f  mment The\sfollo
0040: 77 69 6e 67 5c 73 71 75 65 72 79 5c 73 68 69 74  wing\squery\shit
0050: 73 5c 73 61 6e 5c 73 61 73 73 65 72 74 28 29 5c  s\san\sassert()\
0060: 73 69 6e 5c 73 74 68 65 5c 73 62 79 74 65 2d 63  sin\sthe\sbyte-c
0070: 6f 64 65 5c 73 65 6e 67 69 6e 65 2c 5c 73 6f 72  ode\sengine,\sor
0080: 5c 73 69 66 5c 73 61 73 73 65 72 74 28 29 73 5c  \sif\sassert()s\
0090: 72 5c 6e 61 72 65 5c 73 64 69 73 61 62 6c 65 64  r\nare\sdisabled
00a0: 2c 5c 73 67 6f 65 73 5c 73 69 6e 74 6f 5c 73 61  ,\sgoes\sinto\sa
00b0: 6e 5c 73 65 6e 64 6c 65 73 73 5c 73 6c 6f 6f 70  n\sendless\sloop
00c0: 5c 73 69 6e 5c 73 74 68 65 5c 73 62 79 74 65 5c  \sin\sthe\sbyte\
00d0: 73 63 6f 64 65 2e 5c 72 5c 6e 5c 72 5c 6e 3c 62  scode.\r\n\r\n<b
00e0: 6c 6f 63 6b 71 75 6f 74 65 3e 3c 76 65 72 62 61  lockquote><verba
00f0: 74 69 6d 3e 5c 72 5c 6e 43 52 45 41 54 45 5c 73  tim>\r\nCREATE\s
0100: 54 41 42 4c 45 5c 73 74 31 28 69 64 2c 5c 73 62  TABLE\st1(id,\sb
0110: 2c 5c 73 63 29 3b 5c 72 5c 6e 49 4e 53 45 52 54  ,\sc);\r\nINSERT
0120: 5c 73 49 4e 54 4f 5c 73 74 31 5c 73 56 41 4c 55  \sINTO\st1\sVALU
0130: 45 53 28 31 2c 5c 73 27 41 27 2c 5c 73 27 6f 6e  ES(1,\s'A',\s'on
0140: 65 27 29 3b 5c 72 5c 6e 49 4e 53 45 52 54 5c 73  e');\r\nINSERT\s
0150: 49 4e 54 4f 5c 73 74 31 5c 73 56 41 4c 55 45 53  INTO\st1\sVALUES
0160: 28 32 2c 5c 73 27 42 27 2c 5c 73 27 74 77 6f 27  (2,\s'B',\s'two'
0170: 29 3b 5c 72 5c 6e 49 4e 53 45 52 54 5c 73 49 4e  );\r\nINSERT\sIN
0180: 54 4f 5c 73 74 31 5c 73 56 41 4c 55 45 53 28 33  TO\st1\sVALUES(3
0190: 2c 5c 73 27 43 27 2c 5c 73 27 74 68 72 65 65 27  ,\s'C',\s'three'
01a0: 29 3b 5c 72 5c 6e 49 4e 53 45 52 54 5c 73 49 4e  );\r\nINSERT\sIN
01b0: 54 4f 5c 73 74 31 5c 73 56 41 4c 55 45 53 28 34  TO\st1\sVALUES(4
01c0: 2c 5c 73 27 44 27 2c 5c 73 27 6f 6e 65 27 29 3b  ,\s'D',\s'one');
01d0: 5c 72 5c 6e 49 4e 53 45 52 54 5c 73 49 4e 54 4f  \r\nINSERT\sINTO
01e0: 5c 73 74 31 5c 73 56 41 4c 55 45 53 28 35 2c 5c  \st1\sVALUES(5,\
01f0: 73 27 45 27 2c 5c 73 27 74 77 6f 27 29 3b 5c 72  s'E',\s'two');\r
0200: 5c 6e 53 45 4c 45 43 54 5c 73 69 64 2c 5c 73 62  \nSELECT\sid,\sb
0210: 2c 5c 73 6c 65 61 64 28 63 2c 31 29 5c 73 4f 56  ,\slead(c,1)\sOV
0220: 45 52 28 4f 52 44 45 52 5c 73 42 59 5c 73 63 29  ER(ORDER\sBY\sc)
0230: 5c 73 41 53 5c 73 78 5c 73 46 52 4f 4d 5c 73 74  \sAS\sx\sFROM\st
0240: 31 5c 73 57 48 45 52 45 5c 73 69 64 3e 31 5c 73  1\sWHERE\sid>1\s
0250: 4f 52 44 45 52 5c 73 42 59 5c 73 62 5c 73 4c 49  ORDER\sBY\sb\sLI
0260: 4d 49 54 5c 73 31 3b 5c 72 5c 6e 3c 2f 76 65 72  MIT\s1;\r\n</ver
0270: 62 61 74 69 6d 3e 3c 2f 62 6c 6f 63 6b 71 75 6f  batim></blockquo
0280: 74 65 3e 5c 72 5c 6e 5c 72 5c 6e 54 68 69 73 5c  te>\r\n\r\nThis\
0290: 73 70 72 6f 62 6c 65 6d 5c 73 61 70 70 65 61 72  sproblem\sappear
02a0: 73 5c 73 74 6f 5c 73 68 61 76 65 5c 73 62 65 65  s\sto\shave\sbee
02b0: 6e 5c 73 69 6e 74 72 6f 64 75 63 65 64 5c 73 62  n\sintroduced\sb
02c0: 79 5c 73 63 68 65 63 6b 2d 69 6e 5c 72 5c 6e 5b  y\scheck-in\r\n[
02d0: 32 30 36 37 32 30 31 32 39 65 64 32 66 61 38 38  206720129ed2fa88
02e0: 37 35 61 32 5d 5c 73 77 68 69 63 68 5c 73 77 61  75a2]\swhich\swa
02f0: 73 5c 73 61 5c 73 66 69 78 5c 73 66 6f 72 5c 73  s\sa\sfix\sfor\s
0300: 74 69 63 6b 65 74 5c 72 5c 6e 5b 39 39 33 36 62  ticket\r\n[9936b
0310: 32 66 61 34 34 33 66 65 63 30 33 66 66 32 35 5d  2fa443fec03ff25]
0320: 5c 73 77 68 69 63 68 5c 73 77 61 73 5c 73 74 68  \swhich\swas\sth
0330: 65 5c 73 70 72 65 76 69 6f 75 73 5c 73 70 72 6f  e\sprevious\spro
0340: 62 6c 65 6d 5c 73 6f 66 5c 73 61 6e 5c 72 5c 6e  blem\sof\san\r\n
0350: 65 6e 64 6c 65 73 73 5c 73 6c 6f 6f 70 5c 73 64  endless\sloop\sd
0360: 75 65 5c 73 74 6f 5c 73 74 68 65 5c 73 4f 52 44  ue\sto\sthe\sORD
0370: 45 52 5c 73 42 59 5c 73 4c 49 4d 49 54 5c 73 6f  ER\sBY\sLIMIT\so
0380: 70 74 69 6d 69 7a 61 74 69 6f 6e 2e 0a 4a 20 6c  ptimization..J l
0390: 6f 67 69 6e 20 64 72 68 0a 4a 20 6d 69 6d 65 74  ogin drh.J mimet
03a0: 79 70 65 20 74 65 78 74 2f 78 2d 66 6f 73 73 69  ype text/x-fossi
03b0: 6c 2d 77 69 6b 69 0a 4a 20 73 65 76 65 72 69 74  l-wiki.J severit
03c0: 79 20 53 65 76 65 72 65 0a 4a 20 73 74 61 74 75  y Severe.J statu
03d0: 73 20 4f 70 65 6e 0a 4a 20 74 69 74 6c 65 20 45  s Open.J title E
03e0: 6e 64 6c 65 73 73 5c 73 6c 6f 6f 70 5c 73 6f 6e  ndless\sloop\son
03f0: 5c 73 61 5c 73 71 75 65 72 79 5c 73 77 69 74 68  \sa\squery\swith
0400: 5c 73 77 69 6e 64 6f 77 5c 73 66 75 6e 63 74 69  \swindow\sfuncti
0410: 6f 6e 73 2c 5c 73 4f 52 44 45 52 5c 73 42 59 2c  ons,\sORDER\sBY,
0420: 5c 73 61 6e 64 5c 73 4c 49 4d 49 54 0a 4a 20 74  \sand\sLIMIT.J t
0430: 79 70 65 20 43 6f 64 65 5f 44 65 66 65 63 74 0a  ype Code_Defect.
0440: 4b 20 35 31 30 63 64 65 32 37 37 37 38 33 62 35  K 510cde277783b5
0450: 66 62 35 64 65 36 32 38 33 39 33 39 35 39 38 34  fb5de62839395984
0460: 39 64 66 66 33 37 37 65 62 33 0a 55 20 64 72 68  9dff377eb3.U drh
0470: 0a 5a 20 33 62 39 31 63 34 66 39 66 33 32 34 38  .Z 3b91c4f9f3248
0480: 32 65 32 66 30 36 35 66 36 62 61 33 65 35 66 63  2e2f065f6ba3e5fc
0490: 31 35 32 0a                                      152.