CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
changes.test89 linesDownload Raw Back to test
1# 2021 June 222#3# The author disclaims copyright to this source code.  In place of4# 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#12# Tests for the sqlite3_changes() and sqlite3_total_changes() APIs.13#14 15set testdir [file dirname $argv0]16source $testdir/tester.tcl17set testprefix changes18 19# To test that the change-counters do not suffer from 32-bit signed integer 20# rollover, add the following line to the array of test cases below. The21# test will take will over an hour to run.22#23#   7 (1<<31)+10 ""24#25 26foreach {tn nRow wor} {27  1 50 ""28  2 50 "WITHOUT ROWID"29 30  3 5000 ""31  4 5000 "WITHOUT ROWID"32 33  5 50000 ""34  6 50000 "WITHOUT ROWID"35} {36  reset_db37  set nBig [expr $nRow]38  39  do_execsql_test 1.$tn.0 "40    PRAGMA journal_mode = off;41    CREATE TABLE t1(x INTEGER PRIMARY KEY) $wor;42  " {off}43  44  do_execsql_test 1.$tn.1 {45    WITH s(i) AS (46      SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i < $nBig47    )48    INSERT INTO t1 SELECT i FROM s;49  }50  51  do_test 1.$tn.2 {52    db changes53  } [expr $nBig]54  55  do_test 1.$tn.3 {56    db total_changes57  } [expr $nBig]58  59  do_execsql_test 1.$tn.4 {60    INSERT INTO t1 VALUES(-1)61  }62  63  do_test 1.$tn.5 {64    db changes65  } [expr 1]66  67  do_test 1.$tn.6 {68    db total_changes69  } [expr {$nBig+1}]70  71  do_execsql_test 1.$tn.7a {72    SELECT count(*) FROM t173  } [expr {$nBig+1}]74  75  do_execsql_test 1.$tn.7 {76    DELETE FROM t177  }78  79  do_test 1.$tn.8 {80    db changes81  } [expr {$nBig+1}]82  83  do_test 1.$tn.9 {84    db total_changes85  } [expr {2*($nBig+1)}]86}87 88finish_test89