File: rtree3.test

package info (click to toggle)
db 5.1.29-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 148,952 kB
  • sloc: ansic: 400,169; java: 94,399; tcl: 71,008; sh: 37,399; cs: 30,758; cpp: 21,132; perl: 14,227; xml: 9,854; makefile: 3,848; yacc: 1,003; awk: 942; sql: 801; erlang: 461; python: 216; php: 24; asm: 14
file content (71 lines) | stat: -rw-r--r-- 1,825 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# 2008 Feb 19
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# The focus of this file is testing that the r-tree correctly handles
# out-of-memory conditions.
#

if {![info exists testdir]} {
  set testdir [file join [file dirname $argv0] .. .. test]
} 
source $testdir/tester.tcl

ifcapable !rtree {
  finish_test
  return
}

# Only run these tests if memory debugging is turned on.
#
source $testdir/malloc_common.tcl
if {!$MEMDEBUG} {
   puts "Skipping malloc tests: not compiled with -DSQLITE_MEMDEBUG..."
   finish_test
   return
}

do_malloc_test rtree3-1 -sqlbody {
  BEGIN TRANSACTION;
  CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);
  INSERT INTO rt VALUES(NULL, 3, 5, 7, 9);
  INSERT INTO rt VALUES(NULL, 13, 15, 17, 19);
  DELETE FROM rt WHERE ii = 1;
  SELECT * FROM rt;
  SELECT ii FROM rt WHERE ii = 2;
  COMMIT;
} 
do_malloc_test rtree3-2 -sqlprep {
  CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);
  INSERT INTO rt VALUES(NULL, 3, 5, 7, 9);
} -sqlbody {
  DROP TABLE rt;
} 


do_malloc_test rtree3-3 -sqlprep {
  CREATE VIRTUAL TABLE rt USING rtree(ii, x1, x2, y1, y2);
  INSERT INTO rt VALUES(NULL, 3, 5, 7, 9);
} -tclbody {
  db eval BEGIN
  for {set ii 0} {$ii < 100} {incr ii} {
    set f [expr rand()]
    db eval {INSERT INTO rt VALUES(NULL, $f*10.0, $f*10.0, $f*15.0, $f*15.0)}
  }
  db eval COMMIT
  db eval BEGIN
  for {set ii 0} {$ii < 100} {incr ii} {
    set f [expr rand()]
    db eval { DELETE FROM rt WHERE x1<($f*10.0) AND x1>($f*10.5) }
  }
  db eval COMMIT
} 

finish_test