orderby4.test 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # 2013 March 26
  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 on multi-value primary keys and
  14. # unique indices when only some prefix of the terms in the key are
  15. # used. See ticket http://www.sqlite.org/src/info/a179fe74659
  16. #
  17. set testdir [file dirname $argv0]
  18. source $testdir/tester.tcl
  19. set ::testprefix orderby4
  20. # Generate test data for a join. Verify that the join gets the
  21. # correct answer.
  22. #
  23. do_execsql_test 1.1 {
  24. CREATE TABLE t1(a, b, PRIMARY KEY(a,b));
  25. INSERT INTO t1 VALUES(1,1),(1,2);
  26. CREATE TABLE t2(x, y, PRIMARY KEY(x,y));
  27. INSERT INTO t2 VALUES(3,3),(4,4);
  28. SELECT a, x FROM t1, t2 ORDER BY 1, 2;
  29. } {1 3 1 3 1 4 1 4}
  30. do_execsql_test 1.2 {
  31. SELECT a, x FROM t1 CROSS JOIN t2 ORDER BY 1, 2;
  32. } {1 3 1 3 1 4 1 4}
  33. do_execsql_test 1.3 {
  34. SELECT a, x FROM t2 CROSS JOIN t1 ORDER BY 1, 2;
  35. } {1 3 1 3 1 4 1 4}
  36. do_execsql_test 2.1 {
  37. CREATE TABLE t3(a);
  38. INSERT INTO t3 VALUES(1),(1);
  39. CREATE INDEX t3a ON t3(a);
  40. CREATE TABLE t4(x);
  41. INSERT INTO t4 VALUES(3),(4);
  42. CREATE INDEX t4x ON t4(x);
  43. SELECT a, x FROM t3, t4 ORDER BY 1, 2;
  44. } {1 3 1 3 1 4 1 4}
  45. do_execsql_test 2.2 {
  46. SELECT a, x FROM t3 CROSS JOIN t4 ORDER BY 1, 2;
  47. } {1 3 1 3 1 4 1 4}
  48. do_execsql_test 2.3 {
  49. SELECT a, x FROM t4 CROSS JOIN t3 ORDER BY 1, 2;
  50. } {1 3 1 3 1 4 1 4}
  51. finish_test