CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
8_3_names.test198 linesDownload Raw Back to test
1# 2011 May 172#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# Test cases for the SQLITE_ENABLE_8_3_NAMES feature that forces all13# filename extensions to be limited to 3 characters.  Some embedded14# systems need this to work around microsoft FAT patents, but this15# feature should be disabled on most deployments.16#17 18set testdir [file dirname $argv0]19source $testdir/tester.tcl20ifcapable !8_3_names {21  finish_test22  return23}24 25db close26sqlite3_shutdown27sqlite3_config_uri 128 29do_test 8_3_names-1.0 {30  forcedelete test.db test.nal test.db-journal31  sqlite3 db test.db32  db eval {33    PRAGMA cache_size=10;34    CREATE TABLE t1(x);35    INSERT INTO t1 VALUES(randomblob(20000));36    BEGIN;37    DELETE FROM t1;38    INSERT INTO t1 VALUES(randomblob(15000));39  }40  file exists test.db-journal41} 142do_test 8_3_names-1.1 {43  file exists test.nal44} 045do_test 8_3_names-1.2 {46  db eval {47    ROLLBACK;48    SELECT length(x) FROM t149  }50} 2000051 52db close53do_test 8_3_names-2.0 {54  forcedelete test.db test.nal test.db-journal55  sqlite3 db file:./test.db?8_3_names=156  db eval {57    PRAGMA cache_size=10;58    CREATE TABLE t1(x);59    INSERT INTO t1 VALUES(randomblob(20000));60    BEGIN;61    DELETE FROM t1;62    INSERT INTO t1 VALUES(randomblob(15000));63  }64  file exists test.db-journal65} 066do_test 8_3_names-2.1 {67  file exists test.nal68} 169forcedelete test2.db test2.nal test2.db-journal70copy_file test.db test2.db71copy_file test.nal test2.nal72do_test 8_3_names-2.2 {73  db eval {74    COMMIT;75    SELECT length(x) FROM t176  }77} 1500078do_test 8_3_names-2.3 {79  sqlite3 db2 file:./test2.db?8_3_names=180  db2 eval {81    PRAGMA integrity_check;82    SELECT length(x) FROM t1;83  }84} {ok 20000}85 86db close87do_test 8_3_names-3.0 {88  forcedelete test.db test.nal test.db-journal89  sqlite3 db file:./test.db?8_3_names=090  db eval {91    PRAGMA cache_size=10;92    CREATE TABLE t1(x);93    INSERT INTO t1 VALUES(randomblob(20000));94    BEGIN;95    DELETE FROM t1;96    INSERT INTO t1 VALUES(randomblob(15000));97  }98  file exists test.db-journal99} 1100do_test 8_3_names-3.1 {101  file exists test.nal102} 0103forcedelete test2.db test2.nal test2.db-journal104copy_file test.db test2.db105copy_file test.db-journal test2.db-journal106do_test 8_3_names-3.2 {107  db eval {108    COMMIT;109    SELECT length(x) FROM t1110  }111} 15000112do_test 8_3_names-3.3 {113  sqlite3 db2 file:./test2.db?8_3_names=0114  db2 eval {115    PRAGMA integrity_check;116    SELECT length(x) FROM t1;117  }118} {ok 20000}119 120##########################################################################121# Master journals.122#123db close124forcedelete test.db test2.db125do_test 8_3_names-4.0 {126  sqlite3 db file:./test.db?8_3_names=1127  db eval {128    CREATE TABLE t1(x);129    INSERT INTO t1 VALUES(1);130    ATTACH 'file:./test2.db?8_3_names=1' AS db2;131    CREATE TABLE db2.t2(y);132    INSERT INTO t2 VALUES(2);133    BEGIN;134      INSERT INTO t1 VALUES(3);135      INSERT INTO t2 VALUES(4);136    COMMIT;137    SELECT * FROM t1, t2 ORDER BY x, y138  }139} {1 2 1 4 3 2 3 4}140    141 142##########################################################################143# WAL mode.144#145ifcapable !wal {146  finish_test147  return148}149db close150forcedelete test.db151do_test 8_3_names-5.0 {152  sqlite3 db file:./test.db?8_3_names=1153  load_static_extension db wholenumber154  db eval {155    PRAGMA journal_mode=WAL;156    CREATE TABLE t1(x);157    CREATE VIRTUAL TABLE nums USING wholenumber;158    INSERT INTO t1 SELECT value FROM nums WHERE value BETWEEN 1 AND 1000;159    BEGIN;160    UPDATE t1 SET x=x*2;161  }162  sqlite3 db2 file:./test.db?8_3_names=1163  load_static_extension db2 wholenumber164  db2 eval {165    BEGIN;166    SELECT sum(x) FROM t1;167  }168} {500500}169 170do_test 8_3_names-5.1 {171  file exists test.db-wal172} 0173do_test 8_3_names-5.2 {174  file exists test.wal175} 1176do_test 8_3_names-5.3 {177  file exists test.db-shm178} 0179do_test 8_3_names-5.4 {180  file exists test.shm181} 1182 183 184do_test 8_3_names-5.5 {185  db eval {186    COMMIT;187    SELECT sum(x) FROM t1;188  }189} {1001000}190do_test 8_3_names-5.6 {191  db2 eval {192    SELECT sum(x) FROM t1;193  }194} {500500}195 196 197finish_test198