SQLite

Check-in [07a0e4e982]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add tests to "permutations.test coverage-pager" to cover uncovered branches.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 07a0e4e9820a85bf1690214fef3577866c763f92
User & Date: dan 2013-04-06 11:03:09.144
Context
2013-04-06
18:06
Increase the default SQLITE_MAX_SCHEMA_RETRY to 50. Make sure that macro covers every case where a prepared statement might need to be reprepared due to a schema change. The sqlite3_exec() interface now uses sqlite3_prepare_v2(). (check-in: c1d7304c80 user: drh tags: trunk)
11:03
Add tests to "permutations.test coverage-pager" to cover uncovered branches. (check-in: 07a0e4e982 user: dan tags: trunk)
2013-04-05
20:40
Improve the code coverage of "permutations.test coverage-pager". (check-in: b095e2cdb6 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/pager1.test.
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
      SAVEPOINT abc;
        CREATE TABLE t1(a, b);
      ROLLBACK TO abc;
    COMMIT;
  }
  db close
} {}
breakpoint
do_test pager1-25-2 {
  faultsim_delete_and_reopen
  execsql {
    SAVEPOINT abc;
      CREATE TABLE t1(a, b);
    ROLLBACK TO abc;
    COMMIT;







<







2241
2242
2243
2244
2245
2246
2247

2248
2249
2250
2251
2252
2253
2254
      SAVEPOINT abc;
        CREATE TABLE t1(a, b);
      ROLLBACK TO abc;
    COMMIT;
  }
  db close
} {}

do_test pager1-25-2 {
  faultsim_delete_and_reopen
  execsql {
    SAVEPOINT abc;
      CREATE TABLE t1(a, b);
    ROLLBACK TO abc;
    COMMIT;
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
  reset_db
  db func a_string a_string
  db eval $pragma
  do_execsql_test 34.$tn.1 {
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(1, 2);
  }
  breakpoint
  do_execsql_test 34.$tn.2 {
    BEGIN;
    INSERT INTO t1 VALUES(2, a_string($strsize));
    DELETE FROM t1 WHERE oid=2;
    COMMIT;
    PRAGMA integrity_check;
  } {ok}







<







2538
2539
2540
2541
2542
2543
2544

2545
2546
2547
2548
2549
2550
2551
  reset_db
  db func a_string a_string
  db eval $pragma
  do_execsql_test 34.$tn.1 {
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(1, 2);
  }

  do_execsql_test 34.$tn.2 {
    BEGIN;
    INSERT INTO t1 VALUES(2, a_string($strsize));
    DELETE FROM t1 WHERE oid=2;
    COMMIT;
    PRAGMA integrity_check;
  } {ok}
2601
2602
2603
2604
2605
2606
2607
2608
2609

2610
2611
2612
2613
2614
2615






2616
2617
2618
2619
2620
2621
2622
  2   {file:one?mode=memory&cache=shared}
  3   {file:test1?cache=shared}
  4   {file:test2?another=parameter&yet=anotherone}
} {
  do_test 37.$tn {
    catch { db close }
    sqlite3_shutdown
      sqlite3_config_uri 1
      sqlite3 db $uri

    db eval {
      CREATE TABLE t1(x);
      INSERT INTO t1 VALUES(1);
      SELECT * FROM t1;
    }
  } {1}






  db close
  sqlite3_shutdown
  sqlite3_config_uri 0
}

do_test 38.1 {
  catch { db close }







|
|
>






>
>
>
>
>
>







2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
  2   {file:one?mode=memory&cache=shared}
  3   {file:test1?cache=shared}
  4   {file:test2?another=parameter&yet=anotherone}
} {
  do_test 37.$tn {
    catch { db close }
    sqlite3_shutdown
    sqlite3_config_uri 1
    sqlite3 db $uri

    db eval {
      CREATE TABLE t1(x);
      INSERT INTO t1 VALUES(1);
      SELECT * FROM t1;
    }
  } {1}

  do_execsql_test 37.$tn.2 {
    VACUUM;
    SELECT * FROM t1;
  } {1}

  db close
  sqlite3_shutdown
  sqlite3_config_uri 0
}

do_test 38.1 {
  catch { db close }
2726
2727
2728
2729
2730
2731
2732


2733















2734




























































2735

  sqlite3 db test.db
  execsql {
    PRAGMA cache_size = 1;
    DELETE FROM t1 WHERE rowid%4;
    PRAGMA integrity_check;
  }
} {ok}















































































finish_test








>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

>
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
  sqlite3 db test.db
  execsql {
    PRAGMA cache_size = 1;
    DELETE FROM t1 WHERE rowid%4;
    PRAGMA integrity_check;
  }
} {ok}
db close
tv delete

set pending_prev [sqlite3_test_control_pending_byte 0x1000000]
do_test 42.1 {
  reset_db
  execsql {
    CREATE TABLE t1(x, y);
    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
  }
  db close
  sqlite3_test_control_pending_byte 0x0010000
  sqlite3 db test.db
  db eval { PRAGMA mmap_limit = 0 }
  catchsql { SELECT sum(length(y)) FROM t1 }
} {1 {database disk image is malformed}}
do_test 42.2 {
  reset_db
  execsql {
    CREATE TABLE t1(x, y);
    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
  }
  db close

  testvfs tv -default 1
  tv sectorsize 16384;
  tv devchar [list]
  sqlite3 db test.db -vfs tv
  execsql { UPDATE t1 SET x = randomblob(200) }
} {}
db close
tv delete
sqlite3_test_control_pending_byte $pending_prev

do_test 43.1 {
  reset_db
  execsql {
    CREATE TABLE t1(x, y);
    INSERT INTO t1 VALUES(1, 2);
    CREATE TABLE t2(x, y);
    INSERT INTO t2 VALUES(1, 2);
    CREATE TABLE t3(x, y);
    INSERT INTO t3 VALUES(1, 2);
  }
  db close
  sqlite3 db test.db

  db eval { PRAGMA mmap_limit = 0 }
  db eval { SELECT * FROM t1 }
  sqlite3_db_status db CACHE_MISS 0
} {0 2 0}

do_test 43.2 {
  db eval { SELECT * FROM t2 }
  sqlite3_db_status db CACHE_MISS 1
} {0 3 0}

do_test 43.3 {
  db eval { SELECT * FROM t3 }
  sqlite3_db_status db CACHE_MISS 0
} {0 1 0}

finish_test

Changes to test/pager2.test.
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
  }
}
db close
tv delete


#-------------------------------------------------------------------------
#
# pager2-2.1: Test a ROLLBACK with journal_mode=off.
# pager2-2.2: Test shrinking the database (auto-vacuum) with 
#             journal_mode=off
#
do_test pager2-2.1 {
  faultsim_delete_and_reopen
  execsql {







<







114
115
116
117
118
119
120

121
122
123
124
125
126
127
  }
}
db close
tv delete


#-------------------------------------------------------------------------

# pager2-2.1: Test a ROLLBACK with journal_mode=off.
# pager2-2.2: Test shrinking the database (auto-vacuum) with 
#             journal_mode=off
#
do_test pager2-2.1 {
  faultsim_delete_and_reopen
  execsql {
143
144
145
146
147
148
149
150


















151
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(zeroblob(5000), zeroblob(5000));
    DELETE FROM t1;
    PRAGMA incremental_vacuum;
  }
  file size test.db
} {3072}



















finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
    CREATE TABLE t1(a, b);
    INSERT INTO t1 VALUES(zeroblob(5000), zeroblob(5000));
    DELETE FROM t1;
    PRAGMA incremental_vacuum;
  }
  file size test.db
} {3072}

#-------------------------------------------------------------------------
# Test that shared in-memory databases seem to work.
#
db close
do_test pager2-3.1 {
  forcedelete test.db
  sqlite3_shutdown
  sqlite3_config_uri 1

  sqlite3 db1 {file:test.db?mode=memory&cache=shared}
  sqlite3 db2 {file:test.db?mode=memory&cache=shared}
  sqlite3 db3 test.db

  db1 eval { CREATE TABLE t1(a, b) }
  db2 eval { INSERT INTO t1 VALUES(1, 2) }
  list [catch { db3 eval { INSERT INTO t1 VALUES(3, 4) } } msg] $msg
} {1 {no such table: t1}}

finish_test
Changes to test/pagerfault.test.
1479
1480
1481
1482
1483
1484
1485





























































1486
1487
1488
  }
} -body {
  execsql COMMIT
} -test {
  faultsim_test_result {0 {}}
} 































































finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
  }
} -body {
  execsql COMMIT
} -test {
  faultsim_test_result {0 {}}
} 

do_test pagerfault-35-pre {
  faultsim_delete_and_reopen
  execsql {
    CREATE TABLE t1(x PRIMARY KEY, y);
    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
  }
  faultsim_save_and_close
} {}
testvfs tv -default 1
tv sectorsize 8192;
tv devchar [list]
do_faultsim_test pagerfault-35 -prep {
  faultsim_restore_and_reopen
} -body {
  execsql { UPDATE t1 SET x=randomblob(200) }
} -test {
  faultsim_test_result {0 {}}
}
catch {db close}
tv delete

sqlite3_shutdown
sqlite3_config_uri 1
do_test pagerfault-36-pre {
  faultsim_delete_and_reopen
  execsql {
    CREATE TABLE t1(x PRIMARY KEY, y);
    INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
    INSERT INTO t1 SELECT randomblob(200), randomblob(200) FROM t1;
  }
  faultsim_save_and_close
} {}
do_faultsim_test pagerfault-36 -prep {
  faultsim_restore
  sqlite3 db file:test.db?cache=shared
  sqlite3 db2 file:test.db?cache=shared
  db2 eval {
    BEGIN;
    SELECT count(*) FROM sqlite_master;
  }
  db eval {
    PRAGMA cache_size = 1;
    BEGIN;
      UPDATE t1 SET x = randomblob(200);
  }
} -body {
  execsql ROLLBACK db
} -test {
  catch { db eval {UPDATE t1 SET x = randomblob(200)} }
  faultsim_test_result {0 {}}
  catch { db close }
  catch { db2 close }
}

sqlite3_shutdown
sqlite3_config_uri 0

finish_test