/ Check-in [cbec1bfe]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix some comments in new code on this branch. No changes to code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | fcntl_shm_read
Files: files | file ages | folders
SHA3-256: cbec1bfe4b9f0e9fc9849db623694902308ecc05f3898368201a9902c39a138f
User & Date: dan 2017-11-03 19:34:17
Context
2017-11-03
19:34
Fix some comments in new code on this branch. No changes to code. Closed-Leaf check-in: cbec1bfe user: dan tags: fcntl_shm_read
17:51
Merge latest trunk changes with this branch. check-in: 585e0a09 user: dan tags: fcntl_shm_read
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqlite.h.in.

   504    504   #define SQLITE_LOCKED_SHAREDCACHE      (SQLITE_LOCKED |  (1<<8))
   505    505   #define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
   506    506   #define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))
   507    507   #define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
   508    508   #define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))
   509    509   #define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))
   510    510   #define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))
   511         -#define SQLITE_CANTOPEN_DIRTYWAL       (SQLITE_CANTOPEN | (5<<8))
   512    511   #define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))
   513    512   #define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))
   514    513   #define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))
   515    514   #define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))
   516    515   #define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))
   517    516   #define SQLITE_ABORT_ROLLBACK          (SQLITE_ABORT | (2<<8))
   518    517   #define SQLITE_CONSTRAINT_CHECK        (SQLITE_CONSTRAINT | (1<<8))
................................................................................
  1057   1056   ** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write
  1058   1057   ** operations since the previous successful call to 
  1059   1058   ** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.
  1060   1059   ** ^This file control takes the file descriptor out of batch write mode
  1061   1060   ** so that all subsequent write operations are independent.
  1062   1061   ** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without
  1063   1062   ** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].
         1063  +**
         1064  +** <li>[[SQLITE_FCNTL_READ_SHM]]
         1065  +** The [SQLITE_FCNTL_READ_SHM] opcode may be used to read data from 
         1066  +** the shared-memory region used by wal mode if the previous call
         1067  +** to the xShmMap method returned SQLITE_READONLY_CANTLOCK. The argument
         1068  +** must point to an instance of a structure declared as:
         1069  +** <blockquote><pre>
         1070  +**   struct ReadShmArg { void *pBuf; int nBuf };
         1071  +** </pre></blockquote>)^
         1072  +** Before returning, this operation allocates a buffer large enough for
         1073  +** the entire shared-memory using sqlite3_malloc() and populates it with
         1074  +** a copy thereof. ReadShmArg.pBuf is set to point to the buffer, and
         1075  +** ReadShmArg to its size in bytes. It is the responsibility of the caller
         1076  +** to eventually free the buffer using sqlite3_free().
  1064   1077   ** </ul>
  1065   1078   */
  1066   1079   #define SQLITE_FCNTL_LOCKSTATE               1
  1067   1080   #define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
  1068   1081   #define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
  1069   1082   #define SQLITE_FCNTL_LAST_ERRNO              4
  1070   1083   #define SQLITE_FCNTL_SIZE_HINT               5

Changes to src/wal.c.

  2341   2341     }
  2342   2342   
  2343   2343     if( !useWal ){
  2344   2344       rc = walIndexReadHdr(pWal, pChanged);
  2345   2345       if( rc==SQLITE_READONLY_CANTLOCK ){
  2346   2346         /* This is a readonly_shm connection and there are no other connections
  2347   2347         ** to the database. So the *-shm file may not be accessed using mmap.
  2348         -      ** Take WAL_READ_LOCK(0) before proceding.  */
         2348  +      ** Try to open an "unlocked" transaction - one that loads the *-shm
         2349  +      ** file into memory using read() - instead.  */
  2349   2350         assert( pWal->nWiData>0 && pWal->apWiData[0]==0 );
  2350   2351         assert( pWal->readOnly & WAL_SHM_RDONLY );
  2351   2352         return walBeginUnlocked(pWal, pChanged);
  2352   2353       }
  2353   2354       if( rc==SQLITE_BUSY ){
  2354   2355         /* If there is not a recovery running in another thread or process
  2355   2356         ** then convert BUSY errors to WAL_RETRY.  If recovery is known to