mallocK.test 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # 2008 August 01
  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 test script checks malloc failures in WHERE clause analysis.
  13. #
  14. # $Id: mallocK.test,v 1.3 2009/01/08 21:00:03 drh Exp $
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. source $testdir/malloc_common.tcl
  18. set sql {SELECT * FROM t1, t2 WHERE (a=1 OR a=2)}
  19. for {set x 1} {$x<5} {incr x} {
  20. append sql " AND b=y"
  21. do_malloc_test mallocK-1.$x -sqlbody $sql -sqlprep {
  22. CREATE TABLE t1(a,b);
  23. CREATE TABLE t2(x,y);
  24. }
  25. }
  26. set sql {SELECT * FROM t1 WHERE a GLOB 'xyz*' AND (a=1 OR a=2)}
  27. for {set x 1} {$x<5} {incr x} {
  28. append sql " AND b!=$x"
  29. do_malloc_test mallocK-2.$x -sqlbody $sql -sqlprep {
  30. CREATE TABLE t1(a,b);
  31. }
  32. }
  33. set sql {SELECT * FROM t1 WHERE a BETWEEN 5 AND 10}
  34. for {set x 1} {$x<5} {incr x} {
  35. append sql " AND b=$x"
  36. do_malloc_test mallocK-3.$x -sqlbody $sql -sqlprep {
  37. CREATE TABLE t1(a,b);
  38. }
  39. }
  40. set sql {SELECT * FROM t1 WHERE b=0}
  41. for {set x 1} {$x<5} {incr x} {
  42. set term "(b=$x"
  43. for {set y 0} {$y<$x} {incr y} {
  44. append term " AND a!=$y"
  45. }
  46. append sql " OR $term)"
  47. do_malloc_test mallocK-4.$x -sqlbody $sql -sqlprep {
  48. CREATE TABLE t1(a,b);
  49. }
  50. }
  51. ifcapable vtab {
  52. set sql {SELECT * FROM t2 WHERE a MATCH 'xyz'}
  53. for {set x 1} {$x<5} {incr x} {
  54. append sql " AND b!=$x"
  55. do_malloc_test mallocK-5.$x -sqlbody $sql -tclprep {
  56. register_echo_module [sqlite3_connection_pointer db]
  57. db eval {
  58. CREATE TABLE t1(a,b);
  59. CREATE VIRTUAL TABLE t2 USING echo(t1);
  60. }
  61. }
  62. }
  63. }
  64. finish_test