tkt3442.test 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # 2008 October 20
  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.
  12. #
  13. # This file implements tests to verify that ticket #3442 has been
  14. # fixed.
  15. #
  16. #
  17. # $Id: tkt3442.test,v 1.2 2009/06/05 17:09:12 drh Exp $
  18. set testdir [file dirname $argv0]
  19. source $testdir/tester.tcl
  20. # Create a schema with some indexes.
  21. #
  22. do_test tkt3442-1.1 {
  23. execsql {
  24. CREATE TABLE listhash(
  25. key INTEGER PRIMARY KEY,
  26. id TEXT,
  27. node INTEGER
  28. );
  29. CREATE UNIQUE INDEX ididx ON listhash(id);
  30. }
  31. } {}
  32. # Explain Query Plan
  33. #
  34. proc EQP {sql} {
  35. uplevel "execsql {EXPLAIN QUERY PLAN $sql}"
  36. }
  37. # These tests perform an EXPLAIN QUERY PLAN on both versions of the
  38. # SELECT referenced in ticket #3442 (both '5000' and "5000")
  39. # and verify that the query plan is the same.
  40. #
  41. ifcapable explain {
  42. do_test tkt3442-1.2 {
  43. EQP { SELECT node FROM listhash WHERE id='5000' LIMIT 1; }
  44. } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}
  45. do_test tkt3442-1.3 {
  46. EQP { SELECT node FROM listhash WHERE id="5000" LIMIT 1; }
  47. } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}
  48. }
  49. # Some extra tests testing other permutations of 5000.
  50. #
  51. ifcapable explain {
  52. do_test tkt3442-1.4 {
  53. EQP { SELECT node FROM listhash WHERE id=5000 LIMIT 1; }
  54. } {0 0 0 {SEARCH TABLE listhash USING INDEX ididx (id=?)}}
  55. }
  56. do_test tkt3442-1.5 {
  57. catchsql {
  58. SELECT node FROM listhash WHERE id=[5000] LIMIT 1;
  59. }
  60. } {1 {no such column: 5000}}
  61. finish_test