OLD | NEW |
1 # 2001 September 15 | 1 # 2001 September 15 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 # Verify that queries use an index. We are using the special variable | 60 # Verify that queries use an index. We are using the special variable |
61 # "sqlite_search_count" which tallys the number of executions of MoveTo | 61 # "sqlite_search_count" which tallys the number of executions of MoveTo |
62 # and Next operators in the VDBE. By verifing that the search count is | 62 # and Next operators in the VDBE. By verifing that the search count is |
63 # small we can be assured that indices are being used properly. | 63 # small we can be assured that indices are being used properly. |
64 # | 64 # |
65 do_test where-1.1.1 { | 65 do_test where-1.1.1 { |
66 count {SELECT x, y, w FROM t1 WHERE w=10} | 66 count {SELECT x, y, w FROM t1 WHERE w=10} |
67 } {3 121 10 3} | 67 } {3 121 10 3} |
68 do_test where-1.1.2 { | 68 do_eqp_test where-1.1.2 { |
69 set sqlite_query_plan | 69 SELECT x, y, w FROM t1 WHERE w=10 |
70 } {t1 i1w} | 70 } {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} |
71 do_test where-1.1.3 { | 71 do_test where-1.1.3 { |
72 db status step | 72 db status step |
73 } {0} | 73 } {0} |
74 do_test where-1.1.4 { | 74 do_test where-1.1.4 { |
75 db eval {SELECT x, y, w FROM t1 WHERE +w=10} | 75 db eval {SELECT x, y, w FROM t1 WHERE +w=10} |
76 } {3 121 10} | 76 } {3 121 10} |
77 do_test where-1.1.5 { | 77 do_test where-1.1.5 { |
78 db status step | 78 db status step |
79 } {99} | 79 } {99} |
80 do_test where-1.1.6 { | 80 do_eqp_test where-1.1.6 { |
81 set sqlite_query_plan | 81 SELECT x, y, w FROM t1 WHERE +w=10 |
82 } {t1 {}} | 82 } {*SCAN TABLE t1*} |
83 do_test where-1.1.7 { | 83 do_test where-1.1.7 { |
84 count {SELECT x, y, w AS abc FROM t1 WHERE abc=10} | 84 count {SELECT x, y, w AS abc FROM t1 WHERE abc=10} |
85 } {3 121 10 3} | 85 } {3 121 10 3} |
86 do_test where-1.1.8 { | 86 do_eqp_test where-1.1.8 { |
87 set sqlite_query_plan | 87 SELECT x, y, w AS abc FROM t1 WHERE abc=10 |
88 } {t1 i1w} | 88 } {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} |
89 do_test where-1.1.9 { | 89 do_test where-1.1.9 { |
90 db status step | 90 db status step |
91 } {0} | 91 } {0} |
92 do_test where-1.2.1 { | 92 do_test where-1.2.1 { |
93 count {SELECT x, y, w FROM t1 WHERE w=11} | 93 count {SELECT x, y, w FROM t1 WHERE w=11} |
94 } {3 144 11 3} | 94 } {3 144 11 3} |
95 do_test where-1.2.2 { | 95 do_test where-1.2.2 { |
96 count {SELECT x, y, w AS abc FROM t1 WHERE abc=11} | 96 count {SELECT x, y, w AS abc FROM t1 WHERE abc=11} |
97 } {3 144 11 3} | 97 } {3 144 11 3} |
98 do_test where-1.3.1 { | 98 do_test where-1.3.1 { |
99 count {SELECT x, y, w AS abc FROM t1 WHERE 11=w} | 99 count {SELECT x, y, w AS abc FROM t1 WHERE 11=w} |
100 } {3 144 11 3} | 100 } {3 144 11 3} |
101 do_test where-1.3.2 { | 101 do_test where-1.3.2 { |
102 count {SELECT x, y, w AS abc FROM t1 WHERE 11=abc} | 102 count {SELECT x, y, w AS abc FROM t1 WHERE 11=abc} |
103 } {3 144 11 3} | 103 } {3 144 11 3} |
104 do_test where-1.4.1 { | 104 do_test where-1.4.1 { |
105 count {SELECT w, x, y FROM t1 WHERE 11=w AND x>2} | 105 count {SELECT w, x, y FROM t1 WHERE 11=w AND x>2} |
106 } {11 3 144 3} | 106 } {11 3 144 3} |
107 do_test where-1.4.2 { | 107 do_eqp_test where-1.4.2 { |
108 set sqlite_query_plan | 108 SELECT w, x, y FROM t1 WHERE 11=w AND x>2 |
109 } {t1 i1w} | 109 } {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} |
110 do_test where-1.4.3 { | 110 do_test where-1.4.3 { |
111 count {SELECT w AS a, x AS b, y FROM t1 WHERE 11=a AND b>2} | 111 count {SELECT w AS a, x AS b, y FROM t1 WHERE 11=a AND b>2} |
112 } {11 3 144 3} | 112 } {11 3 144 3} |
113 do_test where-1.4.4 { | 113 do_eqp_test where-1.4.4 { |
114 set sqlite_query_plan | 114 SELECT w AS a, x AS b, y FROM t1 WHERE 11=a AND b>2 |
115 } {t1 i1w} | 115 } {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} |
116 do_test where-1.5 { | 116 do_test where-1.5 { |
117 count {SELECT x, y FROM t1 WHERE y<200 AND w=11 AND x>2} | 117 count {SELECT x, y FROM t1 WHERE y<200 AND w=11 AND x>2} |
118 } {3 144 3} | 118 } {3 144 3} |
119 do_test where-1.5.2 { | 119 do_eqp_test where-1.5.2 { |
120 set sqlite_query_plan | 120 SELECT x, y FROM t1 WHERE y<200 AND w=11 AND x>2 |
121 } {t1 i1w} | 121 } {*SEARCH TABLE t1 USING INDEX i1w (w=?)*} |
122 do_test where-1.6 { | 122 do_test where-1.6 { |
123 count {SELECT x, y FROM t1 WHERE y<200 AND x>2 AND w=11} | 123 count {SELECT x, y FROM t1 WHERE y<200 AND x>2 AND w=11} |
124 } {3 144 3} | 124 } {3 144 3} |
125 do_test where-1.7 { | 125 do_test where-1.7 { |
126 count {SELECT x, y FROM t1 WHERE w=11 AND y<200 AND x>2} | 126 count {SELECT x, y FROM t1 WHERE w=11 AND y<200 AND x>2} |
127 } {3 144 3} | 127 } {3 144 3} |
128 do_test where-1.8 { | 128 do_test where-1.8 { |
129 count {SELECT x, y FROM t1 WHERE w>10 AND y=144 AND x=3} | 129 count {SELECT x, y FROM t1 WHERE w>10 AND y=144 AND x=3} |
130 } {3 144 3} | 130 } {3 144 3} |
131 do_test where-1.8.2 { | 131 do_eqp_test where-1.8.2 { |
132 set sqlite_query_plan | 132 SELECT x, y FROM t1 WHERE w>10 AND y=144 AND x=3 |
133 } {t1 i1xy} | 133 } {*SEARCH TABLE t1 USING INDEX i1xy (x=? AND y=?)*} |
134 do_test where-1.8.3 { | 134 do_eqp_test where-1.8.3 { |
135 count {SELECT x, y FROM t1 WHERE y=144 AND x=3} | 135 SELECT x, y FROM t1 WHERE y=144 AND x=3 |
136 set sqlite_query_plan | 136 } {*SEARCH TABLE t1 USING COVERING INDEX i1xy (x=? AND y=?)*} |
137 } {{} i1xy} | |
138 do_test where-1.9 { | 137 do_test where-1.9 { |
139 count {SELECT x, y FROM t1 WHERE y=144 AND w>10 AND x=3} | 138 count {SELECT x, y FROM t1 WHERE y=144 AND w>10 AND x=3} |
140 } {3 144 3} | 139 } {3 144 3} |
141 do_test where-1.10 { | 140 do_test where-1.10 { |
142 count {SELECT x, y FROM t1 WHERE x=3 AND w>=10 AND y=121} | 141 count {SELECT x, y FROM t1 WHERE x=3 AND w>=10 AND y=121} |
143 } {3 121 3} | 142 } {3 121 3} |
144 do_test where-1.11 { | 143 do_test where-1.11 { |
145 count {SELECT x, y FROM t1 WHERE x=3 AND y=100 AND w<10} | 144 count {SELECT x, y FROM t1 WHERE x=3 AND y=100 AND w<10} |
146 } {3 100 3} | 145 } {3 100 3} |
147 | 146 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 count {SELECT w FROM t1 WHERE w>96 AND w==97} | 230 count {SELECT w FROM t1 WHERE w>96 AND w==97} |
232 } {97 2} | 231 } {97 2} |
233 do_test where-1.33.5 { | 232 do_test where-1.33.5 { |
234 count {SELECT w FROM t1 WHERE w==97 AND w==97} | 233 count {SELECT w FROM t1 WHERE w==97 AND w==97} |
235 } {97 2} | 234 } {97 2} |
236 do_test where-1.34 { | 235 do_test where-1.34 { |
237 count {SELECT w FROM t1 WHERE w+1==98} | 236 count {SELECT w FROM t1 WHERE w+1==98} |
238 } {97 99} | 237 } {97 99} |
239 do_test where-1.35 { | 238 do_test where-1.35 { |
240 count {SELECT w FROM t1 WHERE w<3} | 239 count {SELECT w FROM t1 WHERE w<3} |
241 } {1 2 2} | 240 } {1 2 3} |
242 do_test where-1.36 { | 241 do_test where-1.36 { |
243 count {SELECT w FROM t1 WHERE w<=3} | 242 count {SELECT w FROM t1 WHERE w<=3} |
244 } {1 2 3 3} | 243 } {1 2 3 4} |
245 do_test where-1.37 { | 244 do_test where-1.37 { |
246 count {SELECT w FROM t1 WHERE w+1<=4 ORDER BY w} | 245 count {SELECT w FROM t1 WHERE w+1<=4 ORDER BY w} |
247 } {1 2 3 99} | 246 } {1 2 3 99} |
248 | 247 |
249 do_test where-1.38 { | 248 do_test where-1.38 { |
250 count {SELECT (w) FROM t1 WHERE (w)>(97)} | 249 count {SELECT (w) FROM t1 WHERE (w)>(97)} |
251 } {98 99 100 3} | 250 } {98 99 100 3} |
252 do_test where-1.39 { | 251 do_test where-1.39 { |
253 count {SELECT (w) FROM t1 WHERE (w)>=(97)} | 252 count {SELECT (w) FROM t1 WHERE (w)>=(97)} |
254 } {97 98 99 100 4} | 253 } {97 98 99 100 4} |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 do_test where-5.1 { | 371 do_test where-5.1 { |
373 count { | 372 count { |
374 SELECT * FROM t1 WHERE rowid IN (1,2,3,1234) order by 1; | 373 SELECT * FROM t1 WHERE rowid IN (1,2,3,1234) order by 1; |
375 } | 374 } |
376 } {1 0 4 2 1 9 3 1 16 4} | 375 } {1 0 4 2 1 9 3 1 16 4} |
377 do_test where-5.2 { | 376 do_test where-5.2 { |
378 count { | 377 count { |
379 SELECT * FROM t1 WHERE rowid+0 IN (1,2,3,1234) order by 1; | 378 SELECT * FROM t1 WHERE rowid+0 IN (1,2,3,1234) order by 1; |
380 } | 379 } |
381 } {1 0 4 2 1 9 3 1 16 102} | 380 } {1 0 4 2 1 9 3 1 16 102} |
382 do_test where-5.3 { | 381 do_test where-5.3a { |
383 count { | 382 count { |
384 SELECT * FROM t1 WHERE w IN (-1,1,2,3) order by 1; | 383 SELECT * FROM t1 WHERE w IN (-1,1,2,3) order by 1; |
385 } | 384 } |
386 } {1 0 4 2 1 9 3 1 16 14} | 385 } {1 0 4 2 1 9 3 1 16 13} |
| 386 do_test where-5.3b { |
| 387 count { |
| 388 SELECT * FROM t1 WHERE w IN (3,-1,1,2) order by 1; |
| 389 } |
| 390 } {1 0 4 2 1 9 3 1 16 13} |
| 391 do_test where-5.3c { |
| 392 count { |
| 393 SELECT * FROM t1 WHERE w IN (3,2,-1,1,2) order by 1; |
| 394 } |
| 395 } {1 0 4 2 1 9 3 1 16 13} |
| 396 do_test where-5.3d { |
| 397 count { |
| 398 SELECT * FROM t1 WHERE w IN (-1,1,2,3) order by 1 DESC; |
| 399 } |
| 400 } {3 1 16 2 1 9 1 0 4 12} |
387 do_test where-5.4 { | 401 do_test where-5.4 { |
388 count { | 402 count { |
389 SELECT * FROM t1 WHERE w+0 IN (-1,1,2,3) order by 1; | 403 SELECT * FROM t1 WHERE w+0 IN (-1,1,2,3) order by 1; |
390 } | 404 } |
391 } {1 0 4 2 1 9 3 1 16 102} | 405 } {1 0 4 2 1 9 3 1 16 102} |
392 do_test where-5.5 { | 406 do_test where-5.5 { |
393 count { | 407 count { |
394 SELECT * FROM t1 WHERE rowid IN | 408 SELECT * FROM t1 WHERE rowid IN |
395 (select rowid from t1 where rowid IN (-1,2,4)) | 409 (select rowid from t1 where rowid IN (-1,2,4)) |
396 ORDER BY 1; | 410 ORDER BY 1; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 do_test where-5.14 { | 459 do_test where-5.14 { |
446 count { | 460 count { |
447 SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,10) ORDER BY 1; | 461 SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,10) ORDER BY 1; |
448 } | 462 } |
449 } {2 1 9 8} | 463 } {2 1 9 8} |
450 do_test where-5.15 { | 464 do_test where-5.15 { |
451 count { | 465 count { |
452 SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,16) ORDER BY 1; | 466 SELECT * FROM t1 WHERE x IN (1,7) AND y IN (9,16) ORDER BY 1; |
453 } | 467 } |
454 } {2 1 9 3 1 16 11} | 468 } {2 1 9 3 1 16 11} |
| 469 do_test where-5.100 { |
| 470 db eval { |
| 471 SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969) |
| 472 ORDER BY x, y |
| 473 } |
| 474 } {2 1 9 54 5 3025 62 5 3969} |
| 475 do_test where-5.101 { |
| 476 db eval { |
| 477 SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969) |
| 478 ORDER BY x DESC, y DESC |
| 479 } |
| 480 } {62 5 3969 54 5 3025 2 1 9} |
| 481 do_test where-5.102 { |
| 482 db eval { |
| 483 SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969) |
| 484 ORDER BY x DESC, y |
| 485 } |
| 486 } {54 5 3025 62 5 3969 2 1 9} |
| 487 do_test where-5.103 { |
| 488 db eval { |
| 489 SELECT w, x, y FROM t1 WHERE x IN (1,5) AND y IN (9,8,3025,1000,3969) |
| 490 ORDER BY x, y DESC |
| 491 } |
| 492 } {2 1 9 62 5 3969 54 5 3025} |
455 } | 493 } |
456 | 494 |
457 # This procedure executes the SQL. Then it checks to see if the OP_Sort | 495 # This procedure executes the SQL. Then it checks to see if the OP_Sort |
458 # opcode was executed. If an OP_Sort did occur, then "sort" is appended | 496 # opcode was executed. If an OP_Sort did occur, then "sort" is appended |
459 # to the result. If no OP_Sort happened, then "nosort" is appended. | 497 # to the result. If no OP_Sort happened, then "nosort" is appended. |
460 # | 498 # |
461 # This procedure is used to check to make sure sorting is or is not | 499 # This procedure is used to check to make sure sorting is or is not |
462 # occurring as expected. | 500 # occurring as expected. |
463 # | 501 # |
464 proc cksort {sql} { | 502 proc cksort {sql} { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 cksort { | 542 cksort { |
505 SELECT * FROM t3 WHERE a>0 ORDER BY a LIMIT 3 | 543 SELECT * FROM t3 WHERE a>0 ORDER BY a LIMIT 3 |
506 } | 544 } |
507 } {1 100 4 2 99 9 3 98 16 nosort} | 545 } {1 100 4 2 99 9 3 98 16 nosort} |
508 do_test where-6.7 { | 546 do_test where-6.7 { |
509 cksort { | 547 cksort { |
510 SELECT * FROM t3 WHERE b>0 ORDER BY a LIMIT 3 | 548 SELECT * FROM t3 WHERE b>0 ORDER BY a LIMIT 3 |
511 } | 549 } |
512 } {1 100 4 2 99 9 3 98 16 nosort} | 550 } {1 100 4 2 99 9 3 98 16 nosort} |
513 ifcapable subquery { | 551 ifcapable subquery { |
514 do_test where-6.8 { | 552 do_test where-6.8a { |
515 cksort { | 553 cksort { |
516 SELECT * FROM t3 WHERE a IN (3,5,7,1,9,4,2) ORDER BY a LIMIT 3 | 554 SELECT * FROM t3 WHERE a IN (3,5,7,1,9,4,2) ORDER BY a LIMIT 3 |
517 } | 555 } |
518 } {1 100 4 2 99 9 3 98 16 sort} | 556 } {1 100 4 2 99 9 3 98 16 nosort} |
| 557 do_test where-6.8b { |
| 558 cksort { |
| 559 SELECT * FROM t3 WHERE a IN (3,5,7,1,9,4,2) ORDER BY a DESC LIMIT 3 |
| 560 } |
| 561 } {9 92 100 7 94 64 5 96 36 nosort} |
519 } | 562 } |
520 do_test where-6.9.1 { | 563 do_test where-6.9.1 { |
521 cksort { | 564 cksort { |
522 SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a LIMIT 3 | 565 SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a LIMIT 3 |
523 } | 566 } |
524 } {1 100 4 nosort} | 567 } {1 100 4 nosort} |
525 do_test where-6.9.1.1 { | 568 do_test where-6.9.1.1 { |
526 cksort { | 569 cksort { |
527 SELECT * FROM t3 WHERE a>=1 AND a=1 AND c>0 ORDER BY a LIMIT 3 | 570 SELECT * FROM t3 WHERE a>=1 AND a=1 AND c>0 ORDER BY a LIMIT 3 |
528 } | 571 } |
(...skipping 25 matching lines...) Expand all Loading... |
554 } {1 100 4 nosort} | 597 } {1 100 4 nosort} |
555 do_test where-6.9.6 { | 598 do_test where-6.9.6 { |
556 cksort { | 599 cksort { |
557 SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY c DESC LIMIT 3 | 600 SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY c DESC LIMIT 3 |
558 } | 601 } |
559 } {1 100 4 nosort} | 602 } {1 100 4 nosort} |
560 do_test where-6.9.7 { | 603 do_test where-6.9.7 { |
561 cksort { | 604 cksort { |
562 SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY c,a LIMIT 3 | 605 SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY c,a LIMIT 3 |
563 } | 606 } |
564 } {1 100 4 sort} | 607 } {1 100 4 nosort} |
565 do_test where-6.9.8 { | 608 do_test where-6.9.8 { |
566 cksort { | 609 cksort { |
567 SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a DESC, c ASC LIMIT 3 | 610 SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a DESC, c ASC LIMIT 3 |
568 } | 611 } |
569 } {1 100 4 nosort} | 612 } {1 100 4 nosort} |
570 do_test where-6.9.9 { | 613 do_test where-6.9.9 { |
571 cksort { | 614 cksort { |
572 SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a ASC, c DESC LIMIT 3 | 615 SELECT * FROM t3 WHERE a=1 AND c>0 ORDER BY a ASC, c DESC LIMIT 3 |
573 } | 616 } |
574 } {1 100 4 nosort} | 617 } {1 100 4 nosort} |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 cksort { | 1115 cksort { |
1073 SELECT * FROM t7 ORDER BY a ASC, b DESC; | 1116 SELECT * FROM t7 ORDER BY a ASC, b DESC; |
1074 } | 1117 } |
1075 } {1 one 4 four nosort} | 1118 } {1 one 4 four nosort} |
1076 | 1119 |
1077 # Ticket #2211. | 1120 # Ticket #2211. |
1078 # | 1121 # |
1079 # When optimizing out ORDER BY clauses, make sure that trailing terms | 1122 # When optimizing out ORDER BY clauses, make sure that trailing terms |
1080 # of the ORDER BY clause do not reference other tables in a join. | 1123 # of the ORDER BY clause do not reference other tables in a join. |
1081 # | 1124 # |
| 1125 if {[permutation] != "no_optimization"} { |
1082 do_test where-14.1 { | 1126 do_test where-14.1 { |
1083 execsql { | 1127 execsql { |
1084 CREATE TABLE t8(a INTEGER PRIMARY KEY, b TEXT UNIQUE); | 1128 CREATE TABLE t8(a INTEGER PRIMARY KEY, b TEXT UNIQUE, c CHAR(100)); |
1085 INSERT INTO t8 VALUES(1,'one'); | 1129 INSERT INTO t8(a,b) VALUES(1,'one'); |
1086 INSERT INTO t8 VALUES(4,'four'); | 1130 INSERT INTO t8(a,b) VALUES(4,'four'); |
1087 } | 1131 } |
1088 cksort { | 1132 cksort { |
1089 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, y.b | 1133 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, y.b |
1090 } | 1134 } |
1091 } {1/4 1/1 4/4 4/1 sort} | 1135 } {1/4 1/1 4/4 4/1 nosort} |
1092 do_test where-14.2 { | 1136 do_test where-14.2 { |
1093 cksort { | 1137 cksort { |
1094 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, y.b DESC | 1138 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, y.b DESC |
1095 } | 1139 } |
1096 } {1/1 1/4 4/1 4/4 sort} | 1140 } {1/1 1/4 4/1 4/4 nosort} |
1097 do_test where-14.3 { | 1141 do_test where-14.3 { |
1098 cksort { | 1142 cksort { |
1099 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, x.b | 1143 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, x.b |
1100 } | 1144 } |
1101 } {1/1 1/4 4/1 4/4 nosort} | 1145 } {1/4 1/1 4/4 4/1 nosort} |
1102 do_test where-14.4 { | 1146 do_test where-14.4 { |
1103 cksort { | 1147 cksort { |
1104 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, x.b DESC | 1148 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.a, x.b DESC |
1105 } | 1149 } |
1106 } {1/1 1/4 4/1 4/4 nosort} | 1150 } {1/4 1/1 4/4 4/1 nosort} |
1107 do_test where-14.5 { | 1151 do_test where-14.5 { |
| 1152 # This test case changed from "nosort" to "sort". See ticket 2a5629202f. |
1108 cksort { | 1153 cksort { |
1109 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||x.b | 1154 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||x.b |
1110 } | 1155 } |
1111 } {4/1 4/4 1/1 1/4 nosort} | 1156 } {/4/[14] 4/[14] 1/[14] 1/[14] sort/} |
1112 do_test where-14.6 { | 1157 do_test where-14.6 { |
| 1158 # This test case changed from "nosort" to "sort". See ticket 2a5629202f. |
1113 cksort { | 1159 cksort { |
1114 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||x.b DESC | 1160 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||x.b DESC |
1115 } | 1161 } |
1116 } {4/1 4/4 1/1 1/4 nosort} | 1162 } {/4/[14] 4/[14] 1/[14] 1/[14] sort/} |
1117 do_test where-14.7 { | 1163 do_test where-14.7 { |
1118 cksort { | 1164 cksort { |
1119 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||y.b | 1165 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||y.b |
1120 } | 1166 } |
1121 } {4/1 4/4 1/1 1/4 sort} | 1167 } {4/1 4/4 1/1 1/4 sort} |
1122 do_test where-14.7.1 { | 1168 do_test where-14.7.1 { |
1123 cksort { | 1169 cksort { |
1124 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a, y.a||y.b | 1170 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a, y.a||y.b |
1125 } | 1171 } |
1126 } {4/1 4/4 1/1 1/4 sort} | 1172 } {4/1 4/4 1/1 1/4 sort} |
1127 do_test where-14.7.2 { | 1173 do_test where-14.7.2 { |
1128 cksort { | 1174 cksort { |
1129 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a, x.a||x.b | 1175 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a, x.a||x.b |
1130 } | 1176 } |
1131 } {4/1 4/4 1/1 1/4 nosort} | 1177 } {4/4 4/1 1/4 1/1 nosort} |
1132 do_test where-14.8 { | 1178 do_test where-14.8 { |
1133 cksort { | 1179 cksort { |
1134 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||y.b DESC | 1180 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||y.b DESC |
1135 } | 1181 } |
1136 } {4/4 4/1 1/4 1/1 sort} | 1182 } {4/4 4/1 1/4 1/1 sort} |
1137 do_test where-14.9 { | 1183 do_test where-14.9 { |
1138 cksort { | 1184 cksort { |
1139 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||y.b | 1185 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||y.b |
1140 } | 1186 } |
1141 } {4/4 4/1 1/4 1/1 sort} | 1187 } {4/4 4/1 1/4 1/1 sort} |
1142 do_test where-14.10 { | 1188 do_test where-14.10 { |
1143 cksort { | 1189 cksort { |
1144 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||y.b DESC | 1190 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, x.a||y.b DESC |
1145 } | 1191 } |
1146 } {4/1 4/4 1/1 1/4 sort} | 1192 } {4/1 4/4 1/1 1/4 sort} |
1147 do_test where-14.11 { | 1193 do_test where-14.11 { |
1148 cksort { | 1194 cksort { |
1149 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||x.b | 1195 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||x.b |
1150 } | 1196 } |
1151 } {4/1 4/4 1/1 1/4 sort} | 1197 } {4/1 4/4 1/1 1/4 sort} |
1152 do_test where-14.12 { | 1198 do_test where-14.12 { |
1153 cksort { | 1199 cksort { |
1154 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||x.b DESC | 1200 SELECT x.a || '/' || y.a FROM t8 x, t8 y ORDER BY x.b, y.a||x.b DESC |
1155 } | 1201 } |
1156 } {4/4 4/1 1/4 1/1 sort} | 1202 } {4/4 4/1 1/4 1/1 sort} |
| 1203 } ;# {permutation != "no_optimization"} |
1157 | 1204 |
1158 # Ticket #2445. | 1205 # Ticket #2445. |
1159 # | 1206 # |
1160 # There was a crash that could occur when a where clause contains an | 1207 # There was a crash that could occur when a where clause contains an |
1161 # alias for an expression in the result set, and that expression retrieves | 1208 # alias for an expression in the result set, and that expression retrieves |
1162 # a column of the second or subsequent table in a join. | 1209 # a column of the second or subsequent table in a join. |
1163 # | 1210 # |
1164 do_test where-15.1 { | 1211 do_test where-15.1 { |
1165 execsql { | 1212 execsql { |
1166 CREATE TEMP TABLE t1 (a, b, c, d, e); | 1213 CREATE TEMP TABLE t1 (a, b, c, d, e); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 } | 1297 } |
1251 } {1.5 42} | 1298 } {1.5 42} |
1252 do_test where-17.5 { | 1299 do_test where-17.5 { |
1253 execsql { | 1300 execsql { |
1254 CREATE TABLE tother(a, b); | 1301 CREATE TABLE tother(a, b); |
1255 INSERT INTO tother VALUES(1, 3.7); | 1302 INSERT INTO tother VALUES(1, 3.7); |
1256 SELECT id, a FROM tbooking, tother WHERE id>a; | 1303 SELECT id, a FROM tbooking, tother WHERE id>a; |
1257 } | 1304 } |
1258 } {42 1 43 1} | 1305 } {42 1 43 1} |
1259 | 1306 |
| 1307 # Ticket [be84e357c035d068135f20bcfe82761bbf95006b] 2013-09-03 |
| 1308 # Segfault during query involving LEFT JOIN column in the ORDER BY clause. |
| 1309 # |
| 1310 do_execsql_test where-18.1 { |
| 1311 CREATE TABLE t181(a); |
| 1312 CREATE TABLE t182(b,c); |
| 1313 INSERT INTO t181 VALUES(1); |
| 1314 SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY c IS NULL; |
| 1315 } {1} |
| 1316 do_execsql_test where-18.2 { |
| 1317 SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY +c; |
| 1318 } {1} |
| 1319 do_execsql_test where-18.3 { |
| 1320 SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY c; |
| 1321 } {1} |
| 1322 do_execsql_test where-18.4 { |
| 1323 INSERT INTO t181 VALUES(1),(1),(1),(1); |
| 1324 SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY +c; |
| 1325 } {1} |
| 1326 do_execsql_test where-18.5 { |
| 1327 INSERT INTO t181 VALUES(2); |
| 1328 SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY c IS NULL, +a; |
| 1329 } {1 2} |
| 1330 do_execsql_test where-18.6 { |
| 1331 INSERT INTO t181 VALUES(2); |
| 1332 SELECT DISTINCT a FROM t181 LEFT JOIN t182 ON a=b ORDER BY +a, +c IS NULL; |
| 1333 } {1 2} |
| 1334 |
| 1335 |
1260 finish_test | 1336 finish_test |
OLD | NEW |