From: drh Date: Tue, 17 Jan 2012 15:29:14 +0000 (+0000) Subject: Remove the undocumented PRAGMA omit_readlock hack. X-Git-Tag: version-3.7.11~91 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33f111dc724af4012c76057bf6fd9b8e06dd6608;p=thirdparty%2Fsqlite.git Remove the undocumented PRAGMA omit_readlock hack. FossilOrigin-Name: 96900c47e4fc6ed55cefc10d55d3d8d16bcb1d31 --- diff --git a/manifest b/manifest index 3c45dc8dad..2dc7b9518b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\scommand-lin\sshell\sto\sinterpret\sCSV\sfiles\sas\sdescribed\sby\nthe\swikipedia\sarticle\son\sCSV. -D 2012-01-16T16:56:31.707 +C Remove\sthe\sundocumented\sPRAGMA\somit_readlock\shack. +D 2012-01-17T15:29:14.086 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -125,8 +125,8 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c e9538bad2d4a4fcd4308f1aed7cb18a0fbc968f9 F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c a65816cc000bdd421772986e64c88c9035331332 -F src/btree.h f5d775cd6cfc7ac32a2535b70e8d2af48ef5f2ce +F src/btree.c 24bde768288b3365bc6acfbb24030f76fefe7e1f +F src/btree.h 46e9f04672f1390255bc56865a3238b384d0f2d5 F src/btreeInt.h 6c9960645c431c9456ca56498f43a2b3bf1fa8c2 F src/build.c 8e2a4dedad860fed982270ef43968505f35ec57f F src/callback.c 0425c6320730e6d3981acfb9202c1bed9016ad1a @@ -168,13 +168,13 @@ F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c 657672fab2580a84116c140b36ee3d6b6fc75b4e F src/os_win.c 5ac061ae1326a71500cee578ed0fd9113b4f6a37 -F src/pager.c 4d58c983d9f4d34bc2d48e4280361ccaeecd03c5 -F src/pager.h 5cd760857707529b403837d813d86b68938d6183 +F src/pager.c 2d892f7b901a8867a33bc21742086165a3a99af8 +F src/pager.h a435da8421dc7844b7f9c7f37b636c160c50208a F src/parse.y fabb2e7047417d840e6fdb3ef0988a86849a08ba F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h b1d8775a9bddf44e65edb0d20bfc57a4982f840f F src/pcache1.c 281822d22265245b19f908cb3f5df725f7e11b06 -F src/pragma.c fb979b7b5103ad0db1b72bcf349c83f5dec62574 +F src/pragma.c dbad8484b9e7d53c70c94b583f968eec9ee2ed78 F src/prepare.c ec4989f7f480544bdc4192fe663470d2a2d7d61e F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -184,7 +184,7 @@ F src/select.c a1d075db66a0ea42807353501b62997969e5be79 F src/shell.c f492df9fc2de27e4700ecbaa948729fc47af88d7 F src/sqlite.h.in 53516617d2945a411d028674d7fa20dd394b9ec0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h b8fdd9c39c8d7f5c794f4ea917293d9c75b9aff2 +F src/sqliteInt.h b2bceb669152129283e4b7d6f699e0788a7fb5ec F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 4568e72dfd36b6a5911f93457364deb072e0b03a F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -374,7 +374,7 @@ F test/descidx1.test 533dcbda614b0463b0ea029527fd27e5a9ab2d66 F test/descidx2.test 9f1a0c83fd57f8667c82310ca21b30a350888b5d F test/descidx3.test fe720e8b37d59f4cef808b0bf4e1b391c2e56b6f F test/diskfull.test 106391384780753ea6896b7b4f005d10e9866b6e -F test/distinct.test df5b11ad606439129c88720a86787bc9ca181f31 +F test/distinct.test 76908ed038c5186ffb8acf5954ed64e22056f311 F test/distinctagg.test 1a6ef9c87a58669438fc771450d7a72577417376 F test/e_createtable.test 48598b15e8fe6554d301e7b65a10c9851f177e84 F test/e_delete.test ec168cd4b08d681e6d5847f462203755ad647532 @@ -606,7 +606,7 @@ F test/misc3.test fe55130a43e444ee75e2156ff75dc96e964b5738 F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 F test/misc5.test 528468b26d03303b1f047146e5eefc941b9069f5 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 -F test/misc7.test eafaa41b9133d7a2ded4641bbe5f340731d35a52 +F test/misc7.test 6743b810884ef64ae14c07ad1f9f858c40c06100 F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054 F test/multiplex.test e08cc7177bd6d85990ee1d71100bb6c684c02256 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a @@ -621,7 +621,7 @@ F test/notnull.test cc7c78340328e6112a13c3e311a9ab3127114347 F test/null.test a8b09b8ed87852742343b33441a9240022108993 F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394 F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3 -F test/pager1.test 9e9f5f1c6d4df4831dbff213b1262ef94bf72118 +F test/pager1.test efef0bb4035d7180ec58308f1d449475e4670b48 F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442 @@ -987,7 +987,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P de11cd5cc903e56ff641079bc64dd0ae5e133aa7 -R dacb46e8be9eb1ebee00515eda49d8d2 +P 93aa17d866873e11dde5ffbefe74497f229977c1 +R 10335ebf2ef7305693adeccf03d51204 U drh -Z 9bfd5c27d81636d73cbec09996ae37dd +Z 39607908f591a79c538e47098a517cec diff --git a/manifest.uuid b/manifest.uuid index 8708fe5312..7cef0f4e8a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -93aa17d866873e11dde5ffbefe74497f229977c1 \ No newline at end of file +96900c47e4fc6ed55cefc10d55d3d8d16bcb1d31 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 2532406651..14ddee57e8 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1689,11 +1689,8 @@ static int btreeInvokeBusyHandler(void *pArg){ ** If zFilename is ":memory:" then an in-memory database is created ** that is automatically destroyed when it is closed. ** -** The "flags" parameter is a bitmask that might contain bits -** BTREE_OMIT_JOURNAL and/or BTREE_NO_READLOCK. The BTREE_NO_READLOCK -** bit is also set if the SQLITE_NoReadlock flags is set in db->flags. -** These flags are passed through into sqlite3PagerOpen() and must -** be the same values as PAGER_OMIT_JOURNAL and PAGER_NO_READLOCK. +** The "flags" parameter is a bitmask that might contain bits like +** BTREE_OMIT_JOURNAL and/or BTREE_MEMORY. ** ** If the database is already opened in the same database connection ** and we are in shared cache mode, then the open will fail with an @@ -1740,9 +1737,6 @@ int sqlite3BtreeOpen( /* A BTREE_SINGLE database is always a temporary and/or ephemeral */ assert( (flags & BTREE_SINGLE)==0 || isTempDb ); - if( db->flags & SQLITE_NoReadlock ){ - flags |= BTREE_NO_READLOCK; - } if( isMemdb ){ flags |= BTREE_MEMORY; } diff --git a/src/btree.h b/src/btree.h index 9e3a73b3b6..637dc486e1 100644 --- a/src/btree.h +++ b/src/btree.h @@ -57,10 +57,9 @@ int sqlite3BtreeOpen( ** pager.h. */ #define BTREE_OMIT_JOURNAL 1 /* Do not create or use a rollback journal */ -#define BTREE_NO_READLOCK 2 /* Omit readlocks on readonly files */ -#define BTREE_MEMORY 4 /* This is an in-memory DB */ -#define BTREE_SINGLE 8 /* The file contains at most 1 b-tree */ -#define BTREE_UNORDERED 16 /* Use of a hash implementation is OK */ +#define BTREE_MEMORY 2 /* This is an in-memory DB */ +#define BTREE_SINGLE 4 /* The file contains at most 1 b-tree */ +#define BTREE_UNORDERED 8 /* Use of a hash implementation is OK */ int sqlite3BtreeClose(Btree*); int sqlite3BtreeSetCacheSize(Btree*,int); diff --git a/src/pager.c b/src/pager.c index 6f3b651668..be360448f0 100644 --- a/src/pager.c +++ b/src/pager.c @@ -612,7 +612,6 @@ struct Pager { u8 exclusiveMode; /* Boolean. True if locking_mode==EXCLUSIVE */ u8 journalMode; /* One of the PAGER_JOURNALMODE_* values */ u8 useJournal; /* Use a rollback journal on this file */ - u8 noReadlock; /* Do not bother to obtain readlocks */ u8 noSync; /* Do not sync the journal if true */ u8 fullSync; /* Do extra syncs of the journal for robustness */ u8 ckptSyncFlags; /* SYNC_NORMAL or SYNC_FULL for checkpoint */ @@ -860,7 +859,7 @@ static int assert_pager_state(Pager *p){ case PAGER_READER: assert( pPager->errCode==SQLITE_OK ); assert( p->eLock!=UNKNOWN_LOCK ); - assert( p->eLock>=SHARED_LOCK || p->noReadlock ); + assert( p->eLock>=SHARED_LOCK ); break; case PAGER_WRITER_LOCKED: @@ -3069,7 +3068,7 @@ static int pagerPagecount(Pager *pPager, Pgno *pnPage){ ** contains no valid committed transactions. */ assert( pPager->eState==PAGER_OPEN ); - assert( pPager->eLock>=SHARED_LOCK || pPager->noReadlock ); + assert( pPager->eLock>=SHARED_LOCK ); nPage = sqlite3WalDbsize(pPager->pWal); /* If the database size was not available from the WAL sub-system, @@ -3124,7 +3123,7 @@ static int pagerPagecount(Pager *pPager, Pgno *pnPage){ static int pagerOpenWalIfPresent(Pager *pPager){ int rc = SQLITE_OK; assert( pPager->eState==PAGER_OPEN ); - assert( pPager->eLock>=SHARED_LOCK || pPager->noReadlock ); + assert( pPager->eLock>=SHARED_LOCK ); if( !pPager->tempFile ){ int isWal; /* True if WAL file exists */ @@ -4287,7 +4286,7 @@ static int pagerStress(void *p, PgHdr *pPg){ ** ** The flags argument is used to specify properties that affect the ** operation of the pager. It should be passed some bitwise combination -** of the PAGER_OMIT_JOURNAL and PAGER_NO_READLOCK flags. +** of the PAGER_* flags. ** ** The vfsFlags parameter is a bitmask to pass to the flags parameter ** of the xOpen() method of the supplied VFS when opening files. @@ -4318,7 +4317,6 @@ int sqlite3PagerOpen( char *zPathname = 0; /* Full path to database file */ int nPathname = 0; /* Number of bytes in zPathname */ int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */ - int noReadlock = (flags & PAGER_NO_READLOCK)!=0; /* True to omit read-lock */ int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */ u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */ const char *zUri = 0; /* URI args to copy */ @@ -4525,7 +4523,6 @@ int sqlite3PagerOpen( IOTRACE(("OPEN %p %s\n", pPager, pPager->zFilename)) pPager->useJournal = (u8)useJournal; - pPager->noReadlock = (noReadlock && readOnly) ?1:0; /* pPager->stmtOpen = 0; */ /* pPager->stmtInUse = 0; */ /* pPager->nRef = 0; */ @@ -4747,14 +4744,11 @@ int sqlite3PagerSharedLock(Pager *pPager){ int bHotJournal = 1; /* True if there exists a hot journal-file */ assert( !MEMDB ); - assert( pPager->noReadlock==0 || pPager->readOnly ); - if( pPager->noReadlock==0 ){ - rc = pager_wait_on_lock(pPager, SHARED_LOCK); - if( rc!=SQLITE_OK ){ - assert( pPager->eLock==NO_LOCK || pPager->eLock==UNKNOWN_LOCK ); - goto failed; - } + rc = pager_wait_on_lock(pPager, SHARED_LOCK); + if( rc!=SQLITE_OK ){ + assert( pPager->eLock==NO_LOCK || pPager->eLock==UNKNOWN_LOCK ); + goto failed; } /* If a journal file exists, and there is no RESERVED lock on the @@ -6762,7 +6756,7 @@ static int pagerOpenWal(Pager *pPager){ int rc = SQLITE_OK; assert( pPager->pWal==0 && pPager->tempFile==0 ); - assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK || pPager->noReadlock); + assert( pPager->eLock==SHARED_LOCK || pPager->eLock==EXCLUSIVE_LOCK ); /* If the pager is already in exclusive-mode, the WAL module will use ** heap-memory for the wal-index instead of the VFS shared-memory diff --git a/src/pager.h b/src/pager.h index f68b19f6eb..e5088bdabc 100644 --- a/src/pager.h +++ b/src/pager.h @@ -58,8 +58,7 @@ typedef struct PgHdr DbPage; ** NOTE: These values must match the corresponding BTREE_ values in btree.h. */ #define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ -#define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ -#define PAGER_MEMORY 0x0004 /* In-memory database */ +#define PAGER_MEMORY 0x0002 /* In-memory database */ /* ** Valid values for the second argument to sqlite3PagerLockingMode(). diff --git a/src/pragma.c b/src/pragma.c index 581bcaf0eb..ce7f2fc52f 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -189,7 +189,6 @@ static int flagPragma(Parse *pParse, const char *zLeft, const char *zRight){ #endif /* The following is VERY experimental */ { "writable_schema", SQLITE_WriteSchema|SQLITE_RecoveryMode }, - { "omit_readlock", SQLITE_NoReadlock }, /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted ** flag if there are any active statements. */ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 6e48b1c4f2..9071bef416 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -946,8 +946,7 @@ struct sqlite3 { #define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */ #define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */ #define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */ -#define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when - ** accessing read-only databases */ + /* 0x00020000 Unused */ #define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */ #define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */ #define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */ diff --git a/test/distinct.test b/test/distinct.test index e0a913604d..3fb9c8478a 100644 --- a/test/distinct.test +++ b/test/distinct.test @@ -46,8 +46,8 @@ proc do_temptables_test {tn sql temptables} { set ret "" db eval "EXPLAIN [set sql]" { if {$opcode == "OpenEphemeral" || $opcode == "SorterOpen"} { - if {$p5 != "10" && $p5!="00"} { error "p5 = $p5" } - if {$p5 == "10"} { + if {$p5 != "08" && $p5!="00"} { error "p5 = $p5" } + if {$p5 == "08"} { lappend ret hash } else { lappend ret btree diff --git a/test/misc7.test b/test/misc7.test index 9dee327877..c69e60bb7c 100644 --- a/test/misc7.test +++ b/test/misc7.test @@ -151,6 +151,12 @@ db2 close # Test that nothing goes horribly wrong when attaching a database # after the omit_readlock pragma has been exercised. # +# Note: The PRAGMA omit_readlock was an early hack to disable the +# fcntl() calls for read-only databases so that read-only databases could +# be read on broken NFS systems. That pragma has now been removed. +# (Use the unix-none VFS as a replacement, if needed.) But these tests +# do not really depend on omit_readlock, so we left them in place. +# do_test misc7-7.1 { forcedelete test2.db forcedelete test2.db-journal diff --git a/test/pager1.test b/test/pager1.test index 99b25bdc00..415eb6ab81 100644 --- a/test/pager1.test +++ b/test/pager1.test @@ -54,6 +54,8 @@ do_not_use_codec # pager1-16.*: Varying sqlite3_vfs.mxPathname # # pager1-17.*: Tests related to "PRAGMA omit_readlock" +# (The omit_readlock pragma has been removed and so have +# these tests.) # # pager1-18.*: Test that the pager layer responds correctly if the b-tree # requests an invalid page number (due to db corruption). @@ -1708,75 +1710,6 @@ for {set ii [expr $::file_len-5]} {$ii < [expr $::file_len+20]} {incr ii} { tv delete } -#------------------------------------------------------------------------- -# Test "PRAGMA omit_readlock". -# -# pager1-17.$tn.1.*: Test that if a second connection has an open -# read-transaction, it is not usually possible to write -# the database. -# -# pager1-17.$tn.2.*: Test that if the second connection was opened with -# the SQLITE_OPEN_READONLY flag, and -# "PRAGMA omit_readlock = 1" is executed before attaching -# the database and opening a read-transaction on it, it is -# possible to write the db. -# -# pager1-17.$tn.3.*: Test that if the second connection was *not* opened with -# the SQLITE_OPEN_READONLY flag, executing -# "PRAGMA omit_readlock = 1" has no effect. -# -do_multiclient_test tn { - do_test pager1-17.$tn.1.1 { - sql1 { - CREATE TABLE t1(a, b); - INSERT INTO t1 VALUES(1, 2); - } - sql2 { - BEGIN; - SELECT * FROM t1; - } - } {1 2} - do_test pager1-17.$tn.1.2 { - csql1 { INSERT INTO t1 VALUES(3, 4) } - } {1 {database is locked}} - do_test pager1-17.$tn.1.3 { - sql2 { COMMIT } - sql1 { INSERT INTO t1 VALUES(3, 4) } - } {} - - do_test pager1-17.$tn.2.1 { - code2 { - db2 close - sqlite3 db2 :memory: -readonly 1 - } - sql2 { - PRAGMA omit_readlock = 1; - ATTACH 'test.db' AS two; - BEGIN; - SELECT * FROM t1; - } - } {1 2 3 4} - do_test pager1-17.$tn.2.2 { sql1 "INSERT INTO t1 VALUES(5, 6)" } {} - do_test pager1-17.$tn.2.3 { sql2 "SELECT * FROM t1" } {1 2 3 4} - do_test pager1-17.$tn.2.4 { sql2 "COMMIT ; SELECT * FROM t1" } {1 2 3 4 5 6} - - do_test pager1-17.$tn.3.1 { - code2 { - db2 close - sqlite3 db2 :memory: - } - sql2 { - PRAGMA omit_readlock = 1; - ATTACH 'test.db' AS two; - BEGIN; - SELECT * FROM t1; - } - } {1 2 3 4 5 6} - do_test pager1-17.$tn.3.2 { - csql1 { INSERT INTO t1 VALUES(3, 4) } - } {1 {database is locked}} - do_test pager1-17.$tn.3.3 { sql2 COMMIT } {} -} #------------------------------------------------------------------------- # Test the pagers response to the b-tree layer requesting illegal page