orderby5.test 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # 2013-06-14
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # a legal notice, here is a blessing:
  5. #
  6. # May you do good and not evil.
  7. # May you find forgiveness for yourself and forgive others.
  8. # May you share freely, never taking more than you give.
  9. #
  10. #***********************************************************************
  11. # This file implements regression tests for SQLite library. The
  12. # focus of this file is testing that the optimizations that disable
  13. # ORDER BY clauses work correctly
  14. #
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. set ::testprefix orderby5
  18. # Generate test data for a join. Verify that the join gets the
  19. # correct answer.
  20. #
  21. do_execsql_test 1.1 {
  22. CREATE TABLE t1(a,b,c);
  23. CREATE INDEX t1bc ON t1(b,c);
  24. EXPLAIN QUERY PLAN
  25. SELECT DISTINCT a, b, c FROM t1 WHERE a=0;
  26. } {~/B-TREE/}
  27. do_execsql_test 1.2.1 {
  28. EXPLAIN QUERY PLAN
  29. SELECT DISTINCT a, c, b FROM t1 WHERE a=0;
  30. } {~/B-TREE/}
  31. do_execsql_test 1.2.2 {
  32. EXPLAIN QUERY PLAN
  33. SELECT DISTINCT a, c, b FROM t1 WHERE a='xyz' COLLATE nocase;
  34. } {/B-TREE/}
  35. do_execsql_test 1.2.3 {
  36. EXPLAIN QUERY PLAN
  37. SELECT DISTINCT a COLLATE nocase, c, b FROM t1 WHERE a='xyz';
  38. } {/B-TREE/}
  39. do_execsql_test 1.2.4 {
  40. EXPLAIN QUERY PLAN
  41. SELECT DISTINCT a COLLATE nocase, c, b FROM t1 WHERE a='xyz' COLLATE nocase;
  42. } {~/B-TREE/}
  43. do_execsql_test 1.3 {
  44. EXPLAIN QUERY PLAN
  45. SELECT DISTINCT b, a, c FROM t1 WHERE a=0;
  46. } {~/B-TREE/}
  47. do_execsql_test 1.4 {
  48. EXPLAIN QUERY PLAN
  49. SELECT DISTINCT b, c, a FROM t1 WHERE a=0;
  50. } {~/B-TREE/}
  51. do_execsql_test 1.5 {
  52. EXPLAIN QUERY PLAN
  53. SELECT DISTINCT c, a, b FROM t1 WHERE a=0;
  54. } {~/B-TREE/}
  55. do_execsql_test 1.6 {
  56. EXPLAIN QUERY PLAN
  57. SELECT DISTINCT c, b, a FROM t1 WHERE a=0;
  58. } {~/B-TREE/}
  59. do_execsql_test 1.7 {
  60. EXPLAIN QUERY PLAN
  61. SELECT DISTINCT c, b, a FROM t1 WHERE +a=0;
  62. } {/B-TREE/}
  63. do_execsql_test 2.1 {
  64. EXPLAIN QUERY PLAN
  65. SELECT * FROM t1 WHERE a=0 ORDER BY a, b, c;
  66. } {~/B-TREE/}
  67. do_execsql_test 2.2 {
  68. EXPLAIN QUERY PLAN
  69. SELECT * FROM t1 WHERE +a=0 ORDER BY a, b, c;
  70. } {/B-TREE/}
  71. do_execsql_test 2.3 {
  72. EXPLAIN QUERY PLAN
  73. SELECT * FROM t1 WHERE a=0 ORDER BY b, a, c;
  74. } {~/B-TREE/}
  75. do_execsql_test 2.4 {
  76. EXPLAIN QUERY PLAN
  77. SELECT * FROM t1 WHERE a=0 ORDER BY b, c, a;
  78. } {~/B-TREE/}
  79. do_execsql_test 2.5 {
  80. EXPLAIN QUERY PLAN
  81. SELECT * FROM t1 WHERE a=0 ORDER BY a, c, b;
  82. } {/B-TREE/}
  83. do_execsql_test 2.6 {
  84. EXPLAIN QUERY PLAN
  85. SELECT * FROM t1 WHERE a=0 ORDER BY c, a, b;
  86. } {/B-TREE/}
  87. do_execsql_test 2.7 {
  88. EXPLAIN QUERY PLAN
  89. SELECT * FROM t1 WHERE a=0 ORDER BY c, b, a;
  90. } {/B-TREE/}
  91. finish_test