1cd61c281Sdrh# 2002 March 6 2cd61c281Sdrh# 3cd61c281Sdrh# The author disclaims copyright to this source code. In place of 4cd61c281Sdrh# a legal notice, here is a blessing: 5cd61c281Sdrh# 6cd61c281Sdrh# May you do good and not evil. 7cd61c281Sdrh# May you find forgiveness for yourself and forgive others. 8cd61c281Sdrh# May you share freely, never taking more than you give. 9cd61c281Sdrh# 10cd61c281Sdrh#*********************************************************************** 11cd61c281Sdrh# This file implements regression tests for SQLite library. 12cd61c281Sdrh# 13cd61c281Sdrh# This file implements tests for the PRAGMA command. 14cd61c281Sdrh# 15*f96a3778Sdanielk1977# $Id: pragma.test,v 1.69 2008/10/23 05:45:07 danielk1977 Exp $ 16cd61c281Sdrh 17cd61c281Sdrhset testdir [file dirname $argv0] 18cd61c281Sdrhsource $testdir/tester.tcl 19cd61c281Sdrh 2091cf71b0Sdanielk1977# Test organization: 2191cf71b0Sdanielk1977# 2291cf71b0Sdanielk1977# pragma-1.*: Test cache_size, default_cache_size and synchronous on main db. 2391cf71b0Sdanielk1977# pragma-2.*: Test synchronous on attached db. 2491cf71b0Sdanielk1977# pragma-3.*: Test detection of table/index inconsistency by integrity_check. 2591cf71b0Sdanielk1977# pragma-4.*: Test cache_size and default_cache_size on attached db. 2691cf71b0Sdanielk1977# pragma-5.*: Test that pragma synchronous may not be used inside of a 2791cf71b0Sdanielk1977# transaction. 28cc6bd383Sdanielk1977# pragma-6.*: Test schema-query pragmas. 29cc6bd383Sdanielk1977# pragma-7.*: Miscellaneous tests. 30cc6bd383Sdanielk1977# pragma-8.*: Test user_version and schema_version pragmas. 319a09a3caStpoindex# pragma-9.*: Test temp_store and temp_store_directory. 32cc6bd383Sdanielk1977# pragma-10.*: Test the count_changes pragma in the presence of triggers. 3348af65aeSdanielk1977# pragma-11.*: Test the collation_list pragma. 3459a93791Sdanielk1977# pragma-14.*: Test the page_count pragma. 358cf6c554Sdanielk1977# pragma-15.*: Test that the value set using the cache_size pragma is not 368cf6c554Sdanielk1977# reset when the schema is reloaded. 3791cf71b0Sdanielk1977# 3891cf71b0Sdanielk1977 3905a82983Sdrhifcapable !pragma { 4005a82983Sdrh finish_test 4105a82983Sdrh return 4205a82983Sdrh} 4305a82983Sdrh 44cd61c281Sdrh# Delete the preexisting database to avoid the special setup 45cd61c281Sdrh# that the "all.test" script does. 46cd61c281Sdrh# 47cd61c281Sdrhdb close 4825403650Sdrhfile delete test.db test.db-journal 4925403650Sdrhfile delete test3.db test3.db-journal 50dddca286Sdrhsqlite3 db test.db; set DB [sqlite3_connection_pointer db] 51cd61c281Sdrh 521e9daa6aSdrh 53c7b4a44cSdanielk1977ifcapable pager_pragmas { 541e9daa6aSdrhset DFLT_CACHE_SZ [db one {PRAGMA default_cache_size}] 551e9daa6aSdrhset TEMP_CACHE_SZ [db one {PRAGMA temp.default_cache_size}] 56cd61c281Sdrhdo_test pragma-1.1 { 57cd61c281Sdrh execsql { 58cd61c281Sdrh PRAGMA cache_size; 59cd61c281Sdrh PRAGMA default_cache_size; 60cd61c281Sdrh PRAGMA synchronous; 61cd61c281Sdrh } 621e9daa6aSdrh} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2] 63cd61c281Sdrhdo_test pragma-1.2 { 64cd61c281Sdrh execsql { 65eb43e5c7Sdrh PRAGMA synchronous=OFF; 66cd61c281Sdrh PRAGMA cache_size=1234; 67cd61c281Sdrh PRAGMA cache_size; 68cd61c281Sdrh PRAGMA default_cache_size; 69cd61c281Sdrh PRAGMA synchronous; 70cd61c281Sdrh } 711e9daa6aSdrh} [list 1234 $DFLT_CACHE_SZ 0] 72cd61c281Sdrhdo_test pragma-1.3 { 73cd61c281Sdrh db close 74ef4ac8f9Sdrh sqlite3 db test.db 75cd61c281Sdrh execsql { 76cd61c281Sdrh PRAGMA cache_size; 77cd61c281Sdrh PRAGMA default_cache_size; 78cd61c281Sdrh PRAGMA synchronous; 79cd61c281Sdrh } 801e9daa6aSdrh} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2] 81cd61c281Sdrhdo_test pragma-1.4 { 82cd61c281Sdrh execsql { 83cd61c281Sdrh PRAGMA synchronous=OFF; 84cd61c281Sdrh PRAGMA cache_size; 85cd61c281Sdrh PRAGMA default_cache_size; 86cd61c281Sdrh PRAGMA synchronous; 87cd61c281Sdrh } 881e9daa6aSdrh} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 0] 89cd61c281Sdrhdo_test pragma-1.5 { 90cd61c281Sdrh execsql { 91cd61c281Sdrh PRAGMA cache_size=4321; 92cd61c281Sdrh PRAGMA cache_size; 93cd61c281Sdrh PRAGMA default_cache_size; 94cd61c281Sdrh PRAGMA synchronous; 95cd61c281Sdrh } 961e9daa6aSdrh} [list 4321 $DFLT_CACHE_SZ 0] 97cd61c281Sdrhdo_test pragma-1.6 { 98cd61c281Sdrh execsql { 99cd61c281Sdrh PRAGMA synchronous=ON; 100cd61c281Sdrh PRAGMA cache_size; 101cd61c281Sdrh PRAGMA default_cache_size; 102cd61c281Sdrh PRAGMA synchronous; 103cd61c281Sdrh } 1041e9daa6aSdrh} [list 4321 $DFLT_CACHE_SZ 1] 105cd61c281Sdrhdo_test pragma-1.7 { 106cd61c281Sdrh db close 107ef4ac8f9Sdrh sqlite3 db test.db 108cd61c281Sdrh execsql { 109cd61c281Sdrh PRAGMA cache_size; 110cd61c281Sdrh PRAGMA default_cache_size; 111cd61c281Sdrh PRAGMA synchronous; 112cd61c281Sdrh } 1131e9daa6aSdrh} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ 2] 114cd61c281Sdrhdo_test pragma-1.8 { 115cd61c281Sdrh execsql { 116cd61c281Sdrh PRAGMA default_cache_size=123; 117cd61c281Sdrh PRAGMA cache_size; 118cd61c281Sdrh PRAGMA default_cache_size; 119cd61c281Sdrh PRAGMA synchronous; 120cd61c281Sdrh } 12191cf71b0Sdanielk1977} {123 123 2} 122802d69a7Sdrhdo_test pragma-1.9.1 { 123cd61c281Sdrh db close 124dddca286Sdrh sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db] 125cd61c281Sdrh execsql { 126cd61c281Sdrh PRAGMA cache_size; 127cd61c281Sdrh PRAGMA default_cache_size; 128cd61c281Sdrh PRAGMA synchronous; 129cd61c281Sdrh } 13091cf71b0Sdanielk1977} {123 123 2} 131802d69a7Sdrhifcapable vacuum { 132802d69a7Sdrh do_test pragma-1.9.2 { 133802d69a7Sdrh execsql { 134802d69a7Sdrh VACUUM; 135802d69a7Sdrh PRAGMA cache_size; 136802d69a7Sdrh PRAGMA default_cache_size; 137802d69a7Sdrh PRAGMA synchronous; 138802d69a7Sdrh } 139802d69a7Sdrh } {123 123 2} 140802d69a7Sdrh} 14191cf71b0Sdanielk1977do_test pragma-1.10 { 1425a38705eSdrh execsql { 1434303feedSdrh PRAGMA synchronous=NORMAL; 1444303feedSdrh PRAGMA cache_size; 1454303feedSdrh PRAGMA default_cache_size; 1464303feedSdrh PRAGMA synchronous; 1474303feedSdrh } 14891cf71b0Sdanielk1977} {123 123 1} 14991cf71b0Sdanielk1977do_test pragma-1.11 { 1504303feedSdrh execsql { 1514303feedSdrh PRAGMA synchronous=FULL; 1524303feedSdrh PRAGMA cache_size; 1534303feedSdrh PRAGMA default_cache_size; 1544303feedSdrh PRAGMA synchronous; 1554303feedSdrh } 15691cf71b0Sdanielk1977} {123 123 2} 15791cf71b0Sdanielk1977do_test pragma-1.12 { 1584303feedSdrh db close 159dddca286Sdrh sqlite3 db test.db; set ::DB [sqlite3_connection_pointer db] 1604303feedSdrh execsql { 1614303feedSdrh PRAGMA cache_size; 1624303feedSdrh PRAGMA default_cache_size; 1634303feedSdrh PRAGMA synchronous; 1644303feedSdrh } 16591cf71b0Sdanielk1977} {123 123 2} 16691cf71b0Sdanielk1977 1675260f7e9Sdrh# Make sure the pragma handler understands numeric values in addition 1685260f7e9Sdrh# to keywords like "off" and "full". 1695260f7e9Sdrh# 1705260f7e9Sdrhdo_test pragma-1.13 { 1715260f7e9Sdrh execsql { 1725260f7e9Sdrh PRAGMA synchronous=0; 1735260f7e9Sdrh PRAGMA synchronous; 1745260f7e9Sdrh } 1755260f7e9Sdrh} {0} 1765260f7e9Sdrhdo_test pragma-1.14 { 1775260f7e9Sdrh execsql { 1785260f7e9Sdrh PRAGMA synchronous=2; 1795260f7e9Sdrh PRAGMA synchronous; 1805260f7e9Sdrh } 1815260f7e9Sdrh} {2} 182c7b4a44cSdanielk1977} ;# ifcapable pager_pragmas 1835260f7e9Sdrh 1845260f7e9Sdrh# Test turning "flag" pragmas on and off. 1855260f7e9Sdrh# 1866338c762Sdanielk1977ifcapable debug { 1876338c762Sdanielk1977 # Pragma "vdbe_listing" is only available if compiled with SQLITE_DEBUG 1886338c762Sdanielk1977 # 1895260f7e9Sdrh do_test pragma-1.15 { 1905260f7e9Sdrh execsql { 1915260f7e9Sdrh PRAGMA vdbe_listing=YES; 1925260f7e9Sdrh PRAGMA vdbe_listing; 1935260f7e9Sdrh } 1945260f7e9Sdrh } {1} 1955260f7e9Sdrh do_test pragma-1.16 { 1965260f7e9Sdrh execsql { 1975260f7e9Sdrh PRAGMA vdbe_listing=NO; 1985260f7e9Sdrh PRAGMA vdbe_listing; 1995260f7e9Sdrh } 2005260f7e9Sdrh } {0} 2016338c762Sdanielk1977} 2026338c762Sdanielk1977 2035260f7e9Sdrhdo_test pragma-1.17 { 2045260f7e9Sdrh execsql { 2055260f7e9Sdrh PRAGMA parser_trace=ON; 2065260f7e9Sdrh PRAGMA parser_trace=OFF; 2075260f7e9Sdrh } 2085260f7e9Sdrh} {} 2095260f7e9Sdrhdo_test pragma-1.18 { 2105260f7e9Sdrh execsql { 2115260f7e9Sdrh PRAGMA bogus = -1234; -- Parsing of negative values 2125260f7e9Sdrh } 2135260f7e9Sdrh} {} 2145260f7e9Sdrh 21591cf71b0Sdanielk1977# Test modifying the safety_level of an attached database. 2165a8f9374Sdanielk1977ifcapable pager_pragmas&&attach { 21791cf71b0Sdanielk1977 do_test pragma-2.1 { 21891cf71b0Sdanielk1977 file delete -force test2.db 21991cf71b0Sdanielk1977 file delete -force test2.db-journal 2204303feedSdrh execsql { 22191cf71b0Sdanielk1977 ATTACH 'test2.db' AS aux; 2224303feedSdrh } 22391cf71b0Sdanielk1977 } {} 22491cf71b0Sdanielk1977 do_test pragma-2.2 { 2254303feedSdrh execsql { 22691cf71b0Sdanielk1977 pragma aux.synchronous; 2274303feedSdrh } 22891cf71b0Sdanielk1977 } {2} 22991cf71b0Sdanielk1977 do_test pragma-2.3 { 23091cf71b0Sdanielk1977 execsql { 23191cf71b0Sdanielk1977 pragma aux.synchronous = OFF; 23291cf71b0Sdanielk1977 pragma aux.synchronous; 23391cf71b0Sdanielk1977 pragma synchronous; 23491cf71b0Sdanielk1977 } 23591cf71b0Sdanielk1977 } {0 2} 23691cf71b0Sdanielk1977 do_test pragma-2.4 { 23791cf71b0Sdanielk1977 execsql { 23891cf71b0Sdanielk1977 pragma aux.synchronous = ON; 23991cf71b0Sdanielk1977 pragma synchronous; 24091cf71b0Sdanielk1977 pragma aux.synchronous; 24191cf71b0Sdanielk1977 } 24291cf71b0Sdanielk1977 } {2 1} 243c7b4a44cSdanielk1977} ;# ifcapable pager_pragmas 2444303feedSdrh 245ed717fe3Sdrh# Construct a corrupted index and make sure the integrity_check 246ed717fe3Sdrh# pragma finds it. 247ed717fe3Sdrh# 24825d6543dSdrh# These tests won't work if the database is encrypted 24925d6543dSdrh# 250ed717fe3Sdrhdo_test pragma-3.1 { 2511e9daa6aSdrh db close 2521e9daa6aSdrh file delete -force test.db test.db-journal 2531e9daa6aSdrh sqlite3 db test.db 254ed717fe3Sdrh execsql { 2551e9daa6aSdrh PRAGMA auto_vacuum=OFF; 256ed717fe3Sdrh BEGIN; 257ed717fe3Sdrh CREATE TABLE t2(a,b,c); 258ed717fe3Sdrh CREATE INDEX i2 ON t2(a); 259ed717fe3Sdrh INSERT INTO t2 VALUES(11,2,3); 260ed717fe3Sdrh INSERT INTO t2 VALUES(22,3,4); 261ed717fe3Sdrh COMMIT; 262ed717fe3Sdrh SELECT rowid, * from t2; 263ed717fe3Sdrh } 264ed717fe3Sdrh} {1 11 2 3 2 22 3 4} 2655a8f9374Sdanielk1977ifcapable attach { 26640e016e4Sdrh if {![sqlite3 -has-codec] && $sqlite_options(integrityck)} { 267ed717fe3Sdrh do_test pragma-3.2 { 268bb8a279eSdrh db eval {SELECT rootpage FROM sqlite_master WHERE name='i2'} break 269bb8a279eSdrh set pgsz [db eval {PRAGMA page_size}] 270bb8a279eSdrh # overwrite the header on the rootpage of the index in order to 271bb8a279eSdrh # make the index appear to be empty. 272bb8a279eSdrh # 273bb8a279eSdrh set offset [expr {$pgsz*($rootpage-1)}] 274bb8a279eSdrh hexio_write test.db $offset 0a00000000040000000000 275bb8a279eSdrh db close 276bb8a279eSdrh sqlite3 db test.db 277ed717fe3Sdrh execsql {PRAGMA integrity_check} 278bb8a279eSdrh } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}} 27991cf71b0Sdanielk1977 do_test pragma-3.3 { 2801dcdbc06Sdrh execsql {PRAGMA integrity_check=1} 2811dcdbc06Sdrh } {{rowid 1 missing from index i2}} 2821dcdbc06Sdrh do_test pragma-3.4 { 28391cf71b0Sdanielk1977 execsql { 2841dcdbc06Sdrh ATTACH DATABASE 'test.db' AS t2; 2851dcdbc06Sdrh PRAGMA integrity_check 28691cf71b0Sdanielk1977 } 287bb8a279eSdrh } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}} 2881dcdbc06Sdrh do_test pragma-3.5 { 2891dcdbc06Sdrh execsql { 290bb8a279eSdrh PRAGMA integrity_check=4 2911dcdbc06Sdrh } 292bb8a279eSdrh } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2}} 2931dcdbc06Sdrh do_test pragma-3.6 { 2941dcdbc06Sdrh execsql { 2951dcdbc06Sdrh PRAGMA integrity_check=xyz 2961dcdbc06Sdrh } 297bb8a279eSdrh } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}} 2981dcdbc06Sdrh do_test pragma-3.7 { 2991dcdbc06Sdrh execsql { 3001dcdbc06Sdrh PRAGMA integrity_check=0 3011dcdbc06Sdrh } 302bb8a279eSdrh } {{rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}} 3031dcdbc06Sdrh 3041dcdbc06Sdrh # Add additional corruption by appending unused pages to the end of 3051dcdbc06Sdrh # the database file testerr.db 3061dcdbc06Sdrh # 3071dcdbc06Sdrh do_test pragma-3.8 { 3081dcdbc06Sdrh execsql {DETACH t2} 3091dcdbc06Sdrh file delete -force testerr.db testerr.db-journal 310e3d559adSdrh set out [open testerr.db w] 311e3d559adSdrh fconfigure $out -translation binary 312e3d559adSdrh set in [open test.db r] 313e3d559adSdrh fconfigure $in -translation binary 3141dcdbc06Sdrh puts -nonewline $out [read $in] 3151dcdbc06Sdrh seek $in 0 3161dcdbc06Sdrh puts -nonewline $out [read $in] 3171dcdbc06Sdrh close $in 3181dcdbc06Sdrh close $out 3191dcdbc06Sdrh execsql {REINDEX t2} 3201dcdbc06Sdrh execsql {PRAGMA integrity_check} 3211dcdbc06Sdrh } {ok} 32241c58b78Sdanielk1977 do_test pragma-3.8.1 { 32341c58b78Sdanielk1977 execsql {PRAGMA quick_check} 32441c58b78Sdanielk1977 } {ok} 3251dcdbc06Sdrh do_test pragma-3.9 { 3261dcdbc06Sdrh execsql { 3271dcdbc06Sdrh ATTACH 'testerr.db' AS t2; 3281dcdbc06Sdrh PRAGMA integrity_check 3291dcdbc06Sdrh } 3301dcdbc06Sdrh } {{*** in database t2 *** 3311dcdbc06SdrhPage 4 is never used 3321dcdbc06SdrhPage 5 is never used 333bb8a279eSdrhPage 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}} 3341dcdbc06Sdrh do_test pragma-3.10 { 3351dcdbc06Sdrh execsql { 3361dcdbc06Sdrh PRAGMA integrity_check=1 3371dcdbc06Sdrh } 3381dcdbc06Sdrh } {{*** in database t2 *** 3391dcdbc06SdrhPage 4 is never used}} 3401dcdbc06Sdrh do_test pragma-3.11 { 3411dcdbc06Sdrh execsql { 3421dcdbc06Sdrh PRAGMA integrity_check=5 3431dcdbc06Sdrh } 3441dcdbc06Sdrh } {{*** in database t2 *** 3451dcdbc06SdrhPage 4 is never used 3461dcdbc06SdrhPage 5 is never used 347bb8a279eSdrhPage 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2}} 3481dcdbc06Sdrh do_test pragma-3.12 { 3491dcdbc06Sdrh execsql { 3501dcdbc06Sdrh PRAGMA integrity_check=4 3511dcdbc06Sdrh } 3521dcdbc06Sdrh } {{*** in database t2 *** 3531dcdbc06SdrhPage 4 is never used 3541dcdbc06SdrhPage 5 is never used 3551dcdbc06SdrhPage 6 is never used} {rowid 1 missing from index i2}} 3561dcdbc06Sdrh do_test pragma-3.13 { 3571dcdbc06Sdrh execsql { 3581dcdbc06Sdrh PRAGMA integrity_check=3 3591dcdbc06Sdrh } 3601dcdbc06Sdrh } {{*** in database t2 *** 3611dcdbc06SdrhPage 4 is never used 3621dcdbc06SdrhPage 5 is never used 3631dcdbc06SdrhPage 6 is never used}} 3641dcdbc06Sdrh do_test pragma-3.14 { 3651dcdbc06Sdrh execsql { 3661dcdbc06Sdrh PRAGMA integrity_check(2) 3671dcdbc06Sdrh } 3681dcdbc06Sdrh } {{*** in database t2 *** 3691dcdbc06SdrhPage 4 is never used 3701dcdbc06SdrhPage 5 is never used}} 3711dcdbc06Sdrh do_test pragma-3.15 { 3721dcdbc06Sdrh execsql { 3731dcdbc06Sdrh ATTACH 'testerr.db' AS t3; 3741dcdbc06Sdrh PRAGMA integrity_check 3751dcdbc06Sdrh } 3761dcdbc06Sdrh } {{*** in database t2 *** 3771dcdbc06SdrhPage 4 is never used 3781dcdbc06SdrhPage 5 is never used 379bb8a279eSdrhPage 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 *** 3801dcdbc06SdrhPage 4 is never used 3811dcdbc06SdrhPage 5 is never used 382bb8a279eSdrhPage 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2}} 3831dcdbc06Sdrh do_test pragma-3.16 { 3841dcdbc06Sdrh execsql { 385bb8a279eSdrh PRAGMA integrity_check(10) 3861dcdbc06Sdrh } 3871dcdbc06Sdrh } {{*** in database t2 *** 3881dcdbc06SdrhPage 4 is never used 3891dcdbc06SdrhPage 5 is never used 390bb8a279eSdrhPage 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 *** 3911dcdbc06SdrhPage 4 is never used 3921dcdbc06SdrhPage 5 is never used 3931dcdbc06SdrhPage 6 is never used} {rowid 1 missing from index i2}} 3941dcdbc06Sdrh do_test pragma-3.17 { 3951dcdbc06Sdrh execsql { 396bb8a279eSdrh PRAGMA integrity_check=8 3971dcdbc06Sdrh } 3981dcdbc06Sdrh } {{*** in database t2 *** 3991dcdbc06SdrhPage 4 is never used 4001dcdbc06SdrhPage 5 is never used 401bb8a279eSdrhPage 6 is never used} {rowid 1 missing from index i2} {rowid 2 missing from index i2} {wrong # of entries in index i2} {*** in database t3 *** 4021dcdbc06SdrhPage 4 is never used 4031dcdbc06SdrhPage 5 is never used}} 4041dcdbc06Sdrh do_test pragma-3.18 { 4051dcdbc06Sdrh execsql { 4061dcdbc06Sdrh PRAGMA integrity_check=4 4071dcdbc06Sdrh } 4081dcdbc06Sdrh } {{*** in database t2 *** 4091dcdbc06SdrhPage 4 is never used 4101dcdbc06SdrhPage 5 is never used 4111dcdbc06SdrhPage 6 is never used} {rowid 1 missing from index i2}} 4121dcdbc06Sdrh } 4131dcdbc06Sdrh do_test pragma-3.99 { 4141dcdbc06Sdrh catchsql {DETACH t3} 4151dcdbc06Sdrh catchsql {DETACH t2} 41690ddb123Sdrh file delete -force testerr.db testerr.db-journal 41705a6f4acSdrh catchsql {DROP INDEX i2} 4181dcdbc06Sdrh } {0 {}} 4195a8f9374Sdanielk1977} 42091cf71b0Sdanielk1977 42191cf71b0Sdanielk1977# Test modifying the cache_size of an attached database. 4225a8f9374Sdanielk1977ifcapable pager_pragmas&&attach { 42391cf71b0Sdanielk1977do_test pragma-4.1 { 42491cf71b0Sdanielk1977 execsql { 4251e9daa6aSdrh ATTACH 'test2.db' AS aux; 42691cf71b0Sdanielk1977 pragma aux.cache_size; 42791cf71b0Sdanielk1977 pragma aux.default_cache_size; 42891cf71b0Sdanielk1977 } 4291e9daa6aSdrh} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ] 4301bdd9b57Sdrhdo_test pragma-4.2 { 4311bdd9b57Sdrh execsql { 43291cf71b0Sdanielk1977 pragma aux.cache_size = 50; 43391cf71b0Sdanielk1977 pragma aux.cache_size; 43491cf71b0Sdanielk1977 pragma aux.default_cache_size; 4351bdd9b57Sdrh } 4361e9daa6aSdrh} [list 50 $DFLT_CACHE_SZ] 4371bdd9b57Sdrhdo_test pragma-4.3 { 4381bdd9b57Sdrh execsql { 43991cf71b0Sdanielk1977 pragma aux.default_cache_size = 456; 44091cf71b0Sdanielk1977 pragma aux.cache_size; 44191cf71b0Sdanielk1977 pragma aux.default_cache_size; 4421bdd9b57Sdrh } 44391cf71b0Sdanielk1977} {456 456} 4441bdd9b57Sdrhdo_test pragma-4.4 { 4451bdd9b57Sdrh execsql { 44691cf71b0Sdanielk1977 pragma cache_size; 44791cf71b0Sdanielk1977 pragma default_cache_size; 4481bdd9b57Sdrh } 4491e9daa6aSdrh} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ] 4501bdd9b57Sdrhdo_test pragma-4.5 { 4511bdd9b57Sdrh execsql { 45291cf71b0Sdanielk1977 DETACH aux; 45391cf71b0Sdanielk1977 ATTACH 'test3.db' AS aux; 45491cf71b0Sdanielk1977 pragma aux.cache_size; 45591cf71b0Sdanielk1977 pragma aux.default_cache_size; 4561bdd9b57Sdrh } 4571e9daa6aSdrh} [list $DFLT_CACHE_SZ $DFLT_CACHE_SZ] 4581bdd9b57Sdrhdo_test pragma-4.6 { 4591bdd9b57Sdrh execsql { 46091cf71b0Sdanielk1977 DETACH aux; 46191cf71b0Sdanielk1977 ATTACH 'test2.db' AS aux; 46291cf71b0Sdanielk1977 pragma aux.cache_size; 46391cf71b0Sdanielk1977 pragma aux.default_cache_size; 4641bdd9b57Sdrh } 46591cf71b0Sdanielk1977} {456 456} 466c7b4a44cSdanielk1977} ;# ifcapable pager_pragmas 4671bdd9b57Sdrh 46891cf71b0Sdanielk1977# Test that modifying the sync-level in the middle of a transaction is 46991cf71b0Sdanielk1977# disallowed. 470c7b4a44cSdanielk1977ifcapable pager_pragmas { 47191cf71b0Sdanielk1977do_test pragma-5.0 { 4721bdd9b57Sdrh execsql { 47391cf71b0Sdanielk1977 pragma synchronous; 4741bdd9b57Sdrh } 47591cf71b0Sdanielk1977} {2} 47691cf71b0Sdanielk1977do_test pragma-5.1 { 4771bdd9b57Sdrh catchsql { 4781bdd9b57Sdrh BEGIN; 47991cf71b0Sdanielk1977 pragma synchronous = OFF; 4801bdd9b57Sdrh } 48191cf71b0Sdanielk1977} {1 {Safety level may not be changed inside a transaction}} 48291cf71b0Sdanielk1977do_test pragma-5.2 { 48391cf71b0Sdanielk1977 execsql { 48491cf71b0Sdanielk1977 pragma synchronous; 48591cf71b0Sdanielk1977 } 48691cf71b0Sdanielk1977} {2} 4875260f7e9Sdrhcatchsql {COMMIT;} 488c7b4a44cSdanielk1977} ;# ifcapable pager_pragmas 4895260f7e9Sdrh 4905260f7e9Sdrh# Test schema-query pragmas 4915260f7e9Sdrh# 49227188fb5Sdanielk1977ifcapable schema_pragmas { 4935a8f9374Sdanielk1977ifcapable tempdb&&attach { 4945260f7e9Sdrh do_test pragma-6.1 { 495956bc92cSdrh set res {} 49640e016e4Sdrh execsql {SELECT * FROM sqlite_temp_master} 4975260f7e9Sdrh foreach {idx name file} [execsql {pragma database_list}] { 4985260f7e9Sdrh lappend res $idx $name 4995260f7e9Sdrh } 5005260f7e9Sdrh set res 501a71aa001Sdrh } {0 main 1 temp 2 aux} 50253c0f748Sdanielk1977} 5035260f7e9Sdrhdo_test pragma-6.2 { 5045260f7e9Sdrh execsql { 5055260f7e9Sdrh pragma table_info(t2) 5065260f7e9Sdrh } 507bfa8b102Sdrh} {0 a {} 0 {} 0 1 b {} 0 {} 0 2 c {} 0 {} 0} 508736c7d4bSdrhdb nullvalue <<NULL>> 509417ec638Sdrhdo_test pragma-6.2.2 { 510417ec638Sdrh execsql { 511736c7d4bSdrh CREATE TABLE t5( 512736c7d4bSdrh a TEXT DEFAULT CURRENT_TIMESTAMP, 513736c7d4bSdrh b DEFAULT (5+3), 514736c7d4bSdrh c TEXT, 515736c7d4bSdrh d INTEGER DEFAULT NULL, 516736c7d4bSdrh e TEXT DEFAULT '' 517736c7d4bSdrh ); 518417ec638Sdrh PRAGMA table_info(t5); 519417ec638Sdrh } 520736c7d4bSdrh} {0 a TEXT 0 CURRENT_TIMESTAMP 0 1 b {} 0 5+3 0 2 c TEXT 0 <<NULL>> 0 3 d INTEGER 0 NULL 0 4 e TEXT 0 '' 0} 521736c7d4bSdrhdb nullvalue {} 5226bf89570Sdrhifcapable {foreignkey} { 5235260f7e9Sdrh do_test pragma-6.3 { 5245260f7e9Sdrh execsql { 5255260f7e9Sdrh CREATE TABLE t3(a int references t2(b), b UNIQUE); 5265260f7e9Sdrh pragma foreign_key_list(t3); 5275260f7e9Sdrh } 52850af3e1dSdanielk1977 } {0 0 t2 a b RESTRICT RESTRICT NONE} 5295260f7e9Sdrh do_test pragma-6.4 { 5305260f7e9Sdrh execsql { 5315260f7e9Sdrh pragma index_list(t3); 5325260f7e9Sdrh } 5335260f7e9Sdrh } {0 sqlite_autoindex_t3_1 1} 5346bf89570Sdrh} 5356bf89570Sdrhifcapable {!foreignkey} { 5366bf89570Sdrh execsql {CREATE TABLE t3(a,b UNIQUE)} 5376bf89570Sdrh} 5385260f7e9Sdrhdo_test pragma-6.5 { 5395260f7e9Sdrh execsql { 5405260f7e9Sdrh CREATE INDEX t3i1 ON t3(a,b); 5415260f7e9Sdrh pragma index_info(t3i1); 5425260f7e9Sdrh } 5435260f7e9Sdrh} {0 0 a 1 1 b} 544260d8a6aSdanielk1977 545260d8a6aSdanielk1977ifcapable tempdb { 546260d8a6aSdanielk1977 # Test for ticket #3320. When a temp table of the same name exists, make 547260d8a6aSdanielk1977 # sure the schema of the main table can still be queried using 548260d8a6aSdanielk1977 # "pragma table_info": 549260d8a6aSdanielk1977 do_test pragma-6.6.1 { 550260d8a6aSdanielk1977 execsql { 551260d8a6aSdanielk1977 CREATE TABLE trial(col_main); 552260d8a6aSdanielk1977 CREATE TEMP TABLE trial(col_temp); 553260d8a6aSdanielk1977 } 554260d8a6aSdanielk1977 } {} 555260d8a6aSdanielk1977 do_test pragma-6.6.2 { 556260d8a6aSdanielk1977 execsql { 557260d8a6aSdanielk1977 PRAGMA table_info(trial); 558260d8a6aSdanielk1977 } 559260d8a6aSdanielk1977 } {0 col_temp {} 0 {} 0} 560260d8a6aSdanielk1977 do_test pragma-6.6.3 { 561260d8a6aSdanielk1977 execsql { 562260d8a6aSdanielk1977 PRAGMA temp.table_info(trial); 563260d8a6aSdanielk1977 } 564260d8a6aSdanielk1977 } {0 col_temp {} 0 {} 0} 565260d8a6aSdanielk1977 do_test pragma-6.6.4 { 566260d8a6aSdanielk1977 execsql { 567260d8a6aSdanielk1977 PRAGMA main.table_info(trial); 568260d8a6aSdanielk1977 } 569260d8a6aSdanielk1977 } {0 col_main {} 0 {} 0} 570260d8a6aSdanielk1977} 571*f96a3778Sdanielk1977 572*f96a3778Sdanielk1977breakpoint 573*f96a3778Sdanielk1977do_test pragma-6.7 { 574*f96a3778Sdanielk1977 execsql { 575*f96a3778Sdanielk1977 CREATE TABLE test_table( 576*f96a3778Sdanielk1977 one INT NOT NULL DEFAULT -1, 577*f96a3778Sdanielk1977 two text, 578*f96a3778Sdanielk1977 three VARCHAR(45, 65) DEFAULT 'abcde', 579*f96a3778Sdanielk1977 four REAL DEFAULT X'abcdef', 580*f96a3778Sdanielk1977 five DEFAULT CURRENT_TIME 581*f96a3778Sdanielk1977 ); 582*f96a3778Sdanielk1977 PRAGMA table_info(test_table); 583*f96a3778Sdanielk1977 } 584*f96a3778Sdanielk1977} [concat \ 585*f96a3778Sdanielk1977 {0 one INT 1 -1 0} \ 586*f96a3778Sdanielk1977 {1 two text 0 {} 0} \ 587*f96a3778Sdanielk1977 {2 three {VARCHAR(45, 65)} 0 'abcde' 0} \ 588*f96a3778Sdanielk1977 {3 four REAL 0 X'abcdef' 0} \ 589*f96a3778Sdanielk1977 {4 five {} 0 CURRENT_TIME 0} \ 590*f96a3778Sdanielk1977] 59127188fb5Sdanielk1977} ;# ifcapable schema_pragmas 5925260f7e9Sdrh# Miscellaneous tests 5935260f7e9Sdrh# 59427188fb5Sdanielk1977ifcapable schema_pragmas { 5955260f7e9Sdrhdo_test pragma-7.1 { 5965260f7e9Sdrh # Make sure a pragma knows to read the schema if it needs to 5975260f7e9Sdrh db close 5985260f7e9Sdrh sqlite3 db test.db 5995260f7e9Sdrh execsql { 6005260f7e9Sdrh pragma index_list(t3); 6015260f7e9Sdrh } 6025260f7e9Sdrh} {0 t3i1 0 1 sqlite_autoindex_t3_1 1} 60327188fb5Sdanielk1977} ;# ifcapable schema_pragmas 6046c62608fSdrhifcapable {utf16} { 6055260f7e9Sdrh do_test pragma-7.2 { 6065260f7e9Sdrh db close 6075260f7e9Sdrh sqlite3 db test.db 6085260f7e9Sdrh catchsql { 6095260f7e9Sdrh pragma encoding=bogus; 6105260f7e9Sdrh } 6115260f7e9Sdrh } {1 {unsupported encoding: bogus}} 6126c62608fSdrh} 61353c0f748Sdanielk1977ifcapable tempdb { 6145260f7e9Sdrh do_test pragma-7.3 { 6155260f7e9Sdrh db close 6165260f7e9Sdrh sqlite3 db test.db 6175260f7e9Sdrh execsql { 6185260f7e9Sdrh pragma lock_status; 6195260f7e9Sdrh } 6205260f7e9Sdrh } {main unlocked temp closed} 62153c0f748Sdanielk1977} else { 62253c0f748Sdanielk1977 do_test pragma-7.3 { 62353c0f748Sdanielk1977 db close 62453c0f748Sdanielk1977 sqlite3 db test.db 62553c0f748Sdanielk1977 execsql { 62653c0f748Sdanielk1977 pragma lock_status; 62753c0f748Sdanielk1977 } 62853c0f748Sdanielk1977 } {main unlocked} 62953c0f748Sdanielk1977} 6305260f7e9Sdrh 6315260f7e9Sdrh 632dae2495bSdanielk1977#---------------------------------------------------------------------- 633b92b70bbSdanielk1977# Test cases pragma-8.* test the "PRAGMA schema_version" and "PRAGMA 634b92b70bbSdanielk1977# user_version" statements. 635dae2495bSdanielk1977# 636b92b70bbSdanielk1977# pragma-8.1: PRAGMA schema_version 637b92b70bbSdanielk1977# pragma-8.2: PRAGMA user_version 638dae2495bSdanielk1977# 639dae2495bSdanielk1977 64011cf9fbcSdanielk1977ifcapable schema_version { 64111cf9fbcSdanielk1977 642b92b70bbSdanielk1977# First check that we can set the schema version and then retrieve the 643dae2495bSdanielk1977# same value. 644dae2495bSdanielk1977do_test pragma-8.1.1 { 645dae2495bSdanielk1977 execsql { 646b92b70bbSdanielk1977 PRAGMA schema_version = 105; 647dae2495bSdanielk1977 } 648dae2495bSdanielk1977} {} 649dae2495bSdanielk1977do_test pragma-8.1.2 { 65025403650Sdrh execsql2 { 651b92b70bbSdanielk1977 PRAGMA schema_version; 652dae2495bSdanielk1977 } 65325403650Sdrh} {schema_version 105} 654dae2495bSdanielk1977do_test pragma-8.1.3 { 655dae2495bSdanielk1977 execsql { 656b92b70bbSdanielk1977 PRAGMA schema_version = 106; 657dae2495bSdanielk1977 } 658dae2495bSdanielk1977} {} 659dae2495bSdanielk1977do_test pragma-8.1.4 { 660dae2495bSdanielk1977 execsql { 661b92b70bbSdanielk1977 PRAGMA schema_version; 662dae2495bSdanielk1977 } 663dae2495bSdanielk1977} 106 664dae2495bSdanielk1977 665b92b70bbSdanielk1977# Check that creating a table modifies the schema-version (this is really 666b92b70bbSdanielk1977# to verify that the value being read is in fact the schema version). 667dae2495bSdanielk1977do_test pragma-8.1.5 { 668dae2495bSdanielk1977 execsql { 669dae2495bSdanielk1977 CREATE TABLE t4(a, b, c); 670dae2495bSdanielk1977 INSERT INTO t4 VALUES(1, 2, 3); 671dae2495bSdanielk1977 SELECT * FROM t4; 672dae2495bSdanielk1977 } 673dae2495bSdanielk1977} {1 2 3} 674dae2495bSdanielk1977do_test pragma-8.1.6 { 675dae2495bSdanielk1977 execsql { 676b92b70bbSdanielk1977 PRAGMA schema_version; 677dae2495bSdanielk1977 } 678dae2495bSdanielk1977} 107 679dae2495bSdanielk1977 680dae2495bSdanielk1977# Now open a second connection to the database. Ensure that changing the 681b92b70bbSdanielk1977# schema-version using the first connection forces the second connection 682dae2495bSdanielk1977# to reload the schema. This has to be done using the C-API test functions, 683dae2495bSdanielk1977# because the TCL API accounts for SCHEMA_ERROR and retries the query. 684dae2495bSdanielk1977do_test pragma-8.1.7 { 685dddca286Sdrh sqlite3 db2 test.db; set ::DB2 [sqlite3_connection_pointer db2] 686dae2495bSdanielk1977 execsql { 687dae2495bSdanielk1977 SELECT * FROM t4; 688dae2495bSdanielk1977 } db2 689dae2495bSdanielk1977} {1 2 3} 690dae2495bSdanielk1977do_test pragma-8.1.8 { 691dae2495bSdanielk1977 execsql { 692b92b70bbSdanielk1977 PRAGMA schema_version = 108; 693dae2495bSdanielk1977 } 694dae2495bSdanielk1977} {} 695dae2495bSdanielk1977do_test pragma-8.1.9 { 696dae2495bSdanielk1977 set ::STMT [sqlite3_prepare $::DB2 "SELECT * FROM t4" -1 DUMMY] 697dae2495bSdanielk1977 sqlite3_step $::STMT 698dae2495bSdanielk1977} SQLITE_ERROR 699dae2495bSdanielk1977do_test pragma-8.1.10 { 700dae2495bSdanielk1977 sqlite3_finalize $::STMT 701dae2495bSdanielk1977} SQLITE_SCHEMA 702dae2495bSdanielk1977 703b92b70bbSdanielk1977# Make sure the schema-version can be manipulated in an attached database. 704dae2495bSdanielk1977file delete -force test2.db 705dae2495bSdanielk1977file delete -force test2.db-journal 7065a8f9374Sdanielk1977ifcapable attach { 707dae2495bSdanielk1977 do_test pragma-8.1.11 { 708dae2495bSdanielk1977 execsql { 709dae2495bSdanielk1977 ATTACH 'test2.db' AS aux; 710dae2495bSdanielk1977 CREATE TABLE aux.t1(a, b, c); 711b92b70bbSdanielk1977 PRAGMA aux.schema_version = 205; 712dae2495bSdanielk1977 } 713dae2495bSdanielk1977 } {} 714dae2495bSdanielk1977 do_test pragma-8.1.12 { 715dae2495bSdanielk1977 execsql { 716b92b70bbSdanielk1977 PRAGMA aux.schema_version; 717dae2495bSdanielk1977 } 718dae2495bSdanielk1977 } 205 7195a8f9374Sdanielk1977} 720dae2495bSdanielk1977do_test pragma-8.1.13 { 721dae2495bSdanielk1977 execsql { 722b92b70bbSdanielk1977 PRAGMA schema_version; 723dae2495bSdanielk1977 } 724dae2495bSdanielk1977} 108 725dae2495bSdanielk1977 726b92b70bbSdanielk1977# And check that modifying the schema-version in an attached database 727dae2495bSdanielk1977# forces the second connection to reload the schema. 7285a8f9374Sdanielk1977ifcapable attach { 729dae2495bSdanielk1977 do_test pragma-8.1.14 { 730dddca286Sdrh sqlite3 db2 test.db; set ::DB2 [sqlite3_connection_pointer db2] 731dae2495bSdanielk1977 execsql { 732dae2495bSdanielk1977 ATTACH 'test2.db' AS aux; 733dae2495bSdanielk1977 SELECT * FROM aux.t1; 734dae2495bSdanielk1977 } db2 735dae2495bSdanielk1977 } {} 736dae2495bSdanielk1977 do_test pragma-8.1.15 { 737dae2495bSdanielk1977 execsql { 738b92b70bbSdanielk1977 PRAGMA aux.schema_version = 206; 739dae2495bSdanielk1977 } 740dae2495bSdanielk1977 } {} 741dae2495bSdanielk1977 do_test pragma-8.1.16 { 742dae2495bSdanielk1977 set ::STMT [sqlite3_prepare $::DB2 "SELECT * FROM aux.t1" -1 DUMMY] 743dae2495bSdanielk1977 sqlite3_step $::STMT 744dae2495bSdanielk1977 } SQLITE_ERROR 745dae2495bSdanielk1977 do_test pragma-8.1.17 { 746dae2495bSdanielk1977 sqlite3_finalize $::STMT 747dae2495bSdanielk1977 } SQLITE_SCHEMA 748dae2495bSdanielk1977 do_test pragma-8.1.18 { 749dae2495bSdanielk1977 db2 close 750dae2495bSdanielk1977 } {} 7515a8f9374Sdanielk1977} 752dae2495bSdanielk1977 753b92b70bbSdanielk1977# Now test that the user-version can be read and written (and that we aren't 754b92b70bbSdanielk1977# accidentally manipulating the schema-version instead). 755dae2495bSdanielk1977do_test pragma-8.2.1 { 75625403650Sdrh execsql2 { 757b92b70bbSdanielk1977 PRAGMA user_version; 758dae2495bSdanielk1977 } 75925403650Sdrh} {user_version 0} 760dae2495bSdanielk1977do_test pragma-8.2.2 { 761dae2495bSdanielk1977 execsql { 762b92b70bbSdanielk1977 PRAGMA user_version = 2; 763dae2495bSdanielk1977 } 764dae2495bSdanielk1977} {} 765802d69a7Sdrhdo_test pragma-8.2.3.1 { 76625403650Sdrh execsql2 { 767b92b70bbSdanielk1977 PRAGMA user_version; 768dae2495bSdanielk1977 } 76925403650Sdrh} {user_version 2} 770802d69a7Sdrhdo_test pragma-8.2.3.2 { 771802d69a7Sdrh db close 772802d69a7Sdrh sqlite3 db test.db 773802d69a7Sdrh execsql { 774802d69a7Sdrh PRAGMA user_version; 775802d69a7Sdrh } 776802d69a7Sdrh} {2} 777802d69a7Sdrhdo_test pragma-8.2.4.1 { 778dae2495bSdanielk1977 execsql { 779b92b70bbSdanielk1977 PRAGMA schema_version; 780dae2495bSdanielk1977 } 781dae2495bSdanielk1977} {108} 782802d69a7Sdrhifcapable vacuum { 783802d69a7Sdrh do_test pragma-8.2.4.2 { 784802d69a7Sdrh execsql { 785802d69a7Sdrh VACUUM; 786802d69a7Sdrh PRAGMA user_version; 787802d69a7Sdrh } 788802d69a7Sdrh } {2} 789802d69a7Sdrh do_test pragma-8.2.4.3 { 790802d69a7Sdrh execsql { 791802d69a7Sdrh PRAGMA schema_version; 792802d69a7Sdrh } 793802d69a7Sdrh } {109} 794802d69a7Sdrh} 7955a8f9374Sdanielk1977 7965a8f9374Sdanielk1977ifcapable attach { 797802d69a7Sdrh db eval {ATTACH 'test2.db' AS aux} 798dae2495bSdanielk1977 799b92b70bbSdanielk1977 # Check that the user-version in the auxilary database can be manipulated ( 800dae2495bSdanielk1977 # and that we aren't accidentally manipulating the same in the main db). 801dae2495bSdanielk1977 do_test pragma-8.2.5 { 802dae2495bSdanielk1977 execsql { 803b92b70bbSdanielk1977 PRAGMA aux.user_version; 804dae2495bSdanielk1977 } 805dae2495bSdanielk1977 } {0} 806dae2495bSdanielk1977 do_test pragma-8.2.6 { 807dae2495bSdanielk1977 execsql { 808b92b70bbSdanielk1977 PRAGMA aux.user_version = 3; 809dae2495bSdanielk1977 } 810dae2495bSdanielk1977 } {} 811dae2495bSdanielk1977 do_test pragma-8.2.7 { 812dae2495bSdanielk1977 execsql { 813b92b70bbSdanielk1977 PRAGMA aux.user_version; 814dae2495bSdanielk1977 } 815dae2495bSdanielk1977 } {3} 816dae2495bSdanielk1977 do_test pragma-8.2.8 { 817dae2495bSdanielk1977 execsql { 818b92b70bbSdanielk1977 PRAGMA main.user_version; 819dae2495bSdanielk1977 } 820dae2495bSdanielk1977 } {2} 821dae2495bSdanielk1977 822b92b70bbSdanielk1977 # Now check that a ROLLBACK resets the user-version if it has been modified 823dae2495bSdanielk1977 # within a transaction. 824dae2495bSdanielk1977 do_test pragma-8.2.9 { 825dae2495bSdanielk1977 execsql { 826dae2495bSdanielk1977 BEGIN; 827b92b70bbSdanielk1977 PRAGMA aux.user_version = 10; 828b92b70bbSdanielk1977 PRAGMA user_version = 11; 829dae2495bSdanielk1977 } 830dae2495bSdanielk1977 } {} 831dae2495bSdanielk1977 do_test pragma-8.2.10 { 832dae2495bSdanielk1977 execsql { 833b92b70bbSdanielk1977 PRAGMA aux.user_version; 834dae2495bSdanielk1977 } 835dae2495bSdanielk1977 } {10} 836dae2495bSdanielk1977 do_test pragma-8.2.11 { 837dae2495bSdanielk1977 execsql { 838b92b70bbSdanielk1977 PRAGMA main.user_version; 839dae2495bSdanielk1977 } 840dae2495bSdanielk1977 } {11} 841dae2495bSdanielk1977 do_test pragma-8.2.12 { 842dae2495bSdanielk1977 execsql { 843dae2495bSdanielk1977 ROLLBACK; 844b92b70bbSdanielk1977 PRAGMA aux.user_version; 845dae2495bSdanielk1977 } 846dae2495bSdanielk1977 } {3} 847dae2495bSdanielk1977 do_test pragma-8.2.13 { 848dae2495bSdanielk1977 execsql { 849b92b70bbSdanielk1977 PRAGMA main.user_version; 850dae2495bSdanielk1977 } 851dae2495bSdanielk1977 } {2} 8525a8f9374Sdanielk1977} 853dae2495bSdanielk1977 854b92b70bbSdanielk1977# Try a negative value for the user-version 855dae2495bSdanielk1977do_test pragma-8.2.14 { 856dae2495bSdanielk1977 execsql { 857b92b70bbSdanielk1977 PRAGMA user_version = -450; 858dae2495bSdanielk1977 } 859dae2495bSdanielk1977} {} 860dae2495bSdanielk1977do_test pragma-8.2.15 { 861dae2495bSdanielk1977 execsql { 862b92b70bbSdanielk1977 PRAGMA user_version; 863dae2495bSdanielk1977 } 864dae2495bSdanielk1977} {-450} 865d9c847dcSdanielk1977} ; # ifcapable schema_version 866d9c847dcSdanielk1977 867d19744f3Sdrh# Check to see if TEMP_STORE is memory or disk. Return strings 868d19744f3Sdrh# "memory" or "disk" as appropriate. 869d19744f3Sdrh# 870d19744f3Sdrhproc check_temp_store {} { 871d19744f3Sdrh db eval {CREATE TEMP TABLE IF NOT EXISTS a(b)} 872d19744f3Sdrh db eval {PRAGMA database_list} { 873d19744f3Sdrh if {$name=="temp"} { 87417b90b53Sdanielk1977 set bt [btree_from_db db 1] 87517b90b53Sdanielk1977 if {[btree_ismemdb $bt]} { 876d19744f3Sdrh return "memory" 877d19744f3Sdrh } 87817b90b53Sdanielk1977 return "disk" 879d19744f3Sdrh } 880d19744f3Sdrh } 881d19744f3Sdrh return "unknown" 882d19744f3Sdrh} 883d19744f3Sdrh 8849a09a3caStpoindex 8859a09a3caStpoindex# Test temp_store and temp_store_directory pragmas 8869a09a3caStpoindex# 887268283bcSdrhifcapable pager_pragmas { 8889a09a3caStpoindexdo_test pragma-9.1 { 8899a09a3caStpoindex db close 8909a09a3caStpoindex sqlite3 db test.db 8919a09a3caStpoindex execsql { 8929a09a3caStpoindex PRAGMA temp_store; 8939a09a3caStpoindex } 8949a09a3caStpoindex} {0} 895d19744f3Sdrhif {$TEMP_STORE<=1} { 896d19744f3Sdrh do_test pragma-9.1.1 { 897d19744f3Sdrh check_temp_store 898d19744f3Sdrh } {disk} 899d19744f3Sdrh} else { 900d19744f3Sdrh do_test pragma-9.1.1 { 901d19744f3Sdrh check_temp_store 902d19744f3Sdrh } {memory} 903d19744f3Sdrh} 904d19744f3Sdrh 9059a09a3caStpoindexdo_test pragma-9.2 { 906d19744f3Sdrh db close 907d19744f3Sdrh sqlite3 db test.db 9089a09a3caStpoindex execsql { 9099a09a3caStpoindex PRAGMA temp_store=file; 9109a09a3caStpoindex PRAGMA temp_store; 9119a09a3caStpoindex } 9129a09a3caStpoindex} {1} 913d19744f3Sdrhif {$TEMP_STORE==3} { 914d19744f3Sdrh # When TEMP_STORE is 3, always use memory regardless of pragma settings. 915d19744f3Sdrh do_test pragma-9.2.1 { 916d19744f3Sdrh check_temp_store 917d19744f3Sdrh } {memory} 918d19744f3Sdrh} else { 919d19744f3Sdrh do_test pragma-9.2.1 { 920d19744f3Sdrh check_temp_store 921d19744f3Sdrh } {disk} 922d19744f3Sdrh} 923d19744f3Sdrh 9249a09a3caStpoindexdo_test pragma-9.3 { 925d19744f3Sdrh db close 926d19744f3Sdrh sqlite3 db test.db 9279a09a3caStpoindex execsql { 9289a09a3caStpoindex PRAGMA temp_store=memory; 9299a09a3caStpoindex PRAGMA temp_store; 9309a09a3caStpoindex } 9319a09a3caStpoindex} {2} 932d19744f3Sdrhif {$TEMP_STORE==0} { 933d19744f3Sdrh # When TEMP_STORE is 0, always use the disk regardless of pragma settings. 934d19744f3Sdrh do_test pragma-9.3.1 { 935d19744f3Sdrh check_temp_store 936d19744f3Sdrh } {disk} 937d19744f3Sdrh} else { 938d19744f3Sdrh do_test pragma-9.3.1 { 939d19744f3Sdrh check_temp_store 940d19744f3Sdrh } {memory} 941d19744f3Sdrh} 942d19744f3Sdrh 9439a09a3caStpoindexdo_test pragma-9.4 { 9449a09a3caStpoindex execsql { 9459a09a3caStpoindex PRAGMA temp_store_directory; 9469a09a3caStpoindex } 9479a09a3caStpoindex} {} 94878f82d1eSdrhifcapable wsd { 9499a09a3caStpoindex do_test pragma-9.5 { 950181ddaa1Sdanielk1977 set pwd [string map {' ''} [file nativename [pwd]]] 951268283bcSdrh execsql " 952268283bcSdrh PRAGMA temp_store_directory='$pwd'; 9539a09a3caStpoindex " 9549a09a3caStpoindex } {} 9559a09a3caStpoindex do_test pragma-9.6 { 9569a09a3caStpoindex execsql { 9579a09a3caStpoindex PRAGMA temp_store_directory; 9589a09a3caStpoindex } 959181ddaa1Sdanielk1977 } [list [file nativename [pwd]]] 9609a09a3caStpoindex do_test pragma-9.7 { 961268283bcSdrh catchsql { 9629a09a3caStpoindex PRAGMA temp_store_directory='/NON/EXISTENT/PATH/FOOBAR'; 9639a09a3caStpoindex } 964268283bcSdrh } {1 {not a writable directory}} 9659a09a3caStpoindex do_test pragma-9.8 { 9669a09a3caStpoindex execsql { 9679a09a3caStpoindex PRAGMA temp_store_directory=''; 9689a09a3caStpoindex } 9699a09a3caStpoindex } {} 9701e9daa6aSdrh if {![info exists TEMP_STORE] || $TEMP_STORE<=1} { 97153c0f748Sdanielk1977 ifcapable tempdb { 9729a09a3caStpoindex do_test pragma-9.9 { 9739a09a3caStpoindex execsql { 9749a09a3caStpoindex PRAGMA temp_store_directory; 9759a09a3caStpoindex PRAGMA temp_store=FILE; 9769a09a3caStpoindex CREATE TEMP TABLE temp_store_directory_test(a integer); 9779a09a3caStpoindex INSERT INTO temp_store_directory_test values (2); 9789a09a3caStpoindex SELECT * FROM temp_store_directory_test; 9799a09a3caStpoindex } 9809a09a3caStpoindex } {2} 9819a09a3caStpoindex do_test pragma-9.10 { 982268283bcSdrh catchsql " 983268283bcSdrh PRAGMA temp_store_directory='$pwd'; 9849a09a3caStpoindex SELECT * FROM temp_store_directory_test; 9859a09a3caStpoindex " 986268283bcSdrh } {1 {no such table: temp_store_directory_test}} 9871e9daa6aSdrh } 9881e9daa6aSdrh } 98978f82d1eSdrh} 99095b289b6Sdanielk1977do_test pragma-9.11 { 99195b289b6Sdanielk1977 execsql { 99295b289b6Sdanielk1977 PRAGMA temp_store = 0; 99395b289b6Sdanielk1977 PRAGMA temp_store; 99495b289b6Sdanielk1977 } 99595b289b6Sdanielk1977} {0} 99695b289b6Sdanielk1977do_test pragma-9.12 { 99795b289b6Sdanielk1977 execsql { 99895b289b6Sdanielk1977 PRAGMA temp_store = 1; 99995b289b6Sdanielk1977 PRAGMA temp_store; 100095b289b6Sdanielk1977 } 100195b289b6Sdanielk1977} {1} 100295b289b6Sdanielk1977do_test pragma-9.13 { 100395b289b6Sdanielk1977 execsql { 100495b289b6Sdanielk1977 PRAGMA temp_store = 2; 100595b289b6Sdanielk1977 PRAGMA temp_store; 100695b289b6Sdanielk1977 } 100795b289b6Sdanielk1977} {2} 100895b289b6Sdanielk1977do_test pragma-9.14 { 100995b289b6Sdanielk1977 execsql { 101095b289b6Sdanielk1977 PRAGMA temp_store = 3; 101195b289b6Sdanielk1977 PRAGMA temp_store; 101295b289b6Sdanielk1977 } 101395b289b6Sdanielk1977} {0} 101495b289b6Sdanielk1977do_test pragma-9.15 { 101595b289b6Sdanielk1977 catchsql { 101695b289b6Sdanielk1977 BEGIN EXCLUSIVE; 101795b289b6Sdanielk1977 CREATE TEMP TABLE temp_table(t); 101895b289b6Sdanielk1977 INSERT INTO temp_table VALUES('valuable data'); 101995b289b6Sdanielk1977 PRAGMA temp_store = 1; 102095b289b6Sdanielk1977 } 102195b289b6Sdanielk1977} {1 {temporary storage cannot be changed from within a transaction}} 102295b289b6Sdanielk1977do_test pragma-9.16 { 102395b289b6Sdanielk1977 execsql { 102495b289b6Sdanielk1977 SELECT * FROM temp_table; 102595b289b6Sdanielk1977 COMMIT; 102695b289b6Sdanielk1977 } 102795b289b6Sdanielk1977} {{valuable data}} 1028983e2309Sdanielk1977 1029983e2309Sdanielk1977do_test pragma-9.17 { 1030983e2309Sdanielk1977 execsql { 1031983e2309Sdanielk1977 INSERT INTO temp_table VALUES('valuable data II'); 1032983e2309Sdanielk1977 SELECT * FROM temp_table; 1033983e2309Sdanielk1977 } 1034983e2309Sdanielk1977} {{valuable data} {valuable data II}} 1035983e2309Sdanielk1977 1036983e2309Sdanielk1977do_test pragma-9.18 { 1037983e2309Sdanielk1977 set rc [catch { 1038983e2309Sdanielk1977 db eval {SELECT t FROM temp_table} { 1039983e2309Sdanielk1977 execsql {pragma temp_store = 1} 1040983e2309Sdanielk1977 } 1041983e2309Sdanielk1977 } msg] 1042983e2309Sdanielk1977 list $rc $msg 1043983e2309Sdanielk1977} {1 {temporary storage cannot be changed from within a transaction}} 1044983e2309Sdanielk1977 1045268283bcSdrh} ;# ifcapable pager_pragmas 10469a09a3caStpoindex 1047cc6bd383Sdanielk1977ifcapable trigger { 1048cc6bd383Sdanielk1977 1049cc6bd383Sdanielk1977do_test pragma-10.0 { 1050cc6bd383Sdanielk1977 catchsql { 1051cc6bd383Sdanielk1977 DROP TABLE main.t1; 1052cc6bd383Sdanielk1977 } 1053cc6bd383Sdanielk1977 execsql { 1054cc6bd383Sdanielk1977 PRAGMA count_changes = 1; 1055cc6bd383Sdanielk1977 1056cc6bd383Sdanielk1977 CREATE TABLE t1(a PRIMARY KEY); 1057cc6bd383Sdanielk1977 CREATE TABLE t1_mirror(a); 1058cc6bd383Sdanielk1977 CREATE TABLE t1_mirror2(a); 1059cc6bd383Sdanielk1977 CREATE TRIGGER t1_bi BEFORE INSERT ON t1 BEGIN 1060cc6bd383Sdanielk1977 INSERT INTO t1_mirror VALUES(new.a); 1061cc6bd383Sdanielk1977 END; 1062cc6bd383Sdanielk1977 CREATE TRIGGER t1_ai AFTER INSERT ON t1 BEGIN 1063cc6bd383Sdanielk1977 INSERT INTO t1_mirror2 VALUES(new.a); 1064cc6bd383Sdanielk1977 END; 1065cc6bd383Sdanielk1977 CREATE TRIGGER t1_bu BEFORE UPDATE ON t1 BEGIN 1066cc6bd383Sdanielk1977 UPDATE t1_mirror SET a = new.a WHERE a = old.a; 1067cc6bd383Sdanielk1977 END; 1068cc6bd383Sdanielk1977 CREATE TRIGGER t1_au AFTER UPDATE ON t1 BEGIN 1069cc6bd383Sdanielk1977 UPDATE t1_mirror2 SET a = new.a WHERE a = old.a; 1070cc6bd383Sdanielk1977 END; 1071cc6bd383Sdanielk1977 CREATE TRIGGER t1_bd BEFORE DELETE ON t1 BEGIN 1072cc6bd383Sdanielk1977 DELETE FROM t1_mirror WHERE a = old.a; 1073cc6bd383Sdanielk1977 END; 1074cc6bd383Sdanielk1977 CREATE TRIGGER t1_ad AFTER DELETE ON t1 BEGIN 1075cc6bd383Sdanielk1977 DELETE FROM t1_mirror2 WHERE a = old.a; 1076cc6bd383Sdanielk1977 END; 1077cc6bd383Sdanielk1977 } 1078cc6bd383Sdanielk1977} {} 1079cc6bd383Sdanielk1977 1080cc6bd383Sdanielk1977do_test pragma-10.1 { 1081cc6bd383Sdanielk1977 execsql { 1082cc6bd383Sdanielk1977 INSERT INTO t1 VALUES(randstr(10,10)); 1083cc6bd383Sdanielk1977 } 1084cc6bd383Sdanielk1977} {1} 1085cc6bd383Sdanielk1977do_test pragma-10.2 { 1086cc6bd383Sdanielk1977 execsql { 1087cc6bd383Sdanielk1977 UPDATE t1 SET a = randstr(10,10); 1088cc6bd383Sdanielk1977 } 1089cc6bd383Sdanielk1977} {1} 1090cc6bd383Sdanielk1977do_test pragma-10.3 { 1091cc6bd383Sdanielk1977 execsql { 1092cc6bd383Sdanielk1977 DELETE FROM t1; 1093cc6bd383Sdanielk1977 } 1094cc6bd383Sdanielk1977} {1} 1095cc6bd383Sdanielk1977 1096cc6bd383Sdanielk1977} ;# ifcapable trigger 1097cc6bd383Sdanielk1977 109848af65aeSdanielk1977ifcapable schema_pragmas { 109948af65aeSdanielk1977 do_test pragma-11.1 { 110048af65aeSdanielk1977 execsql2 { 110148af65aeSdanielk1977 pragma collation_list; 110248af65aeSdanielk1977 } 11039b5adfa2Sdrh } {seq 0 name NOCASE seq 1 name RTRIM seq 2 name BINARY} 110448af65aeSdanielk1977 do_test pragma-11.2 { 110548af65aeSdanielk1977 db collate New_Collation blah... 110648af65aeSdanielk1977 execsql { 110748af65aeSdanielk1977 pragma collation_list; 110848af65aeSdanielk1977 } 11099b5adfa2Sdrh } {0 New_Collation 1 NOCASE 2 RTRIM 3 BINARY} 111048af65aeSdanielk1977} 111148af65aeSdanielk1977 1112ddfb2f03Sdanielk1977ifcapable schema_pragmas&&tempdb { 1113ddfb2f03Sdanielk1977 do_test pragma-12.1 { 1114ddfb2f03Sdanielk1977 sqlite3 db2 test.db 1115ddfb2f03Sdanielk1977 execsql { 1116ddfb2f03Sdanielk1977 PRAGMA temp.table_info('abc'); 1117ddfb2f03Sdanielk1977 } db2 1118ddfb2f03Sdanielk1977 } {} 1119ddfb2f03Sdanielk1977 db2 close 1120ddfb2f03Sdanielk1977 1121ddfb2f03Sdanielk1977 do_test pragma-12.2 { 1122ddfb2f03Sdanielk1977 sqlite3 db2 test.db 1123ddfb2f03Sdanielk1977 execsql { 1124ddfb2f03Sdanielk1977 PRAGMA temp.default_cache_size = 200; 1125ddfb2f03Sdanielk1977 PRAGMA temp.default_cache_size; 1126ddfb2f03Sdanielk1977 } db2 1127ddfb2f03Sdanielk1977 } {200} 1128ddfb2f03Sdanielk1977 db2 close 1129ddfb2f03Sdanielk1977 1130ddfb2f03Sdanielk1977 do_test pragma-12.3 { 1131ddfb2f03Sdanielk1977 sqlite3 db2 test.db 1132ddfb2f03Sdanielk1977 execsql { 1133ddfb2f03Sdanielk1977 PRAGMA temp.cache_size = 400; 1134ddfb2f03Sdanielk1977 PRAGMA temp.cache_size; 1135ddfb2f03Sdanielk1977 } db2 1136ddfb2f03Sdanielk1977 } {400} 1137ddfb2f03Sdanielk1977 db2 close 1138ddfb2f03Sdanielk1977} 1139ddfb2f03Sdanielk1977 11404b2688abSdanielk1977ifcapable bloblit { 11414b2688abSdanielk1977 114205a82983Sdrhdo_test pragma-13.1 { 114305a82983Sdrh execsql { 114405a82983Sdrh DROP TABLE IF EXISTS t4; 114505a82983Sdrh PRAGMA vdbe_trace=on; 114605a82983Sdrh PRAGMA vdbe_listing=on; 114705a82983Sdrh PRAGMA sql_trace=on; 114805a82983Sdrh CREATE TABLE t4(a INTEGER PRIMARY KEY,b); 114905a82983Sdrh INSERT INTO t4(b) VALUES(x'0123456789abcdef0123456789abcdef0123456789'); 115005a82983Sdrh INSERT INTO t4(b) VALUES(randstr(30,30)); 115105a82983Sdrh INSERT INTO t4(b) VALUES(1.23456); 115205a82983Sdrh INSERT INTO t4(b) VALUES(NULL); 115305a82983Sdrh INSERT INTO t4(b) VALUES(0); 115405a82983Sdrh INSERT INTO t4(b) SELECT b||b||b||b FROM t4; 115505a82983Sdrh SELECT * FROM t4; 115605a82983Sdrh } 115705a82983Sdrh execsql { 115805a82983Sdrh PRAGMA vdbe_trace=off; 115905a82983Sdrh PRAGMA vdbe_listing=off; 116005a82983Sdrh PRAGMA sql_trace=off; 116105a82983Sdrh } 116205a82983Sdrh} {} 116305a82983Sdrh 11644b2688abSdanielk1977} ;# ifcapable bloblit 11654b2688abSdanielk1977 116659a93791Sdanielk1977ifcapable pager_pragmas { 116759a93791Sdanielk1977 db close 116859a93791Sdanielk1977 file delete -force test.db 116959a93791Sdanielk1977 sqlite3 db test.db 117059a93791Sdanielk1977 117159a93791Sdanielk1977 do_test pragma-14.1 { 117259a93791Sdanielk1977 execsql { pragma auto_vacuum = 0 } 117359a93791Sdanielk1977 execsql { pragma page_count } 117459a93791Sdanielk1977 } {0} 117559a93791Sdanielk1977 117659a93791Sdanielk1977 do_test pragma-14.2 { 117759a93791Sdanielk1977 execsql { 117859a93791Sdanielk1977 CREATE TABLE abc(a, b, c); 117959a93791Sdanielk1977 PRAGMA page_count; 118059a93791Sdanielk1977 } 118159a93791Sdanielk1977 } {2} 118259a93791Sdanielk1977 118359a93791Sdanielk1977 do_test pragma-14.3 { 118459a93791Sdanielk1977 execsql { 118559a93791Sdanielk1977 BEGIN; 118659a93791Sdanielk1977 CREATE TABLE def(a, b, c); 118759a93791Sdanielk1977 PRAGMA page_count; 118859a93791Sdanielk1977 } 118959a93791Sdanielk1977 } {3} 119059a93791Sdanielk1977 119159a93791Sdanielk1977 do_test pragma-14.4 { 119259a93791Sdanielk1977 set page_size [db one {pragma page_size}] 119359a93791Sdanielk1977 expr [file size test.db] / $page_size 119459a93791Sdanielk1977 } {2} 119559a93791Sdanielk1977 119659a93791Sdanielk1977 do_test pragma-14.5 { 119759a93791Sdanielk1977 execsql { 119859a93791Sdanielk1977 ROLLBACK; 119959a93791Sdanielk1977 PRAGMA page_count; 120059a93791Sdanielk1977 } 120159a93791Sdanielk1977 } {2} 120259a93791Sdanielk1977 120359a93791Sdanielk1977 do_test pragma-14.6 { 120459a93791Sdanielk1977 file delete -force test2.db 120559a93791Sdanielk1977 sqlite3 db2 test2.db 120659a93791Sdanielk1977 execsql { 120759a93791Sdanielk1977 PRAGMA auto_vacuum = 0; 120859a93791Sdanielk1977 CREATE TABLE t1(a, b, c); 120959a93791Sdanielk1977 CREATE TABLE t2(a, b, c); 121059a93791Sdanielk1977 CREATE TABLE t3(a, b, c); 121159a93791Sdanielk1977 CREATE TABLE t4(a, b, c); 121259a93791Sdanielk1977 } db2 121359a93791Sdanielk1977 db2 close 121459a93791Sdanielk1977 execsql { 121559a93791Sdanielk1977 ATTACH 'test2.db' AS aux; 121659a93791Sdanielk1977 PRAGMA aux.page_count; 121759a93791Sdanielk1977 } 121859a93791Sdanielk1977 } {5} 121959a93791Sdanielk1977} 122059a93791Sdanielk1977 12218cf6c554Sdanielk1977# Test that the value set using the cache_size pragma is not reset when the 12228cf6c554Sdanielk1977# schema is reloaded. 12238cf6c554Sdanielk1977# 12248cf6c554Sdanielk1977ifcapable pager_pragmas { 12258cf6c554Sdanielk1977 db close 12268cf6c554Sdanielk1977 sqlite3 db test.db 12278cf6c554Sdanielk1977 do_test pragma-15.1 { 12288cf6c554Sdanielk1977 execsql { 12298cf6c554Sdanielk1977 PRAGMA cache_size=59; 12308cf6c554Sdanielk1977 PRAGMA cache_size; 12318cf6c554Sdanielk1977 } 12328cf6c554Sdanielk1977 } {59} 12338cf6c554Sdanielk1977 do_test pragma-15.2 { 12348cf6c554Sdanielk1977 sqlite3 db2 test.db 12358cf6c554Sdanielk1977 execsql { 12368cf6c554Sdanielk1977 CREATE TABLE newtable(a, b, c); 12378cf6c554Sdanielk1977 } db2 12388cf6c554Sdanielk1977 db2 close 12398cf6c554Sdanielk1977 } {} 12408cf6c554Sdanielk1977 do_test pragma-15.3 { 12418cf6c554Sdanielk1977 # Evaluating this statement will cause the schema to be reloaded (because 12428cf6c554Sdanielk1977 # the schema was changed by another connection in pragma-15.2). At one 12438cf6c554Sdanielk1977 # point there was a bug that reset the cache_size to its default value 12448cf6c554Sdanielk1977 # when this happened. 12458cf6c554Sdanielk1977 execsql { SELECT * FROM sqlite_master } 12468cf6c554Sdanielk1977 execsql { PRAGMA cache_size } 12478cf6c554Sdanielk1977 } {59} 12488cf6c554Sdanielk1977} 12498cf6c554Sdanielk1977 12505558a8a6Sdanielk1977# Reset the sqlite3_temp_directory variable for the next run of tests: 12515558a8a6Sdanielk1977sqlite3 dbX :memory: 12525558a8a6Sdanielk1977dbX eval {PRAGMA temp_store_directory = ""} 12535558a8a6Sdanielk1977dbX close 12545558a8a6Sdanielk1977 1255cd61c281Sdrhfinish_test 1256