|
|
@@ -233,7 +233,7 @@ extern "C" {
|
|
|
*/
|
|
|
#define SQLITE_VERSION "3.8.8"
|
|
|
#define SQLITE_VERSION_NUMBER 3008008
|
|
|
-#define SQLITE_SOURCE_ID "2014-11-27 11:36:36 f095cde579e7417306e11b5c1d2dd90b6bb547d5"
|
|
|
+#define SQLITE_SOURCE_ID "2014-12-06 02:05:44 dd1dd4451f468599f7a0c2f7b5ee6125db3bb152"
|
|
|
|
|
|
/*
|
|
|
** CAPI3REF: Run-Time Library Version Numbers
|
|
|
@@ -1357,7 +1357,7 @@ struct sqlite3_vfs {
|
|
|
** </ul>
|
|
|
**
|
|
|
** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
|
|
|
-** was given no the corresponding lock.
|
|
|
+** was given on the corresponding lock.
|
|
|
**
|
|
|
** The xShmLock method can transition between unlocked and SHARED or
|
|
|
** between unlocked and EXCLUSIVE. It cannot transition between SHARED
|
|
|
@@ -1660,8 +1660,8 @@ struct sqlite3_mem_methods {
|
|
|
** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
|
|
|
** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
|
|
|
** interpreted as a boolean, which enables or disables the collection of
|
|
|
-** memory allocation statistics. ^(When memory allocation statistics are disabled, the
|
|
|
-** following SQLite interfaces become non-operational:
|
|
|
+** memory allocation statistics. ^(When memory allocation statistics are
|
|
|
+** disabled, the following SQLite interfaces become non-operational:
|
|
|
** <ul>
|
|
|
** <li> [sqlite3_memory_used()]
|
|
|
** <li> [sqlite3_memory_highwater()]
|
|
|
@@ -1702,7 +1702,8 @@ struct sqlite3_mem_methods {
|
|
|
** This configuration should not be used if an application-define page
|
|
|
** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2]
|
|
|
** configuration option.
|
|
|
-** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to 8-byte aligned
|
|
|
+** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
|
|
|
+** 8-byte aligned
|
|
|
** memory, the size of each page buffer (sz), and the number of pages (N).
|
|
|
** The sz argument should be the size of the largest database page
|
|
|
** (a power of two between 512 and 32768) plus some extra bytes for each
|
|
|
@@ -1722,7 +1723,8 @@ struct sqlite3_mem_methods {
|
|
|
** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
|
|
|
** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer
|
|
|
** that SQLite will use for all of its dynamic memory allocation needs
|
|
|
-** beyond those provided for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
|
|
|
+** beyond those provided for by [SQLITE_CONFIG_SCRATCH] and
|
|
|
+** [SQLITE_CONFIG_PAGECACHE].
|
|
|
** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled
|
|
|
** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns
|
|
|
** [SQLITE_ERROR] if invoked otherwise.
|
|
|
@@ -1742,9 +1744,9 @@ struct sqlite3_mem_methods {
|
|
|
** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
|
|
|
** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a
|
|
|
** pointer to an instance of the [sqlite3_mutex_methods] structure.
|
|
|
-** The argument specifies alternative low-level mutex routines to be used in place
|
|
|
-** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the
|
|
|
-** content of the [sqlite3_mutex_methods] structure before the call to
|
|
|
+** The argument specifies alternative low-level mutex routines to be used
|
|
|
+** in place the mutex routines built into SQLite.)^ ^SQLite makes a copy of
|
|
|
+** the content of the [sqlite3_mutex_methods] structure before the call to
|
|
|
** [sqlite3_config()] returns. ^If SQLite is compiled with
|
|
|
** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
|
|
|
** the entire mutexing subsystem is omitted from the build and hence calls to
|
|
|
@@ -1782,8 +1784,8 @@ struct sqlite3_mem_methods {
|
|
|
**
|
|
|
** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
|
|
|
** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
|
|
|
-** is a pointer to an [sqlite3_pcache_methods2] object. SQLite copies of the current
|
|
|
-** page cache implementation into that object.)^ </dd>
|
|
|
+** is a pointer to an [sqlite3_pcache_methods2] object. SQLite copies of
|
|
|
+** the current page cache implementation into that object.)^ </dd>
|
|
|
**
|
|
|
** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
|
|
|
** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
|
|
|
@@ -1808,8 +1810,9 @@ struct sqlite3_mem_methods {
|
|
|
** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
|
|
|
** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.
|
|
|
** If non-zero, then URI handling is globally enabled. If the parameter is zero,
|
|
|
-** then URI handling is globally disabled.)^ ^If URI handling is globally enabled,
|
|
|
-** all filenames passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
|
|
|
+** then URI handling is globally disabled.)^ ^If URI handling is globally
|
|
|
+** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],
|
|
|
+** [sqlite3_open16()] or
|
|
|
** specified as part of [ATTACH] commands are interpreted as URIs, regardless
|
|
|
** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
|
|
|
** connection is opened. ^If it is globally disabled, filenames are
|
|
|
@@ -1871,8 +1874,8 @@ struct sqlite3_mem_methods {
|
|
|
** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
|
|
|
** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
|
|
|
** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
|
|
|
-** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
|
|
|
-** ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
|
|
|
+** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
|
|
|
+** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
|
|
|
** that specifies the maximum size of the created heap.
|
|
|
** </dl>
|
|
|
**
|
|
|
@@ -1880,8 +1883,8 @@ struct sqlite3_mem_methods {
|
|
|
** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
|
|
|
** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
|
|
|
** is a pointer to an integer and writes into that integer the number of extra
|
|
|
-** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE]. The amount of
|
|
|
-** extra space required can change depending on the compiler,
|
|
|
+** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].
|
|
|
+** The amount of extra space required can change depending on the compiler,
|
|
|
** target platform, and SQLite version.
|
|
|
** </dl>
|
|
|
*/
|
|
|
@@ -2185,6 +2188,7 @@ SQLITE_API int sqlite3_complete16(const void *sql);
|
|
|
|
|
|
/*
|
|
|
** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
|
|
|
+** KEYWORDS: {busy-handler callback} {busy handler}
|
|
|
**
|
|
|
** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
|
|
|
** that might be invoked with argument P whenever
|
|
|
@@ -2201,7 +2205,7 @@ SQLITE_API int sqlite3_complete16(const void *sql);
|
|
|
** ^The first argument to the busy handler is a copy of the void* pointer which
|
|
|
** is the third argument to sqlite3_busy_handler(). ^The second argument to
|
|
|
** the busy handler callback is the number of times that the busy handler has
|
|
|
-** been invoked for the same locking event. ^If the
|
|
|
+** been invoked previously for the same locking event. ^If the
|
|
|
** busy callback returns 0, then no additional attempts are made to
|
|
|
** access the database and [SQLITE_BUSY] is returned
|
|
|
** to the application.
|
|
|
@@ -4676,7 +4680,8 @@ typedef void (*sqlite3_destructor_type)(void*);
|
|
|
** the [sqlite3_context] pointer, the results are undefined.
|
|
|
*/
|
|
|
SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
|
|
|
-SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,sqlite3_uint64,void(*)(void*));
|
|
|
+SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
|
|
|
+ sqlite3_uint64,void(*)(void*));
|
|
|
SQLITE_API void sqlite3_result_double(sqlite3_context*, sqlite_double);
|
|
|
SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
|
|
|
SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
|
|
|
@@ -7406,97 +7411,114 @@ SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
|
|
|
/*
|
|
|
** CAPI3REF: Checkpoint a database
|
|
|
**
|
|
|
-** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
|
|
|
-** on [database connection] D to be [checkpointed]. ^If X is NULL or an
|
|
|
-** empty string, then a checkpoint is run on all databases of
|
|
|
-** connection D. ^If the database connection D is not in
|
|
|
-** [WAL | write-ahead log mode] then this interface is a harmless no-op.
|
|
|
-** ^The [sqlite3_wal_checkpoint(D,X)] interface initiates a
|
|
|
-** [sqlite3_wal_checkpoint_v2|PASSIVE] checkpoint.
|
|
|
-** Use the [sqlite3_wal_checkpoint_v2()] interface to get a FULL
|
|
|
-** or RESET checkpoint.
|
|
|
+** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
|
|
|
+** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
|
|
|
**
|
|
|
-** ^The [wal_checkpoint pragma] can be used to invoke this interface
|
|
|
-** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the
|
|
|
-** [wal_autocheckpoint pragma] can be used to cause this interface to be
|
|
|
-** run whenever the WAL reaches a certain size threshold.
|
|
|
+** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the
|
|
|
+** [write-ahead log] for database X on [database connection] D to be
|
|
|
+** transferred into the database file and for the write-ahead log to
|
|
|
+** be reset. See the [checkpointing] documentation for addition
|
|
|
+** information.
|
|
|
**
|
|
|
-** See also: [sqlite3_wal_checkpoint_v2()]
|
|
|
+** This interface used to be the only way to cause a checkpoint to
|
|
|
+** occur. But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]
|
|
|
+** interface was added. This interface is retained for backwards
|
|
|
+** compatibility and as a convenience for applications that need to manually
|
|
|
+** start a callback but which do not need the full power (and corresponding
|
|
|
+** complication) of [sqlite3_wal_checkpoint_v2()].
|
|
|
*/
|
|
|
SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
|
|
|
|
|
|
/*
|
|
|
** CAPI3REF: Checkpoint a database
|
|
|
**
|
|
|
-** Run a checkpoint operation on WAL database zDb attached to database
|
|
|
-** handle db. The specific operation is determined by the value of the
|
|
|
-** eMode parameter:
|
|
|
+** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
|
|
|
+** operation on database X of [database connection] D in mode M. Status
|
|
|
+** information is written back into integers pointed to by L and C.)^
|
|
|
+** ^(The M parameter must be a valid [checkpoint mode]:)^
|
|
|
**
|
|
|
** <dl>
|
|
|
** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>
|
|
|
-** Checkpoint as many frames as possible without waiting for any database
|
|
|
-** readers or writers to finish. Sync the db file if all frames in the log
|
|
|
-** are checkpointed. This mode is the same as calling
|
|
|
-** sqlite3_wal_checkpoint(). The [sqlite3_busy_handler|busy-handler callback]
|
|
|
-** is never invoked.
|
|
|
+** ^Checkpoint as many frames as possible without waiting for any database
|
|
|
+** readers or writers to finish, then sync the database file if all frames
|
|
|
+** in the log were checkpointed. ^The [busy-handler callback]
|
|
|
+** is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.
|
|
|
+** ^On the other hand, passive mode might leave the checkpoint unfinished
|
|
|
+** if there are concurrent readers or writers.
|
|
|
**
|
|
|
** <dt>SQLITE_CHECKPOINT_FULL<dd>
|
|
|
-** This mode blocks (it invokes the
|
|
|
+** ^This mode blocks (it invokes the
|
|
|
** [sqlite3_busy_handler|busy-handler callback]) until there is no
|
|
|
** database writer and all readers are reading from the most recent database
|
|
|
-** snapshot. It then checkpoints all frames in the log file and syncs the
|
|
|
-** database file. This call blocks database writers while it is running,
|
|
|
-** but not database readers.
|
|
|
+** snapshot. ^It then checkpoints all frames in the log file and syncs the
|
|
|
+** database file. ^This mode blocks new database writers while it is pending,
|
|
|
+** but new database readers are allowed to continue unimpeded.
|
|
|
**
|
|
|
** <dt>SQLITE_CHECKPOINT_RESTART<dd>
|
|
|
-** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after
|
|
|
-** checkpointing the log file it blocks (calls the
|
|
|
-** [sqlite3_busy_handler|busy-handler callback])
|
|
|
-** until all readers are reading from the database file only. This ensures
|
|
|
-** that the next client to write to the database file restarts the log file
|
|
|
-** from the beginning. This call blocks database writers while it is running,
|
|
|
-** but not database readers.
|
|
|
+** ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition
|
|
|
+** that after checkpointing the log file it blocks (calls the
|
|
|
+** [busy-handler callback])
|
|
|
+** until all readers are reading from the database file only. ^This ensures
|
|
|
+** that the next writer will restart the log file from the beginning.
|
|
|
+** ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new
|
|
|
+** database writer attempts while it is pending, but does not impede readers.
|
|
|
+**
|
|
|
+** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>
|
|
|
+** ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the
|
|
|
+** addition that it also truncates the log file to zero bytes just prior
|
|
|
+** to a successful return.
|
|
|
** </dl>
|
|
|
**
|
|
|
-** If pnLog is not NULL, then *pnLog is set to the total number of frames in
|
|
|
-** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to
|
|
|
-** the total number of checkpointed frames (including any that were already
|
|
|
-** checkpointed when this function is called). *pnLog and *pnCkpt may be
|
|
|
-** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK.
|
|
|
-** If no values are available because of an error, they are both set to -1
|
|
|
-** before returning to communicate this to the caller.
|
|
|
-**
|
|
|
-** All calls obtain an exclusive "checkpoint" lock on the database file. If
|
|
|
+** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in
|
|
|
+** the log file or to -1 if the checkpoint could not run because
|
|
|
+** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not
|
|
|
+** NULL,then *pnCkpt is set to the total number of checkpointed frames in the
|
|
|
+** log file (including any that were already checkpointed before the function
|
|
|
+** was called) or to -1 if the checkpoint could not run due to an error or
|
|
|
+** because the database is not in WAL mode. ^Note that upon successful
|
|
|
+** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been
|
|
|
+** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.
|
|
|
+**
|
|
|
+** ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If
|
|
|
** any other process is running a checkpoint operation at the same time, the
|
|
|
-** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a
|
|
|
+** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a
|
|
|
** busy-handler configured, it will not be invoked in this case.
|
|
|
**
|
|
|
-** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive
|
|
|
-** "writer" lock on the database file. If the writer lock cannot be obtained
|
|
|
-** immediately, and a busy-handler is configured, it is invoked and the writer
|
|
|
-** lock retried until either the busy-handler returns 0 or the lock is
|
|
|
-** successfully obtained. The busy-handler is also invoked while waiting for
|
|
|
-** database readers as described above. If the busy-handler returns 0 before
|
|
|
+** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the
|
|
|
+** exclusive "writer" lock on the database file. ^If the writer lock cannot be
|
|
|
+** obtained immediately, and a busy-handler is configured, it is invoked and
|
|
|
+** the writer lock retried until either the busy-handler returns 0 or the lock
|
|
|
+** is successfully obtained. ^The busy-handler is also invoked while waiting for
|
|
|
+** database readers as described above. ^If the busy-handler returns 0 before
|
|
|
** the writer lock is obtained or while waiting for database readers, the
|
|
|
** checkpoint operation proceeds from that point in the same way as
|
|
|
** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible
|
|
|
-** without blocking any further. SQLITE_BUSY is returned in this case.
|
|
|
+** without blocking any further. ^SQLITE_BUSY is returned in this case.
|
|
|
**
|
|
|
-** If parameter zDb is NULL or points to a zero length string, then the
|
|
|
-** specified operation is attempted on all WAL databases. In this case the
|
|
|
-** values written to output parameters *pnLog and *pnCkpt are undefined. If
|
|
|
+** ^If parameter zDb is NULL or points to a zero length string, then the
|
|
|
+** specified operation is attempted on all WAL databases [attached] to
|
|
|
+** [database connection] db. In this case the
|
|
|
+** values written to output parameters *pnLog and *pnCkpt are undefined. ^If
|
|
|
** an SQLITE_BUSY error is encountered when processing one or more of the
|
|
|
** attached WAL databases, the operation is still attempted on any remaining
|
|
|
-** attached databases and SQLITE_BUSY is returned to the caller. If any other
|
|
|
+** attached databases and SQLITE_BUSY is returned at the end. ^If any other
|
|
|
** error occurs while processing an attached database, processing is abandoned
|
|
|
-** and the error code returned to the caller immediately. If no error
|
|
|
+** and the error code is returned to the caller immediately. ^If no error
|
|
|
** (SQLITE_BUSY or otherwise) is encountered while processing the attached
|
|
|
** databases, SQLITE_OK is returned.
|
|
|
**
|
|
|
-** If database zDb is the name of an attached database that is not in WAL
|
|
|
-** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If
|
|
|
+** ^If database zDb is the name of an attached database that is not in WAL
|
|
|
+** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If
|
|
|
** zDb is not NULL (or a zero length string) and is not the name of any
|
|
|
** attached database, SQLITE_ERROR is returned to the caller.
|
|
|
+**
|
|
|
+** ^Unless it returns SQLITE_MISUSE,
|
|
|
+** the sqlite3_wal_checkpoint_v2() interface
|
|
|
+** sets the error information that is queried by
|
|
|
+** [sqlite3_errcode()] and [sqlite3_errmsg()].
|
|
|
+**
|
|
|
+** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
|
|
|
+** from SQL.
|
|
|
*/
|
|
|
SQLITE_API int sqlite3_wal_checkpoint_v2(
|
|
|
sqlite3 *db, /* Database handle */
|
|
|
@@ -7507,16 +7529,18 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
|
|
|
);
|
|
|
|
|
|
/*
|
|
|
-** CAPI3REF: Checkpoint operation parameters
|
|
|
+** CAPI3REF: Checkpoint Mode Values
|
|
|
+** KEYWORDS: {checkpoint mode}
|
|
|
**
|
|
|
-** These constants can be used as the 3rd parameter to
|
|
|
-** [sqlite3_wal_checkpoint_v2()]. See the [sqlite3_wal_checkpoint_v2()]
|
|
|
-** documentation for additional information about the meaning and use of
|
|
|
-** each of these values.
|
|
|
+** These constants define all valid values for the "checkpoint mode" passed
|
|
|
+** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.
|
|
|
+** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the
|
|
|
+** meaning of each of these checkpoint modes.
|
|
|
*/
|
|
|
-#define SQLITE_CHECKPOINT_PASSIVE 0
|
|
|
-#define SQLITE_CHECKPOINT_FULL 1
|
|
|
-#define SQLITE_CHECKPOINT_RESTART 2
|
|
|
+#define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
|
|
|
+#define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
|
|
|
+#define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for for readers */
|
|
|
+#define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */
|
|
|
|
|
|
/*
|
|
|
** CAPI3REF: Virtual Table Interface Configuration
|
|
|
@@ -7615,12 +7639,12 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
|
|
|
**
|
|
|
** <dl>
|
|
|
** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
|
|
|
-** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set to the
|
|
|
-** total number of times that the X-th loop has run.</dd>
|
|
|
+** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
|
|
|
+** set to the total number of times that the X-th loop has run.</dd>
|
|
|
**
|
|
|
** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
|
|
|
-** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set to the
|
|
|
-** total number of rows examined by all iterations of the X-th loop.</dd>
|
|
|
+** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
|
|
|
+** to the total number of rows examined by all iterations of the X-th loop.</dd>
|
|
|
**
|
|
|
** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
|
|
|
** <dd>^The "double" variable pointed to by the T parameter will be set to the
|
|
|
@@ -7631,14 +7655,14 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
|
|
|
** be the NLOOP value for the current loop.
|
|
|
**
|
|
|
** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
|
|
|
-** <dd>^The "const char *" variable pointed to by the T parameter will be set to
|
|
|
-** a zero-terminated UTF-8 string containing the name of the index or table used
|
|
|
-** for the X-th loop.
|
|
|
+** <dd>^The "const char *" variable pointed to by the T parameter will be set
|
|
|
+** to a zero-terminated UTF-8 string containing the name of the index or table
|
|
|
+** used for the X-th loop.
|
|
|
**
|
|
|
** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
|
|
|
-** <dd>^The "const char *" variable pointed to by the T parameter will be set to
|
|
|
-** a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN] description
|
|
|
-** for the X-th loop.
|
|
|
+** <dd>^The "const char *" variable pointed to by the T parameter will be set
|
|
|
+** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
|
|
|
+** description for the X-th loop.
|
|
|
**
|
|
|
** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
|
|
|
** <dd>^The "int" variable pointed to by the T parameter will be set to the
|
|
|
@@ -7661,8 +7685,8 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
|
|
|
** Return status data for a single loop within query pStmt.
|
|
|
**
|
|
|
** The "iScanStatusOp" parameter determines which status information to return.
|
|
|
-** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior of
|
|
|
-** this interface is undefined.
|
|
|
+** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior
|
|
|
+** of this interface is undefined.
|
|
|
** ^The requested measurement is written into a variable pointed to by
|
|
|
** the "pOut" parameter.
|
|
|
** Parameter "idx" identifies the specific loop to retrieve statistics for.
|
|
|
@@ -11730,7 +11754,7 @@ struct Expr {
|
|
|
/*
|
|
|
** The following are the meanings of bits in the Expr.flags field.
|
|
|
*/
|
|
|
-#define EP_FromJoin 0x000001 /* Originated in ON or USING clause of a join */
|
|
|
+#define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
|
|
|
#define EP_Agg 0x000002 /* Contains one or more aggregate functions */
|
|
|
#define EP_Resolved 0x000004 /* IDs have been resolved to COLUMNs */
|
|
|
#define EP_Error 0x000008 /* Expression contains one or more errors */
|
|
|
@@ -11750,6 +11774,7 @@ struct Expr {
|
|
|
#define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
|
|
|
#define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */
|
|
|
#define EP_Constant 0x080000 /* Node is a constant */
|
|
|
+#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
|
|
|
|
|
|
/*
|
|
|
** These macros can be used to test, set, or clear bits in the
|
|
|
@@ -48400,7 +48425,8 @@ SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int eMode, int *pnLog,
|
|
|
int rc = SQLITE_OK;
|
|
|
if( pPager->pWal ){
|
|
|
rc = sqlite3WalCheckpoint(pPager->pWal, eMode,
|
|
|
- pPager->xBusyHandler, pPager->pBusyHandlerArg,
|
|
|
+ (eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),
|
|
|
+ pPager->pBusyHandlerArg,
|
|
|
pPager->ckptSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,
|
|
|
pnLog, pnCkpt
|
|
|
);
|
|
|
@@ -50211,6 +50237,38 @@ static int walPagesize(Wal *pWal){
|
|
|
return (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16);
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+** The following is guaranteed when this function is called:
|
|
|
+**
|
|
|
+** a) the WRITER lock is held,
|
|
|
+** b) the entire log file has been checkpointed, and
|
|
|
+** c) any existing readers are reading exclusively from the database
|
|
|
+** file - there are no readers that may attempt to read a frame from
|
|
|
+** the log file.
|
|
|
+**
|
|
|
+** This function updates the shared-memory structures so that the next
|
|
|
+** client to write to the database (which may be this one) does so by
|
|
|
+** writing frames into the start of the log file.
|
|
|
+**
|
|
|
+** The value of parameter salt1 is used as the aSalt[1] value in the
|
|
|
+** new wal-index header. It should be passed a pseudo-random value (i.e.
|
|
|
+** one obtained from sqlite3_randomness()).
|
|
|
+*/
|
|
|
+static void walRestartHdr(Wal *pWal, u32 salt1){
|
|
|
+ volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
|
|
|
+ int i; /* Loop counter */
|
|
|
+ u32 *aSalt = pWal->hdr.aSalt; /* Big-endian salt values */
|
|
|
+ pWal->nCkpt++;
|
|
|
+ pWal->hdr.mxFrame = 0;
|
|
|
+ sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));
|
|
|
+ memcpy(&pWal->hdr.aSalt[1], &salt1, 4);
|
|
|
+ walIndexWriteHdr(pWal);
|
|
|
+ pInfo->nBackfill = 0;
|
|
|
+ pInfo->aReadMark[1] = 0;
|
|
|
+ for(i=2; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;
|
|
|
+ assert( pInfo->aReadMark[0]==0 );
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
** Copy as much content as we can from the WAL back into the database file
|
|
|
** in response to an sqlite3_wal_checkpoint() request or the equivalent.
|
|
|
@@ -50245,7 +50303,7 @@ static int walPagesize(Wal *pWal){
|
|
|
static int walCheckpoint(
|
|
|
Wal *pWal, /* Wal connection */
|
|
|
int eMode, /* One of PASSIVE, FULL or RESTART */
|
|
|
- int (*xBusyCall)(void*), /* Function to call when busy */
|
|
|
+ int (*xBusy)(void*), /* Function to call when busy */
|
|
|
void *pBusyArg, /* Context argument for xBusyHandler */
|
|
|
int sync_flags, /* Flags for OsSync() (or 0) */
|
|
|
u8 *zBuf /* Temporary buffer to use */
|
|
|
@@ -50259,7 +50317,6 @@ static int walCheckpoint(
|
|
|
u32 mxPage; /* Max database page to write */
|
|
|
int i; /* Loop counter */
|
|
|
volatile WalCkptInfo *pInfo; /* The checkpoint status information */
|
|
|
- int (*xBusy)(void*) = 0; /* Function to call when waiting for locks */
|
|
|
|
|
|
szPage = walPagesize(pWal);
|
|
|
testcase( szPage<=32768 );
|
|
|
@@ -50274,7 +50331,9 @@ static int walCheckpoint(
|
|
|
}
|
|
|
assert( pIter );
|
|
|
|
|
|
- if( eMode!=SQLITE_CHECKPOINT_PASSIVE ) xBusy = xBusyCall;
|
|
|
+ /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
|
|
|
+ ** in the SQLITE_CHECKPOINT_PASSIVE mode. */
|
|
|
+ assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
|
|
|
|
|
|
/* Compute in mxSafeFrame the index of the last frame of the WAL that is
|
|
|
** safe to write into the database. Frames beyond mxSafeFrame might
|
|
|
@@ -50363,19 +50422,38 @@ static int walCheckpoint(
|
|
|
rc = SQLITE_OK;
|
|
|
}
|
|
|
|
|
|
- /* If this is an SQLITE_CHECKPOINT_RESTART operation, and the entire wal
|
|
|
- ** file has been copied into the database file, then block until all
|
|
|
- ** readers have finished using the wal file. This ensures that the next
|
|
|
- ** process to write to the database restarts the wal file.
|
|
|
+ /* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the
|
|
|
+ ** entire wal file has been copied into the database file, then block
|
|
|
+ ** until all readers have finished using the wal file. This ensures that
|
|
|
+ ** the next process to write to the database restarts the wal file.
|
|
|
*/
|
|
|
if( rc==SQLITE_OK && eMode!=SQLITE_CHECKPOINT_PASSIVE ){
|
|
|
assert( pWal->writeLock );
|
|
|
if( pInfo->nBackfill<pWal->hdr.mxFrame ){
|
|
|
rc = SQLITE_BUSY;
|
|
|
- }else if( eMode==SQLITE_CHECKPOINT_RESTART ){
|
|
|
+ }else if( eMode>=SQLITE_CHECKPOINT_RESTART ){
|
|
|
+ u32 salt1;
|
|
|
+ sqlite3_randomness(4, &salt1);
|
|
|
assert( mxSafeFrame==pWal->hdr.mxFrame );
|
|
|
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);
|
|
|
if( rc==SQLITE_OK ){
|
|
|
+ if( eMode==SQLITE_CHECKPOINT_TRUNCATE ){
|
|
|
+ /* IMPLEMENTATION-OF: R-44699-57140 This mode works the same way as
|
|
|
+ ** SQLITE_CHECKPOINT_RESTART with the addition that it also
|
|
|
+ ** truncates the log file to zero bytes just prior to a
|
|
|
+ ** successful return.
|
|
|
+ **
|
|
|
+ ** In theory, it might be safe to do this without updating the
|
|
|
+ ** wal-index header in shared memory, as all subsequent reader or
|
|
|
+ ** writer clients should see that the entire log file has been
|
|
|
+ ** checkpointed and behave accordingly. This seems unsafe though,
|
|
|
+ ** as it would leave the system in a state where the contents of
|
|
|
+ ** the wal-index header do not match the contents of the
|
|
|
+ ** file-system. To avoid this, update the wal-index header to
|
|
|
+ ** indicate that the log file contains zero valid frames. */
|
|
|
+ walRestartHdr(pWal, salt1);
|
|
|
+ rc = sqlite3OsTruncate(pWal->pWalFd, 0);
|
|
|
+ }
|
|
|
walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
|
|
|
}
|
|
|
}
|
|
|
@@ -51161,7 +51239,6 @@ SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/*
|
|
|
** This function is called just before writing a set of frames to the log
|
|
|
** file (see sqlite3WalFrames()). It checks to see if, instead of appending
|
|
|
@@ -51194,20 +51271,8 @@ static int walRestartLog(Wal *pWal){
|
|
|
** In theory it would be Ok to update the cache of the header only
|
|
|
** at this point. But updating the actual wal-index header is also
|
|
|
** safe and means there is no special case for sqlite3WalUndo()
|
|
|
- ** to handle if this transaction is rolled back.
|
|
|
- */
|
|
|
- int i; /* Loop counter */
|
|
|
- u32 *aSalt = pWal->hdr.aSalt; /* Big-endian salt values */
|
|
|
-
|
|
|
- pWal->nCkpt++;
|
|
|
- pWal->hdr.mxFrame = 0;
|
|
|
- sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));
|
|
|
- aSalt[1] = salt1;
|
|
|
- walIndexWriteHdr(pWal);
|
|
|
- pInfo->nBackfill = 0;
|
|
|
- pInfo->aReadMark[1] = 0;
|
|
|
- for(i=2; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;
|
|
|
- assert( pInfo->aReadMark[0]==0 );
|
|
|
+ ** to handle if this transaction is rolled back. */
|
|
|
+ walRestartHdr(pWal, salt1);
|
|
|
walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
|
|
|
}else if( rc!=SQLITE_BUSY ){
|
|
|
return rc;
|
|
|
@@ -51495,7 +51560,7 @@ SQLITE_PRIVATE int sqlite3WalFrames(
|
|
|
*/
|
|
|
SQLITE_PRIVATE int sqlite3WalCheckpoint(
|
|
|
Wal *pWal, /* Wal connection */
|
|
|
- int eMode, /* PASSIVE, FULL or RESTART */
|
|
|
+ int eMode, /* PASSIVE, FULL, RESTART, or TRUNCATE */
|
|
|
int (*xBusy)(void*), /* Function to call when busy */
|
|
|
void *pBusyArg, /* Context argument for xBusyHandler */
|
|
|
int sync_flags, /* Flags to sync db file with (or 0) */
|
|
|
@@ -51507,29 +51572,42 @@ SQLITE_PRIVATE int sqlite3WalCheckpoint(
|
|
|
int rc; /* Return code */
|
|
|
int isChanged = 0; /* True if a new wal-index header is loaded */
|
|
|
int eMode2 = eMode; /* Mode to pass to walCheckpoint() */
|
|
|
+ int (*xBusy2)(void*) = xBusy; /* Busy handler for eMode2 */
|
|
|
|
|
|
assert( pWal->ckptLock==0 );
|
|
|
assert( pWal->writeLock==0 );
|
|
|
|
|
|
+ /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
|
|
|
+ ** in the SQLITE_CHECKPOINT_PASSIVE mode. */
|
|
|
+ assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
|
|
|
+
|
|
|
if( pWal->readOnly ) return SQLITE_READONLY;
|
|
|
WALTRACE(("WAL%p: checkpoint begins\n", pWal));
|
|
|
+
|
|
|
+ /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive
|
|
|
+ ** "checkpoint" lock on the database file. */
|
|
|
rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
|
|
|
if( rc ){
|
|
|
- /* Usually this is SQLITE_BUSY meaning that another thread or process
|
|
|
- ** is already running a checkpoint, or maybe a recovery. But it might
|
|
|
- ** also be SQLITE_IOERR. */
|
|
|
+ /* EVIDENCE-OF: R-10421-19736 If any other process is running a
|
|
|
+ ** checkpoint operation at the same time, the lock cannot be obtained and
|
|
|
+ ** SQLITE_BUSY is returned.
|
|
|
+ ** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured,
|
|
|
+ ** it will not be invoked in this case.
|
|
|
+ */
|
|
|
+ testcase( rc==SQLITE_BUSY );
|
|
|
+ testcase( xBusy!=0 );
|
|
|
return rc;
|
|
|
}
|
|
|
pWal->ckptLock = 1;
|
|
|
|
|
|
- /* If this is a blocking-checkpoint, then obtain the write-lock as well
|
|
|
- ** to prevent any writers from running while the checkpoint is underway.
|
|
|
- ** This has to be done before the call to walIndexReadHdr() below.
|
|
|
+ /* IMPLEMENTATION-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART and
|
|
|
+ ** TRUNCATE modes also obtain the exclusive "writer" lock on the database
|
|
|
+ ** file.
|
|
|
**
|
|
|
- ** If the writer lock cannot be obtained, then a passive checkpoint is
|
|
|
- ** run instead. Since the checkpointer is not holding the writer lock,
|
|
|
- ** there is no point in blocking waiting for any readers. Assuming no
|
|
|
- ** other error occurs, this function will return SQLITE_BUSY to the caller.
|
|
|
+ ** EVIDENCE-OF: R-60642-04082 If the writer lock cannot be obtained
|
|
|
+ ** immediately, and a busy-handler is configured, it is invoked and the
|
|
|
+ ** writer lock retried until either the busy-handler returns 0 or the
|
|
|
+ ** lock is successfully obtained.
|
|
|
*/
|
|
|
if( eMode!=SQLITE_CHECKPOINT_PASSIVE ){
|
|
|
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_WRITE_LOCK, 1);
|
|
|
@@ -51537,6 +51615,7 @@ SQLITE_PRIVATE int sqlite3WalCheckpoint(
|
|
|
pWal->writeLock = 1;
|
|
|
}else if( rc==SQLITE_BUSY ){
|
|
|
eMode2 = SQLITE_CHECKPOINT_PASSIVE;
|
|
|
+ xBusy2 = 0;
|
|
|
rc = SQLITE_OK;
|
|
|
}
|
|
|
}
|
|
|
@@ -51554,7 +51633,7 @@ SQLITE_PRIVATE int sqlite3WalCheckpoint(
|
|
|
if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){
|
|
|
rc = SQLITE_CORRUPT_BKPT;
|
|
|
}else{
|
|
|
- rc = walCheckpoint(pWal, eMode2, xBusy, pBusyArg, sync_flags, zBuf);
|
|
|
+ rc = walCheckpoint(pWal, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);
|
|
|
}
|
|
|
|
|
|
/* If no error occurred, set the output variables. */
|
|
|
@@ -54022,7 +54101,7 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
|
|
|
testcase( gap+2+nByte==top );
|
|
|
if( gap+2+nByte>top ){
|
|
|
defragment_page:
|
|
|
- testcase( pPage->nCell==0 );
|
|
|
+ assert( pPage->nCell>0 || CORRUPT_DB );
|
|
|
rc = defragmentPage(pPage);
|
|
|
if( rc ) return rc;
|
|
|
top = get2byteNotZero(&data[hdr+5]);
|
|
|
@@ -59082,7 +59161,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
|
|
|
assert( pPage->nOverflow==1 );
|
|
|
|
|
|
/* This error condition is now caught prior to reaching this function */
|
|
|
- if( pPage->nCell==0 ) return SQLITE_CORRUPT_BKPT;
|
|
|
+ if( NEVER(pPage->nCell==0) ) return SQLITE_CORRUPT_BKPT;
|
|
|
|
|
|
/* Allocate a new page. This page will become the right-sibling of
|
|
|
** pPage. Make the parent page writable, so that the new divider cell
|
|
|
@@ -59760,7 +59839,11 @@ static int balance_nonroot(
|
|
|
** if sibling page iOld had the same page number as pNew, and if
|
|
|
** pCell really was a part of sibling page iOld (not a divider or
|
|
|
** overflow cell), we can skip updating the pointer map entries. */
|
|
|
- if( pNew->pgno!=aPgno[iOld] || pCell<aOld || pCell>=&aOld[usableSize] ){
|
|
|
+ if( iOld>=nNew
|
|
|
+ || pNew->pgno!=aPgno[iOld]
|
|
|
+ || pCell<aOld
|
|
|
+ || pCell>=&aOld[usableSize]
|
|
|
+ ){
|
|
|
if( !leafCorrection ){
|
|
|
ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc);
|
|
|
}
|
|
|
@@ -65900,7 +65983,7 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady(
|
|
|
p->aVar[n].db = db;
|
|
|
}
|
|
|
}
|
|
|
- if( p->azVar ){
|
|
|
+ if( p->azVar && pParse->nzVar>0 ){
|
|
|
p->nzVar = pParse->nzVar;
|
|
|
memcpy(p->azVar, pParse->azVar, p->nzVar*sizeof(p->azVar[0]));
|
|
|
memset(pParse->azVar, 0, pParse->nzVar*sizeof(pParse->azVar[0]));
|
|
|
@@ -75830,8 +75913,8 @@ case OP_AggFinal: {
|
|
|
/* Opcode: Checkpoint P1 P2 P3 * *
|
|
|
**
|
|
|
** Checkpoint database P1. This is a no-op if P1 is not currently in
|
|
|
-** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL
|
|
|
-** or RESTART. Write 1 or 0 into mem[P3] if the checkpoint returns
|
|
|
+** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL,
|
|
|
+** RESTART, or TRUNCATE. Write 1 or 0 into mem[P3] if the checkpoint returns
|
|
|
** SQLITE_BUSY or not, respectively. Write the number of pages in the
|
|
|
** WAL after the checkpoint into mem[P3+1] and the number of pages
|
|
|
** in the WAL that have been checkpointed after the checkpoint
|
|
|
@@ -75849,6 +75932,7 @@ case OP_Checkpoint: {
|
|
|
assert( pOp->p2==SQLITE_CHECKPOINT_PASSIVE
|
|
|
|| pOp->p2==SQLITE_CHECKPOINT_FULL
|
|
|
|| pOp->p2==SQLITE_CHECKPOINT_RESTART
|
|
|
+ || pOp->p2==SQLITE_CHECKPOINT_TRUNCATE
|
|
|
);
|
|
|
rc = sqlite3Checkpoint(db, pOp->p1, pOp->p2, &aRes[1], &aRes[2]);
|
|
|
if( rc==SQLITE_BUSY ){
|
|
|
@@ -80612,6 +80696,10 @@ static int lookupName(
|
|
|
if( pMatch ){
|
|
|
pExpr->iTable = pMatch->iCursor;
|
|
|
pExpr->pTab = pMatch->pTab;
|
|
|
+ assert( (pMatch->jointype & JT_RIGHT)==0 ); /* RIGHT JOIN not (yet) supported */
|
|
|
+ if( (pMatch->jointype & JT_LEFT)!=0 ){
|
|
|
+ ExprSetProperty(pExpr, EP_CanBeNull);
|
|
|
+ }
|
|
|
pSchema = pExpr->pTab->pSchema;
|
|
|
}
|
|
|
} /* if( pSrcList ) */
|
|
|
@@ -83169,7 +83257,8 @@ SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){
|
|
|
return 0;
|
|
|
case TK_COLUMN:
|
|
|
assert( p->pTab!=0 );
|
|
|
- return p->iColumn>=0 && p->pTab->aCol[p->iColumn].notNull==0;
|
|
|
+ return ExprHasProperty(p, EP_CanBeNull) ||
|
|
|
+ (p->iColumn>=0 && p->pTab->aCol[p->iColumn].notNull==0);
|
|
|
default:
|
|
|
return 1;
|
|
|
}
|
|
|
@@ -88552,7 +88641,7 @@ static void initAvgEq(Index *pIdx){
|
|
|
i64 nSum100 = 0; /* Number of terms contributing to sumEq */
|
|
|
i64 nDist100; /* Number of distinct values in index */
|
|
|
|
|
|
- if( pIdx->aiRowEst==0 || pIdx->aiRowEst[iCol+1]==0 ){
|
|
|
+ if( !pIdx->aiRowEst || iCol>=pIdx->nKeyCol || pIdx->aiRowEst[iCol+1]==0 ){
|
|
|
nRow = pFinal->anLt[iCol];
|
|
|
nDist100 = (i64)100 * pFinal->anDLt[iCol];
|
|
|
nSample--;
|
|
|
@@ -104169,7 +104258,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
|
|
|
|
|
|
#ifndef SQLITE_OMIT_WAL
|
|
|
/*
|
|
|
- ** PRAGMA [database.]wal_checkpoint = passive|full|restart
|
|
|
+ ** PRAGMA [database.]wal_checkpoint = passive|full|restart|truncate
|
|
|
**
|
|
|
** Checkpoint the database.
|
|
|
*/
|
|
|
@@ -104181,6 +104270,8 @@ SQLITE_PRIVATE void sqlite3Pragma(
|
|
|
eMode = SQLITE_CHECKPOINT_FULL;
|
|
|
}else if( sqlite3StrICmp(zRight, "restart")==0 ){
|
|
|
eMode = SQLITE_CHECKPOINT_RESTART;
|
|
|
+ }else if( sqlite3StrICmp(zRight, "truncate")==0 ){
|
|
|
+ eMode = SQLITE_CHECKPOINT_TRUNCATE;
|
|
|
}
|
|
|
}
|
|
|
sqlite3VdbeSetNumCols(v, 3);
|
|
|
@@ -110089,7 +110180,7 @@ SQLITE_PRIVATE int sqlite3Select(
|
|
|
**
|
|
|
** is transformed to:
|
|
|
**
|
|
|
- ** SELECT xyz FROM ... GROUP BY xyz
|
|
|
+ ** SELECT xyz FROM ... GROUP BY xyz ORDER BY xyz
|
|
|
**
|
|
|
** The second form is preferred as a single index (or temp-table) may be
|
|
|
** used for both the ORDER BY and DISTINCT processing. As originally
|
|
|
@@ -110102,7 +110193,6 @@ SQLITE_PRIVATE int sqlite3Select(
|
|
|
p->selFlags &= ~SF_Distinct;
|
|
|
p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
|
|
|
pGroupBy = p->pGroupBy;
|
|
|
- sSort.pOrderBy = 0;
|
|
|
/* Notice that even thought SF_Distinct has been cleared from p->selFlags,
|
|
|
** the sDistinct.isTnct is still set. Hence, isTnct represents the
|
|
|
** original setting of the SF_Distinct flag, not the current setting */
|
|
|
@@ -115057,6 +115147,7 @@ static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
|
|
|
sqlite3DbFree(db, pOld);
|
|
|
}
|
|
|
pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);
|
|
|
+ memset(&pWC->a[pWC->nTerm], 0, sizeof(pWC->a[0])*(pWC->nSlot-pWC->nTerm));
|
|
|
}
|
|
|
pTerm = &pWC->a[idx = pWC->nTerm++];
|
|
|
if( p && ExprHasProperty(p, EP_Unlikely) ){
|
|
|
@@ -117782,7 +117873,7 @@ static void addScanStatus(
|
|
|
){
|
|
|
const char *zObj = 0;
|
|
|
WhereLoop *pLoop = pLvl->pWLoop;
|
|
|
- if( (pLoop->wsFlags & (WHERE_IPK|WHERE_VIRTUALTABLE))==0 ){
|
|
|
+ if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 && pLoop->u.btree.pIndex!=0 ){
|
|
|
zObj = pLoop->u.btree.pIndex->zName;
|
|
|
}else{
|
|
|
zObj = pSrclist->a[pLvl->iFrom].zName;
|
|
|
@@ -118426,10 +118517,9 @@ static Bitmask codeOneLoopStart(
|
|
|
Expr *pExpr = pWC->a[iTerm].pExpr;
|
|
|
if( &pWC->a[iTerm] == pTerm ) continue;
|
|
|
if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
|
|
|
- testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
|
|
|
- testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );
|
|
|
- if( pWC->a[iTerm].wtFlags & (TERM_ORINFO|TERM_VIRTUAL) ) continue;
|
|
|
+ if( (pWC->a[iTerm].wtFlags & TERM_VIRTUAL)!=0 ) continue;
|
|
|
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
|
|
|
+ testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
|
|
|
pExpr = sqlite3ExprDup(db, pExpr, 0);
|
|
|
pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
|
|
|
}
|
|
|
@@ -127426,6 +127516,14 @@ SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){
|
|
|
for(j=0; j<db->nDb; j++){
|
|
|
struct Db *pDb = &db->aDb[j];
|
|
|
if( pDb->pBt ){
|
|
|
+ if( pDb->pSchema ){
|
|
|
+ /* Must clear the KeyInfo cache. See ticket [e4a18565a36884b00edf] */
|
|
|
+ for(i=sqliteHashFirst(&pDb->pSchema->idxHash); i; i=sqliteHashNext(i)){
|
|
|
+ Index *pIdx = sqliteHashData(i);
|
|
|
+ sqlite3KeyInfoUnref(pIdx->pKeyInfo);
|
|
|
+ pIdx->pKeyInfo = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
sqlite3BtreeClose(pDb->pBt);
|
|
|
pDb->pBt = 0;
|
|
|
if( j!=1 ){
|
|
|
@@ -128333,10 +128431,13 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
|
|
|
if( pnLog ) *pnLog = -1;
|
|
|
if( pnCkpt ) *pnCkpt = -1;
|
|
|
|
|
|
- assert( SQLITE_CHECKPOINT_FULL>SQLITE_CHECKPOINT_PASSIVE );
|
|
|
- assert( SQLITE_CHECKPOINT_FULL<SQLITE_CHECKPOINT_RESTART );
|
|
|
- assert( SQLITE_CHECKPOINT_PASSIVE+2==SQLITE_CHECKPOINT_RESTART );
|
|
|
- if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_RESTART ){
|
|
|
+ assert( SQLITE_CHECKPOINT_PASSIVE==0 );
|
|
|
+ assert( SQLITE_CHECKPOINT_FULL==1 );
|
|
|
+ assert( SQLITE_CHECKPOINT_RESTART==2 );
|
|
|
+ assert( SQLITE_CHECKPOINT_TRUNCATE==3 );
|
|
|
+ if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){
|
|
|
+ /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint
|
|
|
+ ** mode: */
|
|
|
return SQLITE_MISUSE;
|
|
|
}
|
|
|
|
|
|
@@ -128364,7 +128465,9 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
|
|
|
** checkpointed.
|
|
|
*/
|
|
|
SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
|
|
|
- return sqlite3_wal_checkpoint_v2(db, zDb, SQLITE_CHECKPOINT_PASSIVE, 0, 0);
|
|
|
+ /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to
|
|
|
+ ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */
|
|
|
+ return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0);
|
|
|
}
|
|
|
|
|
|
#ifndef SQLITE_OMIT_WAL
|
|
|
@@ -140623,7 +140726,7 @@ static int isVowel(const char *z){
|
|
|
** by a consonant.
|
|
|
**
|
|
|
** In this routine z[] is in reverse order. So we are really looking
|
|
|
-** for an instance of of a consonant followed by a vowel.
|
|
|
+** for an instance of a consonant followed by a vowel.
|
|
|
*/
|
|
|
static int m_gt_0(const char *z){
|
|
|
while( isVowel(z) ){ z++; }
|