Improved error messages. Limit the number of auxiliary columns to 100.
[sqlite.git] / ext / rtree / rtree1.test
blobed154cd3a3351cc303240e40b34423e6238dd27f
1 # 2008 Feb 19
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # The focus of this file is testing the r-tree extension.
15 if {![info exists testdir]} {
16   set testdir [file join [file dirname [info script]] .. .. test]
18 source [file join [file dirname [info script]] rtree_util.tcl]
19 source $testdir/tester.tcl
20 set testprefix rtree1
22 # Test plan:
24 #   rtree-1.*: Creating/destroying r-tree tables.
25 #   rtree-2.*: Test the implicit constraints - unique rowid and
26 #              (coord[N]<=coord[N+1]) for even values of N. Also
27 #              automatic assigning of rowid values.
28 #   rtree-3.*: Linear scans of r-tree data.
29 #   rtree-4.*: Test INSERT
30 #   rtree-5.*: Test DELETE
31 #   rtree-6.*: Test UPDATE
32 #   rtree-7.*: Test renaming an r-tree table.
33 #   rtree-8.*: Test constrained scans of r-tree data.
35 #   rtree-12.*: Test that on-conflict clauses are supported.
36 #   rtree-13.*: Test that bug [d2889096e7bdeac6d] has been fixed.
37 #   rtree-14.*: Test if a non-integer is inserted into the PK column of an
38 #               r-tree table, it is converted to an integer before being
39 #               inserted. Also that if a non-numeric is inserted into one
40 #               of the min/max dimension columns, it is converted to the
41 #               required type before being inserted.
42 #   rtree-15.*: Check that DROP TABLE works within a transaction that
43 #               writes to an r-tree table.
46 ifcapable !rtree {
47   finish_test
48   return
51 #----------------------------------------------------------------------------
52 # Test cases rtree-1.* test CREATE and DROP table statements.
55 # Test creating and dropping an rtree table.
57 do_test rtree-1.1.1 {
58   execsql { CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2) }
59 } {}
60 do_test rtree-1.1.2 {
61   execsql { SELECT name FROM sqlite_master ORDER BY name }
62 } {t1 t1_node t1_parent t1_rowid}
63 do_test rtree-1.1.3 {
64   execsql { 
65     DROP TABLE t1; 
66     SELECT name FROM sqlite_master ORDER BY name;
67   }
68 } {}
70 # Test creating and dropping an rtree table with an odd name in
71 # an attached database.
73 do_test rtree-1.2.1 {
74   file delete -force test2.db
75   execsql {
76     ATTACH 'test2.db' AS aux;
77     CREATE VIRTUAL TABLE aux.'a" "b' USING rtree(ii, x1, x2, y1, y2);
78   }
79 } {}
80 do_test rtree-1.2.2 {
81   execsql { SELECT name FROM sqlite_master ORDER BY name }
82 } {}
83 do_test rtree-1.2.3 {
84   execsql { SELECT name FROM aux.sqlite_master ORDER BY name }
85 } {{a" "b} {a" "b_node} {a" "b_parent} {a" "b_rowid}}
86 do_test rtree-1.2.4 {
87   execsql { 
88     DROP TABLE aux.'a" "b'; 
89     SELECT name FROM aux.sqlite_master ORDER BY name;
90   }
91 } {}
93 # Test that the logic for checking the number of columns specified
94 # for an rtree table. Acceptable values are odd numbers between 3 and
95 # 11, inclusive.
97 set cols [list i1 i2 i3 i4 i5 i6 i7 i8 i9 iA iB iC iD iE iF iG iH iI iJ iK]
98 for {set nCol 1} {$nCol<[llength $cols]} {incr nCol} {
100   set columns [join [lrange $cols 0 [expr {$nCol-1}]] ,]
102   set X {0 {}}
103   if {$nCol%2 == 0}  { set X {1 {Wrong number of columns for an rtree table}} }
104   if {$nCol < 3}     { set X {1 {Too few columns for an rtree table}} }
105   if {$nCol > 11}    { set X {1 {Too many columns for an rtree table}} }
107   do_test rtree-1.3.$nCol {
108     catchsql " 
109       CREATE VIRTUAL TABLE t1 USING rtree($columns);
110     "
111   } $X
113   catchsql { DROP TABLE t1 }
116 # Like execsql except display output as integer where that can be
117 # done without loss of information.
119 proc execsql_intout {sql} {
120   set out {}
121   foreach term [execsql $sql] {
122     regsub {\.0$} $term {} term
123     lappend out $term
124   }
125   return $out
128 # Test that it is possible to open an existing database that contains
129 # r-tree tables.
131 do_execsql_test rtree-1.4.1a {
132   CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2);
133   INSERT INTO t1 VALUES(1, 5.0, 10.0);
134   SELECT substr(hex(data),1,40) FROM t1_node;
135 } {00000001000000000000000140A0000041200000}
136 do_execsql_test rtree-1.4.1b {
137   INSERT INTO t1 VALUES(2, 15.0, 20.0);
138 } {}
139 do_test rtree-1.4.2 {
140   db close
141   sqlite3 db test.db
142   execsql_intout { SELECT * FROM t1 ORDER BY ii }
143 } {1 5 10 2 15 20}
144 do_test rtree-1.4.3 {
145   execsql { DROP TABLE t1 }
146 } {}
148 # Test that it is possible to create an r-tree table with ridiculous
149 # column names.
151 do_test rtree-1.5.1 {
152   execsql_intout {
153     CREATE VIRTUAL TABLE t1 USING rtree("the key", "x dim.", "x2'dim");
154     INSERT INTO t1 VALUES(1, 2, 3);
155     SELECT "the key", "x dim.", "x2'dim" FROM t1;
156   }
157 } {1 2 3}
158 do_test rtree-1.5.1 {
159   execsql { DROP TABLE t1 }
160 } {}
162 # Force the r-tree constructor to fail.
164 do_test rtree-1.6.1 {
165   execsql { CREATE TABLE t1_rowid(a); }
166   catchsql {
167     CREATE VIRTUAL TABLE t1 USING rtree("the key", "x dim.", "x2'dim");
168   }
169 } {1 {table "t1_rowid" already exists}}
170 do_test rtree-1.6.1 {
171   execsql { DROP TABLE t1_rowid }
172 } {}
174 #----------------------------------------------------------------------------
175 # Test cases rtree-2.* 
177 do_test rtree-2.1.1 {
178   execsql { 
179     CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2);
180     SELECT * FROM t1;
181   }
182 } {}
184 do_test rtree-2.1.2 {
185   execsql { INSERT INTO t1 VALUES(NULL, 1, 3, 2, 4) }
186   execsql_intout { SELECT * FROM t1 }
187 } {1 1 3 2 4}
188 do_test rtree-2.1.3 {
189   execsql { INSERT INTO t1 VALUES(NULL, 1, 3, 2, 4) }
190   execsql { SELECT rowid FROM t1 ORDER BY rowid }
191 } {1 2}
192 do_test rtree-2.1.3 {
193   execsql { INSERT INTO t1 VALUES(NULL, 1, 3, 2, 4) }
194   execsql { SELECT ii FROM t1 ORDER BY ii }
195 } {1 2 3}
197 do_test rtree-2.2.1 {
198   catchsql { INSERT INTO t1 VALUES(2, 1, 3, 2, 4) }
199 } {1 {UNIQUE constraint failed: t1.ii}}
200 do_test rtree-2.2.2 {
201   catchsql { INSERT INTO t1 VALUES(4, 1, 3, 4, 2) }
202 } {1 {rtree constraint failed: t1.(y1<=y2)}}
203 do_test rtree-2.2.3 {
204   catchsql { INSERT INTO t1 VALUES(4, 3, 1, 2, 4) }
205 } {1 {rtree constraint failed: t1.(x1<=x2)}}
206 do_test rtree-2.2.4 {
207   execsql { SELECT ii FROM t1 ORDER BY ii }
208 } {1 2 3}
210 do_test rtree-2.X {
211   execsql { DROP TABLE t1 }
212 } {}
214 #----------------------------------------------------------------------------
215 # Test cases rtree-3.* test linear scans of r-tree table data. To test
216 # this we have to insert some data into an r-tree, but that is not the
217 # focus of these tests.
219 do_test rtree-3.1.1 {
220   execsql { 
221     CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2, y1, y2);
222     SELECT * FROM t1;
223   }
224 } {}
225 do_test rtree-3.1.2 {
226   execsql_intout { 
227     INSERT INTO t1 VALUES(5, 1, 3, 2, 4);
228     SELECT * FROM t1;
229   }
230 } {5 1 3 2 4}
231 do_test rtree-3.1.3 {
232   execsql_intout {
233     INSERT INTO t1 VALUES(6, 2, 6, 4, 8);
234     SELECT * FROM t1;
235   }
236 } {5 1 3 2 4 6 2 6 4 8}
238 # Test the constraint on the coordinates (c[i]<=c[i+1] where (i%2==0)):
239 do_test rtree-3.2.1 {
240   catchsql { INSERT INTO t1 VALUES(7, 2, 6, 4, 3) }
241 } {1 {rtree constraint failed: t1.(y1<=y2)}}
242 do_test rtree-3.2.2 {
243   catchsql { INSERT INTO t1 VALUES(8, 2, 6, 3, 3) }
244 } {0 {}}
246 #----------------------------------------------------------------------------
247 # Test cases rtree-5.* test DELETE operations.
249 do_test rtree-5.1.1 {
250   execsql { CREATE VIRTUAL TABLE t2 USING rtree(ii, x1, x2) }
251 } {}
252 do_test rtree-5.1.2 {
253   execsql_intout { 
254     INSERT INTO t2 VALUES(1, 10, 20);
255     INSERT INTO t2 VALUES(2, 30, 40);
256     INSERT INTO t2 VALUES(3, 50, 60);
257     SELECT * FROM t2 ORDER BY ii;
258   }
259 } {1 10 20 2 30 40 3 50 60}
260 do_test rtree-5.1.3 {
261   execsql_intout { 
262     DELETE FROM t2 WHERE ii=2;
263     SELECT * FROM t2 ORDER BY ii;
264   }
265 } {1 10 20 3 50 60}
266 do_test rtree-5.1.4 {
267   execsql_intout { 
268     DELETE FROM t2 WHERE ii=1;
269     SELECT * FROM t2 ORDER BY ii;
270   }
271 } {3 50 60}
272 do_test rtree-5.1.5 {
273   execsql { 
274     DELETE FROM t2 WHERE ii=3;
275     SELECT * FROM t2 ORDER BY ii;
276   }
277 } {}
278 do_test rtree-5.1.6 {
279   execsql { SELECT * FROM t2_rowid }
280 } {}
282 #----------------------------------------------------------------------------
283 # Test cases rtree-5.* test UPDATE operations.
285 do_test rtree-6.1.1 {
286   execsql { CREATE VIRTUAL TABLE t3 USING rtree(ii, x1, x2, y1, y2) }
287 } {}
288 do_test rtree-6.1.2 {
289   execsql_intout {
290     INSERT INTO t3 VALUES(1, 2, 3, 4, 5);
291     UPDATE t3 SET x2=5;
292     SELECT * FROM t3;
293   }
294 } {1 2 5 4 5}
295 do_test rtree-6.1.3 {
296   execsql { UPDATE t3 SET ii = 2 }
297   execsql_intout { SELECT * FROM t3 }
298 } {2 2 5 4 5}
300 #----------------------------------------------------------------------------
301 # Test cases rtree-7.* test rename operations.
303 do_test rtree-7.1.1 {
304   execsql {
305     CREATE VIRTUAL TABLE t4 USING rtree(ii, x1, x2, y1, y2, z1, z2);
306     INSERT INTO t4 VALUES(1, 2, 3, 4, 5, 6, 7);
307   }
308 } {}
309 do_test rtree-7.1.2 {
310   execsql { ALTER TABLE t4 RENAME TO t5 }
311   execsql_intout { SELECT * FROM t5 }
312 } {1 2 3 4 5 6 7}
313 do_test rtree-7.1.3 {
314   db close
315   sqlite3 db test.db
316   execsql_intout { SELECT * FROM t5 }
317 } {1 2 3 4 5 6 7}
318 do_test rtree-7.1.4 {
319   execsql { ALTER TABLE t5 RENAME TO 'raisara "one"'''}
320   execsql_intout { SELECT * FROM "raisara ""one""'" }
321 } {1 2 3 4 5 6 7}
322 do_test rtree-7.1.5 {
323   execsql_intout { SELECT * FROM 'raisara "one"''' }
324 } {1 2 3 4 5 6 7}
325 do_test rtree-7.1.6 {
326   execsql { ALTER TABLE "raisara ""one""'" RENAME TO "abc 123" }
327   execsql_intout { SELECT * FROM "abc 123" }
328 } {1 2 3 4 5 6 7}
329 do_test rtree-7.1.7 {
330   db close
331   sqlite3 db test.db
332   execsql_intout { SELECT * FROM "abc 123" }
333 } {1 2 3 4 5 6 7}
335 # An error midway through a rename operation.
336 do_test rtree-7.2.1 {
337   execsql { 
338     CREATE TABLE t4_node(a);
339   }
340   catchsql { ALTER TABLE "abc 123" RENAME TO t4 }
341 } {1 {SQL logic error}}
342 do_test rtree-7.2.2 {
343   execsql_intout { SELECT * FROM "abc 123" }
344 } {1 2 3 4 5 6 7}
345 do_test rtree-7.2.3 {
346   execsql { 
347     DROP TABLE t4_node;
348     CREATE TABLE t4_rowid(a);
349   }
350   catchsql { ALTER TABLE "abc 123" RENAME TO t4 }
351 } {1 {SQL logic error}}
352 do_test rtree-7.2.4 {
353   db close
354   sqlite3 db test.db
355   execsql_intout { SELECT * FROM "abc 123" }
356 } {1 2 3 4 5 6 7}
357 do_test rtree-7.2.5 {
358   execsql { DROP TABLE t4_rowid }
359   execsql { ALTER TABLE "abc 123" RENAME TO t4 }
360   execsql_intout { SELECT * FROM t4 }
361 } {1 2 3 4 5 6 7}
364 #----------------------------------------------------------------------------
365 # Test cases rtree-8.*
368 # Test that the function to determine if a leaf cell is part of the
369 # result set works.
370 do_test rtree-8.1.1 {
371   execsql {
372     CREATE VIRTUAL TABLE t6 USING rtree(ii, x1, x2);
373     INSERT INTO t6 VALUES(1, 3, 7);
374     INSERT INTO t6 VALUES(2, 4, 6);
375   }
376 } {}
377 do_test rtree-8.1.2 { execsql { SELECT ii FROM t6 WHERE x1>2 } } {1 2}
378 do_test rtree-8.1.3 { execsql { SELECT ii FROM t6 WHERE x1>3 } } {2}
379 do_test rtree-8.1.4 { execsql { SELECT ii FROM t6 WHERE x1>4 } } {}
380 do_test rtree-8.1.5 { execsql { SELECT ii FROM t6 WHERE x1>5 } } {}
381 do_test rtree-8.1.6 { execsql { SELECT ii FROM t6 WHERE x1<3 } } {}
382 do_test rtree-8.1.7 { execsql { SELECT ii FROM t6 WHERE x1<4 } } {1}
383 do_test rtree-8.1.8 { execsql { SELECT ii FROM t6 WHERE x1<5 } } {1 2}
385 #----------------------------------------------------------------------------
386 # Test cases rtree-9.*
388 # Test that ticket #3549 is fixed.
389 do_test rtree-9.1 {
390   execsql {
391     CREATE TABLE foo (id INTEGER PRIMARY KEY);
392     CREATE VIRTUAL TABLE bar USING rtree (id, minX, maxX, minY, maxY);
393     INSERT INTO foo VALUES (null);
394     INSERT INTO foo SELECT null FROM foo;
395     INSERT INTO foo SELECT null FROM foo;
396     INSERT INTO foo SELECT null FROM foo;
397     INSERT INTO foo SELECT null FROM foo;
398     INSERT INTO foo SELECT null FROM foo;
399     INSERT INTO foo SELECT null FROM foo;
400     DELETE FROM foo WHERE id > 40;
401     INSERT INTO bar SELECT NULL, 0, 0, 0, 0 FROM foo;
402   }
403 } {}
405 # This used to crash.
406 do_test rtree-9.2 {
407   execsql {
408     SELECT count(*) FROM bar b1, bar b2, foo s1 WHERE s1.id = b1.id;
409   }
410 } {1600}
411 do_test rtree-9.3 {
412   execsql {
413     SELECT count(*) FROM bar b1, bar b2, foo s1 
414     WHERE b1.minX <= b2.maxX AND s1.id = b1.id;
415   }
416 } {1600}
418 #-------------------------------------------------------------------------
419 # Ticket #3970: Check that the error message is meaningful when a 
420 # keyword is used as a column name.
422 do_test rtree-10.1 {
423   catchsql { CREATE VIRTUAL TABLE t7 USING rtree(index, x1, y1, x2, y2) }
424 } {1 {near "index": syntax error}}
426 #-------------------------------------------------------------------------
427 # Test last_insert_rowid().
429 do_test rtree-11.1 {
430   execsql {
431     CREATE VIRTUAL TABLE t8 USING rtree(idx, x1, x2, y1, y2);
432     INSERT INTO t8 VALUES(1, 1.0, 1.0, 2.0, 2.0);
433     SELECT last_insert_rowid();
434   }
435 } {1}
436 do_test rtree-11.2 {
437   execsql {
438     INSERT INTO t8 VALUES(NULL, 1.0, 1.0, 2.0, 2.0);
439     SELECT last_insert_rowid();
440   }
441 } {2}
443 #-------------------------------------------------------------------------
444 # Test on-conflict clause handling.
446 db_delete_and_reopen
447 do_execsql_test 12.0.1 {
448   CREATE VIRTUAL TABLE t1 USING rtree_i32(idx, x1, x2, y1, y2);
449   INSERT INTO t1 VALUES(1,   1, 2, 3, 4);
450   SELECT substr(hex(data),1,56) FROM t1_node;
451 } {00000001000000000000000100000001000000020000000300000004}
452 do_execsql_test 12.0.2 {
453   INSERT INTO t1 VALUES(2,   2, 3, 4, 5);
454   INSERT INTO t1 VALUES(3,   3, 4, 5, 6);
456   CREATE TABLE source(idx, x1, x2, y1, y2);
457   INSERT INTO source VALUES(5, 8, 8, 8, 8);
458   INSERT INTO source VALUES(2, 7, 7, 7, 7);
460 db_save_and_close
461 foreach {tn sql_template testdata} {
462   1    "INSERT %CONF% INTO t1 VALUES(2, 7, 7, 7, 7)" {
463     ROLLBACK 0 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6}
464     ABORT    0 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
465     IGNORE   0 0 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
466     FAIL     0 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
467     REPLACE  0 0 {1 1 2 3 4   2 7 7 7 7   3 3 4 5 6   4 4 5 6 7}
468   }
470   2    "INSERT %CONF% INTO t1 SELECT * FROM source" {
471     ROLLBACK 1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6}
472     ABORT    1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
473     IGNORE   1 0 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7  5 8 8 8 8}
474     FAIL     1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7  5 8 8 8 8}
475     REPLACE  1 0 {1 1 2 3 4   2 7 7 7 7   3 3 4 5 6   4 4 5 6 7  5 8 8 8 8}
476   }
478   3    "UPDATE %CONF% t1 SET idx = 2 WHERE idx = 4" {
479     ROLLBACK 1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6}
480     ABORT    1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
481     IGNORE   1 0 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
482     FAIL     1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
483     REPLACE  1 0 {1 1 2 3 4   2 4 5 6 7   3 3 4 5 6}
484   }
486   3    "UPDATE %CONF% t1 SET idx = ((idx+1)%5)+1 WHERE idx > 2" {
487     ROLLBACK 1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6}
488     ABORT    1 1 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
489     IGNORE   1 0 {1 1 2 3 4   2 2 3 4 5               4 4 5 6 7   5 3 4 5 6}
490     FAIL     1 1 {1 1 2 3 4   2 2 3 4 5               4 4 5 6 7   5 3 4 5 6}
491     REPLACE  1 0 {1 4 5 6 7   2 2 3 4 5                           5 3 4 5 6}
492   }
494   4    "INSERT %CONF% INTO t1 VALUES(2, 7, 6, 7, 7)" {
495     ROLLBACK 0 2 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6}
496     ABORT    0 2 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
497     IGNORE   0 0 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
498     FAIL     0 2 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
499     REPLACE  0 2 {1 1 2 3 4   2 2 3 4 5   3 3 4 5 6   4 4 5 6 7}
500   }
502 } {
503   foreach {mode uses error data} $testdata {
504     db_restore_and_reopen
506     set sql [string map [list %CONF% "OR $mode"] $sql_template]
507     set testname "12.$tn.[string tolower $mode]"
509     execsql {
510       BEGIN;
511         INSERT INTO t1 VALUES(4,   4, 5, 6, 7);
512     }
514     set res(0) {0 {}}
515     set res(1) {1 {UNIQUE constraint failed: t1.idx}}
516     set res(2) {1 {rtree constraint failed: t1.(x1<=x2)}}
518     do_catchsql_test $testname.1 $sql $res($error)
519     do_test $testname.2 [list sql_uses_stmt db $sql] $uses
520     do_execsql_test $testname.3 { SELECT * FROM t1 ORDER BY idx } $data
522     do_rtree_integrity_test $testname.4 t1
523     db close
524   }
527 #-------------------------------------------------------------------------
528 # Test that bug [d2889096e7bdeac6d] has been fixed.
530 reset_db
531 do_execsql_test 13.1 {
532   CREATE VIRTUAL TABLE t9 USING rtree(id, xmin, xmax);
533   INSERT INTO t9 VALUES(1,0,0);            
534   INSERT INTO t9 VALUES(2,0,0);
535   SELECT * FROM t9 WHERE id IN (1, 2);
536 } {1 0.0 0.0 2 0.0 0.0}
538 do_execsql_test 13.2 {
539   WITH r(x) AS (
540     SELECT 1 UNION ALL
541     SELECT 2 UNION ALL
542     SELECT 3
543   )
544   SELECT * FROM r CROSS JOIN t9 WHERE id=x;
545 } {1 1 0.0 0.0 2 2 0.0 0.0}
547 #-------------------------------------------------------------------------
548 # Test if a non-integer is inserted into the PK column of an r-tree
549 # table, it is converted to an integer before being inserted. Also
550 # that if a non-numeric is inserted into one of the min/max dimension
551 # columns, it is converted to the required type before being inserted.
553 do_execsql_test 14.1 {
554   CREATE VIRTUAL TABLE t10 USING rtree(ii, x1, x2);
557 do_execsql_test 14.2 {
558   INSERT INTO t10 VALUES(NULL,   1, 2);
559   INSERT INTO t10 VALUES(NULL,   2, 3);
560   INSERT INTO t10 VALUES('4xxx', 3, 4);
561   INSERT INTO t10 VALUES(5.0,    4, 5);
562   INSERT INTO t10 VALUES(6.4,    5, 6);
564 do_execsql_test 14.3 {
565   SELECT * FROM t10;
566 } {
567   1 1.0 2.0   2 2.0 3.0   4 3.0 4.0   5 4.0 5.0   6 5.0 6.0
570 do_execsql_test 14.4 {
571   DELETE FROM t10;
572   INSERT INTO t10 VALUES(1, 'one', 'two');
573   INSERT INTO t10 VALUES(2, '52xyz', '81...');
575 do_execsql_test 14.5 {
576   SELECT * FROM t10;
577 } {
578   1 0.0 0.0
579   2 52.0 81.0
582 do_execsql_test 14.4 {
583   DROP TABLE t10;
584   CREATE VIRTUAL TABLE t10 USING rtree_i32(ii, x1, x2);
585   INSERT INTO t10 VALUES(1, 'one', 'two');
586   INSERT INTO t10 VALUES(2, '52xyz', '81...');
587   INSERT INTO t10 VALUES(3, 42.3, 49.9);
589 do_execsql_test 14.5 {
590   SELECT * FROM t10;
591 } {
592   1 0 0
593   2 52 81
594   3 42 49
597 #-------------------------------------------------------------------------
599 do_execsql_test 15.0 {
600   CREATE VIRTUAL TABLE rt USING rtree(id, x1,x2, y1,y2);
601   CREATE TEMP TABLE t13(a, b, c);
603 do_execsql_test 15.1 {
604   BEGIN;
605   INSERT INTO rt VALUES(1,2,3,4,5);
607 do_execsql_test 15.2 {
608   DROP TABLE t13;
609   COMMIT;
612 # Test cases for the new auxiliary columns feature
614 do_catchsql_test 16.100 {
615   CREATE VIRTUAL TABLE t16 USING rtree(id,x0,x1,y0,+aux1,x1);
616 } {1 {Auxiliary rtree columns must be last}}
617 do_test 16.110 {
618   set sql {
619     CREATE VIRTUAL TABLE t16 USING rtree(
620       id, x00, x01, x10, x11, x20, x21, x30, x31, x40, x41
621   }
622   for {set i 12} {$i<=100} {incr i} {
623      append sql ", +a$i"
624   }
625   append sql ");"
626   execsql $sql
627 } {}
628 do_test 16.120 {
629   set sql {
630     CREATE VIRTUAL TABLE t16b USING rtree(
631       id, x00, x01, x10, x11, x20, x21, x30, x31, x40, x41
632   }
633   for {set i 12} {$i<=101} {incr i} {
634      append sql ", +a$i"
635   }
636   append sql ");"
637   catchsql $sql
638 } {1 {Too many columns for an rtree table}}
644 expand_all_sql db
645 finish_test