mallocH.test 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 various obscure operations.
  13. #
  14. # $Id: mallocH.test,v 1.2 2008/08/01 20:10:09 drh Exp $
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. source $testdir/malloc_common.tcl
  18. # Malloc failures in journaling of in-memory databases.
  19. #
  20. do_malloc_test mallocH-1 -tclprep {
  21. db close
  22. sqlite3 db :memory:
  23. db eval {
  24. CREATE TABLE t1(x UNIQUE, y);
  25. INSERT INTO t1 VALUES(1,2);
  26. }
  27. } -sqlbody {
  28. INSERT INTO t1 SELECT x+1, y+100 FROM t1;
  29. }
  30. # Malloc failures while parsing a CASE expression.
  31. #
  32. do_malloc_test mallocH-2 -sqlbody {
  33. SELECT CASE WHEN 1 THEN 1 END;
  34. }
  35. # Malloc failures while parsing a EXISTS(SELECT ...)
  36. #
  37. do_malloc_test mallocH-3 -sqlbody {
  38. SELECT 3+EXISTS(SELECT * FROM sqlite_master);
  39. }
  40. # Malloc failures within the replace() function.
  41. #
  42. do_malloc_test mallocH-3 -sqlbody {
  43. SELECT replace('ababa','a','xyzzy');
  44. }
  45. # Malloc failures during EXPLAIN.
  46. #
  47. ifcapable explain {
  48. do_malloc_test mallocH-4 -sqlprep {
  49. CREATE TABLE abc(a PRIMARY KEY, b, c);
  50. } -sqlbody {
  51. EXPLAIN SELECT * FROM abc AS t2 WHERE rowid=1;
  52. EXPLAIN QUERY PLAN SELECT * FROM abc AS t2 WHERE rowid=1;
  53. }
  54. }
  55. # Malloc failure during integrity_check pragma.
  56. #
  57. do_malloc_test mallocH-5 -sqlprep {
  58. CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
  59. CREATE TABLE t2(x,y);
  60. INSERT INTO t1 VALUES(1,2);
  61. INSERT INTO t2 SELECT * FROM t1;
  62. } -sqlbody {
  63. PRAGMA integrity_check;
  64. }
  65. finish_test