drh | d2f8313 | 2015-03-25 17:35:01 +0000 | [diff] [blame] | 1 | # 2015-03-25 |
| 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 | # This file implements regression tests for SQLite library. |
| 12 | # |
| 13 | # The focus of this script is making multiple calls to saveCursorPosition() |
| 14 | # and restoreCursorPosition() when cursors have eState==CURSOR_SKIPNEXT |
| 15 | # |
| 16 | |
| 17 | set testdir [file dirname $argv0] |
| 18 | source $testdir/tester.tcl |
| 19 | |
| 20 | load_static_extension db eval |
| 21 | do_execsql_test btree02-100 { |
| 22 | CREATE TABLE t1(a TEXT, ax INTEGER, b INT, PRIMARY KEY(a,ax)) WITHOUT ROWID; |
| 23 | WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<10) |
drh | aa243aa | 2018-12-27 16:55:01 +0000 | [diff] [blame] | 24 | INSERT INTO t1(a,ax,b) SELECT printf('%02x',i+160), random(), i FROM c; |
drh | d2f8313 | 2015-03-25 17:35:01 +0000 | [diff] [blame] | 25 | CREATE INDEX t1a ON t1(a); |
| 26 | CREATE TABLE t2(x,y); |
| 27 | CREATE TABLE t3(cnt); |
| 28 | WITH RECURSIVE c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<4) |
| 29 | INSERT INTO t3(cnt) SELECT i FROM c; |
| 30 | SELECT count(*) FROM t1; |
| 31 | } {10} |
drh | aa243aa | 2018-12-27 16:55:01 +0000 | [diff] [blame] | 32 | |
| 33 | proc showt1 {} { |
| 34 | puts -nonewline "t1: " |
| 35 | puts [db eval {SELECT printf('(%s,%s)',quote(a),quote(b)) FROM t1}] |
| 36 | } |
| 37 | |
drh | d2f8313 | 2015-03-25 17:35:01 +0000 | [diff] [blame] | 38 | do_test btree02-110 { |
| 39 | db eval BEGIN |
| 40 | set i 0 |
drh | aa243aa | 2018-12-27 16:55:01 +0000 | [diff] [blame] | 41 | # showt1 |
drh | d2f8313 | 2015-03-25 17:35:01 +0000 | [diff] [blame] | 42 | db eval {SELECT a, ax, b, cnt FROM t1 CROSS JOIN t3 WHERE b IS NOT NULL} { |
drh | aa243aa | 2018-12-27 16:55:01 +0000 | [diff] [blame] | 43 | if {$a==""} continue |
drh | d2f8313 | 2015-03-25 17:35:01 +0000 | [diff] [blame] | 44 | db eval {INSERT INTO t2(x,y) VALUES($b,$cnt)} |
| 45 | # puts "a,b,cnt = ($a,$b,$cnt)" |
| 46 | incr i |
| 47 | if {$i%2==1} { |
| 48 | set bx [expr {$b+1000}] |
drh | aa243aa | 2018-12-27 16:55:01 +0000 | [diff] [blame] | 49 | # puts "INSERT ($a),$bx" |
drh | d2f8313 | 2015-03-25 17:35:01 +0000 | [diff] [blame] | 50 | db eval {INSERT INTO t1(a,ax,b) VALUES(printf('(%s)',$a),random(),$bx)} |
drh | aa243aa | 2018-12-27 16:55:01 +0000 | [diff] [blame] | 51 | # showt1 |
drh | d2f8313 | 2015-03-25 17:35:01 +0000 | [diff] [blame] | 52 | } else { |
| 53 | # puts "DELETE a=$a" |
| 54 | db eval {DELETE FROM t1 WHERE a=$a} |
drh | aa243aa | 2018-12-27 16:55:01 +0000 | [diff] [blame] | 55 | # showt1 |
drh | d2f8313 | 2015-03-25 17:35:01 +0000 | [diff] [blame] | 56 | } |
| 57 | db eval {COMMIT; BEGIN} |
| 58 | } |
| 59 | db one {COMMIT; SELECT count(*) FROM t1;} |
drh | aa243aa | 2018-12-27 16:55:01 +0000 | [diff] [blame] | 60 | } {10} |
drh | d2f8313 | 2015-03-25 17:35:01 +0000 | [diff] [blame] | 61 | |
| 62 | finish_test |