tkt3357.test 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # 2008 September 1
  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. #
  12. # This file implements regression tests for SQLite library. The
  13. # focus of this file is testing the fix for ticket #3357.
  14. #
  15. # $Id: tkt3357.test,v 1.2 2009/06/05 17:09:12 drh Exp $
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. do_test tkt3357-1.1 {
  19. execsql {
  20. create table a(id integer primary key, b_id integer, myvalue varchar);
  21. create table b(id integer primary key, bvalue varchar);
  22. insert into a(b_id, myvalue) values(1,'Test');
  23. insert into a(b_id, myvalue) values(1,'Test2');
  24. insert into a(b_id, myvalue) values(1,'Test3');
  25. insert into b(bvalue) values('btest');
  26. }
  27. } {}
  28. do_test tkt3357-1.2 {
  29. execsql {
  30. SELECT cc.id, cc.b_id, cc.myvalue, dd.bvalue
  31. FROM (
  32. SELECT DISTINCT a.id, a.b_id, a.myvalue FROM a
  33. INNER JOIN b ON a.b_id = b.id WHERE b.bvalue = 'btest'
  34. ) cc
  35. LEFT OUTER JOIN b dd ON cc.b_id = dd.id
  36. }
  37. } {1 1 Test btest 2 1 Test2 btest 3 1 Test3 btest}
  38. do_test tkt3357-1.3 {
  39. execsql {
  40. SELECT cc.id, cc.b_id, cc.myvalue
  41. FROM (
  42. SELECT a.id, a.b_id, a.myvalue
  43. FROM a, b WHERE a.b_id = b.id
  44. ) cc
  45. LEFT OUTER JOIN b dd ON cc.b_id = dd.id
  46. }
  47. } {1 1 Test 2 1 Test2 3 1 Test3}
  48. do_test tkt3357-1.4 {
  49. execsql {
  50. SELECT cc.id, cc.b_id, cc.myvalue
  51. FROM (
  52. SELECT DISTINCT a.id, a.b_id, a.myvalue
  53. FROM a, b WHERE a.b_id = b.id
  54. ) cc
  55. LEFT OUTER JOIN b dd ON cc.b_id = dd.id
  56. }
  57. } {1 1 Test 2 1 Test2 3 1 Test3}
  58. finish_test