SQLite4
Hex Artifact Content
Not logged in

Artifact ee3eba80b806d645835ae111e3d33e24c85f6739:


0000: 23 20 32 30 30 37 20 4d 61 79 20 33 30 0a 23 0a  # 2007 May 30.#.
0010: 23 20 54 68 65 20 61 75 74 68 6f 72 20 64 69 73  # The author dis
0020: 63 6c 61 69 6d 73 20 63 6f 70 79 72 69 67 68 74  claims copyright
0030: 20 74 6f 20 74 68 69 73 20 73 6f 75 72 63 65 20   to this source 
0040: 63 6f 64 65 2e 20 20 49 6e 20 70 6c 61 63 65 20  code.  In place 
0050: 6f 66 0a 23 20 61 20 6c 65 67 61 6c 20 6e 6f 74  of.# a legal not
0060: 69 63 65 2c 20 68 65 72 65 20 69 73 20 61 20 62  ice, here is a b
0070: 6c 65 73 73 69 6e 67 3a 0a 23 0a 23 20 20 20 20  lessing:.#.#    
0080: 4d 61 79 20 79 6f 75 20 64 6f 20 67 6f 6f 64 20  May you do good 
0090: 61 6e 64 20 6e 6f 74 20 65 76 69 6c 2e 0a 23 20  and not evil..# 
00a0: 20 20 20 4d 61 79 20 79 6f 75 20 66 69 6e 64 20     May you find 
00b0: 66 6f 72 67 69 76 65 6e 65 73 73 20 66 6f 72 20  forgiveness for 
00c0: 79 6f 75 72 73 65 6c 66 20 61 6e 64 20 66 6f 72  yourself and for
00d0: 67 69 76 65 20 6f 74 68 65 72 73 2e 0a 23 20 20  give others..#  
00e0: 20 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65 20    May you share 
00f0: 66 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74 61  freely, never ta
0100: 6b 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20 79  king more than y
0110: 6f 75 20 67 69 76 65 2e 0a 23 0a 23 2a 2a 2a 2a  ou give..#.#****
0120: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0130: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0140: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0150: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0160: 2a 2a 2a 0a 23 20 54 68 69 73 20 66 69 6c 65 20  ***.# This file 
0170: 63 6f 6e 74 61 69 6e 73 20 61 64 64 69 74 69 6f  contains additio
0180: 6e 61 6c 20 6f 75 74 2d 6f 66 2d 6d 65 6d 6f 72  nal out-of-memor
0190: 79 20 63 68 65 63 6b 73 20 28 73 65 65 20 6d 61  y checks (see ma
01a0: 6c 6c 6f 63 2e 74 63 6c 29 2e 0a 23 20 54 68 65  lloc.tcl)..# The
01b0: 73 65 20 77 65 72 65 20 61 6c 6c 20 64 69 73 63  se were all disc
01c0: 6f 76 65 72 65 64 20 62 79 20 66 75 7a 7a 79 20  overed by fuzzy 
01d0: 67 65 6e 65 72 61 74 69 6f 6e 20 6f 66 20 53 51  generation of SQ
01e0: 4c 2e 20 41 70 61 72 74 20 66 72 6f 6d 0a 23 20  L. Apart from.# 
01f0: 74 68 61 74 20 74 68 65 79 20 68 61 76 65 20 6c  that they have l
0200: 69 74 74 6c 65 20 69 6e 20 63 6f 6d 6d 6f 6e 2e  ittle in common.
0210: 0a 23 0a 23 0a 23 20 24 49 64 3a 20 6d 61 6c 6c  .#.#.# $Id: mall
0220: 6f 63 42 2e 74 65 73 74 2c 76 20 31 2e 39 20 32  ocB.test,v 1.9 2
0230: 30 30 38 2f 30 32 2f 31 38 20 32 32 3a 32 34 3a  008/02/18 22:24:
0240: 35 38 20 64 72 68 20 45 78 70 20 24 0a 0a 73 65  58 drh Exp $..se
0250: 74 20 74 65 73 74 64 69 72 20 5b 66 69 6c 65 20  t testdir [file 
0260: 64 69 72 6e 61 6d 65 20 24 61 72 67 76 30 5d 0a  dirname $argv0].
0270: 73 6f 75 72 63 65 20 24 74 65 73 74 64 69 72 2f  source $testdir/
0280: 74 65 73 74 65 72 2e 74 63 6c 0a 73 6f 75 72 63  tester.tcl.sourc
0290: 65 20 24 74 65 73 74 64 69 72 2f 6d 61 6c 6c 6f  e $testdir/mallo
02a0: 63 5f 63 6f 6d 6d 6f 6e 2e 74 63 6c 0a 0a 23 20  c_common.tcl..# 
02b0: 4f 6e 6c 79 20 72 75 6e 20 74 68 65 73 65 20 74  Only run these t
02c0: 65 73 74 73 20 69 66 20 6d 65 6d 6f 72 79 20 64  ests if memory d
02d0: 65 62 75 67 67 69 6e 67 20 69 73 20 74 75 72 6e  ebugging is turn
02e0: 65 64 20 6f 6e 2e 0a 23 0a 69 66 20 7b 21 24 4d  ed on..#.if {!$M
02f0: 45 4d 44 45 42 55 47 7d 20 7b 0a 20 20 20 70 75  EMDEBUG} {.   pu
0300: 74 73 20 22 53 6b 69 70 70 69 6e 67 20 6d 61 6c  ts "Skipping mal
0310: 6c 6f 63 42 20 74 65 73 74 73 3a 20 6e 6f 74 20  locB tests: not 
0320: 63 6f 6d 70 69 6c 65 64 20 77 69 74 68 20 2d 44  compiled with -D
0330: 53 51 4c 49 54 45 34 5f 4d 45 4d 44 45 42 55 47  SQLITE4_MEMDEBUG
0340: 2e 2e 2e 22 0a 20 20 20 66 69 6e 69 73 68 5f 74  ...".   finish_t
0350: 65 73 74 0a 20 20 20 72 65 74 75 72 6e 0a 7d 0a  est.   return.}.
0360: 73 6f 75 72 63 65 20 24 74 65 73 74 64 69 72 2f  source $testdir/
0370: 6d 61 6c 6c 6f 63 5f 63 6f 6d 6d 6f 6e 2e 74 63  malloc_common.tc
0380: 6c 0a 0a 64 6f 5f 6d 61 6c 6c 6f 63 5f 74 65 73  l..do_malloc_tes
0390: 74 20 6d 61 6c 6c 6f 63 42 2d 31 20 2d 73 71 6c  t mallocB-1 -sql
03a0: 62 6f 64 79 20 7b 53 45 4c 45 43 54 20 2d 20 34  body {SELECT - 4
03b0: 35 36 7d 0a 64 6f 5f 6d 61 6c 6c 6f 63 5f 74 65  56}.do_malloc_te
03c0: 73 74 20 6d 61 6c 6c 6f 63 42 2d 32 20 2d 73 71  st mallocB-2 -sq
03d0: 6c 62 6f 64 79 20 7b 53 45 4c 45 43 54 20 2d 20  lbody {SELECT - 
03e0: 34 35 36 2e 31 7d 0a 64 6f 5f 6d 61 6c 6c 6f 63  456.1}.do_malloc
03f0: 5f 74 65 73 74 20 6d 61 6c 6c 6f 63 42 2d 33 20  _test mallocB-3 
0400: 2d 73 71 6c 62 6f 64 79 20 7b 53 45 4c 45 43 54  -sqlbody {SELECT
0410: 20 72 61 6e 64 6f 6d 28 29 7d 0a 64 6f 5f 6d 61   random()}.do_ma
0420: 6c 6c 6f 63 5f 74 65 73 74 20 6d 61 6c 6c 6f 63  lloc_test malloc
0430: 42 2d 34 20 2d 73 71 6c 62 6f 64 79 20 7b 53 45  B-4 -sqlbody {SE
0440: 4c 45 43 54 20 6c 65 6e 67 74 68 28 7a 65 72 6f  LECT length(zero
0450: 62 6c 6f 62 28 31 30 30 30 29 29 7d 0a 69 66 63  blob(1000))}.ifc
0460: 61 70 61 62 6c 65 20 73 75 62 71 75 65 72 79 20  apable subquery 
0470: 7b 0a 20 20 64 6f 5f 6d 61 6c 6c 6f 63 5f 74 65  {.  do_malloc_te
0480: 73 74 20 6d 61 6c 6c 6f 63 42 2d 35 20 2d 73 71  st mallocB-5 -sq
0490: 6c 62 6f 64 79 20 7b 53 45 4c 45 43 54 20 2a 20  lbody {SELECT * 
04a0: 46 52 4f 4d 20 28 53 45 4c 45 43 54 20 31 29 20  FROM (SELECT 1) 
04b0: 47 52 4f 55 50 20 42 59 20 31 3b 7d 0a 7d 0a 0a  GROUP BY 1;}.}..
04c0: 23 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20  # The following 
04d0: 74 65 73 74 20 63 68 65 63 6b 73 20 74 68 61 74  test checks that
04e0: 20 74 68 65 72 65 20 61 72 65 20 6e 6f 20 72 65   there are no re
04f0: 73 6f 75 72 63 65 20 6c 65 61 6b 73 20 66 6f 6c  source leaks fol
0500: 6c 6f 77 69 6e 67 20 61 0a 23 20 6d 61 6c 6c 6f  lowing a.# mallo
0510: 63 28 29 20 66 61 69 6c 75 72 65 20 69 6e 20 73  c() failure in s
0520: 71 6c 69 74 65 34 5f 73 65 74 5f 61 75 78 64 61  qlite4_set_auxda
0530: 74 61 28 29 2e 0a 23 0a 23 20 4e 6f 74 65 3a 20  ta()..#.# Note: 
0540: 54 68 69 73 20 70 72 6f 62 6c 65 6d 20 77 61 73  This problem was
0550: 20 6e 6f 74 20 64 69 73 63 6f 76 65 72 65 64 20   not discovered 
0560: 62 79 20 66 75 7a 7a 79 20 67 65 6e 65 72 61 74  by fuzzy generat
0570: 69 6f 6e 20 6f 66 20 53 51 4c 2e 20 4e 6f 74 0a  ion of SQL. Not.
0580: 23 20 74 68 61 74 20 69 74 20 72 65 61 6c 6c 79  # that it really
0590: 20 6d 61 74 74 65 72 73 2e 0a 23 0a 64 6f 5f 6d   matters..#.do_m
05a0: 61 6c 6c 6f 63 5f 74 65 73 74 20 6d 61 6c 6c 6f  alloc_test mallo
05b0: 63 42 2d 36 20 2d 73 71 6c 62 6f 64 79 20 7b 20  cB-6 -sqlbody { 
05c0: 53 45 4c 45 43 54 20 74 65 73 74 5f 61 75 78 64  SELECT test_auxd
05d0: 61 74 61 28 27 68 65 6c 6c 6f 20 77 6f 72 6c 64  ata('hello world
05e0: 27 29 3b 20 7d 0a 0a 64 6f 5f 6d 61 6c 6c 6f 63  '); }..do_malloc
05f0: 5f 74 65 73 74 20 6d 61 6c 6c 6f 63 42 2d 37 20  _test mallocB-7 
0600: 2d 73 71 6c 62 6f 64 79 20 7b 0a 20 20 53 45 4c  -sqlbody {.  SEL
0610: 45 43 54 20 73 74 72 66 74 69 6d 65 28 68 65 78  ECT strftime(hex
0620: 28 72 61 6e 64 6f 6d 62 6c 6f 62 28 35 30 29 29  (randomblob(50))
0630: 20 7c 7c 20 27 25 59 27 2c 20 27 6e 6f 77 27 29   || '%Y', 'now')
0640: 0a 7d 0a 0a 66 69 6e 69 73 68 5f 74 65 73 74 0a  .}..finish_test.