Compare commits
301 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5dd26c5ed1 | |||
| 230ad4565e | |||
| 98e57757dc | |||
| e8b45c33cd | |||
| 47405642f2 | |||
| 16938fc374 | |||
| cdce08b05a | |||
| 254c5ad58d | |||
| 87cef5ed35 | |||
| 9eb67ef5f9 | |||
| 7ef2cf86d3 | |||
| 0b316cb36d | |||
| 71dc5f83f4 | |||
| 7dde866d3b | |||
| 65f517d619 | |||
| 96e3015e4d | |||
| 202b2a7b54 | |||
| b0ddbf7922 | |||
| fd34e75b0a | |||
| 6eb7354fab | |||
| afb21dc9ca | |||
| b1c445732e | |||
| effc07ec9c | |||
| 8d65601931 | |||
| c892515c7a | |||
| 9dde91f613 | |||
| 11dbd0be3c | |||
| b3f7a5d8f6 | |||
| 14030cca04 | |||
| 9d905ce1c5 | |||
| 9dfd155f68 | |||
| 31114a38cc | |||
| 4292973810 | |||
| 8d7ffd2904 | |||
| 64477226e2 | |||
| d120a50ef7 | |||
| f14c4c91e1 | |||
| 98c336c2b2 | |||
| cf5696ff0b | |||
| 3ab59dd981 | |||
| 137c1b48d5 | |||
| ac00efc996 | |||
| 472e709136 | |||
| 9077e4652f | |||
| 9783c82de2 | |||
| a294d7f208 | |||
| 0ca5fd6f50 | |||
| a819ff7c54 | |||
| a58abfe7db | |||
| 02369f514d | |||
| bfc3e65a04 | |||
| 55d070bae8 | |||
| 5d0ce656d4 | |||
| 5954108ab1 | |||
| 3c3a5d4ada | |||
| 08fc368485 | |||
| 6a608be78c | |||
| 5f9b5fcbcc | |||
| fc9f56c453 | |||
| 59b15e7b0c | |||
| 9826456ab0 | |||
| 6a25ed176c | |||
| 945e5d112e | |||
| 9ba15fdb8f | |||
| adcbc76bb6 | |||
| db7959d111 | |||
| f0629994ab | |||
| 7d6837fc94 | |||
| ab8ad8dde3 | |||
| 850853be76 | |||
| 7a5d37f540 | |||
| 95003feeb2 | |||
| 5b2b13c8c2 | |||
| b6c8623045 | |||
| 684c1705c9 | |||
| cb2ec5c3fd | |||
| e09460ea13 | |||
| 05c3446396 | |||
| 99320d2dd8 | |||
| 6bfb2e062e | |||
| 2492eda559 | |||
| fb9d9cc7c4 | |||
| 09f78fff30 | |||
| 612beb5e38 | |||
| c9cb469013 | |||
| a240942122 | |||
| a905c73baf | |||
| 5e9d4c221d | |||
| 23dbdf125c | |||
| 7e4f836942 | |||
| 94281e049f | |||
| bd14b600fa | |||
| 1098bdb8e5 | |||
| 3dc850321e | |||
| 9a47771710 | |||
| 5a344ef67c | |||
| 8efab83cf8 | |||
| e3e03777c7 | |||
| fcf3e8076d | |||
| 27fab1c045 | |||
| cf7c1bfc9b | |||
| cd35fbc9ca | |||
| af77b082e8 | |||
| f17089eb01 | |||
| 98424ffbea | |||
| ab18639258 | |||
| 70de00f144 | |||
| d4a1c953a1 | |||
| 36832d61d8 | |||
| 93b95c6c84 | |||
| 58f6bb447e | |||
| c697613beb | |||
| 0f654ac668 | |||
| f5078e74dd | |||
| 788e6d3424 | |||
| 47f677d8d7 | |||
| db5eb1d353 | |||
| 3b5a4942f1 | |||
| 87909ef6fb | |||
| 42f5c182f6 | |||
| 0132ba7496 | |||
| 2bbacc1cf3 | |||
| 0c27f2c2b2 | |||
| 7773fffb18 | |||
| 91a3ea48a4 | |||
| 2ef7860be5 | |||
| bfaa3dbd61 | |||
| 841efe0ca1 | |||
| 25a8d24b7f | |||
| 7e1f717b09 | |||
| 77428e6055 | |||
| 2da2a2698b | |||
| ff9e9b27d5 | |||
| db6fe08914 | |||
| b031157128 | |||
| ef180caded | |||
| 9c1eb40d69 | |||
| 9ee5641ae0 | |||
| 254fa054ec | |||
| a693b000df | |||
| f8d7432aa3 | |||
| 50232dd821 | |||
| 834c48c279 | |||
| 51883dfc8b | |||
| 15e8543ecd | |||
| a63585eb8e | |||
| 9b5c67f784 | |||
| 8e90c85bfb | |||
| dcb3992c66 | |||
| 0131a914d3 | |||
| 2dd93c8838 | |||
| c1b7fdd43e | |||
| fccd5d43a9 | |||
| ec6e332f01 | |||
| eb30704cc9 | |||
| de26c16ea1 | |||
| 0c1fa5c8c6 | |||
| 6ccceeb3bd | |||
| 4921c159bd | |||
| 1d735ad3bb | |||
| b7ee5667c2 | |||
| a233f09330 | |||
| bfbe2b8c80 | |||
| 886fac36ba | |||
| 4af5f425f2 | |||
| 8ba5d0d4f7 | |||
| 51abf049c7 | |||
| ed432167dc | |||
| cdbf6d01a4 | |||
| 3a5fc00808 | |||
| eb816a7547 | |||
| 908803f5e0 | |||
| 699bd8121e | |||
| c7a82772dc | |||
| 5d9c916150 | |||
| 55fba4f05c | |||
| 02bc6f8fb9 | |||
| cb0267185c | |||
| 165ba4a2a5 | |||
| 8706485d1a | |||
| c0f69fcec7 | |||
| 4d13729861 | |||
| 56391f2769 | |||
| 7393c7424e | |||
| 3eba5d00b6 | |||
| 03d405f046 | |||
| d351e7643f | |||
| b25057c291 | |||
| 9c54156a9c | |||
| d828d0debc | |||
| 6aab028db0 | |||
| 9f16a96d4b | |||
| 741802e825 | |||
| fd80ce4b10 | |||
| 9ee9b0f4c3 | |||
| c5856def1e | |||
| 0a2afca904 | |||
| 1af0a4e1df | |||
| 7365bcd72c | |||
| 1c6276eac6 | |||
| 827c9b785e | |||
| 4956bd5f9a | |||
| 63624a0ab8 | |||
| dc1bf28ad4 | |||
| d6396e9b16 | |||
| d4d01a689d | |||
| a096fcc73c | |||
| 50179f91f3 | |||
| 35dcd0e892 | |||
| 7f002db7e3 | |||
| 995b2457e2 | |||
| 7fff2e1cb9 | |||
| e3b047b3d7 | |||
| 7037787d30 | |||
| 606f718480 | |||
| e3c3be8511 | |||
| aa59505ae8 | |||
| 55b36d5c07 | |||
| 6dbb452b38 | |||
| 2ecf1ec8c9 | |||
| 9a89254e7a | |||
| fe329a7370 | |||
| 4d55d35df6 | |||
| 246e1d8faf | |||
| 0195d8ef5d | |||
| e32c7c2b64 | |||
| 0ba9725489 | |||
| ff8e42e2ca | |||
| a8dee8df64 | |||
| 7d931b985a | |||
| 8bbf544747 | |||
| a7d16a5cd1 | |||
| c18d304066 | |||
| 3d4ad18cbe | |||
| 21ac1de75b | |||
| 96b9dc9b36 | |||
| adeb47e57b | |||
| 12891cc492 | |||
| 820fc4933b | |||
| b00083429a | |||
| b0b18f6dca | |||
| 76cb74da4d | |||
| db454d72b6 | |||
| 99b14894eb | |||
| 03206c433c | |||
| 93f88ebbb1 | |||
| faf010d77a | |||
| 7c9ecc62c5 | |||
| 04b9cf1e7e | |||
| f687ba597f | |||
| 76ff0699bb | |||
| 607d4c2184 | |||
| 8c9ea487d0 | |||
| 1d9497a0d0 | |||
| 31441fb50b | |||
| f12cc2a68c | |||
| cd9491ca2f | |||
| e8a1ea6d8b | |||
| 0faad42d59 | |||
| 411547ec6c | |||
| 9a5a469c7a | |||
| 573ebef187 | |||
| 144cd3df05 | |||
| 3561ec2ede | |||
| 01be463eeb | |||
| a62b6bd93c | |||
| f56af5ee2d | |||
| 3f531da564 | |||
| 7b8996c878 | |||
| c8a9d15887 | |||
| 6b3e51bd33 | |||
| 987f821f79 | |||
| f6cf5ea790 | |||
| de36c76a23 | |||
| fef3410f7f | |||
| 57888f7300 | |||
| 4073b26a20 | |||
| ac0a42233a | |||
| 3c40ed4281 | |||
| 0cd4f69c0c | |||
| bf3cf57e15 | |||
| f5e89dba9d | |||
| 0408529b48 | |||
| 5cf03728a6 | |||
| 8b994f29a5 | |||
| 654a965367 | |||
| 0c52b373a0 | |||
| f5cebf71fe | |||
| c299a11c02 | |||
| 8c5847a257 | |||
| b87b25f219 | |||
| 572a21c8e9 | |||
| 70af25d03d | |||
| cec0beebb3 | |||
| 64b310ed1a | |||
| 699bdf056b | |||
| 7b3d71e9cc | |||
| 1a9cde3ba9 | |||
| 773d2d6c09 | |||
| 37d36205f3 | |||
| 3d39434c36 |
+5
-2
@@ -433,6 +433,7 @@ TESTSRC = \
|
||||
$(TOP)/ext/fts3/fts3_term.c \
|
||||
$(TOP)/ext/fts3/fts3_test.c \
|
||||
$(TOP)/ext/session/test_session.c \
|
||||
$(TOP)/ext/session/sqlite3changebatch.c \
|
||||
$(TOP)/ext/rbu/test_rbu.c
|
||||
|
||||
# Statically linked extensions
|
||||
@@ -503,6 +504,7 @@ TESTSRC2 = \
|
||||
$(TOP)/src/pcache1.c \
|
||||
$(TOP)/src/select.c \
|
||||
$(TOP)/src/tokenize.c \
|
||||
$(TOP)/src/treeview.c \
|
||||
$(TOP)/src/utf.c \
|
||||
$(TOP)/src/util.c \
|
||||
$(TOP)/src/vdbeapi.c \
|
||||
@@ -523,8 +525,9 @@ TESTSRC2 = \
|
||||
$(TOP)/ext/fts3/fts3_tokenizer.c \
|
||||
$(TOP)/ext/fts3/fts3_write.c \
|
||||
$(TOP)/ext/async/sqlite3async.c \
|
||||
$(TOP)/ext/session/sqlite3session.c \
|
||||
$(TOP)/ext/misc/stmt.c \
|
||||
$(TOP)/ext/session/sqlite3session.c \
|
||||
$(TOP)/ext/session/test_session.c \
|
||||
fts5.c
|
||||
|
||||
# Header files used by all library source files.
|
||||
@@ -874,7 +877,7 @@ hash.lo: $(TOP)/src/hash.c $(HDR)
|
||||
insert.lo: $(TOP)/src/insert.c $(HDR)
|
||||
$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/insert.c
|
||||
|
||||
json.lo: $(TOP)/src/json.c
|
||||
json.lo: $(TOP)/src/json.c $(HDR)
|
||||
$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/json.c
|
||||
|
||||
legacy.lo: $(TOP)/src/legacy.c $(HDR)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for sqlite 3.39.0.
|
||||
# Generated by GNU Autoconf 2.69 for sqlite 3.39.3.
|
||||
#
|
||||
#
|
||||
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
|
||||
@@ -726,8 +726,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='sqlite'
|
||||
PACKAGE_TARNAME='sqlite'
|
||||
PACKAGE_VERSION='3.39.0'
|
||||
PACKAGE_STRING='sqlite 3.39.0'
|
||||
PACKAGE_VERSION='3.39.3'
|
||||
PACKAGE_STRING='sqlite 3.39.3'
|
||||
PACKAGE_BUGREPORT=''
|
||||
PACKAGE_URL=''
|
||||
|
||||
@@ -1468,7 +1468,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures sqlite 3.39.0 to adapt to many kinds of systems.
|
||||
\`configure' configures sqlite 3.39.3 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@@ -1533,7 +1533,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of sqlite 3.39.0:";;
|
||||
short | recursive ) echo "Configuration of sqlite 3.39.3:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@@ -1661,7 +1661,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
sqlite configure 3.39.0
|
||||
sqlite configure 3.39.3
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@@ -2080,7 +2080,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by sqlite $as_me 3.39.0, which was
|
||||
It was created by sqlite $as_me 3.39.3, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@@ -12390,7 +12390,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by sqlite $as_me 3.39.0, which was
|
||||
This file was extended by sqlite $as_me 3.39.3, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@@ -12456,7 +12456,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
sqlite config.status 3.39.0
|
||||
sqlite config.status 3.39.3
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
|
||||
Begin Concurrent
|
||||
================
|
||||
|
||||
## Overview
|
||||
|
||||
Usually, SQLite allows at most one writer to proceed concurrently. The
|
||||
BEGIN CONCURRENT enhancement allows multiple writers to process write
|
||||
transactions simultanously if the database is in "wal" or "wal2" mode,
|
||||
although the system still serializes COMMIT commands.
|
||||
|
||||
When a write-transaction is opened with "BEGIN CONCURRENT", actually
|
||||
locking the database is deferred until a COMMIT is executed. This means
|
||||
that any number of transactions started with BEGIN CONCURRENT may proceed
|
||||
concurrently. The system uses optimistic page-level-locking to prevent
|
||||
conflicting concurrent transactions from being committed.
|
||||
|
||||
When a BEGIN CONCURRENT transaction is committed, the system checks whether
|
||||
or not any of the database pages that the transaction has read have been
|
||||
modified since the BEGIN CONCURRENT was opened. In other words - it asks
|
||||
if the transaction being committed operates on a different set of data than
|
||||
all other concurrently executing transactions. If the answer is "yes, this
|
||||
transaction did not read or modify any data modified by any concurrent
|
||||
transaction", then the transaction is committed as normal. Otherwise, if the
|
||||
transaction does conflict, it cannot be committed and an SQLITE_BUSY_SNAPSHOT
|
||||
error is returned. At this point, all the client can do is ROLLBACK the
|
||||
transaction.
|
||||
|
||||
If SQLITE_BUSY_SNAPSHOT is returned, messages are output via the sqlite3_log
|
||||
mechanism indicating the page and table or index on which the conflict
|
||||
occurred. This can be useful when optimizing concurrency.
|
||||
|
||||
## Application Programming Notes
|
||||
|
||||
In order to serialize COMMIT processing, SQLite takes a lock on the database
|
||||
as part of each COMMIT command and releases it before returning. At most one
|
||||
writer may hold this lock at any one time. If a writer cannot obtain the lock,
|
||||
it uses SQLite's busy-handler to pause and retry for a while:
|
||||
|
||||
<a href=https://www.sqlite.org/c3ref/busy_handler.html>
|
||||
https://www.sqlite.org/c3ref/busy_handler.html
|
||||
</a>
|
||||
|
||||
If there is significant contention for the writer lock, this mechanism can be
|
||||
inefficient. In this case it is better for the application to use a mutex or
|
||||
some other mechanism that supports blocking to ensure that at most one writer
|
||||
is attempting to COMMIT a BEGIN CONCURRENT transaction at a time. This is
|
||||
usually easier if all writers are part of the same operating system process.
|
||||
|
||||
If all database clients (readers and writers) are located in the same OS
|
||||
process, and if that OS is a Unix variant, then it can be more efficient to
|
||||
the built-in VFS "unix-excl" instead of the default "unix". This is because it
|
||||
uses more efficient locking primitives.
|
||||
|
||||
The key to maximizing concurrency using BEGIN CONCURRENT is to ensure that
|
||||
there are a large number of non-conflicting transactions. In SQLite, each
|
||||
table and each index is stored as a separate b-tree, each of which is
|
||||
distributed over a discrete set of database pages. This means that:
|
||||
|
||||
* Two transactions that write to different sets of tables never
|
||||
conflict, and that
|
||||
|
||||
* Two transactions that write to the same tables or indexes only
|
||||
conflict if the values of the keys (either primary keys or indexed
|
||||
rows) are fairly close together. For example, given a large
|
||||
table with the schema:
|
||||
|
||||
<pre> CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB);</pre>
|
||||
|
||||
writing two rows with adjacent values for "a" probably will cause a
|
||||
conflict (as the two keys are stored on the same page), but writing two
|
||||
rows with vastly different values for "a" will not (as the keys will likly
|
||||
be stored on different pages).
|
||||
|
||||
Note that, in SQLite, if values are not explicitly supplied for an INTEGER
|
||||
PRIMARY KEY, as for example in:
|
||||
|
||||
>
|
||||
INSERT INTO t1(b) VALUES(<blob-value>);
|
||||
|
||||
then monotonically increasing values are assigned automatically. This is
|
||||
terrible for concurrency, as it all but ensures that all new rows are
|
||||
added to the same database page. In such situations, it is better to
|
||||
explicitly assign random values to INTEGER PRIMARY KEY fields.
|
||||
|
||||
This problem also comes up for non-WITHOUT ROWID tables that do not have an
|
||||
explicit INTEGER PRIMARY KEY column. In these cases each table has an implicit
|
||||
INTEGER PRIMARY KEY column that is assigned increasing values, leading to the
|
||||
same problem as omitting to assign a value to an explicit INTEGER PRIMARY KEY
|
||||
column.
|
||||
|
||||
For both explicit and implicit INTEGER PRIMARY KEYs, it is possible to have
|
||||
SQLite assign values at random (instead of the monotonically increasing
|
||||
values) by writing a row with a rowid equal to the largest possible signed
|
||||
64-bit integer to the table. For example:
|
||||
|
||||
INSERT INTO t1(a) VALUES(9223372036854775807);
|
||||
|
||||
Applications should take care not to malfunction due to the presence of such
|
||||
rows.
|
||||
|
||||
The nature of some types of indexes, for example indexes on timestamp fields,
|
||||
can also cause problems (as concurrent transactions may assign similar
|
||||
timestamps that will be stored on the same db page to new records). In these
|
||||
cases the database schema may need to be rethought to increase the concurrency
|
||||
provided by page-level-locking.
|
||||
+9
-7
@@ -4308,8 +4308,7 @@ static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){
|
||||
char *aPoslist = 0; /* Position list for deferred tokens */
|
||||
int nPoslist = 0; /* Number of bytes in aPoslist */
|
||||
int iPrev = -1; /* Token number of previous deferred token */
|
||||
|
||||
assert( pPhrase->doclist.bFreeList==0 );
|
||||
char *aFree = (pPhrase->doclist.bFreeList ? pPhrase->doclist.pList : 0);
|
||||
|
||||
for(iToken=0; iToken<pPhrase->nToken; iToken++){
|
||||
Fts3PhraseToken *pToken = &pPhrase->aToken[iToken];
|
||||
@@ -4323,6 +4322,7 @@ static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){
|
||||
|
||||
if( pList==0 ){
|
||||
sqlite3_free(aPoslist);
|
||||
sqlite3_free(aFree);
|
||||
pPhrase->doclist.pList = 0;
|
||||
pPhrase->doclist.nList = 0;
|
||||
return SQLITE_OK;
|
||||
@@ -4343,6 +4343,7 @@ static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){
|
||||
nPoslist = (int)(aOut - aPoslist);
|
||||
if( nPoslist==0 ){
|
||||
sqlite3_free(aPoslist);
|
||||
sqlite3_free(aFree);
|
||||
pPhrase->doclist.pList = 0;
|
||||
pPhrase->doclist.nList = 0;
|
||||
return SQLITE_OK;
|
||||
@@ -4375,13 +4376,14 @@ static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){
|
||||
nDistance = iPrev - nMaxUndeferred;
|
||||
}
|
||||
|
||||
aOut = (char *)sqlite3_malloc(nPoslist+8);
|
||||
aOut = (char *)sqlite3Fts3MallocZero(nPoslist+FTS3_BUFFER_PADDING);
|
||||
if( !aOut ){
|
||||
sqlite3_free(aPoslist);
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
|
||||
pPhrase->doclist.pList = aOut;
|
||||
assert( p1 && p2 );
|
||||
if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){
|
||||
pPhrase->doclist.bFreeList = 1;
|
||||
pPhrase->doclist.nList = (int)(aOut - pPhrase->doclist.pList);
|
||||
@@ -4394,6 +4396,7 @@ static int fts3EvalDeferredPhrase(Fts3Cursor *pCsr, Fts3Phrase *pPhrase){
|
||||
}
|
||||
}
|
||||
|
||||
if( pPhrase->doclist.pList!=aFree ) sqlite3_free(aFree);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
#endif /* SQLITE_DISABLE_FTS4_DEFERRED */
|
||||
@@ -5568,11 +5571,10 @@ static int fts3EvalTestExpr(
|
||||
|
||||
default: {
|
||||
#ifndef SQLITE_DISABLE_FTS4_DEFERRED
|
||||
if( pCsr->pDeferred
|
||||
&& (pExpr->iDocid==pCsr->iPrevId || pExpr->bDeferred)
|
||||
){
|
||||
if( pCsr->pDeferred && (pExpr->bDeferred || (
|
||||
pExpr->iDocid==pCsr->iPrevId && pExpr->pPhrase->doclist.pList
|
||||
))){
|
||||
Fts3Phrase *pPhrase = pExpr->pPhrase;
|
||||
assert( pExpr->bDeferred || pPhrase->doclist.bFreeList==0 );
|
||||
if( pExpr->bDeferred ){
|
||||
fts3EvalInvalidatePoslist(pPhrase);
|
||||
}
|
||||
|
||||
@@ -16,12 +16,16 @@ source [file join [file dirname [info script]] fts5_common.tcl]
|
||||
source $testdir/malloc_common.tcl
|
||||
set testprefix fts5fault4
|
||||
|
||||
# If SQLITE_ENABLE_FTS3 is defined, omit this file.
|
||||
# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
|
||||
ifcapable !fts5 {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
set ::TMPDBERROR [list 1 \
|
||||
{unable to open a temporary database file for storing temporary tables}
|
||||
]
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# An OOM while dropping an fts5 table.
|
||||
#
|
||||
@@ -391,7 +395,7 @@ do_faultsim_test 14.1 -faults oom-t* -prep {
|
||||
} -body {
|
||||
db eval { ALTER TABLE "tbl one" RENAME TO "tbl two" }
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_test_result {0 {}} $::TMPDBERROR
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
+1
-1
@@ -685,7 +685,7 @@ static const char *re_compile(ReCompiled **ppRe, const char *zIn, int noCase){
|
||||
pRe->zInit[j++] = (unsigned char)(0xc0 | (x>>6));
|
||||
pRe->zInit[j++] = 0x80 | (x&0x3f);
|
||||
}else if( x<=0xffff ){
|
||||
pRe->zInit[j++] = (unsigned char)(0xd0 | (x>>12));
|
||||
pRe->zInit[j++] = (unsigned char)(0xe0 | (x>>12));
|
||||
pRe->zInit[j++] = 0x80 | ((x>>6)&0x3f);
|
||||
pRe->zInit[j++] = 0x80 | (x&0x3f);
|
||||
}else{
|
||||
|
||||
+81
-44
@@ -30,6 +30,16 @@ SQLITE_EXTENSION_INIT1
|
||||
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
|
||||
|
||||
#define STMT_NUM_INTEGER_COLUMN 10
|
||||
typedef struct StmtRow StmtRow;
|
||||
struct StmtRow {
|
||||
sqlite3_int64 iRowid; /* Rowid value */
|
||||
char *zSql; /* column "sql" */
|
||||
int aCol[STMT_NUM_INTEGER_COLUMN+1]; /* all other column values */
|
||||
StmtRow *pNext; /* Next row to return */
|
||||
};
|
||||
|
||||
/* stmt_vtab is a subclass of sqlite3_vtab which will
|
||||
** serve as the underlying representation of a stmt virtual table
|
||||
*/
|
||||
@@ -47,8 +57,7 @@ typedef struct stmt_cursor stmt_cursor;
|
||||
struct stmt_cursor {
|
||||
sqlite3_vtab_cursor base; /* Base class - must be first */
|
||||
sqlite3 *db; /* Database connection for this cursor */
|
||||
sqlite3_stmt *pStmt; /* Statement cursor is currently pointing at */
|
||||
sqlite3_int64 iRowid; /* The rowid */
|
||||
StmtRow *pRow; /* Current row */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -92,7 +101,7 @@ static int stmtConnect(
|
||||
"CREATE TABLE x(sql,ncol,ro,busy,nscan,nsort,naidx,nstep,"
|
||||
"reprep,run,mem)");
|
||||
if( rc==SQLITE_OK ){
|
||||
pNew = sqlite3_malloc( sizeof(*pNew) );
|
||||
pNew = sqlite3_malloc64( sizeof(*pNew) );
|
||||
*ppVtab = (sqlite3_vtab*)pNew;
|
||||
if( pNew==0 ) return SQLITE_NOMEM;
|
||||
memset(pNew, 0, sizeof(*pNew));
|
||||
@@ -114,7 +123,7 @@ static int stmtDisconnect(sqlite3_vtab *pVtab){
|
||||
*/
|
||||
static int stmtOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
|
||||
stmt_cursor *pCur;
|
||||
pCur = sqlite3_malloc( sizeof(*pCur) );
|
||||
pCur = sqlite3_malloc64( sizeof(*pCur) );
|
||||
if( pCur==0 ) return SQLITE_NOMEM;
|
||||
memset(pCur, 0, sizeof(*pCur));
|
||||
pCur->db = ((stmt_vtab*)p)->db;
|
||||
@@ -122,10 +131,21 @@ static int stmtOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
static void stmtCsrReset(stmt_cursor *pCur){
|
||||
StmtRow *pRow = 0;
|
||||
StmtRow *pNext = 0;
|
||||
for(pRow=pCur->pRow; pRow; pRow=pNext){
|
||||
pNext = pRow->pNext;
|
||||
sqlite3_free(pRow);
|
||||
}
|
||||
pCur->pRow = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Destructor for a stmt_cursor.
|
||||
*/
|
||||
static int stmtClose(sqlite3_vtab_cursor *cur){
|
||||
stmtCsrReset((stmt_cursor*)cur);
|
||||
sqlite3_free(cur);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
@@ -136,8 +156,9 @@ static int stmtClose(sqlite3_vtab_cursor *cur){
|
||||
*/
|
||||
static int stmtNext(sqlite3_vtab_cursor *cur){
|
||||
stmt_cursor *pCur = (stmt_cursor*)cur;
|
||||
pCur->iRowid++;
|
||||
pCur->pStmt = sqlite3_next_stmt(pCur->db, pCur->pStmt);
|
||||
StmtRow *pNext = pCur->pRow->pNext;
|
||||
sqlite3_free(pCur->pRow);
|
||||
pCur->pRow = pNext;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@@ -151,39 +172,11 @@ static int stmtColumn(
|
||||
int i /* Which column to return */
|
||||
){
|
||||
stmt_cursor *pCur = (stmt_cursor*)cur;
|
||||
switch( i ){
|
||||
case STMT_COLUMN_SQL: {
|
||||
sqlite3_result_text(ctx, sqlite3_sql(pCur->pStmt), -1, SQLITE_TRANSIENT);
|
||||
break;
|
||||
}
|
||||
case STMT_COLUMN_NCOL: {
|
||||
sqlite3_result_int(ctx, sqlite3_column_count(pCur->pStmt));
|
||||
break;
|
||||
}
|
||||
case STMT_COLUMN_RO: {
|
||||
sqlite3_result_int(ctx, sqlite3_stmt_readonly(pCur->pStmt));
|
||||
break;
|
||||
}
|
||||
case STMT_COLUMN_BUSY: {
|
||||
sqlite3_result_int(ctx, sqlite3_stmt_busy(pCur->pStmt));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
assert( i==STMT_COLUMN_MEM );
|
||||
i = SQLITE_STMTSTATUS_MEMUSED +
|
||||
STMT_COLUMN_NSCAN - SQLITE_STMTSTATUS_FULLSCAN_STEP;
|
||||
/* Fall thru */
|
||||
}
|
||||
case STMT_COLUMN_NSCAN:
|
||||
case STMT_COLUMN_NSORT:
|
||||
case STMT_COLUMN_NAIDX:
|
||||
case STMT_COLUMN_NSTEP:
|
||||
case STMT_COLUMN_REPREP:
|
||||
case STMT_COLUMN_RUN: {
|
||||
sqlite3_result_int(ctx, sqlite3_stmt_status(pCur->pStmt,
|
||||
i-STMT_COLUMN_NSCAN+SQLITE_STMTSTATUS_FULLSCAN_STEP, 0));
|
||||
break;
|
||||
}
|
||||
StmtRow *pRow = pCur->pRow;
|
||||
if( i==STMT_COLUMN_SQL ){
|
||||
sqlite3_result_text(ctx, pRow->zSql, -1, SQLITE_TRANSIENT);
|
||||
}else{
|
||||
sqlite3_result_int(ctx, pRow->aCol[i]);
|
||||
}
|
||||
return SQLITE_OK;
|
||||
}
|
||||
@@ -194,7 +187,7 @@ static int stmtColumn(
|
||||
*/
|
||||
static int stmtRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
|
||||
stmt_cursor *pCur = (stmt_cursor*)cur;
|
||||
*pRowid = pCur->iRowid;
|
||||
*pRowid = pCur->pRow->iRowid;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@@ -204,7 +197,7 @@ static int stmtRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
|
||||
*/
|
||||
static int stmtEof(sqlite3_vtab_cursor *cur){
|
||||
stmt_cursor *pCur = (stmt_cursor*)cur;
|
||||
return pCur->pStmt==0;
|
||||
return pCur->pRow==0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -219,9 +212,53 @@ static int stmtFilter(
|
||||
int argc, sqlite3_value **argv
|
||||
){
|
||||
stmt_cursor *pCur = (stmt_cursor *)pVtabCursor;
|
||||
pCur->pStmt = 0;
|
||||
pCur->iRowid = 0;
|
||||
return stmtNext(pVtabCursor);
|
||||
sqlite3_stmt *p = 0;
|
||||
sqlite3_int64 iRowid = 1;
|
||||
StmtRow **ppRow = 0;
|
||||
|
||||
stmtCsrReset(pCur);
|
||||
ppRow = &pCur->pRow;
|
||||
for(p=sqlite3_next_stmt(pCur->db, 0); p; p=sqlite3_next_stmt(pCur->db, p)){
|
||||
const char *zSql = sqlite3_sql(p);
|
||||
sqlite3_int64 nSql = zSql ? strlen(zSql)+1 : 0;
|
||||
StmtRow *pNew = (StmtRow*)sqlite3_malloc64(sizeof(StmtRow) + nSql);
|
||||
|
||||
if( pNew==0 ) return SQLITE_NOMEM;
|
||||
memset(pNew, 0, sizeof(StmtRow));
|
||||
if( zSql ){
|
||||
pNew->zSql = (char*)&pNew[1];
|
||||
memcpy(pNew->zSql, zSql, nSql);
|
||||
}
|
||||
pNew->aCol[STMT_COLUMN_NCOL] = sqlite3_column_count(p);
|
||||
pNew->aCol[STMT_COLUMN_RO] = sqlite3_stmt_readonly(p);
|
||||
pNew->aCol[STMT_COLUMN_BUSY] = sqlite3_stmt_busy(p);
|
||||
pNew->aCol[STMT_COLUMN_NSCAN] = sqlite3_stmt_status(
|
||||
p, SQLITE_STMTSTATUS_FULLSCAN_STEP, 0
|
||||
);
|
||||
pNew->aCol[STMT_COLUMN_NSORT] = sqlite3_stmt_status(
|
||||
p, SQLITE_STMTSTATUS_SORT, 0
|
||||
);
|
||||
pNew->aCol[STMT_COLUMN_NAIDX] = sqlite3_stmt_status(
|
||||
p, SQLITE_STMTSTATUS_AUTOINDEX, 0
|
||||
);
|
||||
pNew->aCol[STMT_COLUMN_NSTEP] = sqlite3_stmt_status(
|
||||
p, SQLITE_STMTSTATUS_VM_STEP, 0
|
||||
);
|
||||
pNew->aCol[STMT_COLUMN_REPREP] = sqlite3_stmt_status(
|
||||
p, SQLITE_STMTSTATUS_REPREPARE, 0
|
||||
);
|
||||
pNew->aCol[STMT_COLUMN_RUN] = sqlite3_stmt_status(
|
||||
p, SQLITE_STMTSTATUS_RUN, 0
|
||||
);
|
||||
pNew->aCol[STMT_COLUMN_MEM] = sqlite3_stmt_status(
|
||||
p, SQLITE_STMTSTATUS_MEMUSED, 0
|
||||
);
|
||||
pNew->iRowid = iRowid++;
|
||||
*ppRow = pNew;
|
||||
ppRow = &pNew->pNext;
|
||||
}
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -1695,7 +1695,7 @@ static int geopolyUpdate(
|
||||
sqlite3_free(p);
|
||||
nChange = 1;
|
||||
}
|
||||
for(jj=1; jj<pRtree->nAux; jj++){
|
||||
for(jj=1; jj<nData-2; jj++){
|
||||
nChange++;
|
||||
sqlite3_bind_value(pUp, jj+2, aData[jj+2]);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@ ifcapable !rtree {
|
||||
return
|
||||
}
|
||||
|
||||
set ::TMPDBERROR [list 1 \
|
||||
{unable to open a temporary database file for storing temporary tables}
|
||||
]
|
||||
|
||||
# Test summary:
|
||||
#
|
||||
# rtree3-1: Test OOM in simple CREATE TABLE, INSERT, DELETE and SELECT
|
||||
@@ -196,9 +200,9 @@ do_test rtree3-7.prep {
|
||||
do_faultsim_test rtree3-7 -faults oom-* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql { ALTER TABLE rt RENAME TO rt2 }
|
||||
execsql { ALTER TABLE rt RENAME TO rt2 }
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_test_result {0 {}} $::TMPDBERROR
|
||||
}
|
||||
|
||||
do_faultsim_test rtree3-8 -faults oom-* -prep {
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
# 2016 August 23
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
#
|
||||
|
||||
if {![info exists testdir]} {
|
||||
set testdir [file join [file dirname [info script]] .. .. test]
|
||||
}
|
||||
source $testdir/tester.tcl
|
||||
ifcapable !session {finish_test; return}
|
||||
|
||||
set testprefix changebatch1
|
||||
|
||||
|
||||
proc sql_to_changeset {method sql} {
|
||||
sqlite3session S db main
|
||||
S attach *
|
||||
execsql $sql
|
||||
set ret [S $method]
|
||||
S delete
|
||||
return $ret
|
||||
}
|
||||
|
||||
proc do_changebatch_test {tn method args} {
|
||||
set C [list]
|
||||
foreach a $args {
|
||||
lappend C [sql_to_changeset $method $a]
|
||||
}
|
||||
|
||||
sqlite3changebatch cb db
|
||||
set i 1
|
||||
foreach ::cs [lrange $C 0 end-1] {
|
||||
set rc [cb add $::cs]
|
||||
if {$rc!="SQLITE_OK"} { error "expected SQLITE_OK, got $rc (i=$i)" }
|
||||
incr i
|
||||
}
|
||||
|
||||
set ::cs [lindex $C end]
|
||||
do_test $tn { cb add [set ::cs] } SQLITE_CONSTRAINT
|
||||
cb delete
|
||||
}
|
||||
|
||||
proc do_changebatch_test1 {tn args} {
|
||||
uplevel do_changebatch_test $tn changeset $args
|
||||
}
|
||||
proc do_changebatch_test2 {tn args} {
|
||||
uplevel do_changebatch_test $tn fullchangeset $args
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# The body of the following loop contains tests for database schemas
|
||||
# that do not feature multi-column UNIQUE constraints. In this case
|
||||
# it doesn't matter if the changesets are generated using
|
||||
# sqlite3session_changeset() or sqlite3session_fullchangeset().
|
||||
#
|
||||
foreach {tn testfunction} {
|
||||
1 do_changebatch_test1
|
||||
2 do_changebatch_test2
|
||||
} {
|
||||
reset_db
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
do_execsql_test $tn.1.0 {
|
||||
CREATE TABLE t1(a PRIMARY KEY, b);
|
||||
}
|
||||
|
||||
$testfunction $tn.1.1 {
|
||||
INSERT INTO t1 VALUES(1, 1);
|
||||
} {
|
||||
DELETE FROM t1 WHERE a=1;
|
||||
}
|
||||
|
||||
do_execsql_test $tn.1.2.0 {
|
||||
INSERT INTO t1 VALUES(1, 1);
|
||||
INSERT INTO t1 VALUES(2, 2);
|
||||
INSERT INTO t1 VALUES(3, 3);
|
||||
}
|
||||
$testfunction $tn.1.2.1 {
|
||||
DELETE FROM t1 WHERE a=2;
|
||||
} {
|
||||
INSERT INTO t1 VALUES(2, 2);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
do_execsql_test $tn.2.0 {
|
||||
CREATE TABLE x1(a, b PRIMARY KEY, c UNIQUE);
|
||||
CREATE TABLE x2(a PRIMARY KEY, b UNIQUE, c UNIQUE);
|
||||
CREATE INDEX x1a ON x1(a);
|
||||
|
||||
INSERT INTO x1 VALUES(1, 1, 'a');
|
||||
INSERT INTO x1 VALUES(1, 2, 'b');
|
||||
INSERT INTO x1 VALUES(1, 3, 'c');
|
||||
}
|
||||
|
||||
$testfunction $tn.2.1 {
|
||||
DELETE FROM x1 WHERE b=2;
|
||||
} {
|
||||
UPDATE x1 SET c='b' WHERE b=3;
|
||||
}
|
||||
|
||||
$testfunction $tn.2.2 {
|
||||
DELETE FROM x1 WHERE b=1;
|
||||
} {
|
||||
INSERT INTO x1 VALUES(1, 5, 'a');
|
||||
}
|
||||
|
||||
set L [list]
|
||||
for {set i 1000} {$i < 10000} {incr i} {
|
||||
lappend L "INSERT INTO x2 VALUES($i, $i, 'x' || $i)"
|
||||
}
|
||||
lappend L "DELETE FROM x2 WHERE b=1005"
|
||||
$testfunction $tn.2.3 {*}$L
|
||||
|
||||
execsql { INSERT INTO x1 VALUES('f', 'f', 'f') }
|
||||
$testfunction $tn.2.4 {
|
||||
INSERT INTO x2 VALUES('f', 'f', 'f');
|
||||
} {
|
||||
INSERT INTO x1 VALUES('g', 'g', 'g');
|
||||
} {
|
||||
DELETE FROM x1 WHERE b='f';
|
||||
} {
|
||||
INSERT INTO x2 VALUES('g', 'g', 'g');
|
||||
} {
|
||||
INSERT INTO x1 VALUES('f', 'f', 'f');
|
||||
}
|
||||
|
||||
execsql {
|
||||
DELETE FROM x1;
|
||||
INSERT INTO x1 VALUES(1.5, 1.5, 1.5);
|
||||
}
|
||||
$testfunction $tn.2.5 {
|
||||
DELETE FROM x1 WHERE b BETWEEN 1 AND 2;
|
||||
} {
|
||||
INSERT INTO x1 VALUES(2.5, 2.5, 2.5);
|
||||
} {
|
||||
INSERT INTO x1 VALUES(1.5, 1.5, 1.5);
|
||||
}
|
||||
|
||||
execsql {
|
||||
DELETE FROM x2;
|
||||
INSERT INTO x2 VALUES(X'abcd', X'1234', X'7890');
|
||||
INSERT INTO x2 VALUES(X'0000', X'0000', X'0000');
|
||||
}
|
||||
breakpoint
|
||||
$testfunction $tn.2.6 {
|
||||
UPDATE x2 SET c = X'1234' WHERE a=X'abcd';
|
||||
INSERT INTO x2 VALUES(X'1234', X'abcd', X'7890');
|
||||
} {
|
||||
DELETE FROM x2 WHERE b=X'0000';
|
||||
} {
|
||||
INSERT INTO x2 VALUES(1, X'0000', NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test some multi-column UNIQUE constraints. First Using _changeset() to
|
||||
# demonstrate the problem, then using _fullchangeset() to show that it has
|
||||
# been fixed.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 3.0 {
|
||||
CREATE TABLE y1(a PRIMARY KEY, b, c, UNIQUE(b, c));
|
||||
INSERT INTO y1 VALUES(1, 1, 1);
|
||||
INSERT INTO y1 VALUES(2, 2, 2);
|
||||
INSERT INTO y1 VALUES(3, 3, 3);
|
||||
INSERT INTO y1 VALUES(4, 3, 4);
|
||||
BEGIN;
|
||||
}
|
||||
|
||||
do_test 3.1.1 {
|
||||
set c1 [sql_to_changeset changeset { DELETE FROM y1 WHERE a=4 }]
|
||||
set c2 [sql_to_changeset changeset { UPDATE y1 SET c=4 WHERE a=3 }]
|
||||
sqlite3changebatch cb db
|
||||
cb add $c1
|
||||
cb add $c2
|
||||
} {SQLITE_OK}
|
||||
do_test 3.1.2 {
|
||||
cb delete
|
||||
execsql ROLLBACK
|
||||
} {}
|
||||
|
||||
do_test 3.1.1 {
|
||||
set c1 [sql_to_changeset fullchangeset { DELETE FROM y1 WHERE a=4 }]
|
||||
set c2 [sql_to_changeset fullchangeset { UPDATE y1 SET c=4 WHERE a=3 }]
|
||||
sqlite3changebatch cb db
|
||||
cb add $c1
|
||||
cb add $c2
|
||||
} {SQLITE_CONSTRAINT}
|
||||
do_test 3.1.2 {
|
||||
cb delete
|
||||
} {}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 4.0 {
|
||||
CREATE TABLE t1(x, y, z, PRIMARY KEY(x, y), UNIQUE(z));
|
||||
}
|
||||
|
||||
do_test 4.1 {
|
||||
set c1 [sql_to_changeset fullchangeset { INSERT INTO t1 VALUES(1, 2, 3) }]
|
||||
execsql {
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(w, x, y, z, PRIMARY KEY(x, y), UNIQUE(z));
|
||||
}
|
||||
sqlite3changebatch cb db
|
||||
list [catch { cb add $c1 } msg] $msg
|
||||
} {1 SQLITE_RANGE}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
@@ -0,0 +1,42 @@
|
||||
# 2011 Mar 21
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# The focus of this file is testing the session module.
|
||||
#
|
||||
|
||||
if {![info exists testdir]} {
|
||||
set testdir [file join [file dirname [info script]] .. .. test]
|
||||
}
|
||||
source [file join [file dirname [info script]] session_common.tcl]
|
||||
source $testdir/tester.tcl
|
||||
ifcapable !session {finish_test; return}
|
||||
set testprefix changebatchfault
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(a, b, c PRIMARY KEY, UNIQUE(a, b));
|
||||
INSERT INTO t1 VALUES('a', 'a', 'a');
|
||||
INSERT INTO t1 VALUES('b', 'b', 'b');
|
||||
}
|
||||
|
||||
set ::c1 [changeset_from_sql { delete from t1 where c='a' }]
|
||||
set ::c2 [changeset_from_sql { insert into t1 values('c', 'c', 'c') }]
|
||||
|
||||
do_faultsim_test 1 -faults oom-* -body {
|
||||
sqlite3changebatch cb db
|
||||
cb add $::c1
|
||||
cb add $::c2
|
||||
} -test {
|
||||
faultsim_test_result {0 SQLITE_OK} {1 SQLITE_NOMEM}
|
||||
catch { cb delete }
|
||||
}
|
||||
|
||||
|
||||
finish_test
|
||||
@@ -29,7 +29,7 @@ do_test 1.0 {
|
||||
WITH s(i) AS (
|
||||
VALUES(1) UNION ALL SELECT i+1 FROM s WHERe i<10000
|
||||
)
|
||||
INSERT INTO t1 SELECT 'abcde', randomblob(16), i FROM s;
|
||||
INSERT INTO t1 SELECT 'abcde', randomblob(18), i FROM s;
|
||||
}
|
||||
compare_db db db2
|
||||
} {}
|
||||
|
||||
@@ -0,0 +1,485 @@
|
||||
|
||||
#if !defined(SQLITE_TEST) || (defined(SQLITE_ENABLE_SESSION) && defined(SQLITE_ENABLE_PREUPDATE_HOOK))
|
||||
|
||||
#include "sqlite3session.h"
|
||||
#include "sqlite3changebatch.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct BatchTable BatchTable;
|
||||
typedef struct BatchIndex BatchIndex;
|
||||
typedef struct BatchIndexEntry BatchIndexEntry;
|
||||
typedef struct BatchHash BatchHash;
|
||||
|
||||
struct sqlite3_changebatch {
|
||||
sqlite3 *db; /* Database handle used to read schema */
|
||||
BatchTable *pTab; /* First in linked list of tables */
|
||||
int iChangesetId; /* Current changeset id */
|
||||
int iNextIdxId; /* Next available index id */
|
||||
int nEntry; /* Number of entries in hash table */
|
||||
int nHash; /* Number of hash buckets */
|
||||
BatchIndexEntry **apHash; /* Array of hash buckets */
|
||||
};
|
||||
|
||||
struct BatchTable {
|
||||
BatchIndex *pIdx; /* First in linked list of UNIQUE indexes */
|
||||
BatchTable *pNext; /* Next table */
|
||||
char zTab[1]; /* Table name */
|
||||
};
|
||||
|
||||
struct BatchIndex {
|
||||
BatchIndex *pNext; /* Next index on same table */
|
||||
int iId; /* Index id (assigned internally) */
|
||||
int bPk; /* True for PK index */
|
||||
int nCol; /* Size of aiCol[] array */
|
||||
int *aiCol; /* Array of columns that make up index */
|
||||
};
|
||||
|
||||
struct BatchIndexEntry {
|
||||
BatchIndexEntry *pNext; /* Next colliding hash table entry */
|
||||
int iChangesetId; /* Id of associated changeset */
|
||||
int iIdxId; /* Id of index this key is from */
|
||||
int szRecord;
|
||||
char aRecord[1];
|
||||
};
|
||||
|
||||
/*
|
||||
** Allocate and zero a block of nByte bytes. Must be freed using cbFree().
|
||||
*/
|
||||
static void *cbMalloc(int *pRc, int nByte){
|
||||
void *pRet;
|
||||
|
||||
if( *pRc ){
|
||||
pRet = 0;
|
||||
}else{
|
||||
pRet = sqlite3_malloc(nByte);
|
||||
if( pRet ){
|
||||
memset(pRet, 0, nByte);
|
||||
}else{
|
||||
*pRc = SQLITE_NOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
/*
|
||||
** Free an allocation made by cbMalloc().
|
||||
*/
|
||||
static void cbFree(void *p){
|
||||
sqlite3_free(p);
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the hash bucket that pEntry belongs in.
|
||||
*/
|
||||
static int cbHash(sqlite3_changebatch *p, BatchIndexEntry *pEntry){
|
||||
unsigned int iHash = (unsigned int)pEntry->iIdxId;
|
||||
unsigned char *pEnd = (unsigned char*)&pEntry->aRecord[pEntry->szRecord];
|
||||
unsigned char *pIter;
|
||||
|
||||
for(pIter=(unsigned char*)pEntry->aRecord; pIter<pEnd; pIter++){
|
||||
iHash += (iHash << 7) + *pIter;
|
||||
}
|
||||
|
||||
return (int)(iHash % p->nHash);
|
||||
}
|
||||
|
||||
/*
|
||||
** Resize the hash table.
|
||||
*/
|
||||
static int cbHashResize(sqlite3_changebatch *p){
|
||||
int rc = SQLITE_OK;
|
||||
BatchIndexEntry **apNew;
|
||||
int nNew = (p->nHash ? p->nHash*2 : 512);
|
||||
int i;
|
||||
|
||||
apNew = cbMalloc(&rc, sizeof(BatchIndexEntry*) * nNew);
|
||||
if( rc==SQLITE_OK ){
|
||||
int nHash = p->nHash;
|
||||
p->nHash = nNew;
|
||||
for(i=0; i<nHash; i++){
|
||||
BatchIndexEntry *pEntry;
|
||||
while( (pEntry=p->apHash[i])!=0 ){
|
||||
int iHash = cbHash(p, pEntry);
|
||||
p->apHash[i] = pEntry->pNext;
|
||||
pEntry->pNext = apNew[iHash];
|
||||
apNew[iHash] = pEntry;
|
||||
}
|
||||
}
|
||||
|
||||
cbFree(p->apHash);
|
||||
p->apHash = apNew;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Allocate a new sqlite3_changebatch object.
|
||||
*/
|
||||
int sqlite3changebatch_new(sqlite3 *db, sqlite3_changebatch **pp){
|
||||
sqlite3_changebatch *pRet;
|
||||
int rc = SQLITE_OK;
|
||||
*pp = pRet = (sqlite3_changebatch*)cbMalloc(&rc, sizeof(sqlite3_changebatch));
|
||||
if( pRet ){
|
||||
pRet->db = db;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Add a BatchIndex entry for index zIdx to table pTab.
|
||||
*/
|
||||
static int cbAddIndex(
|
||||
sqlite3_changebatch *p,
|
||||
BatchTable *pTab,
|
||||
const char *zIdx,
|
||||
int bPk
|
||||
){
|
||||
int nCol = 0;
|
||||
sqlite3_stmt *pIndexInfo = 0;
|
||||
BatchIndex *pNew = 0;
|
||||
int rc;
|
||||
char *zIndexInfo;
|
||||
|
||||
zIndexInfo = (char*)sqlite3_mprintf("PRAGMA main.index_info = %Q", zIdx);
|
||||
if( zIndexInfo ){
|
||||
rc = sqlite3_prepare_v2(p->db, zIndexInfo, -1, &pIndexInfo, 0);
|
||||
sqlite3_free(zIndexInfo);
|
||||
}else{
|
||||
rc = SQLITE_NOMEM;
|
||||
}
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
while( SQLITE_ROW==sqlite3_step(pIndexInfo) ){ nCol++; }
|
||||
rc = sqlite3_reset(pIndexInfo);
|
||||
}
|
||||
|
||||
pNew = (BatchIndex*)cbMalloc(&rc, sizeof(BatchIndex) + sizeof(int) * nCol);
|
||||
if( rc==SQLITE_OK ){
|
||||
pNew->nCol = nCol;
|
||||
pNew->bPk = bPk;
|
||||
pNew->aiCol = (int*)&pNew[1];
|
||||
pNew->iId = p->iNextIdxId++;
|
||||
while( SQLITE_ROW==sqlite3_step(pIndexInfo) ){
|
||||
int i = sqlite3_column_int(pIndexInfo, 0);
|
||||
int j = sqlite3_column_int(pIndexInfo, 1);
|
||||
pNew->aiCol[i] = j;
|
||||
}
|
||||
rc = sqlite3_reset(pIndexInfo);
|
||||
}
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
pNew->pNext = pTab->pIdx;
|
||||
pTab->pIdx = pNew;
|
||||
}else{
|
||||
cbFree(pNew);
|
||||
}
|
||||
sqlite3_finalize(pIndexInfo);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Free the object passed as the first argument.
|
||||
*/
|
||||
static void cbFreeTable(BatchTable *pTab){
|
||||
BatchIndex *pIdx;
|
||||
BatchIndex *pIdxNext;
|
||||
for(pIdx=pTab->pIdx; pIdx; pIdx=pIdxNext){
|
||||
pIdxNext = pIdx->pNext;
|
||||
cbFree(pIdx);
|
||||
}
|
||||
cbFree(pTab);
|
||||
}
|
||||
|
||||
/*
|
||||
** Find or create the BatchTable object named zTab.
|
||||
*/
|
||||
static int cbFindTable(
|
||||
sqlite3_changebatch *p,
|
||||
const char *zTab,
|
||||
BatchTable **ppTab
|
||||
){
|
||||
BatchTable *pRet = 0;
|
||||
int rc = SQLITE_OK;
|
||||
|
||||
for(pRet=p->pTab; pRet; pRet=pRet->pNext){
|
||||
if( 0==sqlite3_stricmp(zTab, pRet->zTab) ) break;
|
||||
}
|
||||
|
||||
if( pRet==0 ){
|
||||
int nTab = strlen(zTab);
|
||||
pRet = (BatchTable*)cbMalloc(&rc, nTab + sizeof(BatchTable));
|
||||
if( pRet ){
|
||||
sqlite3_stmt *pIndexList = 0;
|
||||
char *zIndexList = 0;
|
||||
int rc2;
|
||||
memcpy(pRet->zTab, zTab, nTab);
|
||||
|
||||
zIndexList = sqlite3_mprintf("PRAGMA main.index_list = %Q", zTab);
|
||||
if( zIndexList==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
}else{
|
||||
rc = sqlite3_prepare_v2(p->db, zIndexList, -1, &pIndexList, 0);
|
||||
sqlite3_free(zIndexList);
|
||||
}
|
||||
|
||||
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pIndexList) ){
|
||||
if( sqlite3_column_int(pIndexList, 2) ){
|
||||
const char *zIdx = (const char*)sqlite3_column_text(pIndexList, 1);
|
||||
const char *zTyp = (const char*)sqlite3_column_text(pIndexList, 3);
|
||||
rc = cbAddIndex(p, pRet, zIdx, (zTyp[0]=='p'));
|
||||
}
|
||||
}
|
||||
rc2 = sqlite3_finalize(pIndexList);
|
||||
if( rc==SQLITE_OK ) rc = rc2;
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
pRet->pNext = p->pTab;
|
||||
p->pTab = pRet;
|
||||
}else{
|
||||
cbFreeTable(pRet);
|
||||
pRet = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*ppTab = pRet;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Extract value iVal from the changeset iterator passed as the first
|
||||
** argument. Set *ppVal to point to the value before returning.
|
||||
**
|
||||
** This function attempts to extract the value using function xVal
|
||||
** (which is always either sqlite3changeset_new or sqlite3changeset_old).
|
||||
** If the call returns SQLITE_OK but does not supply an sqlite3_value*
|
||||
** pointer, an attempt to extract the value is made using the xFallback
|
||||
** function.
|
||||
*/
|
||||
static int cbGetChangesetValue(
|
||||
sqlite3_changeset_iter *pIter,
|
||||
int (*xVal)(sqlite3_changeset_iter*,int,sqlite3_value**),
|
||||
int (*xFallback)(sqlite3_changeset_iter*,int,sqlite3_value**),
|
||||
int iVal,
|
||||
sqlite3_value **ppVal
|
||||
){
|
||||
int rc = xVal(pIter, iVal, ppVal);
|
||||
if( rc==SQLITE_OK && *ppVal==0 && xFallback ){
|
||||
rc = xFallback(pIter, iVal, ppVal);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int cbAddToHash(
|
||||
sqlite3_changebatch *p,
|
||||
sqlite3_changeset_iter *pIter,
|
||||
BatchIndex *pIdx,
|
||||
int (*xVal)(sqlite3_changeset_iter*,int,sqlite3_value**),
|
||||
int (*xFallback)(sqlite3_changeset_iter*,int,sqlite3_value**),
|
||||
int *pbConf
|
||||
){
|
||||
BatchIndexEntry *pNew;
|
||||
int sz = pIdx->nCol;
|
||||
int i;
|
||||
int iOut = 0;
|
||||
int rc = SQLITE_OK;
|
||||
|
||||
for(i=0; rc==SQLITE_OK && i<pIdx->nCol; i++){
|
||||
sqlite3_value *pVal;
|
||||
rc = cbGetChangesetValue(pIter, xVal, xFallback, pIdx->aiCol[i], &pVal);
|
||||
if( rc==SQLITE_OK ){
|
||||
int eType = 0;
|
||||
if( pVal ) eType = sqlite3_value_type(pVal);
|
||||
switch( eType ){
|
||||
case 0:
|
||||
case SQLITE_NULL:
|
||||
return SQLITE_OK;
|
||||
|
||||
case SQLITE_INTEGER:
|
||||
sz += 8;
|
||||
break;
|
||||
case SQLITE_FLOAT:
|
||||
sz += 8;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB );
|
||||
sz += sqlite3_value_bytes(pVal);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pNew = cbMalloc(&rc, sizeof(BatchIndexEntry) + sz);
|
||||
if( pNew ){
|
||||
pNew->iChangesetId = p->iChangesetId;
|
||||
pNew->iIdxId = pIdx->iId;
|
||||
pNew->szRecord = sz;
|
||||
|
||||
for(i=0; i<pIdx->nCol; i++){
|
||||
int eType;
|
||||
sqlite3_value *pVal;
|
||||
rc = cbGetChangesetValue(pIter, xVal, xFallback, pIdx->aiCol[i], &pVal);
|
||||
if( rc!=SQLITE_OK ) break; /* coverage: condition is never true */
|
||||
eType = sqlite3_value_type(pVal);
|
||||
pNew->aRecord[iOut++] = eType;
|
||||
switch( eType ){
|
||||
case SQLITE_INTEGER: {
|
||||
sqlite3_int64 i64 = sqlite3_value_int64(pVal);
|
||||
memcpy(&pNew->aRecord[iOut], &i64, 8);
|
||||
iOut += 8;
|
||||
break;
|
||||
}
|
||||
case SQLITE_FLOAT: {
|
||||
double d64 = sqlite3_value_double(pVal);
|
||||
memcpy(&pNew->aRecord[iOut], &d64, sizeof(double));
|
||||
iOut += sizeof(double);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
int nByte = sqlite3_value_bytes(pVal);
|
||||
const char *z = (const char*)sqlite3_value_blob(pVal);
|
||||
memcpy(&pNew->aRecord[iOut], z, nByte);
|
||||
iOut += nByte;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( rc==SQLITE_OK && p->nEntry>=(p->nHash/2) ){
|
||||
rc = cbHashResize(p);
|
||||
}
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
BatchIndexEntry *pIter;
|
||||
int iHash = cbHash(p, pNew);
|
||||
|
||||
assert( iHash>=0 && iHash<p->nHash );
|
||||
for(pIter=p->apHash[iHash]; pIter; pIter=pIter->pNext){
|
||||
if( pNew->szRecord==pIter->szRecord
|
||||
&& 0==memcmp(pNew->aRecord, pIter->aRecord, pNew->szRecord)
|
||||
){
|
||||
if( pNew->iChangesetId!=pIter->iChangesetId ){
|
||||
*pbConf = 1;
|
||||
}
|
||||
cbFree(pNew);
|
||||
pNew = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( pNew ){
|
||||
pNew->pNext = p->apHash[iHash];
|
||||
p->apHash[iHash] = pNew;
|
||||
p->nEntry++;
|
||||
}
|
||||
}else{
|
||||
cbFree(pNew);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Add a changeset to the current batch.
|
||||
*/
|
||||
int sqlite3changebatch_add(sqlite3_changebatch *p, void *pBuf, int nBuf){
|
||||
sqlite3_changeset_iter *pIter; /* Iterator opened on pBuf/nBuf */
|
||||
int rc; /* Return code */
|
||||
int bConf = 0; /* Conflict was detected */
|
||||
|
||||
rc = sqlite3changeset_start(&pIter, nBuf, pBuf);
|
||||
if( rc==SQLITE_OK ){
|
||||
int rc2;
|
||||
for(rc2 = sqlite3changeset_next(pIter);
|
||||
rc2==SQLITE_ROW;
|
||||
rc2 = sqlite3changeset_next(pIter)
|
||||
){
|
||||
BatchTable *pTab;
|
||||
BatchIndex *pIdx;
|
||||
const char *zTab; /* Table this change applies to */
|
||||
int nCol; /* Number of columns in table */
|
||||
int op; /* UPDATE, INSERT or DELETE */
|
||||
|
||||
sqlite3changeset_op(pIter, &zTab, &nCol, &op, 0);
|
||||
assert( op==SQLITE_INSERT || op==SQLITE_UPDATE || op==SQLITE_DELETE );
|
||||
|
||||
rc = cbFindTable(p, zTab, &pTab);
|
||||
assert( pTab || rc!=SQLITE_OK );
|
||||
if( pTab ){
|
||||
for(pIdx=pTab->pIdx; pIdx && rc==SQLITE_OK; pIdx=pIdx->pNext){
|
||||
if( op==SQLITE_UPDATE && pIdx->bPk ) continue;
|
||||
if( op==SQLITE_UPDATE || op==SQLITE_DELETE ){
|
||||
rc = cbAddToHash(p, pIter, pIdx, sqlite3changeset_old, 0, &bConf);
|
||||
}
|
||||
if( op==SQLITE_UPDATE || op==SQLITE_INSERT ){
|
||||
rc = cbAddToHash(p, pIter, pIdx,
|
||||
sqlite3changeset_new, sqlite3changeset_old, &bConf
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if( rc!=SQLITE_OK ) break;
|
||||
}
|
||||
|
||||
rc2 = sqlite3changeset_finalize(pIter);
|
||||
if( rc==SQLITE_OK ) rc = rc2;
|
||||
}
|
||||
|
||||
if( rc==SQLITE_OK && bConf ){
|
||||
rc = SQLITE_CONSTRAINT;
|
||||
}
|
||||
p->iChangesetId++;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Zero an existing changebatch object.
|
||||
*/
|
||||
void sqlite3changebatch_zero(sqlite3_changebatch *p){
|
||||
int i;
|
||||
for(i=0; i<p->nHash; i++){
|
||||
BatchIndexEntry *pEntry;
|
||||
BatchIndexEntry *pNext;
|
||||
for(pEntry=p->apHash[i]; pEntry; pEntry=pNext){
|
||||
pNext = pEntry->pNext;
|
||||
cbFree(pEntry);
|
||||
}
|
||||
}
|
||||
cbFree(p->apHash);
|
||||
p->nHash = 0;
|
||||
p->apHash = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Delete a changebatch object.
|
||||
*/
|
||||
void sqlite3changebatch_delete(sqlite3_changebatch *p){
|
||||
BatchTable *pTab;
|
||||
BatchTable *pTabNext;
|
||||
|
||||
sqlite3changebatch_zero(p);
|
||||
for(pTab=p->pTab; pTab; pTab=pTabNext){
|
||||
pTabNext = pTab->pNext;
|
||||
cbFreeTable(pTab);
|
||||
}
|
||||
cbFree(p);
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the db handle.
|
||||
*/
|
||||
sqlite3 *sqlite3changebatch_db(sqlite3_changebatch *p){
|
||||
return p->db;
|
||||
}
|
||||
|
||||
#endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */
|
||||
@@ -0,0 +1,82 @@
|
||||
|
||||
#if !defined(SQLITECHANGEBATCH_H_)
|
||||
#define SQLITECHANGEBATCH_H_ 1
|
||||
|
||||
typedef struct sqlite3_changebatch sqlite3_changebatch;
|
||||
|
||||
/*
|
||||
** Create a new changebatch object for detecting conflicts between
|
||||
** changesets associated with a schema equivalent to that of the "main"
|
||||
** database of the open database handle db passed as the first
|
||||
** parameter. It is the responsibility of the caller to ensure that
|
||||
** the database handle is not closed until after the changebatch
|
||||
** object has been deleted.
|
||||
**
|
||||
** A changebatch object is used to detect batches of non-conflicting
|
||||
** changesets. Changesets that do not conflict may be applied to the
|
||||
** target database in any order without affecting the final state of
|
||||
** the database.
|
||||
**
|
||||
** The changebatch object only works reliably if PRIMARY KEY and UNIQUE
|
||||
** constraints on tables affected by the changesets use collation
|
||||
** sequences that are equivalent to built-in collation sequence
|
||||
** BINARY for the == operation.
|
||||
**
|
||||
** If successful, SQLITE_OK is returned and (*pp) set to point to
|
||||
** the new changebatch object. If an error occurs, an SQLite error
|
||||
** code is returned and the final value of (*pp) is undefined.
|
||||
*/
|
||||
int sqlite3changebatch_new(sqlite3 *db, sqlite3_changebatch **pp);
|
||||
|
||||
/*
|
||||
** Argument p points to a buffer containing a changeset n bytes in
|
||||
** size. Assuming no error occurs, this function returns SQLITE_OK
|
||||
** if the changeset does not conflict with any changeset passed
|
||||
** to an sqlite3changebatch_add() call made on the same
|
||||
** sqlite3_changebatch* handle since the most recent call to
|
||||
** sqlite3changebatch_zero(). If the changeset does conflict with
|
||||
** an earlier such changeset, SQLITE_CONSTRAINT is returned. Or,
|
||||
** if an error occurs, some other SQLite error code may be returned.
|
||||
**
|
||||
** One changeset is said to conflict with another if
|
||||
** either:
|
||||
**
|
||||
** * the two changesets contain operations (INSERT, UPDATE or
|
||||
** DELETE) on the same row, identified by primary key, or
|
||||
**
|
||||
** * the two changesets contain operations (INSERT, UPDATE or
|
||||
** DELETE) on rows with identical values in any combination
|
||||
** of fields constrained by a UNIQUE constraint.
|
||||
**
|
||||
** Even if this function returns SQLITE_CONFLICT, the current
|
||||
** changeset is added to the internal data structures - so future
|
||||
** calls to this function may conflict with it. If this function
|
||||
** returns any result code other than SQLITE_OK or SQLITE_CONFLICT,
|
||||
** the result of any future call to sqlite3changebatch_add() is
|
||||
** undefined.
|
||||
**
|
||||
** Only changesets may be passed to this function. Passing a
|
||||
** patchset to this function results in an SQLITE_MISUSE error.
|
||||
*/
|
||||
int sqlite3changebatch_add(sqlite3_changebatch*, void *p, int n);
|
||||
|
||||
/*
|
||||
** Zero a changebatch object. This causes the records of all earlier
|
||||
** calls to sqlite3changebatch_add() to be discarded.
|
||||
*/
|
||||
void sqlite3changebatch_zero(sqlite3_changebatch*);
|
||||
|
||||
/*
|
||||
** Return a copy of the first argument passed to the sqlite3changebatch_new()
|
||||
** call used to create the changebatch object passed as the only argument
|
||||
** to this function.
|
||||
*/
|
||||
sqlite3 *sqlite3changebatch_db(sqlite3_changebatch*);
|
||||
|
||||
/*
|
||||
** Delete a changebatch object.
|
||||
*/
|
||||
void sqlite3changebatch_delete(sqlite3_changebatch*);
|
||||
|
||||
#endif /* !defined(SQLITECHANGEBATCH_H_) */
|
||||
|
||||
@@ -25,6 +25,13 @@ typedef struct SessionInput SessionInput;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The three different types of changesets generated.
|
||||
*/
|
||||
#define SESSIONS_PATCHSET 0
|
||||
#define SESSIONS_CHANGESET 1
|
||||
#define SESSIONS_FULLCHANGESET 2
|
||||
|
||||
static int sessions_strm_chunk_size = SESSIONS_STRM_CHUNK_SIZE;
|
||||
|
||||
typedef struct SessionHook SessionHook;
|
||||
@@ -2233,7 +2240,7 @@ static void sessionAppendCol(
|
||||
*/
|
||||
static int sessionAppendUpdate(
|
||||
SessionBuffer *pBuf, /* Buffer to append to */
|
||||
int bPatchset, /* True for "patchset", 0 for "changeset" */
|
||||
int ePatchset, /* True for "patchset", 0 for "changeset" */
|
||||
sqlite3_stmt *pStmt, /* Statement handle pointing at new row */
|
||||
SessionChange *p, /* Object containing old values */
|
||||
u8 *abPK /* Boolean array - true for PK columns */
|
||||
@@ -2297,8 +2304,8 @@ static int sessionAppendUpdate(
|
||||
|
||||
/* Add a field to the old.* record. This is omitted if this modules is
|
||||
** currently generating a patchset. */
|
||||
if( bPatchset==0 ){
|
||||
if( bChanged || abPK[i] ){
|
||||
if( ePatchset!=SESSIONS_PATCHSET ){
|
||||
if( ePatchset==SESSIONS_FULLCHANGESET || bChanged || abPK[i] ){
|
||||
sessionAppendBlob(pBuf, pCsr, nAdvance, &rc);
|
||||
}else{
|
||||
sessionAppendByte(pBuf, 0, &rc);
|
||||
@@ -2307,7 +2314,7 @@ static int sessionAppendUpdate(
|
||||
|
||||
/* Add a field to the new.* record. Or the only record if currently
|
||||
** generating a patchset. */
|
||||
if( bChanged || (bPatchset && abPK[i]) ){
|
||||
if( bChanged || (ePatchset==SESSIONS_PATCHSET && abPK[i]) ){
|
||||
sessionAppendCol(&buf2, pStmt, i, &rc);
|
||||
}else{
|
||||
sessionAppendByte(&buf2, 0, &rc);
|
||||
@@ -2333,7 +2340,7 @@ static int sessionAppendUpdate(
|
||||
*/
|
||||
static int sessionAppendDelete(
|
||||
SessionBuffer *pBuf, /* Buffer to append to */
|
||||
int bPatchset, /* True for "patchset", 0 for "changeset" */
|
||||
int eChangeset, /* One of SESSIONS_CHANGESET etc. */
|
||||
SessionChange *p, /* Object containing old values */
|
||||
int nCol, /* Number of columns in table */
|
||||
u8 *abPK /* Boolean array - true for PK columns */
|
||||
@@ -2343,7 +2350,7 @@ static int sessionAppendDelete(
|
||||
sessionAppendByte(pBuf, SQLITE_DELETE, &rc);
|
||||
sessionAppendByte(pBuf, p->bIndirect, &rc);
|
||||
|
||||
if( bPatchset==0 ){
|
||||
if( eChangeset!=SESSIONS_PATCHSET ){
|
||||
sessionAppendBlob(pBuf, p->aRecord, p->nRecord, &rc);
|
||||
}else{
|
||||
int i;
|
||||
@@ -2516,12 +2523,12 @@ static int sessionSelectBind(
|
||||
*/
|
||||
static void sessionAppendTableHdr(
|
||||
SessionBuffer *pBuf, /* Append header to this buffer */
|
||||
int bPatchset, /* Use the patchset format if true */
|
||||
int ePatchset, /* Use the patchset format if true */
|
||||
SessionTable *pTab, /* Table object to append header for */
|
||||
int *pRc /* IN/OUT: Error code */
|
||||
){
|
||||
/* Write a table header */
|
||||
sessionAppendByte(pBuf, (bPatchset ? 'P' : 'T'), pRc);
|
||||
sessionAppendByte(pBuf, (ePatchset==SESSIONS_PATCHSET) ? 'P' : 'T', pRc);
|
||||
sessionAppendVarint(pBuf, pTab->nCol, pRc);
|
||||
sessionAppendBlob(pBuf, pTab->abPK, pTab->nCol, pRc);
|
||||
sessionAppendBlob(pBuf, (u8 *)pTab->zName, (int)strlen(pTab->zName)+1, pRc);
|
||||
@@ -2539,7 +2546,7 @@ static void sessionAppendTableHdr(
|
||||
*/
|
||||
static int sessionGenerateChangeset(
|
||||
sqlite3_session *pSession, /* Session object */
|
||||
int bPatchset, /* True for patchset, false for changeset */
|
||||
int ePatchset, /* One of SESSIONS_CHANGESET etc. */
|
||||
int (*xOutput)(void *pOut, const void *pData, int nData),
|
||||
void *pOut, /* First argument for xOutput */
|
||||
int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
|
||||
@@ -2586,7 +2593,7 @@ static int sessionGenerateChangeset(
|
||||
}
|
||||
|
||||
/* Write a table header */
|
||||
sessionAppendTableHdr(&buf, bPatchset, pTab, &rc);
|
||||
sessionAppendTableHdr(&buf, ePatchset, pTab, &rc);
|
||||
|
||||
/* Build and compile a statement to execute: */
|
||||
if( rc==SQLITE_OK ){
|
||||
@@ -2611,10 +2618,10 @@ static int sessionGenerateChangeset(
|
||||
}
|
||||
}else{
|
||||
assert( abPK!=0 ); /* Because sessionSelectStmt() returned ok */
|
||||
rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK);
|
||||
rc = sessionAppendUpdate(&buf, ePatchset, pSel, p, abPK);
|
||||
}
|
||||
}else if( p->op!=SQLITE_INSERT ){
|
||||
rc = sessionAppendDelete(&buf, bPatchset, p, nCol, abPK);
|
||||
rc = sessionAppendDelete(&buf, ePatchset, p, nCol, abPK);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_reset(pSel);
|
||||
@@ -2674,7 +2681,8 @@ int sqlite3session_changeset(
|
||||
int rc;
|
||||
|
||||
if( pnChangeset==0 || ppChangeset==0 ) return SQLITE_MISUSE;
|
||||
rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset);
|
||||
rc = sessionGenerateChangeset(
|
||||
pSession, SESSIONS_CHANGESET, 0, 0, pnChangeset, ppChangeset);
|
||||
assert( rc || pnChangeset==0
|
||||
|| pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize
|
||||
);
|
||||
@@ -2690,7 +2698,8 @@ int sqlite3session_changeset_strm(
|
||||
void *pOut
|
||||
){
|
||||
if( xOutput==0 ) return SQLITE_MISUSE;
|
||||
return sessionGenerateChangeset(pSession, 0, xOutput, pOut, 0, 0);
|
||||
return sessionGenerateChangeset(
|
||||
pSession, SESSIONS_CHANGESET, xOutput, pOut, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2702,7 +2711,8 @@ int sqlite3session_patchset_strm(
|
||||
void *pOut
|
||||
){
|
||||
if( xOutput==0 ) return SQLITE_MISUSE;
|
||||
return sessionGenerateChangeset(pSession, 1, xOutput, pOut, 0, 0);
|
||||
return sessionGenerateChangeset(
|
||||
pSession, SESSIONS_PATCHSET, xOutput, pOut, 0, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2718,9 +2728,20 @@ int sqlite3session_patchset(
|
||||
void **ppPatchset /* OUT: Buffer containing changeset */
|
||||
){
|
||||
if( pnPatchset==0 || ppPatchset==0 ) return SQLITE_MISUSE;
|
||||
return sessionGenerateChangeset(pSession, 1, 0, 0, pnPatchset, ppPatchset);
|
||||
return sessionGenerateChangeset(
|
||||
pSession, SESSIONS_PATCHSET, 0, 0, pnPatchset, ppPatchset);
|
||||
}
|
||||
|
||||
int sqlite3session_fullchangeset(
|
||||
sqlite3_session *pSession, /* Session object */
|
||||
int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
|
||||
void **ppChangeset /* OUT: Buffer containing changeset */
|
||||
){
|
||||
return sessionGenerateChangeset(
|
||||
pSession, SESSIONS_FULLCHANGESET, 0, 0, pnChangeset, ppChangeset);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Enable or disable the session object passed as the first argument.
|
||||
*/
|
||||
@@ -5263,10 +5284,11 @@ static int sessionChangegroupOutput(
|
||||
** hash tables attached to the SessionTable objects in list p->pList.
|
||||
*/
|
||||
for(pTab=pGrp->pList; rc==SQLITE_OK && pTab; pTab=pTab->pNext){
|
||||
int eChangeset = pGrp->bPatch ? SESSIONS_PATCHSET : SESSIONS_CHANGESET;
|
||||
int i;
|
||||
if( pTab->nEntry==0 ) continue;
|
||||
|
||||
sessionAppendTableHdr(&buf, pGrp->bPatch, pTab, &rc);
|
||||
sessionAppendTableHdr(&buf, eChangeset, pTab, &rc);
|
||||
for(i=0; i<pTab->nChange; i++){
|
||||
SessionChange *p;
|
||||
for(p=pTab->apChange[i]; p; p=p->pNext){
|
||||
|
||||
@@ -355,6 +355,19 @@ int sqlite3session_changeset(
|
||||
void **ppChangeset /* OUT: Buffer containing changeset */
|
||||
);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Generate A Full Changeset From A Session Object
|
||||
**
|
||||
** This function is similar to sqlite3session_changeset(), except that for
|
||||
** each row affected by an UPDATE statement, all old.* values are recorded
|
||||
** as part of the changeset, not just those modified.
|
||||
*/
|
||||
int sqlite3session_fullchangeset(
|
||||
sqlite3_session *pSession, /* Session object */
|
||||
int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
|
||||
void **ppChangeset /* OUT: Buffer containing changeset */
|
||||
);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Return An Upper-limit For The Size Of The Changeset
|
||||
** METHOD: sqlite3_session
|
||||
|
||||
+147
-17
@@ -221,6 +221,7 @@ static int testStreamOutput(
|
||||
** $session indirect INTEGER
|
||||
** $session patchset
|
||||
** $session table_filter SCRIPT
|
||||
** $session fullchangeset
|
||||
*/
|
||||
static int SQLITE_TCLAPI test_session_cmd(
|
||||
void *clientData,
|
||||
@@ -234,20 +235,20 @@ static int SQLITE_TCLAPI test_session_cmd(
|
||||
const char *zSub;
|
||||
int nArg;
|
||||
const char *zMsg;
|
||||
int iSub;
|
||||
} aSub[] = {
|
||||
{ "attach", 1, "TABLE", }, /* 0 */
|
||||
{ "changeset", 0, "", }, /* 1 */
|
||||
{ "delete", 0, "", }, /* 2 */
|
||||
{ "enable", 1, "BOOL", }, /* 3 */
|
||||
{ "indirect", 1, "BOOL", }, /* 4 */
|
||||
{ "isempty", 0, "", }, /* 5 */
|
||||
{ "table_filter", 1, "SCRIPT", }, /* 6 */
|
||||
{ "attach", 1, "TABLE" }, /* 0 */
|
||||
{ "changeset", 0, "" }, /* 1 */
|
||||
{ "delete", 0, "" }, /* 2 */
|
||||
{ "enable", 1, "BOOL" }, /* 3 */
|
||||
{ "indirect", 1, "BOOL" }, /* 4 */
|
||||
{ "isempty", 0, "" }, /* 5 */
|
||||
{ "table_filter", 1, "SCRIPT" }, /* 6 */
|
||||
{ "patchset", 0, "", }, /* 7 */
|
||||
{ "diff", 2, "FROMDB TBL", }, /* 8 */
|
||||
{ "memory_used", 0, "", }, /* 9 */
|
||||
{ "changeset_size", 0, "", }, /* 10 */
|
||||
{ "object_config_size", 1, "INTEGER", }, /* 11 */
|
||||
{ "diff", 2, "FROMDB TBL" }, /* 8 */
|
||||
{ "fullchangeset",0, "" }, /* 9 */
|
||||
{ "memory_used", 0, "", }, /* 10 */
|
||||
{ "changeset_size", 0, "", }, /* 11 */
|
||||
{ "object_config_size", 1, "INTEGER", }, /* 12 */
|
||||
{ 0 }
|
||||
};
|
||||
int iSub;
|
||||
@@ -277,10 +278,11 @@ static int SQLITE_TCLAPI test_session_cmd(
|
||||
break;
|
||||
}
|
||||
|
||||
case 9: /* fullchangeset */
|
||||
case 7: /* patchset */
|
||||
case 1: { /* changeset */
|
||||
TestSessionsBlob o = {0, 0};
|
||||
if( test_tcl_integer(interp, SESSION_STREAM_TCL_VAR) ){
|
||||
if( iSub!=9 && test_tcl_integer(interp, SESSION_STREAM_TCL_VAR) ){
|
||||
void *pCtx = (void*)&o;
|
||||
if( iSub==7 ){
|
||||
rc = sqlite3session_patchset_strm(pSession, testStreamOutput, pCtx);
|
||||
@@ -290,6 +292,8 @@ static int SQLITE_TCLAPI test_session_cmd(
|
||||
}else{
|
||||
if( iSub==7 ){
|
||||
rc = sqlite3session_patchset(pSession, &o.n, &o.p);
|
||||
}else if( iSub==9 ){
|
||||
rc = sqlite3session_fullchangeset(pSession, &o.n, &o.p);
|
||||
}else{
|
||||
rc = sqlite3session_changeset(pSession, &o.n, &o.p);
|
||||
}
|
||||
@@ -304,6 +308,7 @@ static int SQLITE_TCLAPI test_session_cmd(
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 2: /* delete */
|
||||
Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));
|
||||
break;
|
||||
@@ -354,18 +359,18 @@ static int SQLITE_TCLAPI test_session_cmd(
|
||||
break;
|
||||
}
|
||||
|
||||
case 9: { /* memory_used */
|
||||
case 10: { /* memory_used */
|
||||
sqlite3_int64 nMalloc = sqlite3session_memory_used(pSession);
|
||||
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(nMalloc));
|
||||
break;
|
||||
}
|
||||
|
||||
case 10: {
|
||||
case 11: {
|
||||
sqlite3_int64 nSize = sqlite3session_changeset_size(pSession);
|
||||
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(nSize));
|
||||
break;
|
||||
}
|
||||
case 11: {
|
||||
case 12: {
|
||||
int rc;
|
||||
int iArg;
|
||||
if( Tcl_GetIntFromObj(interp, objv[2], &iArg) ){
|
||||
@@ -521,7 +526,7 @@ static int test_filter_handler(
|
||||
|
||||
Tcl_DecrRefCount(pEval);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
static int test_conflict_handler(
|
||||
void *pCtx, /* Pointer to TestConflictHandler structure */
|
||||
@@ -1163,6 +1168,127 @@ static int SQLITE_TCLAPI test_sqlite3session_foreach(
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
#include "sqlite3changebatch.h"
|
||||
|
||||
typedef struct TestChangebatch TestChangebatch;
|
||||
struct TestChangebatch {
|
||||
sqlite3_changebatch *pChangebatch;
|
||||
};
|
||||
|
||||
/*
|
||||
** Tclcmd: $changebatch add BLOB
|
||||
** $changebatch zero
|
||||
** $changebatch delete
|
||||
*/
|
||||
static int SQLITE_TCLAPI test_changebatch_cmd(
|
||||
void *clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
TestChangebatch *p = (TestChangebatch*)clientData;
|
||||
sqlite3_changebatch *pChangebatch = p->pChangebatch;
|
||||
struct SessionSubcmd {
|
||||
const char *zSub;
|
||||
int nArg;
|
||||
const char *zMsg;
|
||||
int iSub;
|
||||
} aSub[] = {
|
||||
{ "add", 1, "CHANGESET", }, /* 0 */
|
||||
{ "zero", 0, "", }, /* 1 */
|
||||
{ "delete", 0, "", }, /* 2 */
|
||||
{ 0 }
|
||||
};
|
||||
int iSub;
|
||||
int rc;
|
||||
|
||||
if( objc<2 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "SUBCOMMAND ...");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
rc = Tcl_GetIndexFromObjStruct(interp,
|
||||
objv[1], aSub, sizeof(aSub[0]), "sub-command", 0, &iSub
|
||||
);
|
||||
if( rc!=TCL_OK ) return rc;
|
||||
if( objc!=2+aSub[iSub].nArg ){
|
||||
Tcl_WrongNumArgs(interp, 2, objv, aSub[iSub].zMsg);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
switch( iSub ){
|
||||
case 0: { /* add */
|
||||
int nArg;
|
||||
unsigned char *pArg = Tcl_GetByteArrayFromObj(objv[2], &nArg);
|
||||
rc = sqlite3changebatch_add(pChangebatch, pArg, nArg);
|
||||
if( rc!=SQLITE_OK && rc!=SQLITE_CONSTRAINT ){
|
||||
return test_session_error(interp, rc, 0);
|
||||
}else{
|
||||
extern const char *sqlite3ErrName(int);
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: { /* zero */
|
||||
sqlite3changebatch_zero(pChangebatch);
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: /* delete */
|
||||
Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));
|
||||
break;
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
static void SQLITE_TCLAPI test_changebatch_del(void *clientData){
|
||||
TestChangebatch *p = (TestChangebatch*)clientData;
|
||||
sqlite3changebatch_delete(p->pChangebatch);
|
||||
ckfree((char*)p);
|
||||
}
|
||||
|
||||
/*
|
||||
** Tclcmd: sqlite3changebatch CMD DB-HANDLE
|
||||
*/
|
||||
static int SQLITE_TCLAPI test_sqlite3changebatch(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
sqlite3 *db;
|
||||
Tcl_CmdInfo info;
|
||||
int rc; /* sqlite3session_create() return code */
|
||||
TestChangebatch *p; /* New wrapper object */
|
||||
|
||||
if( objc!=3 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "CMD DB-HANDLE");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if( 0==Tcl_GetCommandInfo(interp, Tcl_GetString(objv[2]), &info) ){
|
||||
Tcl_AppendResult(interp, "no such handle: ", Tcl_GetString(objv[2]), 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
db = *(sqlite3 **)info.objClientData;
|
||||
|
||||
p = (TestChangebatch*)ckalloc(sizeof(TestChangebatch));
|
||||
memset(p, 0, sizeof(TestChangebatch));
|
||||
rc = sqlite3changebatch_new(db, &p->pChangebatch);
|
||||
if( rc!=SQLITE_OK ){
|
||||
ckfree((char*)p);
|
||||
return test_session_error(interp, rc, 0);
|
||||
}
|
||||
|
||||
Tcl_CreateObjCommand(
|
||||
interp, Tcl_GetString(objv[1]), test_changebatch_cmd, (ClientData)p,
|
||||
test_changebatch_del
|
||||
);
|
||||
Tcl_SetObjResult(interp, objv[1]);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** tclcmd: CMD configure REBASE-BLOB
|
||||
** tclcmd: CMD rebase CHANGESET
|
||||
@@ -1345,6 +1471,10 @@ int TestSession_Init(Tcl_Interp *interp){
|
||||
Tcl_CreateObjCommand(interp, p->zCmd, p->xProc, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
Tcl_CreateObjCommand(
|
||||
interp, "sqlite3changebatch", test_sqlite3changebatch, 0, 0
|
||||
);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -423,6 +423,7 @@ TESTSRC2 = \
|
||||
$(TOP)/src/select.c \
|
||||
$(TOP)/src/threads.c \
|
||||
$(TOP)/src/tokenize.c \
|
||||
$(TOP)/src/treeview.c \
|
||||
$(TOP)/src/utf.c \
|
||||
$(TOP)/src/util.c \
|
||||
$(TOP)/src/vdbeapi.c \
|
||||
@@ -442,6 +443,7 @@ TESTSRC2 = \
|
||||
$(TOP)/ext/async/sqlite3async.c \
|
||||
$(TOP)/ext/misc/stmt.c \
|
||||
$(TOP)/ext/session/sqlite3session.c \
|
||||
$(TOP)/ext/session/sqlite3changebatch.c \
|
||||
$(TOP)/ext/session/test_session.c \
|
||||
fts5.c
|
||||
|
||||
@@ -998,6 +1000,9 @@ THREADTEST3_SRC = $(TOP)/test/threadtest3.c \
|
||||
threadtest3$(EXE): sqlite3.o $(THREADTEST3_SRC) $(TOP)/src/test_multiplex.c
|
||||
$(TCCX) $(TOP)/test/threadtest3.c $(TOP)/src/test_multiplex.c sqlite3.o -o $@ $(THREADLIB)
|
||||
|
||||
bc_test1$(EXE): sqlite3.o $(TOP)/test/bc_test1.c $(TOP)/test/tt3_core.c
|
||||
$(TCCX) $(TOP)/test/bc_test1.c sqlite3.o -o $@ $(THREADLIB)
|
||||
|
||||
threadtest: threadtest3$(EXE)
|
||||
./threadtest3$(EXE)
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
C Version\s3.39.0
|
||||
D 2022-06-25T14:57:57.276
|
||||
C Version\s3.39.3\spatches\sapplied\sto\sthe\sbegin-concurrent\sbranch.
|
||||
D 2022-09-05T12:39:06.361
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
F Makefile.in bccb0ed3f05fc41aee15da77c844c48b5da419cbb9af35b8a147536c9ad1c822
|
||||
F Makefile.in 21c3063046056bac86a5b0c5c6ccd0bcafa2b126233b48b8fc3789528a0e14e9
|
||||
F Makefile.linux-gcc f609543700659711fbd230eced1f01353117621dccae7b9fb70daa64236c5241
|
||||
F Makefile.msc de7cb3e095ce2fdc33513ccd76ebdaeda1483d0ddab0410fe65cbdeadd4c0ee1
|
||||
F README.md 8b8df9ca852aeac4864eb1e400002633ee6db84065bd01b78c33817f97d31f5e
|
||||
F VERSION fa8e7d2d1cc962f9e14c6d410387cf75860ee139462763fda887c1be4261f824
|
||||
F VERSION 44ff0193e2e50e452ced9e0d671d85d52b7ef48e555d4ee5e96574c5e6a9e3b7
|
||||
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
|
||||
F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2
|
||||
F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90
|
||||
@@ -34,10 +34,11 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63
|
||||
F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6
|
||||
F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc
|
||||
F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559
|
||||
F configure 00378d14cca0ce02fa9eca28fd494789c2eda7d10d86003a5f9a42f34b0af418 x
|
||||
F configure db90011c341bf24afacc0b9957757c67a9db58e9ee7a34f265be1b9dc56c75da x
|
||||
F configure.ac 3ef6eeff4387585bfcab76b0c3f6e15a0618587bb90245dd5d44e4378141bb35
|
||||
F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad
|
||||
F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd
|
||||
F doc/begin_concurrent.md e694a2a1c623833e7de8b688e81ec30fd4439a78d6b74be61bce0b1e8f590470
|
||||
F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347bb123ce1ea4f
|
||||
F doc/lemon.html efc0cd2345d66905505d98f862e1c571512def0ceb5b016cb658fd4918eb76a3
|
||||
F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710
|
||||
@@ -102,7 +103,7 @@ F ext/fts3/README.content b9078d0843a094d86af0d48dffbff13c906702b4c3558012e67b9c
|
||||
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
|
||||
F ext/fts3/README.tokenizers b92bdeb8b46503f0dd301d364efc5ef59ef9fa8e2758b8e742f39fa93a2e422d
|
||||
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
|
||||
F ext/fts3/fts3.c 6634a3854e70afa8710ee5e3a7253cd0f0c89d4cce207fcbfe2ead3bad1db7d5
|
||||
F ext/fts3/fts3.c b20bd583991e740c1e14371896f3ab61d7b6c033740646366bbf6667191bc4e2
|
||||
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
|
||||
F ext/fts3/fts3Int.h dafdc371f9fbab175744b06cfe019d5f040cdfdbd11fea752f5dc28d45b04c05
|
||||
F ext/fts3/fts3_aux.c f0dc9bd98582615b7750218899bd0c729879b6bbf94d1be57ca1833ff49afc6f
|
||||
@@ -191,7 +192,7 @@ F ext/fts5/test/fts5eb.test a973baadac524dbbb4ad9b0e99030e12cabde2c6b28e0ac43729
|
||||
F ext/fts5/test/fts5fault1.test d28a65caee75db6897c3cf1358c5230d3bb2a3bf7fb31062c19c7e5382b3d2bd
|
||||
F ext/fts5/test/fts5fault2.test 69c8fdbef830cd0d450908d4504d5bb86609e255af99c421c20a0756251fe344
|
||||
F ext/fts5/test/fts5fault3.test da2f9e3e56ff5740d68ebdd6877c97089e7ed28ddff28a0da87a6afea27e5522
|
||||
F ext/fts5/test/fts5fault4.test 1c1db5fcfe59401e7833146100f1d8de284a0a686fac31ddac9fb56c459f725b
|
||||
F ext/fts5/test/fts5fault4.test 87a10d0caee57da587c7588b0c8d25d2930197399b4812ad1e4d574c75324cee
|
||||
F ext/fts5/test/fts5fault5.test a336e4e11847de24c9497f80cce18e00bb3fab7fb11f97d04eb9af898900a762
|
||||
F ext/fts5/test/fts5fault6.test a0fc0a8f99e4b16500c31dfc7e38e1defe0f1693ac47650517ac7b723b1956f8
|
||||
F ext/fts5/test/fts5fault7.test 0acbec416edb24b8881f154e99c31e9ccf73f539cfcd164090be139e9e97ed4c
|
||||
@@ -334,7 +335,7 @@ F ext/misc/normalize.c bd84355c118e297522aba74de34a4fd286fc775524e0499b14473918d
|
||||
F ext/misc/percentile.c b9086e223d583bdaf8cb73c98a6539d501a2fc4282654adbfea576453d82e691
|
||||
F ext/misc/prefixes.c 0f4f8cff5aebc00a7e3ac4021fd59cfe1a8e17c800ceaf592859ecb9cbc38196
|
||||
F ext/misc/qpvtab.c 09738419e25f603a35c0ac8bd0a04daab794f48d08a9bc07a6085b9057b99009
|
||||
F ext/misc/regexp.c b267fd05ff8d38b22f4c2809d7b7a2c61d522e9faf2feb928dbb9662e4a3a386
|
||||
F ext/misc/regexp.c 03e483711534c437b2e29648d2a4b7730f5cb781a434ac8150907376bc4489f6
|
||||
F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c
|
||||
F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c
|
||||
F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946
|
||||
@@ -344,7 +345,7 @@ F ext/misc/shathree.c 7b17615869a495659f1569ada1d8d3d21b4a24614f2746d93cc87ef7c0
|
||||
F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
|
||||
F ext/misc/spellfix.c 94df9bbfa514a563c1484f684a2df3d128a2f7209a84ca3ca100c68a0163e29f
|
||||
F ext/misc/sqlar.c 0ace5d3c10fe736dc584bf1159a36b8e2e60fab309d310cd8a0eecd9036621b6
|
||||
F ext/misc/stmt.c 35063044a388ead95557e4b84b89c1b93accc2f1c6ddea3f9710e8486a7af94a
|
||||
F ext/misc/stmt.c ed05ad78013edccd43f4fc33d8244001f6f886eb2dfd2106ba33616ac514c6fb
|
||||
F ext/misc/templatevtab.c 8a16a91a5ceaccfcbd6aaaa56d46828806e460dd194965b3f77bf38f14b942c4
|
||||
F ext/misc/totype.c fa4aedeb07f66169005dffa8de3b0a2b621779fd44f85c103228a42afa71853b
|
||||
F ext/misc/uint.c 053fed3bce2e89583afcd4bf804d75d659879bbcedac74d0fa9ed548839a030b
|
||||
@@ -413,12 +414,12 @@ F ext/repair/test/checkfreelist01.test 3e8aa6aeb4007680c94a8d07b41c339aa635cc782
|
||||
F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c335096108c12c01bddbadcec
|
||||
F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c
|
||||
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
||||
F ext/rtree/geopoly.c cc3f89c11abcf114fa60d74709ae8b5bc1eae5a261b30bc1bb7085089c03bfab
|
||||
F ext/rtree/geopoly.c bb0dcd013dbb3fe0335b6bbae0d9c29fcfffda93d5ef6c31daa47e802132e435
|
||||
F ext/rtree/rtree.c d7b4b8b81d8d54376a7f81de5be85ec58b37c11604bcf42984a8418b34158d93
|
||||
F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412
|
||||
F ext/rtree/rtree1.test d47f58832145fcfed9067bc457ca8664962196c4566c17a1ebd679367db55d11
|
||||
F ext/rtree/rtree2.test 9d9deddbb16fd0c30c36e6b4fdc3ee3132d765567f0f9432ee71e1303d32603d
|
||||
F ext/rtree/rtree3.test 4ee5d7df86040efe3d8d84f141f2962a7745452200a7cba1db06f86d97050499
|
||||
F ext/rtree/rtree3.test 272594f88c344e973864008bbe4c71fd3a41a264c097d568593ee7886d83d409
|
||||
F ext/rtree/rtree4.test 304de65d484540111b896827e4261815e5dca4ce28eeecd58be648cd73452c4b
|
||||
F ext/rtree/rtree5.test 49c9041d713d54560b315c2c7ef7207ee287eba1b20f8266968a06f2e55d3142
|
||||
F ext/rtree/rtree6.test 9ce3691c1aac43070a9f194f0ebf54372db346c5a82241fd11b525ed53ce9f3f
|
||||
@@ -449,6 +450,8 @@ F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
|
||||
F ext/rtree/util/randomshape.tcl 54ee03d0d4a1c621806f7f44d5b78d2db8fac26e0e8687c36c4bd0203b27dbff
|
||||
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
|
||||
F ext/rtree/visual01.txt e9c2564083bcd30ec51b07f881bffbf0e12b50a3f6fced0c222c5c1d2f94ac66
|
||||
F ext/session/changebatch1.test 9ceaa8f7b2a505933e250fbe6cbc550e4ce1e59d
|
||||
F ext/session/changebatchfault.test be49c793219bf387ad692a60856b921f0854ad6d
|
||||
F ext/session/changeset.c 7a1e6a14c7e92d36ca177e92e88b5281acd709f3b726298dc34ec0fb58869cb5
|
||||
F ext/session/changesetfuzz.c 227076ab0ae4447d742c01ee88a564da6478bbf26b65108bf8fac9cd8b0b24aa
|
||||
F ext/session/changesetfuzz1.test 2e1b90d888fbf0eea5e1bd2f1e527a48cc85f8e0ff75df1ec4e320b21f580b3a
|
||||
@@ -467,7 +470,7 @@ F ext/session/sessionD.test 4f91d0ca8afc4c3969c72c9f0b5ea9527e21de29039937d0d973
|
||||
F ext/session/sessionE.test b2010949c9d7415306f64e3c2072ddabc4b8250c98478d3c0c4d064bce83111d
|
||||
F ext/session/sessionF.test d37ed800881e742c208df443537bf29aa49fd56eac520d0f0c6df3e6320f3401
|
||||
F ext/session/sessionG.test 3828b944cd1285f4379340fd36f8b64c464fc84df6ff3ccbc95578fd87140b9c
|
||||
F ext/session/sessionH.test b17afdbd3b8f17e9bab91e235acf167cf35485db2ab2df0ea8893fbb914741a4
|
||||
F ext/session/sessionH.test ecabc041e04e48671a94cd7c02993bc73f75dced943280a026e89cdf64374eef
|
||||
F ext/session/session_common.tcl f613174665456b2d916ae8df3e5735092a1c1712f36f46840172e9a01e8cc53e
|
||||
F ext/session/session_speed_test.c dcf0ef58d76b70c8fbd9eab3be77cf9deb8bc1638fed8be518b62d6cbdef88b3
|
||||
F ext/session/sessionat.test 52993535f1230a42f70886643574ba7ae60ef854f8add9c8e3fcc3eb5c564bd2
|
||||
@@ -482,16 +485,18 @@ F ext/session/sessionrebase.test ccfa716b23bd1d3b03217ee58cfd90c78d4b99f53e6a9a2
|
||||
F ext/session/sessionsize.test 6f644aff31c7f1e4871e9ff3542766e18da68fc7e587b83a347ea9820a002dd8
|
||||
F ext/session/sessionstat1.test 218d351cf9fcd6648f125a26b607b140310160184723c2666091b54450a68fb5
|
||||
F ext/session/sessionwor.test 6fd9a2256442cebde5b2284936ae9e0d54bde692d0f5fd009ecef8511f4cf3fc
|
||||
F ext/session/sqlite3session.c 1d019c5caf51936ef24c761db63552b06e0e0d951c8740bba9639b17fa0cb107
|
||||
F ext/session/sqlite3session.h 0907de79bc13a2e3af30a6dc29acc60792a3eaf7d33d44cf52500d0f3c2b2171
|
||||
F ext/session/test_session.c f433f68a8a8c64b0f5bc74dc725078f12483301ad4ae8375205eef790274a787
|
||||
F ext/session/sqlite3changebatch.c d5553b79e012ee2cb06c0a96bdf9dfe19e66354390ea0036cc46c4953142d517
|
||||
F ext/session/sqlite3changebatch.h e72016998c9a22d439ddfd547b69e1ebac810c24
|
||||
F ext/session/sqlite3session.c 421854336ece362552508426d89091c1832148066f0641e8d72e22f58d9241f3
|
||||
F ext/session/sqlite3session.h c26e54521584ad26dcb459171d94bbe6412ca26ed4613551c7f0c80aad129abd
|
||||
F ext/session/test_session.c 226461035031632255c8098f3bcfa4ea27f0b051efd88857a2a36bcea5c294b9
|
||||
F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3
|
||||
F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04
|
||||
F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865f002fc80cb
|
||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
|
||||
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
|
||||
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
|
||||
F main.mk a5412510e5ec952915a7fda34e02079bb4e6ff8f97903f2a3d9ad2dee3e18044
|
||||
F main.mk 6c80d0ae4791e299c7cad5f7a6ea01c8861710e8ec1b6d81e92d09ca959b964c
|
||||
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
|
||||
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
|
||||
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
|
||||
@@ -508,12 +513,12 @@ F src/analyze.c aabdf3769c7fd9954a8ec508eb7041ae174b66f88d12c47199fabbea9a646467
|
||||
F src/attach.c 4431f82f0247bf3aaf91589acafdff77d1882235c95407b36da1585c765fbbc8
|
||||
F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf
|
||||
F src/backup.c a2891172438e385fdbe97c11c9745676bec54f518d4447090af97189fd8e52d7
|
||||
F src/bitvec.c 7c849aac407230278445cb069bebc5f89bf2ddd87c5ed9459b070a9175707b3d
|
||||
F src/bitvec.c 3907fcbe8a0c8c2db58d97087d15cdabbf2842adb9125df9ab9ff87d3db16775
|
||||
F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
|
||||
F src/btree.c b5a74c39d3123dadd190019c0afadd7f62b43dfe0712a39e9d0ff2fe26be5d93
|
||||
F src/btree.h 74d64b8f28cfa4a894d14d4ed64fa432cd697b98b61708d4351482ae15913e22
|
||||
F src/btreeInt.h 8ce1332edd89dfd2461d561ac10a0ab5601c8e06200cb5230596c3caaf54482e
|
||||
F src/build.c 23f874642825d7eaaeeb7a3281b2b1a75e1d4c4dd9ae4dceddcd908266634214
|
||||
F src/btree.c 890831d57243e833584bfcdd0df2720b3e340055901ce65dd0057746c628204a
|
||||
F src/btree.h 900067641b64d619e6e2a93bd115c952a52f41d3bee32e551e2a4ceee05fc431
|
||||
F src/btreeInt.h 650add92a0ffc8c315406f140325c5f41f0e386848dafbb1e27a72fe7cf6f179
|
||||
F src/build.c 53a4c32c6c4c4dd0899641229fd090170f93ab45b622f118a2371df698d68002
|
||||
F src/callback.c 4c19af69835787bfe790ac560f3071a824eb629f34e41f97b52ce5235c77de1c
|
||||
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
|
||||
F src/ctime.c 026dbdcdbd8c3cde98a88483ee88310ff43150ab164ad768f12cc700a11495ad
|
||||
@@ -524,7 +529,7 @@ F src/delete.c a8e844af211a48b13b5b358be77a12c860c6a557c21990ad51a548e2536500ce
|
||||
F src/expr.c 4907afcb86d72b5525d8767515ce425ec53c7a2d3664441b46cef5b376ee0cba
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
F src/fkey.c d965ede15d8360c09ed59348940649ee647b192e784466837d7aefa836d1d91e
|
||||
F src/func.c 8f72e88cccdee22185133c10f96ccd61dc34c5ea4b1fa9a73c237ef59b2e64f1
|
||||
F src/func.c c4b2229aac24b3d7989ef51abae0e5e87e58e8bda3c7b6c55f76d231dbedfb8d
|
||||
F src/global.c e83ee571b79ee3adc32e380cf554cf1254bc43763d23786c71721fbcdfbbb965
|
||||
F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19
|
||||
F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
|
||||
@@ -534,8 +539,8 @@ F src/insert.c 173845e5a6bac96ae937409e4f876b631f26b31dabb9df8fd0eb3b130b2bb3a7
|
||||
F src/json.c 7749b98c62f691697c7ee536b570c744c0583cab4a89200fdd0fc2aa8cc8cbd6
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c 853385cc7a604157e137585097949252d5d0c731768e16b044608e5c95c3614b
|
||||
F src/main.c e946f1d9e30bf49cf399ddf860cfd2319e3a97bbaabfb8e87d6ab985a20d54ad
|
||||
F src/malloc.c a9127efdcef92d6934c6339ea9813075b90edc0ce2e5c723556381a3828fb720
|
||||
F src/main.c 6f5dff0d731fd653d762cad92021a937f2273bb00cf9628de4727ec019dac662
|
||||
F src/malloc.c 4a3785323104678a8b4b0a482fe0c2a80900e7468ddf76ab0f2ea1c79a8ca8cd
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
|
||||
F src/mem2.c c8bfc9446fd0798bddd495eb5d9dbafa7d4b7287d8c22d50a83ac9daa26d8a75
|
||||
@@ -554,33 +559,33 @@ F src/os.c b1c4f2d485961e9a5b6b648c36687d25047c252222e9660b7cc25a6e1ea436ab
|
||||
F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63
|
||||
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
|
||||
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
|
||||
F src/os_unix.c 2df2b33db88f00af13805d4573ee126bc5973f9e3b91d03c575fa7ba64e7dc41
|
||||
F src/os_win.c a8ea80037e81127ca01959daa87387cc135f325c88dc745376c4f760de852a10
|
||||
F src/os_unix.c 1b376305176544b29c38b2f169597ee2ce17739bb29fed6d7579708b99c98876
|
||||
F src/os_win.c d55025aeb5b36b5d92d7c09fe709edaf2be901420782540ba4adad86729636a0
|
||||
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
|
||||
F src/pager.c 74596fc3d5d8a50de32c37225fc300cccd5ea27ea303c5f4b845d6572f999c5f
|
||||
F src/pager.h f82e9844166e1585f5786837ddc7709966138ced17f568c16af7ccf946c2baa3
|
||||
F src/parse.y 8e67d820030d2655b9942ffe61c1e7e6b96cea2f2f72183533299393907d0564
|
||||
F src/pager.c 9ba563d9233b4e33adfcce3e84c709d49c1a2ecbf9697daa9021edbf9577e6c5
|
||||
F src/pager.h 7b2ec7bba30b21a97b68d5bdc0dbb82a75f48c4b1457180988f9d409fb789e16
|
||||
F src/parse.y 17c50d262d92083badeb60b3ebe4725e19c76548f90aea898ab07d4f2940a7d8
|
||||
F src/pcache.c 084e638432c610f95aea72b8509f0845d2791293f39d1b82f0c0a7e089c3bb6b
|
||||
F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586
|
||||
F src/pcache1.c 54881292a9a5db202b2c0ac541c5e3ef9a5e8c4f1c1383adb2601d5499a60e65
|
||||
F src/pragma.c d1aead03e8418ff586c7cfca344c50a914b8eb06abd841e8e91a982d823671da
|
||||
F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7
|
||||
F src/pragma.c 404c0fe37b51f6def2c9ec6b07c80f0355673f0e74d720dc9a58a78725502417
|
||||
F src/pragma.h 1f421360eed1a7721e8c521463df8519a7c8d0d5893ebd9dbfe0dba8de996f8c
|
||||
F src/prepare.c c62820c15dcb63013519c8e41d9f928d7478672cc902cfd0581c733c271dbf45
|
||||
F src/printf.c 6166a30417b05c5b2f82e1f183f75faa2926ad60531c0b688a57dbc951441a20
|
||||
F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c
|
||||
F src/resolve.c 1655e44c77c51ebbe82924287528a78bd4a4aaaf34189dbae28d19ccf2ca615c
|
||||
F src/printf.c e99ee9741e79ae3873458146f59644276657340385ade4e76a5f5d1c25793764
|
||||
F src/random.c d4127b3d8ba155e293cc1abb19f70992c147abd5cc911df25582cb481b705974
|
||||
F src/resolve.c f0d663c9b1ceeb3e7d262ede872dd3b24b323a7cc11d84c05a39d962e7d64b07
|
||||
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
|
||||
F src/select.c 2db8bbf13f57cc9872f9b927546e98f5ea583e9e364182426492a434a994421b
|
||||
F src/shell.c.in 08e59f1cb9d9b1180aba52861aaada0c95f6ddd210488719684e160a0724c806
|
||||
F src/sqlite.h.in 172528c287399a34f188154017b7268bf82c6d5b780902e361958d2318c4e37c
|
||||
F src/select.c 3e8041f760d621232bf8702eb805044c7fbaa7c41659ecbc27fc33e90898aada
|
||||
F src/shell.c.in 8490f940c723eb4415426d35da9118118895354e7c6b909dac42474e5d062d50
|
||||
F src/sqlite.h.in 31d227e5cc2db23d15381b82932ea3cc5901f81eb632b1bf3b443756406e04fd
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h a988810c9b21c0dc36dc7a62735012339dc76fc7ab448fb0792721d30eacb69d
|
||||
F src/sqliteInt.h 8353e96646372efdb0795a13cd9949831b4992c928de8f5c43b2524e8a4c6e7b
|
||||
F src/sqliteInt.h 96015cf7d0d6ef411ba1af62a739c5b3b600528acaf93e901afcf91ef13ec7fa
|
||||
F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657
|
||||
F src/status.c 4a3da6d77eeb3531cb0dbdf7047772a2a1b99f98c69e90ce009c75fe6328b2c0
|
||||
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
|
||||
F src/tclsqlite.c 4e64ba300a5a26e0f1170e09032429faeb65e45e8f3d1a7833e8edb69fc2979e
|
||||
F src/test1.c 1356984e97bff07e4a8cc3863e892f05b3348678a74783bb6f350b76316736f1
|
||||
F src/test1.c 95c688261edf59ff77676aca426b343beb9f90d6548ecb16189ce614e5a63620
|
||||
F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
|
||||
F src/test3.c 61798bb0d38b915067a8c8e03f5a534b431181f802659a6616f9b4ff7d872644
|
||||
F src/test4.c 4533b76419e7feb41b40582554663ed3cd77aaa54e135cf76b3205098cd6e664
|
||||
@@ -595,7 +600,7 @@ F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0
|
||||
F src/test_bestindex.c 8294d8223b7f18a3ddb7f9a0e30815dcca4e61681f78b538c870f7d934f88b81
|
||||
F src/test_blob.c ae4a0620b478548afb67963095a7417cd06a4ec0a56adb453542203bfdcb31ce
|
||||
F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274
|
||||
F src/test_config.c 8264637b06a3c1f0727c88d1ea32dcf7986b9e7e358a970cae87cdac8a5b2708
|
||||
F src/test_config.c c7a93ef3c0c881e3c46ff14163af886a602317206d82a7dc4ebbf400e661a6ff
|
||||
F src/test_delete.c e2fe07646dff6300b48d49b2fee2fe192ed389e834dd635e3b3bac0ce0bf9f8f
|
||||
F src/test_demovfs.c 86142ba864d4297d54c5b2e972e74f3141ae4b30f05b3a95824184ed2d3d7f91
|
||||
F src/test_devsym.c aff2255ea290d7718da08af30cdf18e470ff7325a5eff63e0057b1496ed66593
|
||||
@@ -634,19 +639,19 @@ F src/test_windirent.h 90dfbe95442c9762357fe128dc7ae3dc199d006de93eb33ba3972e0a9
|
||||
F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f
|
||||
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
||||
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
|
||||
F src/tokenize.c a38f52058b517929e264094abd0b5fd1e8e145a1aa43bc6f6a72ae5218f96c98
|
||||
F src/treeview.c 0bd550f5974565eba541db339906be7a3f9e91beafb879cb40705382887f08e1
|
||||
F src/tokenize.c 36eb0799e487759bbe73e5742b82ee676f06cea2515ff578d03c59a74ccf2d6c
|
||||
F src/treeview.c 07787f67cd297a6d09d04b8d70c06769c60c9c1d9080378f93929c16f8fd3298
|
||||
F src/trigger.c 61bea163b1fa3039bc572ed8312461b978e5c527e5301f302b078f4c1ccdec6a
|
||||
F src/update.c c52a7991bece0453d22c77c08469512ee2f1391c12503fd347d1c939220c5877
|
||||
F src/update.c c17295f85ad5e81bc040701d76c599915ab847098f2ed29149807c537fdd3cb0
|
||||
F src/upsert.c 8789047a8f0a601ea42fa0256d1ba3190c13746b6ba940fe2d25643a7e991937
|
||||
F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0
|
||||
F src/util.c 602fe229f32a96ceccae4f40824129669582096f7c355f53dbac156c9fecef23
|
||||
F src/vacuum.c bb346170b0b54c6683bba4a5983aea40485597fdf605c87ec8bc2e199fe88cd8
|
||||
F src/vdbe.c 3df15f0f2cd9d8faeeea18398a62f16c07fda2bfd8d726186f07508ad69b40e2
|
||||
F src/util.c 0be191521ff6d2805995f4910f0b6231b42843678b2efdc1abecaf39929a673f
|
||||
F src/vacuum.c 5b7888f917936dda09f98b1fda164cff1dad44fb5e143436bdbb9dc3191ce2df
|
||||
F src/vdbe.c 2c7aaff87b2507fc7f6616dc49d6bced7c5b2ea5e40ed540ff69165bbbdcd1f5
|
||||
F src/vdbe.h 07641758ca8b4f4c6d81ea667ea167c541e6ece21f5574da11e3d21ec37e2662
|
||||
F src/vdbeInt.h 2cad0aeeb106371ed0e0946bab89f60627087068847afc2451c05056961c18da
|
||||
F src/vdbeapi.c 602610f1252d59cd69742f78a1e2f6fbae40a4b407f5506a6a7b869b0df08ff2
|
||||
F src/vdbeaux.c 328b866880e67526300aa2361c5e50beb3d97dd8746db37dd4aa0135aea60e4d
|
||||
F src/vdbeaux.c 829eda97bd0691dee30c775c9e29267efd66fef65ddbfe15d12fac064f802e36
|
||||
F src/vdbeblob.c 5e61ce31aca17db8fb60395407457a8c1c7fb471dde405e0cd675974611dcfcd
|
||||
F src/vdbemem.c 5ebf05c0182addedb1607ade848e1c83cef40981df94d1abfab0c59288c6064f
|
||||
F src/vdbesort.c 43756031ca7430f7aec3ef904824a7883c4ede783e51f280d99b9b65c0796e35
|
||||
@@ -654,12 +659,12 @@ F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf8
|
||||
F src/vdbevtab.c f99b275366c5fc5e2d99f734729880994ab9500bdafde7fae3b02d562b9d323c
|
||||
F src/vtab.c 3d72c780d1ea08906a198e4f033921a658a54590e3ed72c544995d84f3f9464a
|
||||
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
||||
F src/wal.c b9df133a705093da8977da5eb202eaadb844839f1c7297c08d33471f5491843d
|
||||
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
|
||||
F src/wal.c 419c0a98dd65b9419fd07bdd4f9facc61143c33d57b0dbeffd83cf38a2e0e33e
|
||||
F src/wal.h 7ffe787437f20a098af347011967a6d3bb8e5c3dc645e6be59eff44d2b2c5297
|
||||
F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
|
||||
F src/where.c 9a44063e60d8f42dd9dc8147b8e8dcfc315bbd13e25c395211292c36d828c869
|
||||
F src/where.c e7b7c9d37f4f8d14d4d05b20e57ae43712a51ffed7d45f547a23f9c42ee483dd
|
||||
F src/whereInt.h b48ca529ffe293c18cbfa8326af18a09e39910de66fb3e96ef788c7cbf8ef3a7
|
||||
F src/wherecode.c 0b09abfcb88c61c6a6984a3e065786631ff35495e9bdf865e6b74ab0a1299c5b
|
||||
F src/wherecode.c f8acceb057286ed95b66689d1981985228fd925001fdc49dbd3b112f4d739174
|
||||
F src/whereexpr.c 55a39f42aaf982574fbf52906371a84cceed98a994422198dfd03db4fce4cc46
|
||||
F src/window.c fff1b51757438c664e471d5184634e48dcdf8ea34b640f3b1b0810b1e06de18c
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
@@ -743,6 +748,7 @@ F test/backup_malloc.test 0c9abdf74c51e7bedb66d504cd684f28d4bd4027
|
||||
F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f
|
||||
F test/badutf2.test f310fd3b24a491b6b77bccdf14923b85d6ebcce751068c180d93a6b8ff854399
|
||||
F test/bc_common.tcl b5e42d80305be95697e6370e015af571e5333a1c
|
||||
F test/bc_test1.c e0a092579552e066ed4ce7bcdaecfa69c4aacc8d
|
||||
F test/bestindex1.test 856a453dff8c68b4568601eed5a8b5e20b4763af9229f3947c215729ed878db0
|
||||
F test/bestindex2.test 394ff8fbf34703391247116d6a44e1c50ee7282236ee77909044573cefc37bc0
|
||||
F test/bestindex3.test 34bea272b0e0f835651b16a3931dbe7ac927039be6b2e1cb617bbe1d584b492b
|
||||
@@ -810,6 +816,15 @@ F test/collateB.test 1e68906951b846570f29f20102ed91d29e634854ee47454d725f2151eca
|
||||
F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1
|
||||
F test/colname.test 87ad5458bb8709312dac0d6755fd30e8e4ca83298d0a9ef6e5c24277a3c3390e
|
||||
F test/columncount.test 6fe99c2f35738b0129357a1cf3fa483f76140f4cd8a89014c88c33c876d2638f
|
||||
F test/concfault.test e5370cd686f601a01909377cac3bbf13dac56d39dd4ad6b04ccbec9eeeaccb18
|
||||
F test/concurrent.test a0248ec6e3e79a5948453649cf86b5b359175cba55ea636b15426d6f0fa6c3da
|
||||
F test/concurrent2.test de748c7dd749c77e2af2c4b914b9b09a28ac09608042ca498c0251dc6f46aa1a
|
||||
F test/concurrent3.test 530671ac706f6a1d0f4992dbdd33a86408330d03cd90fb9e82ecb1b27f5fd081
|
||||
F test/concurrent4.test e0b12cd467137e50259df3b4f837507e82aaa07c35941c88664dc8ed1d089c44
|
||||
F test/concurrent5.test 0c16cbf7446af162a14e6def30445e94016064eb994e5aa4ebb2bebc59554176
|
||||
F test/concurrent6.test a7860e9ca13bb5fb76bcf41c5524fbfa9c37e6e258ecf84ffb5748a272488c67
|
||||
F test/concurrent7.test b96fa5c4cfdf8d5c0bc66b6934214500bad0260884a736f054ccc76e81aae85d
|
||||
F test/concurrent8.test b93937e74a8efb8b84f2fea7595b53418c5f29777bbe9cbdb5dc219b3dd72a7d
|
||||
F test/conflict.test ac0667090f66130ac77d5fb764655558ca6600dd6d88f670ca9123b61c448337
|
||||
F test/conflict2.test 5557909ce683b1073982f5d1b61dfb1d41e369533bfdaf003180c5bc87282dd1
|
||||
F test/conflict3.test 81865d9599609aca394fb3b9cd5f561d4729ea5b176bece3644f6ecb540f88ac
|
||||
@@ -836,7 +851,7 @@ F test/corruptJ.test 4d5ccc4bf959464229a836d60142831ef76a5aa4
|
||||
F test/corruptK.test 5b4212fe346699831c5ad559a62c54e11c0611bdde1ea8423a091f9c01aa32af
|
||||
F test/corruptL.test ecce40d7b9b909a670a42a45d86e30d927735d7e7f09041af438b19529d35532
|
||||
F test/corruptM.test 7d574320e08c1b36caa3e47262061f186367d593a7e305d35f15289cc2c3e067
|
||||
F test/corruptN.test 60b5a62944b4f0029ba07edaa5fd8e670539d6b0a8d99db26c068d435675cbfe
|
||||
F test/corruptN.test f0b26fda7556581af9667904ce2fa1e5749cd018b56c8fb77bda143d3ab6ccbf
|
||||
F test/cost.test b11cdbf9f11ffe8ef99c9881bf390e61fe92baf2182bad1dbe6de59a7295c576
|
||||
F test/count.test cd4bd531066e8d77ef8fe1e3fc8253d042072e117ccab214b290cf83f1602249
|
||||
F test/countofview.test e17d6e6688cf74f22783c9ec6e788c0790ee4fbbaee713affd00b1ac0bb39b86
|
||||
@@ -1007,7 +1022,7 @@ F test/fts3conf.test c84bbaec81281c1788aa545ac6e78a6bd6cde2bdbbce2da261690e3659f
|
||||
F test/fts3corrupt.test 6732477c5ace050c5758a40a8b5706c8c0cccd416b9c558e0e15224805a40e57
|
||||
F test/fts3corrupt2.test e318f0676e5e78d5a4b702637e2bb25265954c08a1b1e4aaf93c7880bb0c67d0
|
||||
F test/fts3corrupt3.test 0d5b69a0998b4adf868cc301fc78f3d0707745f1d984ce044c205cdb764b491f
|
||||
F test/fts3corrupt4.test 799ff994b964fed7201be6b6b62c7ff2ef7bb3da6c02b9eaf0d96a5a4d9b6ca3
|
||||
F test/fts3corrupt4.test 589e043d1114ea02c83530e459ef5c2d6adce63094e72826ed3bceb02e795116
|
||||
F test/fts3corrupt5.test 0549f85ec4bd22e992f645f13c59b99d652f2f5e643dac75568bfd23a6db7ed5
|
||||
F test/fts3corrupt6.test f417c910254f32c0bc9ead7affa991a1d5aec35b3b32a183ffb05eea78289525
|
||||
F test/fts3cov.test 7eacdbefd756cfa4dc2241974e3db2834e9b372ca215880e00032222f32194cf
|
||||
@@ -1024,8 +1039,8 @@ F test/fts3expr3.test c4d4a7d6327418428c96e0a3a1137c251b8dfbf8
|
||||
F test/fts3expr4.test f5b2832549f01b1f7f73389fa21d4b875499bc95bf7c8b36271844888c6a0938
|
||||
F test/fts3expr5.test a5b9a053becbdb8e973fbf4d6d3abaabeb42d511d1848bd57931f3e0a1cf983e
|
||||
F test/fts3f.test 8c438d5e1cab526b0021988fb1dc70cf3597b006a33ffd6c955ee89929077fe3
|
||||
F test/fts3fault.test 798e45af84be7978ca33d5bdc94246eb44724db24174b5d8e9b1ac46c57fb08d
|
||||
F test/fts3fault2.test 6a17a11d8034b1c4eca9f3091649273d56c49ff049e2173df8060f94341e9da0
|
||||
F test/fts3fault.test f4e1342acfe6d216a001490e8cd52afac1f9ffe4a11bbcdcb296129a45c5df45
|
||||
F test/fts3fault2.test 7b2741e5095367238380b0fcdb837f36c24484c7a5f353659b387df63cf039ec
|
||||
F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641
|
||||
F test/fts3fuzz001.test e3c7b0ce9b04cc02281dcc96812a277f02df03cd7dc082055d87e11eb18aaf56
|
||||
F test/fts3join.test ee25def5e763ea8879c19e74f862d5191410ccc7259338887a3685e97f512662
|
||||
@@ -1168,7 +1183,7 @@ F test/join4.test 1a352e4e267114444c29266ce79e941af5885916
|
||||
F test/join5.test d22b6cba8fb59ab3f1c82701434c360705eb12d4ce200c449f37b018fc47681a
|
||||
F test/join6.test f809c025fa253f9e150c0e9afd4cef8813257bceeb6f46e04041228c9403cc2c
|
||||
F test/join7.test 2268dcbb54b724391dda3748ea95c60d960607ffeed67885675998e7117697f6
|
||||
F test/join8.test d0e75bf880a1b1ee8fda57d8187170c5b2ff0c0cd0e1d6d474faa99fe1283d8d
|
||||
F test/join8.test ef5fb09a7ce6b59addb8bd16e11607db6c44a0afcac5774a5dc03193fd0a1df5
|
||||
F test/join9.test 9056ddd3b0c0f4f9d658f4521038d9a37dc23ead8ca9a505d0b0db2b6a471e05
|
||||
F test/joinA.test 7eab225dc1c1ab258a5e62513a4ed7cabbd3db971d59d5d92f4fb6fa14c12f6a
|
||||
F test/joinB.test 1b2ba3fc8568b49411787fccbf540570c148e9b6a53a30f80691cb6268098ded
|
||||
@@ -1183,7 +1198,7 @@ F test/journal3.test 7c3cf23ffc77db06601c1fcfc9743de8441cb77db9d1aa931863d94f5ff
|
||||
F test/jrnlmode.test 9b5bc01dac22223cb60ec2d5f97acf568d73820794386de5634dcadbea9e1946
|
||||
F test/jrnlmode2.test 8759a1d4657c064637f8b079592651530db738419e1d649c6df7048cd724363d
|
||||
F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa
|
||||
F test/json101.test 9d46b8e254c4e23306da175dd226d5c4f164db6b294bcea98e5dcd891ba48c91
|
||||
F test/json101.test 9f6337e7423d2c1774d1d485c919fc4e11c8f7e423a2f8831f73471983432108
|
||||
F test/json102.test 327e77275f338c028faefa2da5164daf6b142a165e3015ff2a6e4251ddc6a0ac
|
||||
F test/json103.test 53df87f83a4e5fa0c0a56eb29ff6c94055c6eb919f33316d62161a8880112dbe
|
||||
F test/json104.test a502dc01853aada95d721b3b275afbe2dc18fffdac1fea6e96fb20c13586bbb5
|
||||
@@ -1233,7 +1248,7 @@ F test/mallocJ.test b5d1839da331d96223e5f458856f8ffe1366f62e
|
||||
F test/mallocK.test 25897506da0098cea09b302ff432b0fb6d8002773c1e0fc9732aa8b444bfd455
|
||||
F test/mallocL.test fb311ff80afddf3b1a75e52289081f4754d901dc
|
||||
F test/mallocM.test 78bbe9d3da84a5c679123cdb40d7b2010b18fc46e13897e4f253c6ba6fbff134
|
||||
F test/malloc_common.tcl aac62499b76be719fac31e7a3e54a7fd53272e7f
|
||||
F test/malloc_common.tcl 806c50379cf4fa65008cd4d5af18273e5dac8ab62d1d4316c76aa2ecd2e54018
|
||||
F test/malloctraceviewer.tcl b7a54595270c1d201abf1c3f3d461f27eaf24cdef623ad08a0fe5e411264c8a9
|
||||
F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e
|
||||
F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f
|
||||
@@ -1244,7 +1259,7 @@ F test/memjournal2.test 89a4e0d1084170a281efa4d54c2677599f986f44227f98f7dfae2828
|
||||
F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2
|
||||
F test/memsubsys1.test 9e7555a22173b8f1c96c281ce289b338fcba2abe8b157f8798ca195bbf1d347e
|
||||
F test/memsubsys2.test 3e4a8d0c05fd3e5fa92017c64666730a520c7e08
|
||||
F test/merge1.test 0ade470d77b689c4a64dc7f736527fcd893140bcafa70af8f7b98523cfb83f16
|
||||
F test/merge1.test 2de6d6ef8d25402764b1aab49d8f9d7f89208c89a6674e437f76de4c812157b8
|
||||
F test/minmax.test fe638b55d77d2375531a8f549b338eafcd9adfbd2f72df37ed77d9b26ca0a71a
|
||||
F test/minmax2.test cf9311babb6f0518d04e42fd6a42c619531c4309a9dd790a2c4e9b3bc595e0de
|
||||
F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354
|
||||
@@ -1274,6 +1289,7 @@ F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660
|
||||
F test/nan.test 437d40e6d0778b050d7750726c0cbd2c9936b81962926e8f8c48ca698f00f4d1
|
||||
F test/nockpt.test 8c43b25af63b0bd620cf1b003529e37b6f1dc53bd22690e96a1bd73f78dde53a
|
||||
F test/nolock.test f196cf8b8fbea4e2ca345140a2b3f3b0da45c76e
|
||||
F test/noop_update.test 74d71bbe5d37f7861cc2402ed620eb165b8e6b00159cdcada7df716420336651
|
||||
F test/normalize.test f23b6c5926c59548635fcf39678ac613e726121e073dd902a3062fbb83903b72
|
||||
F test/notify1.test 669b2b743618efdc18ca4b02f45423d5d2304abf
|
||||
F test/notify2.test 2ecabaa1305083856b7c39cf32816b612740c161
|
||||
@@ -1285,7 +1301,7 @@ F test/null.test b7ff206a1c60fe01aa2abd33ef9ea83c93727d993ca8a613de86e925c9f2bc6
|
||||
F test/nulls1.test 7a5e4346ee4285034100b4cd20e6784f16a9d6c927e44ecdf10034086bbee9c9
|
||||
F test/numcast.test 5d126f7f581432e86a90d1e35cac625164aec4a1
|
||||
F test/numindex1.test 20a5450d4b056e48cd5db30e659f13347a099823
|
||||
F test/offset1.test f06b83657bcf26f9ce805e67450e189e282143b2
|
||||
F test/offset1.test 72cca52482cbd5bc687cfa67aa2566c859081b5a353fd2f9da9bbd3914dea1ef
|
||||
F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394
|
||||
F test/optfuzz-db01.c 9f2fa80b8f84ebbf1f2e8b13421a4e0477fe300f6686fbd76cac1d2db66e0fdc
|
||||
F test/optfuzz-db01.txt 21f6bdeadc701cf11528276e2a55c70bfcb846ba42df327f979bd9e7b6ce7041
|
||||
@@ -1313,7 +1329,6 @@ F test/pagerfault2.test caf4c7facb914fd3b03a17b31ae2b180c8d6ca1f
|
||||
F test/pagerfault3.test 1003fcda009bf48a8e22a516e193b6ef0dd1bbd8
|
||||
F test/pageropt.test 84e4cc5cbca285357f7906e99b21be4f2bf5abc0
|
||||
F test/pagesize.test 5769fc62d8c890a83a503f67d47508dfdc543305
|
||||
F test/parser1.test 6ccdf5e459a5dc4673d3273dc311a7e9742ca952dd0551a6a6320d27035ce4b3
|
||||
F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
|
||||
F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
|
||||
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
|
||||
@@ -1342,7 +1357,7 @@ F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df
|
||||
F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736
|
||||
F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8
|
||||
F test/recover.test ccb8c2623902a92ebb76770edd075cb4f75a4760bb7afde38026572c6e79070d
|
||||
F test/regexp1.test 0c3ff80f66b0eff80e623eb5db7a3dad512095c573d78ac23009785f6d8f51ce
|
||||
F test/regexp1.test 4a44e014664a109bbb1c37d29d9b61ca5aa5a7f49cc564c95208a80f818e3377
|
||||
F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed1368b5
|
||||
F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d
|
||||
F test/releasetest_data.tcl 11ba48a21ed1c808147b0e77c6e93d204577f4327ffe6d7c3b34cd3c01eac3a2
|
||||
@@ -1357,7 +1372,7 @@ F test/round1.test 768018b04522ca420b1aba8a24bd76091d269f3bce3902af3ec6ebcee41ab
|
||||
F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc
|
||||
F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81
|
||||
F test/rowid.test e29025be95baf6b32f0d5edef59a7633028325896a98f1caa8019559ca910350
|
||||
F test/rowvalue.test ff1ffa31cebe12feb6f989e09263f3b1e8c560db94b40fe006126a8435fd6832
|
||||
F test/rowvalue.test baf4fa3ec1a8c1c920c3faa5fd25959cb454bbd99ac8960397c34549d9fc4abe
|
||||
F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b
|
||||
F test/rowvalue3.test 1347e25ca11c547c5a6ff0cc5626f95aa9740e9275bfaec096029f57cb2130ce
|
||||
F test/rowvalue4.test 441e7e366ac6d939a3a95a574031c56ec2a854077a91d66eee5ff1d86cb5be58
|
||||
@@ -1390,7 +1405,7 @@ F test/securedel.test 2f70b2449186a1921bd01ec9da407fbfa98c3a7a5521854c300c194b2f
|
||||
F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5
|
||||
F test/select1.test 692e84cfa29c405854c69e8a4027183d64c22952866a123fabbce741a379e889
|
||||
F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56
|
||||
F test/select3.test 399a0b23f8618bfe07ea24fb67f2952f620d6eba662bccabf6f4f71c2d89e6c9
|
||||
F test/select3.test ce4f78bbc809b0513f960f1ee84cdbc5af50ba112c343d5266558a8b2468f656
|
||||
F test/select4.test f0684d3da3bccacbe2a1ebadf6fb49d9df6f53acb4c6ebc228a88d0d6054cc7b
|
||||
F test/select5.test 8afc5e5dcdebc2be54472e73ebd9cd1adef1225fd15d37a1c62f969159f390ae
|
||||
F test/select6.test 9b2fb4ffedf52e1b5703cfcae1212e7a4a063f014c0458d78d29aca3db766d1f
|
||||
@@ -1691,6 +1706,7 @@ F test/triggerG.test 2b816093c91ba73c733cfa8aedcc210ad819d72a98b1da30768a3c56505
|
||||
F test/triggerupfrom.test d1f9e56090408115c522bee626cc33a2f3370f627a5e341d832589d72e3aa271
|
||||
F test/trustschema1.test 4e970aef0bfe0cee139703cc7209d0e0f07725d999b180ba50770f49edef1494
|
||||
F test/tt3_checkpoint.c ac7ca661d739280c89d9c253897df64a59a49369bd1247207ac0f655b622579d
|
||||
F test/tt3_core.c 8cd89ead95410f70e7fb02c79f1e040f9c5ad5cf
|
||||
F test/tt3_index.c 39eec10a35f57672225be4d182862152896dee4a
|
||||
F test/tt3_lookaside1.c 0377e202c3c2a50d688cb65ba203afeda6fafeb9
|
||||
F test/tt3_shared.c b37d22defc944a2ac4c91c927fd06c1d48cd51e2ce9d004fe868625bd2399f93
|
||||
@@ -1764,7 +1780,7 @@ F test/vtabdistinct.test 7688f0889358f849fd60bbfde1ded38b014b18066076d4bfbb75395
|
||||
F test/vtabdrop.test 65d4cf6722972e5499bdaf0c0d70ee3b8133944a4e4bc31862563f32a7edca12
|
||||
F test/vtabrhs1.test 9b5ecbc74a689500c33a4b2b36761f9bcc22fcc4e3f9d21066ee0c9c74cf5f6c
|
||||
F test/wal.test b7cc6984709f54afbf8441747ced1f646af120bf0c1b1d847bfa39306fbea089
|
||||
F test/wal2.test 31f6e2c404b9f2cdf9ca19b105a1742fdc19653c2c936da39e3658c617524046
|
||||
F test/wal2.test 88d34cc62bf5460ad6b1f837cd56ab55731bb0637ff99e113b790873d9b60b14
|
||||
F test/wal3.test 2a93004bc0fb2b5c29888964024695bade278ab2
|
||||
F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
|
||||
F test/wal5.test 9c11da7aeccd83a46d79a556ad11a18d3cb15aa9
|
||||
@@ -1773,7 +1789,7 @@ F test/wal64k.test 2a525c0f45d709bae3765c71045ccec5df7d100ccbd3a7860fdba46c9addb
|
||||
F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd
|
||||
F test/wal8.test d9df3fba4caad5854ed69ed673c68482514203c8
|
||||
F test/wal9.test 378e76a9ad09cd9bee06c172ad3547b0129a6750
|
||||
F test/wal_common.tcl a98f17fba96206122eff624db0ab13ec377be4fe
|
||||
F test/wal_common.tcl 37902864b63794e9bf59393b8887e21a9cbd4db8
|
||||
F test/walbak.test 018d4e5a3d45c6298d11b99f09a8ef6876527946
|
||||
F test/walbig.test f437473a16cfb314867c6b5d1dbcd519e73e3434
|
||||
F test/walblock.test be48f3a75eff0b4456209f26b3ce186c2015497d
|
||||
@@ -1911,7 +1927,7 @@ F tool/mkmsvcmin.tcl 6ecab9fe22c2c8de4d82d4c46797bda3d2deac8e763885f5a38d0c44a89
|
||||
F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef
|
||||
F tool/mkopcodeh.tcl 5dab48c49a25452257494e9601702ab63adaba6bd54a9b382615fa52661c8f8c
|
||||
F tool/mkopts.tcl 680f785fdb09729fd9ac50632413da4eadbdf9071535e3f26d03795828ab07fa
|
||||
F tool/mkpragmatab.tcl bd07bd59d45d0f3448e123d6937e9811195f9908a51e09d774609883055bfd3d
|
||||
F tool/mkpragmatab.tcl 8dcba40365eceba24f059d82bbc8b61bb647d5a0b8076f24a1876872a1b58832
|
||||
F tool/mkshellc.tcl df5d249617f9cc94d5c48eb0401673eb3f31f383ecbc54e8a13ca3dd97e89450
|
||||
F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9
|
||||
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
|
||||
@@ -1978,11 +1994,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P cd6254fcd32798f7be4e6d827597ddaa2e46ac6e2f0149cd3a3be0416fa18835
|
||||
R 4b3e64a86ee9acaa4f97f1ab6ad6f3ae
|
||||
T +sym-major-release *
|
||||
T +sym-release *
|
||||
T +sym-version-3.39.0 *
|
||||
P fb45624a319ed56268749d584839fa0a3c35d331513ca41451438dda988f9df8 4635f4a69c8c2a8df242b384a992aea71224e39a2ccab42d8c0b0602f1e826e8
|
||||
R 775b113344ca9d46da4fdca9c2001a8a
|
||||
T *branch * begin-concurrent-3.39
|
||||
T *sym-begin-concurrent-3.39 *
|
||||
T -sym-begin-concurrent *
|
||||
U drh
|
||||
Z f64bfe891f96e530fe80668f0f22f84a
|
||||
Z 7c3f404c7741cbf959d90f4576dc159f
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
14e166f40dbfa6e055543f8301525f2ca2e96a02a57269818b9e69e162e98918
|
||||
31304de83ef1dbb186f1776a57eee3f1185f23870352ea4e7e50d204a812fb9c
|
||||
@@ -171,6 +171,12 @@ int sqlite3BitvecSet(Bitvec *p, u32 i){
|
||||
if( p==0 ) return SQLITE_OK;
|
||||
assert( i>0 );
|
||||
assert( i<=p->iSize );
|
||||
if( i>p->iSize || i==0 ){
|
||||
sqlite3_log(SQLITE_ERROR,
|
||||
"Bitvec: setting bit %d of bitvec size %d\n", (int)i, (int)p->iSize
|
||||
);
|
||||
abort();
|
||||
}
|
||||
i--;
|
||||
while((p->iSize > BITVEC_NBIT) && p->iDivisor) {
|
||||
u32 bin = i/p->iDivisor;
|
||||
|
||||
+612
-42
@@ -480,7 +480,240 @@ static void downgradeAllSharedCacheTableLocks(Btree *p){
|
||||
|
||||
#endif /* SQLITE_OMIT_SHARED_CACHE */
|
||||
|
||||
static void releasePage(MemPage *pPage); /* Forward reference */
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
/*
|
||||
** The following structure - BtreePtrmap - stores the in-memory pointer map
|
||||
** used for newly allocated pages in CONCURRENT transactions. Such pages are
|
||||
** always allocated in a contiguous block (from the end of the file) starting
|
||||
** with page BtreePtrmap.iFirst.
|
||||
*/
|
||||
typedef struct RollbackEntry RollbackEntry;
|
||||
typedef struct PtrmapEntry PtrmapEntry;
|
||||
struct PtrmapEntry {
|
||||
Pgno parent;
|
||||
u8 eType;
|
||||
};
|
||||
struct RollbackEntry {
|
||||
Pgno pgno;
|
||||
Pgno parent;
|
||||
u8 eType;
|
||||
};
|
||||
struct BtreePtrmap {
|
||||
Pgno iFirst; /* First new page number aPtr[0] */
|
||||
|
||||
int nPtrAlloc; /* Allocated size of aPtr[] array */
|
||||
PtrmapEntry *aPtr; /* Array of parent page numbers */
|
||||
|
||||
int nSvpt; /* Used size of aSvpt[] array */
|
||||
int nSvptAlloc; /* Allocated size of aSvpt[] */
|
||||
int *aSvpt; /* First aRollback[] entry for savepoint i */
|
||||
|
||||
int nRollback; /* Used size of aRollback[] array */
|
||||
int nRollbackAlloc; /* Allocated size of aRollback[] array */
|
||||
RollbackEntry *aRollback; /* Array of rollback entries */
|
||||
};
|
||||
|
||||
/* !defined(SQLITE_OMIT_CONCURRENT)
|
||||
**
|
||||
** If page number pgno is greater than or equal to BtreePtrmap.iFirst,
|
||||
** store an entry for it in the pointer-map structure.
|
||||
*/
|
||||
static int btreePtrmapStore(
|
||||
BtShared *pBt,
|
||||
Pgno pgno,
|
||||
u8 eType,
|
||||
Pgno parent
|
||||
){
|
||||
BtreePtrmap *pMap = pBt->pMap;
|
||||
if( pgno>=pMap->iFirst ){
|
||||
int iEntry = pgno - pMap->iFirst;
|
||||
|
||||
/* Grow the aPtr[] array as required */
|
||||
while( iEntry>=pMap->nPtrAlloc ){
|
||||
int nNew = pMap->nPtrAlloc ? pMap->nPtrAlloc*2 : 16;
|
||||
PtrmapEntry *aNew = (PtrmapEntry*)sqlite3_realloc(
|
||||
pMap->aPtr, nNew*sizeof(PtrmapEntry)
|
||||
);
|
||||
if( aNew==0 ){
|
||||
return SQLITE_NOMEM;
|
||||
}else{
|
||||
int nByte = (nNew-pMap->nPtrAlloc)*sizeof(PtrmapEntry);
|
||||
memset(&aNew[pMap->nPtrAlloc], 0, nByte);
|
||||
pMap->aPtr = aNew;
|
||||
pMap->nPtrAlloc = nNew;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add an entry to the rollback log if required */
|
||||
if( pMap->nSvpt>0 && pMap->aPtr[iEntry].parent ){
|
||||
if( pMap->nRollback>=pMap->nRollbackAlloc ){
|
||||
int nNew = pMap->nRollback ? pMap->nRollback*2 : 16;
|
||||
RollbackEntry *aNew = (RollbackEntry*)sqlite3_realloc(
|
||||
pMap->aRollback, nNew*sizeof(RollbackEntry)
|
||||
);
|
||||
if( aNew==0 ){
|
||||
return SQLITE_NOMEM;
|
||||
}else{
|
||||
pMap->aRollback = aNew;
|
||||
pMap->nRollbackAlloc = nNew;
|
||||
}
|
||||
}
|
||||
|
||||
pMap->aRollback[pMap->nRollback].pgno = pgno;
|
||||
pMap->aRollback[pMap->nRollback].parent = pMap->aPtr[iEntry].parent;
|
||||
pMap->aRollback[pMap->nRollback].eType = pMap->aPtr[iEntry].eType;
|
||||
pMap->nRollback++;
|
||||
}
|
||||
|
||||
/* Update the aPtr[] array */
|
||||
pMap->aPtr[iEntry].parent = parent;
|
||||
pMap->aPtr[iEntry].eType = eType;
|
||||
}
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/* !defined(SQLITE_OMIT_CONCURRENT)
|
||||
**
|
||||
** Open savepoint iSavepoint, if it is not already open.
|
||||
*/
|
||||
static int btreePtrmapBegin(BtShared *pBt, int nSvpt){
|
||||
BtreePtrmap *pMap = pBt->pMap;
|
||||
if( pMap && nSvpt>pMap->nSvpt ){
|
||||
int i;
|
||||
if( nSvpt>=pMap->nSvptAlloc ){
|
||||
int nNew = pMap->nSvptAlloc ? pMap->nSvptAlloc*2 : 16;
|
||||
int *aNew = sqlite3_realloc(pMap->aSvpt, sizeof(int) * nNew);
|
||||
if( aNew==0 ){
|
||||
return SQLITE_NOMEM;
|
||||
}else{
|
||||
pMap->aSvpt = aNew;
|
||||
pMap->nSvptAlloc = nNew;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=pMap->nSvpt; i<nSvpt; i++){
|
||||
pMap->aSvpt[i] = pMap->nRollback;
|
||||
}
|
||||
pMap->nSvpt = nSvpt;
|
||||
}
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/* !defined(SQLITE_OMIT_CONCURRENT)
|
||||
**
|
||||
** Rollback (if op==SAVEPOINT_ROLLBACK) or release (if op==SAVEPOINT_RELEASE)
|
||||
** savepoint iSvpt.
|
||||
*/
|
||||
static void btreePtrmapEnd(BtShared *pBt, int op, int iSvpt){
|
||||
BtreePtrmap *pMap = pBt->pMap;
|
||||
if( pMap ){
|
||||
assert( op==SAVEPOINT_ROLLBACK || op==SAVEPOINT_RELEASE );
|
||||
assert( iSvpt>=0 || (iSvpt==-1 && op==SAVEPOINT_ROLLBACK) );
|
||||
if( iSvpt<0 ){
|
||||
pMap->nSvpt = 0;
|
||||
pMap->nRollback = 0;
|
||||
memset(pMap->aPtr, 0, sizeof(Pgno) * pMap->nPtrAlloc);
|
||||
}else if( iSvpt<pMap->nSvpt ){
|
||||
if( op==SAVEPOINT_ROLLBACK ){
|
||||
int ii;
|
||||
for(ii=pMap->nRollback-1; ii>=pMap->aSvpt[iSvpt]; ii--){
|
||||
RollbackEntry *p = &pMap->aRollback[ii];
|
||||
PtrmapEntry *pEntry = &pMap->aPtr[p->pgno - pMap->iFirst];
|
||||
pEntry->parent = p->parent;
|
||||
pEntry->eType = p->eType;
|
||||
}
|
||||
}
|
||||
pMap->nSvpt = iSvpt + (op==SAVEPOINT_ROLLBACK);
|
||||
pMap->nRollback = pMap->aSvpt[iSvpt];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* !defined(SQLITE_OMIT_CONCURRENT)
|
||||
**
|
||||
** This function is called after an CONCURRENT transaction is opened on the
|
||||
** database. It allocates the BtreePtrmap structure used to track pointers
|
||||
** to allocated pages and zeroes the nFree/iTrunk fields in the database
|
||||
** header on page 1.
|
||||
*/
|
||||
static int btreePtrmapAllocate(BtShared *pBt){
|
||||
int rc = SQLITE_OK;
|
||||
if( pBt->pMap==0 ){
|
||||
BtreePtrmap *pMap = sqlite3_malloc(sizeof(BtreePtrmap));
|
||||
if( pMap==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
}else{
|
||||
memset(&pBt->pPage1->aData[32], 0, sizeof(u32)*2);
|
||||
memset(pMap, 0, sizeof(BtreePtrmap));
|
||||
pMap->iFirst = pBt->nPage + 1;
|
||||
pBt->pMap = pMap;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* !defined(SQLITE_OMIT_CONCURRENT)
|
||||
**
|
||||
** Free any BtreePtrmap structure allocated by an earlier call to
|
||||
** btreePtrmapAllocate().
|
||||
*/
|
||||
static void btreePtrmapDelete(BtShared *pBt){
|
||||
BtreePtrmap *pMap = pBt->pMap;
|
||||
if( pMap ){
|
||||
sqlite3_free(pMap->aRollback);
|
||||
sqlite3_free(pMap->aPtr);
|
||||
sqlite3_free(pMap->aSvpt);
|
||||
sqlite3_free(pMap);
|
||||
pBt->pMap = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Check that the pointer-map does not contain any entries with a parent
|
||||
** page of 0. Call sqlite3_log() multiple times to output the entire
|
||||
** data structure if it does.
|
||||
*/
|
||||
static void btreePtrmapCheck(BtShared *pBt, Pgno nPage){
|
||||
Pgno i;
|
||||
int bProblem = 0;
|
||||
BtreePtrmap *p = pBt->pMap;
|
||||
|
||||
for(i=p->iFirst; i<=nPage; i++){
|
||||
PtrmapEntry *pEntry = &p->aPtr[i-p->iFirst];
|
||||
if( pEntry->eType==PTRMAP_OVERFLOW1
|
||||
|| pEntry->eType==PTRMAP_OVERFLOW2
|
||||
|| pEntry->eType==PTRMAP_BTREE
|
||||
){
|
||||
if( pEntry->parent==0 ){
|
||||
bProblem = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( bProblem ){
|
||||
for(i=p->iFirst; i<=nPage; i++){
|
||||
PtrmapEntry *pEntry = &p->aPtr[i-p->iFirst];
|
||||
sqlite3_log(SQLITE_CORRUPT,
|
||||
"btreePtrmapCheck: pgno=%d eType=%d parent=%d",
|
||||
(int)i, (int)pEntry->eType, (int)pEntry->parent
|
||||
);
|
||||
}
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
#else /* SQLITE_OMIT_CONCURRENT */
|
||||
# define btreePtrmapAllocate(x) SQLITE_OK
|
||||
# define btreePtrmapDelete(x)
|
||||
# define btreePtrmapBegin(x,y) SQLITE_OK
|
||||
# define btreePtrmapEnd(x,y,z)
|
||||
# define btreePtrmapCheck(y,z)
|
||||
#endif /* SQLITE_OMIT_CONCURRENT */
|
||||
|
||||
static void releasePage(MemPage *pPage); /* Forward reference */
|
||||
static void releasePageOne(MemPage *pPage); /* Forward reference */
|
||||
static void releasePageNotNull(MemPage *pPage); /* Forward reference */
|
||||
|
||||
@@ -1005,6 +1238,13 @@ static void ptrmapPut(BtShared *pBt, Pgno key, u8 eType, Pgno parent, int *pRC){
|
||||
/* The super-journal page number must never be used as a pointer map page */
|
||||
assert( 0==PTRMAP_ISPAGE(pBt, PENDING_BYTE_PAGE(pBt)) );
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
if( pBt->pMap ){
|
||||
*pRC = btreePtrmapStore(pBt, key, eType, parent);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
assert( pBt->autoVacuum );
|
||||
if( key==0 ){
|
||||
*pRC = SQLITE_CORRUPT_BKPT;
|
||||
@@ -2315,6 +2555,17 @@ getAndInitPage_error1:
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
/*
|
||||
** Set the value of the MemPage.pgnoRoot variable, if it exists.
|
||||
*/
|
||||
static void setMempageRoot(MemPage *pPg, u32 pgnoRoot){
|
||||
pPg->pgnoRoot = pgnoRoot;
|
||||
}
|
||||
#else
|
||||
# define setMempageRoot(x,y)
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Release a MemPage. This should be called once for each prior
|
||||
** call to btreeGetPage.
|
||||
@@ -3493,6 +3744,7 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){
|
||||
BtShared *pBt = p->pBt;
|
||||
Pager *pPager = pBt->pPager;
|
||||
int rc = SQLITE_OK;
|
||||
int bConcurrent = (p->db->eConcurrent && !ISAUTOVACUUM);
|
||||
|
||||
sqlite3BtreeEnter(p);
|
||||
btreeIntegrity(p);
|
||||
@@ -3580,7 +3832,8 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){
|
||||
if( (pBt->btsFlags & BTS_READ_ONLY)!=0 ){
|
||||
rc = SQLITE_READONLY;
|
||||
}else{
|
||||
rc = sqlite3PagerBegin(pPager, wrflag>1, sqlite3TempInMemory(p->db));
|
||||
int exFlag = bConcurrent ? -1 : (wrflag>1);
|
||||
rc = sqlite3PagerBegin(pPager, exFlag, sqlite3TempInMemory(p->db));
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = newDatabase(pBt);
|
||||
}else if( rc==SQLITE_BUSY_SNAPSHOT && pBt->inTransaction==TRANS_NONE ){
|
||||
@@ -3644,6 +3897,15 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag, int *pSchemaVersion){
|
||||
}
|
||||
|
||||
trans_begun:
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
if( bConcurrent && rc==SQLITE_OK && sqlite3PagerIsWal(pBt->pPager) ){
|
||||
rc = sqlite3PagerBeginConcurrent(pBt->pPager);
|
||||
if( rc==SQLITE_OK && wrflag ){
|
||||
rc = btreePtrmapAllocate(pBt);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
if( pSchemaVersion ){
|
||||
*pSchemaVersion = get4byte(&pBt->pPage1->aData[40]);
|
||||
@@ -3653,7 +3915,11 @@ trans_begun:
|
||||
** open savepoints. If the second parameter is greater than 0 and
|
||||
** the sub-journal is not already open, then it will be opened here.
|
||||
*/
|
||||
rc = sqlite3PagerOpenSavepoint(pPager, p->db->nSavepoint);
|
||||
int nSavepoint = p->db->nSavepoint;
|
||||
rc = sqlite3PagerOpenSavepoint(pPager, nSavepoint);
|
||||
if( rc==SQLITE_OK && nSavepoint ){
|
||||
rc = btreePtrmapBegin(pBt, nSavepoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4118,6 +4384,175 @@ static int autoVacuumCommit(Btree *p){
|
||||
# define setChildPtrmaps(x) SQLITE_OK
|
||||
#endif
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
/*
|
||||
** This function is called as part of merging an CONCURRENT transaction with
|
||||
** the snapshot at the head of the wal file. It relocates all pages in the
|
||||
** range iFirst..iLast, inclusive. It is assumed that the BtreePtrmap
|
||||
** structure at BtShared.pMap contains the location of the pointers to each
|
||||
** page in the range.
|
||||
**
|
||||
** If pnCurrent is NULL, then all pages in the range are moved to currently
|
||||
** free locations (i.e. free-list entries) within the database file before page
|
||||
** iFirst.
|
||||
**
|
||||
** Or, if pnCurrent is not NULL, then it points to a value containing the
|
||||
** current size of the database file in pages. In this case, all pages are
|
||||
** relocated to the end of the database file - page iFirst is relocated to
|
||||
** page (*pnCurrent+1), page iFirst+1 to page (*pnCurrent+2), and so on.
|
||||
** Value *pnCurrent is set to the new size of the database before this
|
||||
** function returns.
|
||||
**
|
||||
** If no error occurs, SQLITE_OK is returned. Otherwise, an SQLite error code.
|
||||
*/
|
||||
static int btreeRelocateRange(
|
||||
BtShared *pBt, /* B-tree handle */
|
||||
Pgno iFirst, /* First page to relocate */
|
||||
Pgno iLast, /* Last page to relocate */
|
||||
Pgno *pnCurrent /* If not NULL, IN/OUT: Database size */
|
||||
){
|
||||
int rc = SQLITE_OK;
|
||||
BtreePtrmap *pMap = pBt->pMap;
|
||||
Pgno iPg;
|
||||
|
||||
for(iPg=iFirst; iPg<=iLast && rc==SQLITE_OK; iPg++){
|
||||
MemPage *pFree = 0; /* Page allocated from free-list */
|
||||
MemPage *pPg = 0;
|
||||
Pgno iNew; /* New page number for pPg */
|
||||
PtrmapEntry *pEntry; /* Pointer map entry for page iPg */
|
||||
|
||||
if( iPg==PENDING_BYTE_PAGE(pBt) ) continue;
|
||||
pEntry = &pMap->aPtr[iPg - pMap->iFirst];
|
||||
|
||||
if( pEntry->eType==PTRMAP_FREEPAGE ){
|
||||
Pgno dummy;
|
||||
rc = allocateBtreePage(pBt, &pFree, &dummy, iPg, BTALLOC_EXACT);
|
||||
if( pFree ){
|
||||
assert( sqlite3PagerPageRefcount(pFree->pDbPage)==1 );
|
||||
sqlite3PcacheDrop(pFree->pDbPage);
|
||||
}
|
||||
assert( rc!=SQLITE_OK || dummy==iPg );
|
||||
}else if( pnCurrent ){
|
||||
btreeGetPage(pBt, iPg, &pPg, 0);
|
||||
assert( sqlite3PagerIswriteable(pPg->pDbPage) );
|
||||
assert( sqlite3PagerPageRefcount(pPg->pDbPage)==1 );
|
||||
iNew = ++(*pnCurrent);
|
||||
if( iNew==PENDING_BYTE_PAGE(pBt) ) iNew = ++(*pnCurrent);
|
||||
rc = relocatePage(pBt, pPg, pEntry->eType, pEntry->parent, iNew, 1);
|
||||
releasePageNotNull(pPg);
|
||||
}else{
|
||||
rc = allocateBtreePage(pBt, &pFree, &iNew, iFirst-1, BTALLOC_LE);
|
||||
assert( rc!=SQLITE_OK || iNew<iFirst );
|
||||
if( rc==SQLITE_OK ){
|
||||
releasePage(pFree);
|
||||
btreeGetPage(pBt, iPg, &pPg, 0);
|
||||
rc = relocatePage(pBt, pPg, pEntry->eType, pEntry->parent,iNew,1);
|
||||
releasePage(pPg);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* !defined(SQLITE_OMIT_CONCURRENT)
|
||||
**
|
||||
** The b-tree handle passed as the only argument is about to commit an
|
||||
** CONCURRENT transaction. At this point it is guaranteed that this is
|
||||
** possible - the wal WRITER lock is held and it is known that there are
|
||||
** no conflicts with committed transactions.
|
||||
*/
|
||||
static int btreeFixUnlocked(Btree *p){
|
||||
BtShared *pBt = p->pBt;
|
||||
MemPage *pPage1 = pBt->pPage1;
|
||||
u8 *p1 = pPage1->aData;
|
||||
Pager *pPager = pBt->pPager;
|
||||
int rc = SQLITE_OK;
|
||||
|
||||
/* If page 1 of the database is not writable, then no pages were allocated
|
||||
** or freed by this transaction. In this case no special handling is
|
||||
** required. Otherwise, if page 1 is dirty, proceed. */
|
||||
BtreePtrmap *pMap = pBt->pMap;
|
||||
Pgno iTrunk = get4byte(&p1[32]);
|
||||
Pgno nPage = btreePagecount(pBt);
|
||||
u32 nFree = get4byte(&p1[36]);
|
||||
|
||||
assert( pBt->pMap );
|
||||
rc = sqlite3PagerUpgradeSnapshot(pPager, pPage1->pDbPage);
|
||||
assert( p1==pPage1->aData );
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
Pgno nHPage = get4byte(&p1[28]);
|
||||
Pgno nFin = nHPage; /* Size of db after transaction merge */
|
||||
|
||||
if( sqlite3PagerIswriteable(pPage1->pDbPage) ){
|
||||
Pgno iHTrunk = get4byte(&p1[32]);
|
||||
u32 nHFree = get4byte(&p1[36]);
|
||||
|
||||
btreePtrmapCheck(pBt, nPage);
|
||||
|
||||
/* Attach the head database free list to the end of the current
|
||||
** transactions free-list (if any). */
|
||||
if( iTrunk!=0 ){
|
||||
put4byte(&p1[36], nHFree + nFree);
|
||||
put4byte(&p1[32], iTrunk);
|
||||
while( iTrunk ){
|
||||
DbPage *pTrunk = sqlite3PagerLookup(pPager, iTrunk);
|
||||
iTrunk = get4byte((u8*)pTrunk->pData);
|
||||
if( iTrunk==0 ){
|
||||
put4byte((u8*)pTrunk->pData, iHTrunk);
|
||||
}
|
||||
sqlite3PagerUnref(pTrunk);
|
||||
};
|
||||
}
|
||||
|
||||
if( nHPage<(pMap->iFirst-1) ){
|
||||
/* The database consisted of (pMap->iFirst-1) pages when the current
|
||||
** concurrent transaction was opened. And an concurrent transaction may
|
||||
** not be executed on an auto-vacuum database - so the db should
|
||||
** not have shrunk since the transaction was opened. Therefore nHPage
|
||||
** should be set to (pMap->iFirst-1) or greater. */
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
}else{
|
||||
/* The current transaction allocated pages pMap->iFirst through
|
||||
** nPage (inclusive) at the end of the database file. Meanwhile,
|
||||
** other transactions have allocated (iFirst..nHPage). So move
|
||||
** pages (iFirst..MIN(nPage,nHPage)) to (MAX(nPage,nHPage)+1). */
|
||||
Pgno iLast = MIN(nPage, nHPage); /* Last page to move */
|
||||
Pgno nCurrent; /* Current size of db */
|
||||
|
||||
nCurrent = MAX(nPage, nHPage);
|
||||
pBt->nPage = nCurrent;
|
||||
rc = btreeRelocateRange(pBt, pMap->iFirst, iLast, &nCurrent);
|
||||
|
||||
/* There are now no collisions with the snapshot at the head of the
|
||||
** database file. So at this point it would be possible to write
|
||||
** the transaction out to disk. Before doing so though, attempt to
|
||||
** relocate some of the new pages to free locations within the body
|
||||
** of the database file (i.e. free-list entries). */
|
||||
if( rc==SQLITE_OK ){
|
||||
assert( nCurrent!=PENDING_BYTE_PAGE(pBt) );
|
||||
sqlite3PagerSetDbsize(pBt->pPager, nCurrent);
|
||||
nFree = get4byte(&p1[36]);
|
||||
nFin = nCurrent-nFree;
|
||||
if( nCurrent>PENDING_BYTE_PAGE(pBt) && nFin<=PENDING_BYTE_PAGE(pBt) ){
|
||||
nFin--;
|
||||
}
|
||||
nFin = MAX(nFin, nHPage);
|
||||
rc = btreeRelocateRange(pBt, nFin+1, nCurrent, 0);
|
||||
}
|
||||
|
||||
put4byte(&p1[28], nFin);
|
||||
}
|
||||
}
|
||||
sqlite3PagerSetDbsize(pPager, nFin);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
#else
|
||||
# define btreeFixUnlocked(X) SQLITE_OK
|
||||
#endif /* SQLITE_OMIT_CONCURRENT */
|
||||
|
||||
/*
|
||||
** This routine does the first phase of a two-phase commit. This routine
|
||||
** causes a rollback journal to be created (if it does not already exist)
|
||||
@@ -4149,8 +4584,10 @@ int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zSuperJrnl){
|
||||
if( p->inTrans==TRANS_WRITE ){
|
||||
BtShared *pBt = p->pBt;
|
||||
sqlite3BtreeEnter(p);
|
||||
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
if( pBt->autoVacuum ){
|
||||
assert( ISCONCURRENT==0 );
|
||||
rc = autoVacuumCommit(p);
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqlite3BtreeLeave(p);
|
||||
@@ -4161,7 +4598,12 @@ int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zSuperJrnl){
|
||||
sqlite3PagerTruncateImage(pBt->pPager, pBt->nPage);
|
||||
}
|
||||
#endif
|
||||
rc = sqlite3PagerCommitPhaseOne(pBt->pPager, zSuperJrnl, 0);
|
||||
if( rc==SQLITE_OK && ISCONCURRENT && p->db->eConcurrent==CONCURRENT_OPEN ){
|
||||
rc = btreeFixUnlocked(p);
|
||||
}
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3PagerCommitPhaseOne(pBt->pPager, zSuperJrnl, 0);
|
||||
}
|
||||
sqlite3BtreeLeave(p);
|
||||
}
|
||||
return rc;
|
||||
@@ -4204,6 +4646,11 @@ static void btreeEndTransaction(Btree *p){
|
||||
unlockBtreeIfUnused(pBt);
|
||||
}
|
||||
|
||||
/* If this was an CONCURRENT transaction, delete the pBt->pMap object.
|
||||
** Also call PagerEndConcurrent() to ensure that the pager has discarded
|
||||
** the record of all pages read within the transaction. */
|
||||
btreePtrmapDelete(pBt);
|
||||
sqlite3PagerEndConcurrent(pBt->pPager);
|
||||
btreeIntegrity(p);
|
||||
}
|
||||
|
||||
@@ -4433,6 +4880,9 @@ int sqlite3BtreeBeginStmt(Btree *p, int iStatement){
|
||||
** such savepoints while the statement transaction savepoint is active.
|
||||
*/
|
||||
rc = sqlite3PagerOpenSavepoint(pBt->pPager, iStatement);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = btreePtrmapBegin(pBt, iStatement);
|
||||
}
|
||||
sqlite3BtreeLeave(p);
|
||||
return rc;
|
||||
}
|
||||
@@ -4456,6 +4906,7 @@ int sqlite3BtreeSavepoint(Btree *p, int op, int iSavepoint){
|
||||
assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );
|
||||
assert( iSavepoint>=0 || (iSavepoint==-1 && op==SAVEPOINT_ROLLBACK) );
|
||||
sqlite3BtreeEnter(p);
|
||||
btreePtrmapEnd(pBt, op, iSavepoint);
|
||||
if( op==SAVEPOINT_ROLLBACK ){
|
||||
rc = saveAllCursors(pBt, 0, 0);
|
||||
}
|
||||
@@ -5254,6 +5705,7 @@ const void *sqlite3BtreePayloadFetch(BtCursor *pCur, u32 *pAmt){
|
||||
*/
|
||||
static int moveToChild(BtCursor *pCur, u32 newPgno){
|
||||
BtShared *pBt = pCur->pBt;
|
||||
int rc;
|
||||
|
||||
assert( cursorOwnsBtShared(pCur) );
|
||||
assert( pCur->eState==CURSOR_VALID );
|
||||
@@ -5268,7 +5720,12 @@ static int moveToChild(BtCursor *pCur, u32 newPgno){
|
||||
pCur->apPage[pCur->iPage] = pCur->pPage;
|
||||
pCur->ix = 0;
|
||||
pCur->iPage++;
|
||||
return getAndInitPage(pBt, newPgno, &pCur->pPage, pCur, pCur->curPagerFlags);
|
||||
rc = getAndInitPage(pBt, newPgno, &pCur->pPage,
|
||||
pCur, pCur->curPagerFlags);
|
||||
if( rc==SQLITE_OK ){
|
||||
setMempageRoot(pCur->pPage, pCur->pgnoRoot);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
@@ -5380,6 +5837,7 @@ static int moveToRoot(BtCursor *pCur){
|
||||
pCur->eState = CURSOR_INVALID;
|
||||
return rc;
|
||||
}
|
||||
setMempageRoot(pCur->pPage, pCur->pgnoRoot);
|
||||
pCur->iPage = 0;
|
||||
pCur->curIntKey = pCur->pPage->intKey;
|
||||
}
|
||||
@@ -6262,7 +6720,7 @@ static int allocateBtreePage(
|
||||
Pgno mxPage; /* Total size of the database file */
|
||||
|
||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||
assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );
|
||||
assert( eMode==BTALLOC_ANY || (nearby>0 && REQUIRE_PTRMAP ) );
|
||||
pPage1 = pBt->pPage1;
|
||||
mxPage = btreePagecount(pBt);
|
||||
/* EVIDENCE-OF: R-05119-02637 The 4-byte big-endian integer at offset 36
|
||||
@@ -6272,6 +6730,15 @@ static int allocateBtreePage(
|
||||
if( n>=mxPage ){
|
||||
return SQLITE_CORRUPT_BKPT;
|
||||
}
|
||||
|
||||
/* Ensure page 1 is writable. This function will either change the number
|
||||
** of pages in the free-list or the size of the database file. Since both
|
||||
** of these operations involve modifying page 1 header fields, page 1
|
||||
** will definitely be written by this transaction. If this is an CONCURRENT
|
||||
** transaction, ensure the BtreePtrmap structure has been allocated. */
|
||||
rc = sqlite3PagerWrite(pPage1->pDbPage);
|
||||
if( rc ) return rc;
|
||||
|
||||
if( n>0 ){
|
||||
/* There are pages on the freelist. Reuse one of those pages. */
|
||||
Pgno iTrunk;
|
||||
@@ -6282,28 +6749,29 @@ static int allocateBtreePage(
|
||||
** shows that the page 'nearby' is somewhere on the free-list, then
|
||||
** the entire-list will be searched for that page.
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
if( eMode==BTALLOC_EXACT ){
|
||||
if( nearby<=mxPage ){
|
||||
u8 eType;
|
||||
assert( nearby>0 );
|
||||
assert( pBt->autoVacuum );
|
||||
rc = ptrmapGet(pBt, nearby, &eType, 0);
|
||||
if( rc ) return rc;
|
||||
if( eType==PTRMAP_FREEPAGE ){
|
||||
searchList = 1;
|
||||
assert( ISAUTOVACUUM!=ISCONCURRENT );
|
||||
if( ISAUTOVACUUM ){
|
||||
if( nearby<=mxPage ){
|
||||
u8 eType;
|
||||
assert( nearby>0 );
|
||||
assert( pBt->autoVacuum );
|
||||
rc = ptrmapGet(pBt, nearby, &eType, 0);
|
||||
if( rc ) return rc;
|
||||
if( eType==PTRMAP_FREEPAGE ){
|
||||
searchList = 1;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
searchList = 1;
|
||||
}
|
||||
}else if( eMode==BTALLOC_LE ){
|
||||
searchList = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Decrement the free-list count by 1. Set iTrunk to the index of the
|
||||
** first free-list trunk page. iPrevTrunk is initially 1.
|
||||
*/
|
||||
rc = sqlite3PagerWrite(pPage1->pDbPage);
|
||||
if( rc ) return rc;
|
||||
put4byte(&pPage1->aData[36], n-1);
|
||||
|
||||
/* The code within this loop is run only once if the 'searchList' variable
|
||||
@@ -6611,7 +7079,7 @@ static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
|
||||
/* If the database supports auto-vacuum, write an entry in the pointer-map
|
||||
** to indicate that the page is free.
|
||||
*/
|
||||
if( ISAUTOVACUUM ){
|
||||
if( REQUIRE_PTRMAP ){
|
||||
ptrmapPut(pBt, iPage, PTRMAP_FREEPAGE, 0, &rc);
|
||||
if( rc ) goto freepage_out;
|
||||
}
|
||||
@@ -6942,7 +7410,7 @@ static int fillInCell(
|
||||
}
|
||||
#endif
|
||||
rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, 0);
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
|
||||
/* If the database supports auto-vacuum, and the second or subsequent
|
||||
** overflow page is being allocated, add an entry to the pointer-map
|
||||
** for that page now.
|
||||
@@ -6953,14 +7421,13 @@ static int fillInCell(
|
||||
** may misinterpret the uninitialized values and delete the
|
||||
** wrong pages from the database.
|
||||
*/
|
||||
if( pBt->autoVacuum && rc==SQLITE_OK ){
|
||||
if( REQUIRE_PTRMAP && rc==SQLITE_OK ){
|
||||
u8 eType = (pgnoPtrmap?PTRMAP_OVERFLOW2:PTRMAP_OVERFLOW1);
|
||||
ptrmapPut(pBt, pgnoOvfl, eType, pgnoPtrmap, &rc);
|
||||
if( rc ){
|
||||
releasePage(pOvfl);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if( rc ){
|
||||
releasePage(pToRelease);
|
||||
return rc;
|
||||
@@ -7107,6 +7574,7 @@ static void insertCell(
|
||||
assert( j==0 || pPage->aiOvfl[j-1]<(u16)i ); /* Overflows in sorted order */
|
||||
assert( j==0 || i==pPage->aiOvfl[j-1]+1 ); /* Overflows are sequential */
|
||||
}else{
|
||||
BtShared *pBt = pPage->pBt;
|
||||
int rc = sqlite3PagerWrite(pPage->pDbPage);
|
||||
if( rc!=SQLITE_OK ){
|
||||
*pRC = rc;
|
||||
@@ -7121,7 +7589,7 @@ static void insertCell(
|
||||
** if it returns successfully */
|
||||
assert( idx >= 0 );
|
||||
assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
|
||||
assert( idx+sz <= (int)pPage->pBt->usableSize );
|
||||
assert( idx+sz <= (int)pBt->usableSize );
|
||||
pPage->nFree -= (u16)(2 + sz);
|
||||
if( iChild ){
|
||||
/* In a corrupt database where an entry in the cell index section of
|
||||
@@ -7141,14 +7609,12 @@ static void insertCell(
|
||||
/* increment the cell count */
|
||||
if( (++data[pPage->hdrOffset+4])==0 ) data[pPage->hdrOffset+3]++;
|
||||
assert( get2byte(&data[pPage->hdrOffset+3])==pPage->nCell || CORRUPT_DB );
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
if( pPage->pBt->autoVacuum ){
|
||||
if( REQUIRE_PTRMAP ){
|
||||
/* The cell may contain a pointer to an overflow page. If so, write
|
||||
** the entry for the overflow page into the pointer map.
|
||||
*/
|
||||
ptrmapPutOvflPtr(pPage, pPage, pCell, pRC);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7688,7 +8154,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
|
||||
** be marked as dirty. Returning an error code will cause a
|
||||
** rollback, undoing any changes made to the parent page.
|
||||
*/
|
||||
if( ISAUTOVACUUM ){
|
||||
if( REQUIRE_PTRMAP ){
|
||||
ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno, &rc);
|
||||
if( szCell>pNew->minLocal ){
|
||||
ptrmapPutOvflPtr(pNew, pNew, pCell, &rc);
|
||||
@@ -7826,7 +8292,7 @@ static void copyNodeContent(MemPage *pFrom, MemPage *pTo, int *pRC){
|
||||
/* If this is an auto-vacuum database, update the pointer-map entries
|
||||
** for any b-tree or overflow pages that pTo now contains the pointers to.
|
||||
*/
|
||||
if( ISAUTOVACUUM ){
|
||||
if( REQUIRE_PTRMAP ){
|
||||
*pRC = setChildPtrmaps(pTo);
|
||||
}
|
||||
}
|
||||
@@ -7877,7 +8343,8 @@ static int balance_nonroot(
|
||||
int iParentIdx, /* Index of "the page" in pParent */
|
||||
u8 *aOvflSpace, /* page-size bytes of space for parent ovfl */
|
||||
int isRoot, /* True if pParent is a root-page */
|
||||
int bBulk /* True if this call is part of a bulk load */
|
||||
int bBulk, /* True if this call is part of a bulk load */
|
||||
Pgno pgnoRoot /* Root page of b-tree being balanced */
|
||||
){
|
||||
BtShared *pBt; /* The whole database */
|
||||
int nMaxCells = 0; /* Allocated size of apCell, szCell, aFrom. */
|
||||
@@ -7967,6 +8434,7 @@ static int balance_nonroot(
|
||||
memset(apOld, 0, (i+1)*sizeof(MemPage*));
|
||||
goto balance_cleanup;
|
||||
}
|
||||
setMempageRoot(apOld[i], pgnoRoot);
|
||||
if( apOld[i]->nFree<0 ){
|
||||
rc = btreeComputeFreeSpace(apOld[i]);
|
||||
if( rc ){
|
||||
@@ -8314,7 +8782,7 @@ static int balance_nonroot(
|
||||
cntOld[i] = b.nCell;
|
||||
|
||||
/* Set the pointer-map entry for the new sibling page. */
|
||||
if( ISAUTOVACUUM ){
|
||||
if( REQUIRE_PTRMAP ){
|
||||
ptrmapPut(pBt, pNew->pgno, PTRMAP_BTREE, pParent->pgno, &rc);
|
||||
if( rc!=SQLITE_OK ){
|
||||
goto balance_cleanup;
|
||||
@@ -8410,7 +8878,7 @@ static int balance_nonroot(
|
||||
** updated. This happens below, after the sibling pages have been
|
||||
** populated, not here.
|
||||
*/
|
||||
if( ISAUTOVACUUM ){
|
||||
if( REQUIRE_PTRMAP ){
|
||||
MemPage *pOld;
|
||||
MemPage *pNew = pOld = apNew[0];
|
||||
int cntOldNext = pNew->nCell + pNew->nOverflow;
|
||||
@@ -8603,7 +9071,7 @@ static int balance_nonroot(
|
||||
);
|
||||
copyNodeContent(apNew[0], pParent, &rc);
|
||||
freePage(apNew[0], &rc);
|
||||
}else if( ISAUTOVACUUM && !leafCorrection ){
|
||||
}else if( REQUIRE_PTRMAP && !leafCorrection ){
|
||||
/* Fix the pointer map entries associated with the right-child of each
|
||||
** sibling page. All other pointer map entries have already been taken
|
||||
** care of. */
|
||||
@@ -8686,7 +9154,7 @@ static int balance_deeper(MemPage *pRoot, MemPage **ppChild){
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = allocateBtreePage(pBt,&pChild,&pgnoChild,pRoot->pgno,0);
|
||||
copyNodeContent(pRoot, pChild, &rc);
|
||||
if( ISAUTOVACUUM ){
|
||||
if( REQUIRE_PTRMAP ){
|
||||
ptrmapPut(pBt, pgnoChild, PTRMAP_BTREE, pRoot->pgno, &rc);
|
||||
}
|
||||
}
|
||||
@@ -8844,7 +9312,7 @@ static int balance(BtCursor *pCur){
|
||||
*/
|
||||
u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);
|
||||
rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1,
|
||||
pCur->hints&BTREE_BULKLOAD);
|
||||
pCur->hints&BTREE_BULKLOAD, pCur->pgnoRoot);
|
||||
if( pFree ){
|
||||
/* If pFree is not NULL, it points to the pSpace buffer used
|
||||
** by a previous call to balance_nonroot(). Its contents are
|
||||
@@ -9213,7 +9681,7 @@ int sqlite3BtreeInsert(
|
||||
testcase( pCur->curFlags & BTCF_ValidOvfl );
|
||||
invalidateOverflowCache(pCur);
|
||||
if( info.nSize==szNew && info.nLocal==info.nPayload
|
||||
&& (!ISAUTOVACUUM || szNew<pPage->minLocal)
|
||||
&& (!REQUIRE_PTRMAP || szNew<pPage->minLocal)
|
||||
){
|
||||
/* Overwrite the old cell with the new if they are the same size.
|
||||
** We could also try to do this if the old cell is smaller, then add
|
||||
@@ -9800,7 +10268,8 @@ static int clearDatabasePage(
|
||||
BtShared *pBt, /* The BTree that contains the table */
|
||||
Pgno pgno, /* Page number to clear */
|
||||
int freePageFlag, /* Deallocate page if true */
|
||||
i64 *pnChange /* Add number of Cells freed to this counter */
|
||||
i64 *pnChange, /* Add number of Cells freed to this counter */
|
||||
Pgno pgnoRoot
|
||||
){
|
||||
MemPage *pPage;
|
||||
int rc;
|
||||
@@ -9815,6 +10284,7 @@ static int clearDatabasePage(
|
||||
}
|
||||
rc = getAndInitPage(pBt, pgno, &pPage, 0, 0);
|
||||
if( rc ) return rc;
|
||||
setMempageRoot(pPage, pgnoRoot);
|
||||
if( (pBt->openFlags & BTREE_SINGLE)==0
|
||||
&& sqlite3PagerPageRefcount(pPage->pDbPage) != (1 + (pgno==1))
|
||||
){
|
||||
@@ -9825,14 +10295,16 @@ static int clearDatabasePage(
|
||||
for(i=0; i<pPage->nCell; i++){
|
||||
pCell = findCell(pPage, i);
|
||||
if( !pPage->leaf ){
|
||||
rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
|
||||
rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange, pgnoRoot);
|
||||
if( rc ) goto cleardatabasepage_out;
|
||||
}
|
||||
BTREE_CLEAR_CELL(rc, pPage, pCell, info);
|
||||
if( rc ) goto cleardatabasepage_out;
|
||||
}
|
||||
if( !pPage->leaf ){
|
||||
rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
|
||||
rc = clearDatabasePage(
|
||||
pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange, pgnoRoot
|
||||
);
|
||||
if( rc ) goto cleardatabasepage_out;
|
||||
if( pPage->intKey ) pnChange = 0;
|
||||
}
|
||||
@@ -9878,7 +10350,7 @@ int sqlite3BtreeClearTable(Btree *p, int iTable, i64 *pnChange){
|
||||
if( p->hasIncrblobCur ){
|
||||
invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1);
|
||||
}
|
||||
rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
|
||||
rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange, (Pgno)iTable);
|
||||
}
|
||||
sqlite3BtreeLeave(p);
|
||||
return rc;
|
||||
@@ -10785,10 +11257,12 @@ char *sqlite3BtreeIntegrityCheck(
|
||||
}
|
||||
pBt->db->flags = savedDbFlags;
|
||||
|
||||
/* Make sure every page in the file is referenced
|
||||
*/
|
||||
if( !bPartial ){
|
||||
for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){
|
||||
/* Make sure every page in the file is referenced. Skip this if the
|
||||
** database is currently being written by a CONCURRENT transaction (it
|
||||
** may fail as pages that were part of the free-list when the transaction
|
||||
** was opened cannot be counted). */
|
||||
for(i=1; ISCONCURRENT==0 && i<=sCheck.nPage && sCheck.mxErr; i++){
|
||||
#ifdef SQLITE_OMIT_AUTOVACUUM
|
||||
if( getPageReferenced(&sCheck, i)==0 ){
|
||||
checkAppendMsg(&sCheck, "Page %d is never used", i);
|
||||
@@ -11088,6 +11562,102 @@ int sqlite3BtreeIsReadonly(Btree *p){
|
||||
*/
|
||||
int sqlite3HeaderSizeBtree(void){ return ROUND8(sizeof(MemPage)); }
|
||||
|
||||
/*
|
||||
** This function is called to ensure that all locks required to commit the
|
||||
** current write-transaction to the database file are held. If the db is
|
||||
** in rollback mode, this means the EXCLUSIVE lock on the database file.
|
||||
**
|
||||
** Or, if this is an CONCURRENT transaction on a wal-mode database, the WRITER
|
||||
** lock on the wal file. In this case this function also checks that the
|
||||
** CONCURRENT transaction can be safely committed (does not commit with any
|
||||
** other transaction committed since it was opened).
|
||||
**
|
||||
** SQLITE_OK is returned if successful. SQLITE_BUSY if the required locks
|
||||
** cannot be obtained due to a conflicting lock. If the locks cannot be
|
||||
** obtained for an CONCURRENT transaction due to a conflict with an already
|
||||
** committed transaction, SQLITE_BUSY_SNAPSHOT is returned. Otherwise, if
|
||||
** some other error (OOM, IO, etc.) occurs, the relevant SQLite error code
|
||||
** is returned.
|
||||
*/
|
||||
int sqlite3BtreeExclusiveLock(Btree *p){
|
||||
int rc;
|
||||
Pgno pgno = 0;
|
||||
BtShared *pBt = p->pBt;
|
||||
assert( p->inTrans==TRANS_WRITE && pBt->pPage1 );
|
||||
sqlite3BtreeEnter(p);
|
||||
rc = sqlite3PagerExclusiveLock(pBt->pPager,
|
||||
(p->db->eConcurrent==CONCURRENT_SCHEMA) ? 0 : pBt->pPage1->pDbPage,
|
||||
&pgno
|
||||
);
|
||||
#ifdef SQLITE_OMIT_CONCURRENT
|
||||
assert( pgno==0 );
|
||||
#else
|
||||
if( rc==SQLITE_BUSY_SNAPSHOT && pgno ){
|
||||
PgHdr *pPg = 0;
|
||||
int rc2 = sqlite3PagerGet(pBt->pPager, pgno, &pPg, 0);
|
||||
if( rc2==SQLITE_OK ){
|
||||
int bWrite = -1;
|
||||
const char *zObj = 0;
|
||||
const char *zTab = 0;
|
||||
char zContent[17];
|
||||
|
||||
if( pPg ){
|
||||
Pgno pgnoRoot = 0;
|
||||
HashElem *pE;
|
||||
Schema *pSchema;
|
||||
u8 *aData = (u8*)sqlite3PagerGetData(pPg);
|
||||
int i;
|
||||
for(i=0; i<8; i++){
|
||||
static const char hexdigits[] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
|
||||
};
|
||||
zContent[i*2] = hexdigits[(aData[i] >> 4)];
|
||||
zContent[i*2+1] = hexdigits[(aData[i] & 0xF)];
|
||||
}
|
||||
zContent[16] = '\0';
|
||||
|
||||
pgnoRoot = ((MemPage*)sqlite3PagerGetExtra(pPg))->pgnoRoot;
|
||||
bWrite = sqlite3PagerIswriteable(pPg);
|
||||
sqlite3PagerUnref(pPg);
|
||||
|
||||
pSchema = sqlite3SchemaGet(p->db, p);
|
||||
if( pSchema ){
|
||||
for(pE=sqliteHashFirst(&pSchema->tblHash); pE; pE=sqliteHashNext(pE)){
|
||||
Table *pTab = (Table *)sqliteHashData(pE);
|
||||
if( pTab->tnum==(int)pgnoRoot ){
|
||||
zObj = pTab->zName;
|
||||
zTab = 0;
|
||||
}else{
|
||||
Index *pIdx;
|
||||
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
|
||||
if( pIdx->tnum==(int)pgnoRoot ){
|
||||
zObj = pIdx->zName;
|
||||
zTab = pTab->zName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sqlite3_log(SQLITE_OK,
|
||||
"cannot commit CONCURRENT transaction "
|
||||
"- conflict at page %d "
|
||||
"(%s page; part of db %s %s%s%s; content=%s...)",
|
||||
(int)pgno,
|
||||
(bWrite==0?"read-only":(bWrite>0?"read/write":"unknown")),
|
||||
(zTab ? "index" : "table"),
|
||||
(zTab ? zTab : ""), (zTab ? "." : ""), (zObj ? zObj : "UNKNOWN"),
|
||||
zContent
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
sqlite3BtreeLeave(p);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if !defined(SQLITE_OMIT_SHARED_CACHE)
|
||||
/*
|
||||
** Return true if the Btree passed as the only argument is sharable.
|
||||
|
||||
+2
-1
@@ -350,6 +350,8 @@ sqlite3_uint64 sqlite3BtreeSeekCount(Btree*);
|
||||
# define sqlite3BtreeSeekCount(X) 0
|
||||
#endif
|
||||
|
||||
int sqlite3BtreeExclusiveLock(Btree *pBt);
|
||||
|
||||
#ifndef NDEBUG
|
||||
int sqlite3BtreeCursorIsValid(BtCursor*);
|
||||
#endif
|
||||
@@ -408,5 +410,4 @@ int sqlite3BtreeTransferRow(BtCursor*, BtCursor*, i64);
|
||||
# define sqlite3SchemaMutexHeld(X,Y,Z) 1
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* SQLITE_BTREE_H */
|
||||
|
||||
+17
-3
@@ -232,6 +232,7 @@
|
||||
typedef struct MemPage MemPage;
|
||||
typedef struct BtLock BtLock;
|
||||
typedef struct CellInfo CellInfo;
|
||||
typedef struct BtreePtrmap BtreePtrmap;
|
||||
|
||||
/*
|
||||
** This is a magic string that appears at the beginning of every
|
||||
@@ -275,6 +276,9 @@ struct MemPage {
|
||||
u8 intKey; /* True if table b-trees. False for index b-trees */
|
||||
u8 intKeyLeaf; /* True if the leaf of an intKey table */
|
||||
Pgno pgno; /* Page number for this page */
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
Pgno pgnoRoot; /* Root page of b-tree that this page belongs to */
|
||||
#endif
|
||||
/* Only the first 8 bytes (above) are zeroed by pager.c when a new page
|
||||
** is allocated. All fields that follow must be initialized before use */
|
||||
u8 leaf; /* True if a leaf page */
|
||||
@@ -456,6 +460,9 @@ struct BtShared {
|
||||
Btree *pWriter; /* Btree with currently open write transaction */
|
||||
#endif
|
||||
u8 *pTmpSpace; /* Temp space sufficient to hold a single cell */
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
BtreePtrmap *pMap;
|
||||
#endif
|
||||
int nPreformatSize; /* Size of last cell written by TransferRow() */
|
||||
};
|
||||
|
||||
@@ -673,12 +680,19 @@ struct BtCursor {
|
||||
** (sqliteMallocRaw), it is not possible to use conditional compilation.
|
||||
** So, this macro is defined instead.
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
#define ISAUTOVACUUM (pBt->autoVacuum)
|
||||
#else
|
||||
#ifdef SQLITE_OMIT_AUTOVACUUM
|
||||
#define ISAUTOVACUUM 0
|
||||
#else
|
||||
#define ISAUTOVACUUM (pBt->autoVacuum)
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_OMIT_CONCURRENT
|
||||
# define ISCONCURRENT 0
|
||||
#else
|
||||
# define ISCONCURRENT (pBt->pMap!=0)
|
||||
#endif
|
||||
|
||||
#define REQUIRE_PTRMAP (ISAUTOVACUUM || ISCONCURRENT)
|
||||
|
||||
/*
|
||||
** This structure is passed around through all the sanity checking routines
|
||||
|
||||
+4
-4
@@ -89,8 +89,10 @@ void sqlite3TableLock(
|
||||
u8 isWriteLock, /* True for a write lock */
|
||||
const char *zName /* Name of the table to be locked */
|
||||
){
|
||||
#ifdef SQLITE_OMIT_CONCURRENT
|
||||
if( iDb==1 ) return;
|
||||
if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;
|
||||
#endif
|
||||
lockTable(pParse, iDb, iTab, isWriteLock, zName);
|
||||
}
|
||||
|
||||
@@ -331,8 +333,6 @@ void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
|
||||
memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
|
||||
db->mDbFlags |= DBFLAG_PreferBuiltin;
|
||||
sqlite3RunParser(pParse, zSql);
|
||||
sqlite3DbFree(db, pParse->zErrMsg);
|
||||
pParse->zErrMsg = 0;
|
||||
db->mDbFlags = savedDbFlags;
|
||||
sqlite3DbFree(db, zSql);
|
||||
memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ);
|
||||
@@ -5116,7 +5116,7 @@ void sqlite3BeginTransaction(Parse *pParse, int type){
|
||||
}
|
||||
v = sqlite3GetVdbe(pParse);
|
||||
if( !v ) return;
|
||||
if( type!=TK_DEFERRED ){
|
||||
if( type==TK_IMMEDIATE || type==TK_EXCLUSIVE ){
|
||||
for(i=0; i<db->nDb; i++){
|
||||
int eTxnType;
|
||||
Btree *pBt = db->aDb[i].pBt;
|
||||
@@ -5131,7 +5131,7 @@ void sqlite3BeginTransaction(Parse *pParse, int type){
|
||||
sqlite3VdbeUsesBtree(v, i);
|
||||
}
|
||||
}
|
||||
sqlite3VdbeAddOp0(v, OP_AutoCommit);
|
||||
sqlite3VdbeAddOp3(v, OP_AutoCommit, 0, 0, (type==TK_CONCURRENT));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+4
-2
@@ -523,8 +523,9 @@ static void randomFunc(
|
||||
sqlite3_value **NotUsed2
|
||||
){
|
||||
sqlite_int64 r;
|
||||
sqlite3 *db = sqlite3_context_db_handle(context);
|
||||
UNUSED_PARAMETER2(NotUsed, NotUsed2);
|
||||
sqlite3_randomness(sizeof(r), &r);
|
||||
sqlite3FastRandomness(&db->sPrng, sizeof(r), &r);
|
||||
if( r<0 ){
|
||||
/* We need to prevent a random number of 0x8000000000000000
|
||||
** (or -9223372036854775808) since when you do abs() of that
|
||||
@@ -550,6 +551,7 @@ static void randomBlob(
|
||||
){
|
||||
sqlite3_int64 n;
|
||||
unsigned char *p;
|
||||
sqlite3 *db = sqlite3_context_db_handle(context);
|
||||
assert( argc==1 );
|
||||
UNUSED_PARAMETER(argc);
|
||||
n = sqlite3_value_int64(argv[0]);
|
||||
@@ -558,7 +560,7 @@ static void randomBlob(
|
||||
}
|
||||
p = contextMalloc(context, n);
|
||||
if( p ){
|
||||
sqlite3_randomness(n, p);
|
||||
sqlite3FastRandomness(&db->sPrng, n, p);
|
||||
sqlite3_result_blob(context, (char*)p, n, sqlite3_free);
|
||||
}
|
||||
}
|
||||
|
||||
+33
-1
@@ -3242,7 +3242,7 @@ static int openDatabase(
|
||||
db->aDb = db->aDbStatic;
|
||||
db->lookaside.bDisable = 1;
|
||||
db->lookaside.sz = 0;
|
||||
|
||||
sqlite3FastPrngInit(&db->sPrng);
|
||||
assert( sizeof(db->aLimit)==sizeof(aHardLimit) );
|
||||
memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
|
||||
db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS;
|
||||
@@ -4112,8 +4112,11 @@ int sqlite3_test_control(int op, ...){
|
||||
sqlite3ShowTriggerStepList(0);
|
||||
sqlite3ShowTrigger(0);
|
||||
sqlite3ShowTriggerList(0);
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
sqlite3ShowWindow(0);
|
||||
sqlite3ShowWinFunc(0);
|
||||
#endif
|
||||
sqlite3ShowSelect(0);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@@ -4809,6 +4812,35 @@ void sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){
|
||||
}
|
||||
#endif /* SQLITE_ENABLE_SNAPSHOT */
|
||||
|
||||
SQLITE_EXPERIMENTAL int sqlite3_wal_info(
|
||||
sqlite3 *db, const char *zDb,
|
||||
unsigned int *pnPrior, unsigned int *pnFrame
|
||||
){
|
||||
int rc = SQLITE_OK;
|
||||
|
||||
#ifndef SQLITE_OMIT_WAL
|
||||
Btree *pBt;
|
||||
int iDb;
|
||||
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( !sqlite3SafetyCheckOk(db) ){
|
||||
return SQLITE_MISUSE_BKPT;
|
||||
}
|
||||
#endif
|
||||
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
iDb = sqlite3FindDbName(db, zDb);
|
||||
if( iDb<0 ){
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
pBt = db->aDb[iDb].pBt;
|
||||
rc = sqlite3PagerWalInfo(sqlite3BtreePager(pBt), pnPrior, pnFrame);
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
#endif /* SQLITE_OMIT_WAL */
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
|
||||
/*
|
||||
** Given the name of a compile-time option, return true if that option
|
||||
|
||||
@@ -776,8 +776,13 @@ void *sqlite3OomFault(sqlite3 *db){
|
||||
}
|
||||
DisableLookaside;
|
||||
if( db->pParse ){
|
||||
Parse *pParse;
|
||||
sqlite3ErrorMsg(db->pParse, "out of memory");
|
||||
db->pParse->rc = SQLITE_NOMEM_BKPT;
|
||||
for(pParse=db->pParse->pOuterParse; pParse; pParse = pParse->pOuterParse){
|
||||
pParse->nErr++;
|
||||
pParse->rc = SQLITE_NOMEM;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
+70
-11
@@ -1177,6 +1177,10 @@ struct unixInodeInfo {
|
||||
sem_t *pSem; /* Named POSIX semaphore */
|
||||
char aSemName[MAX_PATHNAME+2]; /* Name of that semaphore */
|
||||
#endif
|
||||
#ifdef SQLITE_SHARED_MAPPING
|
||||
sqlite3_int64 nSharedMapping; /* Size of mapped region in bytes */
|
||||
void *pSharedMapping; /* Memory mapped region */
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -1329,6 +1333,13 @@ static void releaseInodeInfo(unixFile *pFile){
|
||||
pInode->nRef--;
|
||||
if( pInode->nRef==0 ){
|
||||
assert( pInode->pShmNode==0 );
|
||||
#ifdef SQLITE_SHARED_MAPPING
|
||||
if( pInode->pSharedMapping ){
|
||||
osMunmap(pInode->pSharedMapping, pInode->nSharedMapping);
|
||||
pInode->pSharedMapping = 0;
|
||||
pInode->nSharedMapping = 0;
|
||||
}
|
||||
#endif
|
||||
sqlite3_mutex_enter(pInode->pLockMutex);
|
||||
closePendingFds(pFile);
|
||||
sqlite3_mutex_leave(pInode->pLockMutex);
|
||||
@@ -2192,6 +2203,14 @@ static int nolockUnlock(sqlite3_file *NotUsed, int NotUsed2){
|
||||
** Close the file.
|
||||
*/
|
||||
static int nolockClose(sqlite3_file *id) {
|
||||
#ifdef SQLITE_SHARED_MAPPING
|
||||
unixFile *pFd = (unixFile*)id;
|
||||
if( pFd->pInode ){
|
||||
unixEnterMutex();
|
||||
releaseInodeInfo(pFd);
|
||||
unixLeaveMutex();
|
||||
}
|
||||
#endif
|
||||
return closeUnixFile(id);
|
||||
}
|
||||
|
||||
@@ -4045,6 +4064,9 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
|
||||
*(i64*)pArg = pFile->mmapSizeMax;
|
||||
if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
|
||||
pFile->mmapSizeMax = newLimit;
|
||||
#ifdef SQLITE_SHARED_MAPPING
|
||||
if( pFile->pInode==0 )
|
||||
#endif
|
||||
if( pFile->mmapSize>0 ){
|
||||
unixUnmapfile(pFile);
|
||||
rc = unixMapfile(pFile, -1);
|
||||
@@ -5119,6 +5141,9 @@ static int unixShmUnmap(
|
||||
*/
|
||||
static void unixUnmapfile(unixFile *pFd){
|
||||
assert( pFd->nFetchOut==0 );
|
||||
#ifdef SQLITE_SHARED_MAPPING
|
||||
if( pFd->pInode ) return;
|
||||
#endif
|
||||
if( pFd->pMapRegion ){
|
||||
osMunmap(pFd->pMapRegion, pFd->mmapSizeActual);
|
||||
pFd->pMapRegion = 0;
|
||||
@@ -5250,6 +5275,28 @@ static int unixMapfile(unixFile *pFd, i64 nMap){
|
||||
nMap = pFd->mmapSizeMax;
|
||||
}
|
||||
|
||||
#ifdef SQLITE_SHARED_MAPPING
|
||||
if( pFd->pInode ){
|
||||
unixInodeInfo *pInode = pFd->pInode;
|
||||
if( pFd->pMapRegion ) return SQLITE_OK;
|
||||
unixEnterMutex();
|
||||
if( pInode->pSharedMapping==0 ){
|
||||
u8 *pNew = osMmap(0, nMap, PROT_READ, MAP_SHARED, pFd->h, 0);
|
||||
if( pNew==MAP_FAILED ){
|
||||
unixLogError(SQLITE_OK, "mmap", pFd->zPath);
|
||||
pFd->mmapSizeMax = 0;
|
||||
}else{
|
||||
pInode->pSharedMapping = pNew;
|
||||
pInode->nSharedMapping = nMap;
|
||||
}
|
||||
}
|
||||
pFd->pMapRegion = pInode->pSharedMapping;
|
||||
pFd->mmapSizeActual = pFd->mmapSize = pInode->nSharedMapping;
|
||||
unixLeaveMutex();
|
||||
return SQLITE_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
assert( nMap>0 || (pFd->mmapSize==0 && pFd->pMapRegion==0) );
|
||||
if( nMap!=pFd->mmapSize ){
|
||||
unixRemapfile(pFd, nMap);
|
||||
@@ -5687,6 +5734,9 @@ static int fillInUnixFile(
|
||||
if( pLockingStyle == &posixIoMethods
|
||||
#if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE
|
||||
|| pLockingStyle == &nfsIoMethods
|
||||
#endif
|
||||
#ifdef SQLITE_SHARED_MAPPING
|
||||
|| pLockingStyle == &nolockIoMethods
|
||||
#endif
|
||||
){
|
||||
unixEnterMutex();
|
||||
@@ -5855,6 +5905,7 @@ static const char *unixTempFileDir(void){
|
||||
static int unixGetTempname(int nBuf, char *zBuf){
|
||||
const char *zDir;
|
||||
int iLimit = 0;
|
||||
int rc = SQLITE_OK;
|
||||
|
||||
/* It's odd to simulate an io-error here, but really this is just
|
||||
** using the io-error infrastructure to test that SQLite handles this
|
||||
@@ -5863,18 +5914,26 @@ static int unixGetTempname(int nBuf, char *zBuf){
|
||||
zBuf[0] = 0;
|
||||
SimulateIOError( return SQLITE_IOERR );
|
||||
|
||||
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
zDir = unixTempFileDir();
|
||||
if( zDir==0 ) return SQLITE_IOERR_GETTEMPPATH;
|
||||
do{
|
||||
u64 r;
|
||||
sqlite3_randomness(sizeof(r), &r);
|
||||
assert( nBuf>2 );
|
||||
zBuf[nBuf-2] = 0;
|
||||
sqlite3_snprintf(nBuf, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX"%llx%c",
|
||||
zDir, r, 0);
|
||||
if( zBuf[nBuf-2]!=0 || (iLimit++)>10 ) return SQLITE_ERROR;
|
||||
}while( osAccess(zBuf,0)==0 );
|
||||
return SQLITE_OK;
|
||||
if( zDir==0 ){
|
||||
rc = SQLITE_IOERR_GETTEMPPATH;
|
||||
}else{
|
||||
do{
|
||||
u64 r;
|
||||
sqlite3_randomness(sizeof(r), &r);
|
||||
assert( nBuf>2 );
|
||||
zBuf[nBuf-2] = 0;
|
||||
sqlite3_snprintf(nBuf, zBuf, "%s/"SQLITE_TEMP_FILE_PREFIX"%llx%c",
|
||||
zDir, r, 0);
|
||||
if( zBuf[nBuf-2]!=0 || (iLimit++)>10 ){
|
||||
rc = SQLITE_ERROR;
|
||||
break;
|
||||
}
|
||||
}while( osAccess(zBuf,0)==0 );
|
||||
}
|
||||
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
return rc;
|
||||
}
|
||||
|
||||
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
|
||||
|
||||
+39
-5
@@ -1922,6 +1922,7 @@ int sqlite3_win32_set_directory8(
|
||||
int rc = sqlite3_initialize();
|
||||
if( rc ) return rc;
|
||||
#endif
|
||||
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
if( type==SQLITE_WIN32_DATA_DIRECTORY_TYPE ){
|
||||
ppDirectory = &sqlite3_data_directory;
|
||||
}else if( type==SQLITE_WIN32_TEMP_DIRECTORY_TYPE ){
|
||||
@@ -1936,14 +1937,19 @@ int sqlite3_win32_set_directory8(
|
||||
if( zValue && zValue[0] ){
|
||||
zCopy = sqlite3_mprintf("%s", zValue);
|
||||
if ( zCopy==0 ){
|
||||
return SQLITE_NOMEM_BKPT;
|
||||
rc = SQLITE_NOMEM_BKPT;
|
||||
goto set_directory8_done;
|
||||
}
|
||||
}
|
||||
sqlite3_free(*ppDirectory);
|
||||
*ppDirectory = zCopy;
|
||||
return SQLITE_OK;
|
||||
rc = SQLITE_OK;
|
||||
}else{
|
||||
rc = SQLITE_ERROR;
|
||||
}
|
||||
return SQLITE_ERROR;
|
||||
set_directory8_done:
|
||||
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4717,6 +4723,18 @@ static int winMakeEndInDirSep(int nBuf, char *zBuf){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** If sqlite3_temp_directory is not, take the mutex and return true.
|
||||
**
|
||||
** If sqlite3_temp_directory is NULL, omit the mutex and return false.
|
||||
*/
|
||||
static int winTempDirDefined(void){
|
||||
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
if( sqlite3_temp_directory!=0 ) return 1;
|
||||
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Create a temporary file name and store the resulting pointer into pzBuf.
|
||||
** The pointer returned in pzBuf must be freed via sqlite3_free().
|
||||
@@ -4753,20 +4771,23 @@ static int winGetTempname(sqlite3_vfs *pVfs, char **pzBuf){
|
||||
*/
|
||||
nDir = nMax - (nPre + 15);
|
||||
assert( nDir>0 );
|
||||
if( sqlite3_temp_directory ){
|
||||
if( winTempDirDefined() ){
|
||||
int nDirLen = sqlite3Strlen30(sqlite3_temp_directory);
|
||||
if( nDirLen>0 ){
|
||||
if( !winIsDirSep(sqlite3_temp_directory[nDirLen-1]) ){
|
||||
nDirLen++;
|
||||
}
|
||||
if( nDirLen>nDir ){
|
||||
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
sqlite3_free(zBuf);
|
||||
OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n"));
|
||||
return winLogError(SQLITE_ERROR, 0, "winGetTempname1", 0);
|
||||
}
|
||||
sqlite3_snprintf(nMax, zBuf, "%s", sqlite3_temp_directory);
|
||||
}
|
||||
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
}
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
else{
|
||||
static const char *azDirs[] = {
|
||||
@@ -5555,7 +5576,7 @@ static BOOL winIsVerbatimPathname(
|
||||
** pathname into zOut[]. zOut[] will be at least pVfs->mxPathname
|
||||
** bytes in size.
|
||||
*/
|
||||
static int winFullPathname(
|
||||
static int winFullPathnameNoMutex(
|
||||
sqlite3_vfs *pVfs, /* Pointer to vfs object */
|
||||
const char *zRelative, /* Possibly relative input path */
|
||||
int nFull, /* Size of output buffer in bytes */
|
||||
@@ -5734,6 +5755,19 @@ static int winFullPathname(
|
||||
}
|
||||
#endif
|
||||
}
|
||||
static int winFullPathname(
|
||||
sqlite3_vfs *pVfs, /* Pointer to vfs object */
|
||||
const char *zRelative, /* Possibly relative input path */
|
||||
int nFull, /* Size of output buffer in bytes */
|
||||
char *zFull /* Output buffer */
|
||||
){
|
||||
int rc;
|
||||
sqlite3_mutex *pMutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR);
|
||||
sqlite3_mutex_enter(pMutex);
|
||||
rc = winFullPathnameNoMutex(pVfs, zRelative, nFull, zFull);
|
||||
sqlite3_mutex_leave(pMutex);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_LOAD_EXTENSION
|
||||
/*
|
||||
|
||||
+192
-25
@@ -658,6 +658,9 @@ struct Pager {
|
||||
u32 cksumInit; /* Quasi-random value added to every checksum */
|
||||
u32 nSubRec; /* Number of records written to sub-journal */
|
||||
Bitvec *pInJournal; /* One bit for each page in the database file */
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
Bitvec *pAllRead; /* Pages read within current CONCURRENT trans. */
|
||||
#endif
|
||||
sqlite3_file *fd; /* File descriptor for database */
|
||||
sqlite3_file *jfd; /* File descriptor for main journal */
|
||||
sqlite3_file *sjfd; /* File descriptor for sub-journal */
|
||||
@@ -915,7 +918,9 @@ static int assert_pager_state(Pager *p){
|
||||
if( !pagerUseWal(pPager) ){
|
||||
assert( p->eLock>=RESERVED_LOCK );
|
||||
}
|
||||
assert( pPager->dbSize==pPager->dbOrigSize );
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
assert( pPager->dbSize==pPager->dbOrigSize || pPager->pAllRead );
|
||||
#endif
|
||||
assert( pPager->dbOrigSize==pPager->dbFileSize );
|
||||
assert( pPager->dbOrigSize==pPager->dbHintSize );
|
||||
assert( pPager->setSuper==0 );
|
||||
@@ -1800,6 +1805,53 @@ static int addToSavepointBitvecs(Pager *pPager, Pgno pgno){
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
/*
|
||||
** If they are not already, begin recording all pages read from the pager layer
|
||||
** by the b-tree layer This is used by concurrent transactions. Return
|
||||
** SQLITE_OK if successful, or an SQLite error code (SQLITE_NOMEM) if an error
|
||||
** occurs.
|
||||
*/
|
||||
int sqlite3PagerBeginConcurrent(Pager *pPager){
|
||||
int rc = SQLITE_OK;
|
||||
if( pPager->pAllRead==0 ){
|
||||
pPager->pAllRead = sqlite3BitvecCreate(pPager->dbSize);
|
||||
pPager->dbOrigSize = pPager->dbSize;
|
||||
if( pPager->pAllRead==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* !defined(SQLITE_OMIT_CONCURRENT)
|
||||
**
|
||||
** Stop recording all pages read from the pager layer by the b-tree layer
|
||||
** and discard any current records.
|
||||
*/
|
||||
void sqlite3PagerEndConcurrent(Pager *pPager){
|
||||
sqlite3BitvecDestroy(pPager->pAllRead);
|
||||
pPager->pAllRead = 0;
|
||||
}
|
||||
|
||||
/* !defined(SQLITE_OMIT_CONCURRENT)
|
||||
**
|
||||
** Return true if the database is in wal mode. False otherwise.
|
||||
*/
|
||||
int sqlite3PagerIsWal(Pager *pPager){
|
||||
return pPager->pWal!=0;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_CONCURRENT */
|
||||
|
||||
/*
|
||||
** Free the Pager.pInJournal and Pager.pAllRead bitvec objects.
|
||||
*/
|
||||
static void pagerFreeBitvecs(Pager *pPager){
|
||||
sqlite3BitvecDestroy(pPager->pInJournal);
|
||||
pPager->pInJournal = 0;
|
||||
sqlite3PagerEndConcurrent(pPager);
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is a no-op if the pager is in exclusive mode and not
|
||||
** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN
|
||||
@@ -1824,8 +1876,7 @@ static void pager_unlock(Pager *pPager){
|
||||
|| pPager->eState==PAGER_ERROR
|
||||
);
|
||||
|
||||
sqlite3BitvecDestroy(pPager->pInJournal);
|
||||
pPager->pInJournal = 0;
|
||||
pagerFreeBitvecs(pPager);
|
||||
releaseAllSavepoints(pPager);
|
||||
|
||||
if( pagerUseWal(pPager) ){
|
||||
@@ -2092,8 +2143,7 @@ static int pager_end_transaction(Pager *pPager, int hasSuper, int bCommit){
|
||||
}
|
||||
#endif
|
||||
|
||||
sqlite3BitvecDestroy(pPager->pInJournal);
|
||||
pPager->pInJournal = 0;
|
||||
pagerFreeBitvecs(pPager);
|
||||
pPager->nRec = 0;
|
||||
if( rc==SQLITE_OK ){
|
||||
if( MEMDB || pagerFlushOnCommit(pPager, bCommit) ){
|
||||
@@ -3103,8 +3153,24 @@ static int pagerRollbackWal(Pager *pPager){
|
||||
** + Reload page content from the database (if refcount>0).
|
||||
*/
|
||||
pPager->dbSize = pPager->dbOrigSize;
|
||||
rc = sqlite3WalUndo(pPager->pWal, pagerUndoCallback, (void *)pPager);
|
||||
rc = sqlite3WalUndo(pPager->pWal, pagerUndoCallback, (void *)pPager,
|
||||
#ifdef SQLITE_OMIT_CONCURRENT
|
||||
0
|
||||
#else
|
||||
pPager->pAllRead!=0
|
||||
#endif
|
||||
);
|
||||
pList = sqlite3PcacheDirtyList(pPager->pPCache);
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
/* If this is an CONCURRENT transaction, then page 1 must be reread from
|
||||
** the db file, even if it is not dirty. This is because the b-tree layer
|
||||
** may have already zeroed the nFree and iTrunk header fields. */
|
||||
if( rc==SQLITE_OK && (pList==0 || pList->pgno!=1) && pPager->pAllRead ){
|
||||
rc = pagerUndoCallback((void*)pPager, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
while( pList && rc==SQLITE_OK ){
|
||||
PgHdr *pNext = pList->pDirty;
|
||||
rc = pagerUndoCallback((void *)pPager, pList->pgno);
|
||||
@@ -3154,6 +3220,8 @@ static int pagerWalFrames(
|
||||
if( p->pgno<=nTruncate ){
|
||||
ppNext = &p->pDirty;
|
||||
nList++;
|
||||
PAGERTRACE(("TO-WAL %d page %d hash(%08x)\n",
|
||||
PAGERID(pPager), p->pgno, pager_pagehash(p)));
|
||||
}
|
||||
}
|
||||
assert( pList );
|
||||
@@ -4225,7 +4293,7 @@ static int syncJournal(Pager *pPager, int newHdr){
|
||||
assert( assert_pager_state(pPager) );
|
||||
assert( !pagerUseWal(pPager) );
|
||||
|
||||
rc = sqlite3PagerExclusiveLock(pPager);
|
||||
rc = sqlite3PagerExclusiveLock(pPager, 0, 0);
|
||||
if( rc!=SQLITE_OK ) return rc;
|
||||
|
||||
if( !pPager->noSync ){
|
||||
@@ -4576,6 +4644,12 @@ static int pagerStress(void *p, PgHdr *pPg){
|
||||
pPager->aStat[PAGER_STAT_SPILL]++;
|
||||
pPg->pDirty = 0;
|
||||
if( pagerUseWal(pPager) ){
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
/* If the transaction is a "BEGIN CONCURRENT" transaction, the page
|
||||
** cannot be flushed to disk. Return early in this case. */
|
||||
if( pPager->pAllRead ) return SQLITE_OK;
|
||||
#endif
|
||||
|
||||
/* Write a single frame for this page to the log. */
|
||||
rc = subjournalPageIfRequired(pPg);
|
||||
if( rc==SQLITE_OK ){
|
||||
@@ -5495,6 +5569,18 @@ static int getPageNormal(
|
||||
assert( assert_pager_state(pPager) );
|
||||
assert( pPager->hasHeldSharedLock==1 );
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
/* If this is an CONCURRENT transaction and the page being read was
|
||||
** present in the database file when the transaction was opened,
|
||||
** mark it as read in the pAllRead vector. */
|
||||
pPg = 0;
|
||||
if( pPager->pAllRead && pgno<=pPager->dbOrigSize ){
|
||||
PAGERTRACE(("USING page %d\n", pgno));
|
||||
rc = sqlite3BitvecSet(pPager->pAllRead, pgno);
|
||||
if( rc!=SQLITE_OK ) goto pager_acquire_err;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( pgno==0 ) return SQLITE_CORRUPT_BKPT;
|
||||
pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);
|
||||
if( pBase==0 ){
|
||||
@@ -5821,6 +5907,7 @@ static int pager_open_journal(Pager *pPager){
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqlite3BitvecDestroy(pPager->pInJournal);
|
||||
pPager->pInJournal = 0;
|
||||
pPager->journalOff = 0;
|
||||
}else{
|
||||
assert( pPager->eState==PAGER_WRITER_LOCKED );
|
||||
pPager->eState = PAGER_WRITER_CACHEMOD;
|
||||
@@ -5833,11 +5920,14 @@ static int pager_open_journal(Pager *pPager){
|
||||
** Begin a write-transaction on the specified pager object. If a
|
||||
** write-transaction has already been opened, this function is a no-op.
|
||||
**
|
||||
** If the exFlag argument is false, then acquire at least a RESERVED
|
||||
** lock on the database file. If exFlag is true, then acquire at least
|
||||
** If the exFlag argument is 0, then acquire at least a RESERVED
|
||||
** lock on the database file. If exFlag is >0, then acquire at least
|
||||
** an EXCLUSIVE lock. If such a lock is already held, no locking
|
||||
** functions need be called.
|
||||
**
|
||||
** If (exFlag<0) and the database is in WAL mode, do not take any locks.
|
||||
** The transaction will run in CONCURRENT mode instead.
|
||||
**
|
||||
** If the subjInMemory argument is non-zero, then any sub-journal opened
|
||||
** within this transaction will be opened as an in-memory file. This
|
||||
** has no effect if the sub-journal is already opened (as it may be when
|
||||
@@ -5855,7 +5945,6 @@ int sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory){
|
||||
|
||||
if( pPager->eState==PAGER_READER ){
|
||||
assert( pPager->pInJournal==0 );
|
||||
|
||||
if( pagerUseWal(pPager) ){
|
||||
/* If the pager is configured to use locking_mode=exclusive, and an
|
||||
** exclusive lock on the database is not already held, obtain it now.
|
||||
@@ -5871,9 +5960,10 @@ int sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory){
|
||||
/* Grab the write lock on the log file. If successful, upgrade to
|
||||
** PAGER_RESERVED state. Otherwise, return an error code to the caller.
|
||||
** The busy-handler is not invoked if another connection already
|
||||
** holds the write-lock. If possible, the upper layer will call it.
|
||||
*/
|
||||
rc = sqlite3WalBeginWriteTransaction(pPager->pWal);
|
||||
** holds the write-lock. If possible, the upper layer will call it. */
|
||||
if( exFlag>=0 ){
|
||||
rc = sqlite3WalBeginWriteTransaction(pPager->pWal);
|
||||
}
|
||||
}else{
|
||||
/* Obtain a RESERVED lock on the database file. If the exFlag parameter
|
||||
** is true, then immediately upgrade this to an EXCLUSIVE lock. The
|
||||
@@ -5881,7 +5971,7 @@ int sqlite3PagerBegin(Pager *pPager, int exFlag, int subjInMemory){
|
||||
** lock, but not when obtaining the RESERVED lock.
|
||||
*/
|
||||
rc = pagerLockDb(pPager, RESERVED_LOCK);
|
||||
if( rc==SQLITE_OK && exFlag ){
|
||||
if( rc==SQLITE_OK && exFlag>0 ){
|
||||
rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
|
||||
}
|
||||
}
|
||||
@@ -6181,7 +6271,7 @@ int sqlite3PagerWrite(PgHdr *pPg){
|
||||
** to sqlite3PagerWrite(). In other words, return TRUE if it is ok
|
||||
** to change the content of the page.
|
||||
*/
|
||||
#ifndef NDEBUG
|
||||
#if !defined(SQLITE_OMIT_CONCURRENT) || !defined(NDEBUG)
|
||||
int sqlite3PagerIswriteable(DbPage *pPg){
|
||||
return pPg->flags & PGHDR_WRITEABLE;
|
||||
}
|
||||
@@ -6337,17 +6427,26 @@ int sqlite3PagerSync(Pager *pPager, const char *zSuper){
|
||||
}
|
||||
|
||||
/*
|
||||
** This function may only be called while a write-transaction is active in
|
||||
** rollback. If the connection is in WAL mode, this call is a no-op.
|
||||
** Otherwise, if the connection does not already have an EXCLUSIVE lock on
|
||||
** the database file, an attempt is made to obtain one.
|
||||
** This function is called to ensure that all locks required to commit the
|
||||
** current write-transaction to the database file are held. If the db is
|
||||
** in rollback mode, this means the EXCLUSIVE lock on the database file.
|
||||
**
|
||||
** If the EXCLUSIVE lock is already held or the attempt to obtain it is
|
||||
** successful, or the connection is in WAL mode, SQLITE_OK is returned.
|
||||
** Otherwise, either SQLITE_BUSY or an SQLITE_IOERR_XXX error code is
|
||||
** returned.
|
||||
** Or, if this is a non-CONCURRENT transaction on a wal-mode database, this
|
||||
** function is a no-op.
|
||||
**
|
||||
** If this is an CONCURRENT transaction on a wal-mode database, this function
|
||||
** attempts to obtain the WRITER lock on the wal file and also checks to
|
||||
** see that the transaction can be safely committed (does not commit with
|
||||
** any other transaction committed since it was opened).
|
||||
**
|
||||
** If the required locks are already held or successfully obtained and
|
||||
** the transaction can be committed, SQLITE_OK is returned. If a required lock
|
||||
** cannot be obtained, SQLITE_BUSY is returned. Or, if the current transaction
|
||||
** is CONCURRENT and cannot be committed due to a conflict, SQLITE_BUSY_SNAPSHOT
|
||||
** is returned. Otherwise, if some other error occurs (IO error, OOM etc.),
|
||||
** and SQLite error code is returned.
|
||||
*/
|
||||
int sqlite3PagerExclusiveLock(Pager *pPager){
|
||||
int sqlite3PagerExclusiveLock(Pager *pPager, PgHdr *pPage1, Pgno *piConflict){
|
||||
int rc = pPager->errCode;
|
||||
assert( assert_pager_state(pPager) );
|
||||
if( rc==SQLITE_OK ){
|
||||
@@ -6359,10 +6458,73 @@ int sqlite3PagerExclusiveLock(Pager *pPager){
|
||||
if( 0==pagerUseWal(pPager) ){
|
||||
rc = pager_wait_on_lock(pPager, EXCLUSIVE_LOCK);
|
||||
}
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
else{
|
||||
if( pPager->pAllRead ){
|
||||
/* This is an CONCURRENT transaction. Attempt to lock the wal database
|
||||
** here. If SQLITE_BUSY (but not SQLITE_BUSY_SNAPSHOT) is returned,
|
||||
** invoke the busy-handler and try again for as long as it returns
|
||||
** non-zero. */
|
||||
do {
|
||||
rc = sqlite3WalLockForCommit(
|
||||
pPager->pWal, pPage1, pPager->pAllRead, piConflict
|
||||
);
|
||||
}while( rc==SQLITE_BUSY
|
||||
&& pPager->xBusyHandler(pPager->pBusyHandlerArg)
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif /* SQLITE_OMIT_CONCURRENT */
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
/*
|
||||
** This function is called as part of committing an CONCURRENT transaction.
|
||||
** At this point the wal WRITER lock is held, and all pages in the cache
|
||||
** except for page 1 are compatible with the snapshot at the head of the
|
||||
** wal file.
|
||||
**
|
||||
** This function updates the in-memory data structures and reloads the
|
||||
** contents of page 1 so that the client is operating on the snapshot
|
||||
** at the head of the wal file.
|
||||
**
|
||||
** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
|
||||
*/
|
||||
int sqlite3PagerUpgradeSnapshot(Pager *pPager, DbPage *pPage1){
|
||||
int rc;
|
||||
|
||||
assert( pPager->pWal && pPager->pAllRead );
|
||||
rc = sqlite3WalUpgradeSnapshot(pPager->pWal);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = readDbPage(pPage1);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* !defined(SQLITE_OMIT_CONCURRENT)
|
||||
**
|
||||
** Set the in-memory cache of the database file size to nSz pages.
|
||||
*/
|
||||
void sqlite3PagerSetDbsize(Pager *pPager, Pgno nSz){
|
||||
pPager->dbSize = nSz;
|
||||
}
|
||||
|
||||
/* !defined(SQLITE_OMIT_CONCURRENT)
|
||||
**
|
||||
** If this is a WAL mode connection and the WRITER lock is currently held,
|
||||
** relinquish it.
|
||||
*/
|
||||
void sqlite3PagerDropExclusiveLock(Pager *pPager){
|
||||
if( pagerUseWal(pPager) ){
|
||||
sqlite3WalEndWriteTransaction(pPager->pWal);
|
||||
}
|
||||
}
|
||||
#endif /* SQLITE_OMIT_CONCURRENT */
|
||||
|
||||
|
||||
/*
|
||||
** Sync the database file for the pager pPager. zSuper points to the name
|
||||
** of a super-journal file that should be written into the individual
|
||||
@@ -7376,7 +7538,7 @@ int sqlite3PagerGetJournalMode(Pager *pPager){
|
||||
int sqlite3PagerOkToChangeJournalMode(Pager *pPager){
|
||||
assert( assert_pager_state(pPager) );
|
||||
if( pPager->eState>=PAGER_WRITER_CACHEMOD ) return 0;
|
||||
if( NEVER(isOpen(pPager->jfd) && pPager->journalOff>0) ) return 0;
|
||||
if( isOpen(pPager->jfd) && pPager->journalOff>0 ) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -7717,6 +7879,11 @@ void sqlite3PagerSnapshotUnlock(Pager *pPager){
|
||||
}
|
||||
|
||||
#endif /* SQLITE_ENABLE_SNAPSHOT */
|
||||
|
||||
int sqlite3PagerWalInfo(Pager *pPager, u32 *pnPrior, u32 *pnFrame){
|
||||
return sqlite3WalInfo(pPager->pWal, pnPrior, pnFrame);
|
||||
}
|
||||
|
||||
#endif /* !SQLITE_OMIT_WAL */
|
||||
|
||||
#ifdef SQLITE_ENABLE_ZIPVFS
|
||||
|
||||
+19
-2
@@ -163,7 +163,7 @@ void *sqlite3PagerGetExtra(DbPage *);
|
||||
void sqlite3PagerPagecount(Pager*, int*);
|
||||
int sqlite3PagerBegin(Pager*, int exFlag, int);
|
||||
int sqlite3PagerCommitPhaseOne(Pager*,const char *zSuper, int);
|
||||
int sqlite3PagerExclusiveLock(Pager*);
|
||||
int sqlite3PagerExclusiveLock(Pager*, DbPage *pPage1, Pgno*);
|
||||
int sqlite3PagerSync(Pager *pPager, const char *zSuper);
|
||||
int sqlite3PagerCommitPhaseTwo(Pager*);
|
||||
int sqlite3PagerRollback(Pager*);
|
||||
@@ -171,6 +171,7 @@ int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
|
||||
int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
|
||||
int sqlite3PagerSharedLock(Pager *pPager);
|
||||
|
||||
|
||||
#ifndef SQLITE_OMIT_WAL
|
||||
int sqlite3PagerCheckpoint(Pager *pPager, sqlite3*, int, int*, int*);
|
||||
int sqlite3PagerWalSupported(Pager *pPager);
|
||||
@@ -225,10 +226,26 @@ void sqlite3PagerTruncateImage(Pager*,Pgno);
|
||||
|
||||
void sqlite3PagerRekey(DbPage*, Pgno, u16);
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
void sqlite3PagerEndConcurrent(Pager*);
|
||||
int sqlite3PagerBeginConcurrent(Pager*);
|
||||
void sqlite3PagerDropExclusiveLock(Pager*);
|
||||
int sqlite3PagerUpgradeSnapshot(Pager *pPager, DbPage*);
|
||||
void sqlite3PagerSetDbsize(Pager *pPager, Pgno);
|
||||
int sqlite3PagerIsWal(Pager*);
|
||||
#else
|
||||
# define sqlite3PagerEndConcurrent(x)
|
||||
#endif
|
||||
|
||||
#if defined(SQLITE_DEBUG) || !defined(SQLITE_OMIT_CONCURRENT)
|
||||
int sqlite3PagerIswriteable(DbPage*);
|
||||
#endif
|
||||
|
||||
int sqlite3PagerWalInfo(Pager*, u32 *pnPrior, u32 *pnFrame);
|
||||
|
||||
/* Functions to support testing and debugging. */
|
||||
#if !defined(NDEBUG) || defined(SQLITE_TEST)
|
||||
Pgno sqlite3PagerPagenumber(DbPage*);
|
||||
int sqlite3PagerIswriteable(DbPage*);
|
||||
#endif
|
||||
#ifdef SQLITE_TEST
|
||||
int *sqlite3PagerStats(Pager*);
|
||||
|
||||
+19
-3
@@ -105,6 +105,13 @@
|
||||
*/
|
||||
struct TrigEvent { int a; IdList * b; };
|
||||
|
||||
/*
|
||||
** Generate a syntax error
|
||||
*/
|
||||
static void parserSyntaxError(Parse *pParse, Token *p){
|
||||
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", p);
|
||||
}
|
||||
|
||||
struct FrameBound { int eType; Expr *pExpr; };
|
||||
|
||||
/*
|
||||
@@ -164,7 +171,16 @@ trans_opt ::= TRANSACTION nm.
|
||||
transtype(A) ::= . {A = TK_DEFERRED;}
|
||||
transtype(A) ::= DEFERRED(X). {A = @X; /*A-overwrites-X*/}
|
||||
transtype(A) ::= IMMEDIATE(X). {A = @X; /*A-overwrites-X*/}
|
||||
transtype(A) ::= EXCLUSIVE(X). {A = @X; /*A-overwrites-X*/}
|
||||
transtype(A) ::= ID(X). {
|
||||
Token *p = &X;
|
||||
if( p->n==9 && sqlite3_strnicmp(p->z,"exclusive",9)==0 ){
|
||||
A = TK_EXCLUSIVE;
|
||||
}else if( p->n==10 && sqlite3_strnicmp(p->z,"concurrent",10)==0 ){
|
||||
A = TK_CONCURRENT; /*A-overwrites-X*/
|
||||
}else{
|
||||
parserSyntaxError(pParse, p);
|
||||
}
|
||||
}
|
||||
cmd ::= COMMIT|END(X) trans_opt. {sqlite3EndTransaction(pParse,@X);}
|
||||
cmd ::= ROLLBACK(X) trans_opt. {sqlite3EndTransaction(pParse,@X);}
|
||||
|
||||
@@ -296,7 +312,6 @@ columnname(A) ::= nm(A) typetoken(Y). {sqlite3AddColumn(pParse,A,Y);}
|
||||
//
|
||||
%token_class id ID|INDEXED.
|
||||
|
||||
|
||||
// And "ids" is an identifer-or-string.
|
||||
//
|
||||
%token_class ids ID|STRING.
|
||||
@@ -1119,7 +1134,7 @@ expr(A) ::= VARIABLE(X). {
|
||||
Token t = X; /*A-overwrites-X*/
|
||||
assert( t.n>=2 );
|
||||
if( pParse->nested==0 ){
|
||||
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
|
||||
parserSyntaxError(pParse, &t);
|
||||
A = 0;
|
||||
}else{
|
||||
A = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
|
||||
@@ -1901,6 +1916,7 @@ filter_clause(A) ::= FILTER LP WHERE expr(X) RP. { A = X; }
|
||||
UPLUS /* Unary plus */
|
||||
TRUTH /* IS TRUE or IS FALSE or IS NOT TRUE or IS NOT FALSE */
|
||||
REGISTER /* Reference to a VDBE register */
|
||||
CONCURRENT /* BEGIN CONCURRENT */
|
||||
VECTOR /* Vector */
|
||||
SELECT_COLUMN /* Choose a single column from a multi-column SELECT */
|
||||
IF_NULL_ROW /* the if-null-row operator */
|
||||
|
||||
@@ -965,6 +965,7 @@ void sqlite3Pragma(
|
||||
**
|
||||
*/
|
||||
case PragTyp_TEMP_STORE_DIRECTORY: {
|
||||
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
if( !zRight ){
|
||||
returnSingleText(v, sqlite3_temp_directory);
|
||||
}else{
|
||||
@@ -974,6 +975,7 @@ void sqlite3Pragma(
|
||||
rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);
|
||||
if( rc!=SQLITE_OK || res==0 ){
|
||||
sqlite3ErrorMsg(pParse, "not a writable directory");
|
||||
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
goto pragma_out;
|
||||
}
|
||||
}
|
||||
@@ -991,6 +993,7 @@ void sqlite3Pragma(
|
||||
}
|
||||
#endif /* SQLITE_OMIT_WSD */
|
||||
}
|
||||
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1009,6 +1012,7 @@ void sqlite3Pragma(
|
||||
**
|
||||
*/
|
||||
case PragTyp_DATA_STORE_DIRECTORY: {
|
||||
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
if( !zRight ){
|
||||
returnSingleText(v, sqlite3_data_directory);
|
||||
}else{
|
||||
@@ -1018,6 +1022,7 @@ void sqlite3Pragma(
|
||||
rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res);
|
||||
if( rc!=SQLITE_OK || res==0 ){
|
||||
sqlite3ErrorMsg(pParse, "not a writable directory");
|
||||
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
goto pragma_out;
|
||||
}
|
||||
}
|
||||
@@ -1029,6 +1034,7 @@ void sqlite3Pragma(
|
||||
}
|
||||
#endif /* SQLITE_OMIT_WSD */
|
||||
}
|
||||
sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_TEMPDIR));
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -441,6 +441,15 @@ static const PragmaName aPragmaName[] = {
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
#if defined(SQLITE_ENABLE_NOOP_UPDATE)
|
||||
{/* zName: */ "noop_update",
|
||||
/* ePragTyp: */ PragTyp_FLAG,
|
||||
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
|
||||
/* ColNames: */ 0, 0,
|
||||
/* iArg: */ SQLITE_NoopUpdate },
|
||||
#endif
|
||||
#endif
|
||||
{/* zName: */ "optimize",
|
||||
/* ePragTyp: */ PragTyp_OPTIMIZE,
|
||||
|
||||
+2
-2
@@ -803,8 +803,8 @@ void sqlite3_str_vappendf(
|
||||
case etSQLESCAPE: /* %q: Escape ' characters */
|
||||
case etSQLESCAPE2: /* %Q: Escape ' and enclose in '...' */
|
||||
case etSQLESCAPE3: { /* %w: Escape " characters */
|
||||
int i, j, k, n, isnull;
|
||||
int needQuote;
|
||||
i64 i, j, k, n;
|
||||
int needQuote, isnull;
|
||||
char ch;
|
||||
char q = ((xtype==etSQLESCAPE3)?'"':'\''); /* Quote character */
|
||||
char *escarg;
|
||||
|
||||
@@ -111,6 +111,33 @@ void sqlite3_randomness(int N, void *pBuf){
|
||||
sqlite3_mutex_leave(mutex);
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize a fast PRNG. A Fast PRNG is called "fast" because it does
|
||||
** not need a mutex to operate, though it does use a mutex to initialize.
|
||||
** The quality of the randomness is not as good as the global PRNG.
|
||||
*/
|
||||
void sqlite3FastPrngInit(FastPrng *pPrng){
|
||||
sqlite3_randomness(sizeof(*pPrng), pPrng);
|
||||
pPrng->x |= 1;
|
||||
}
|
||||
|
||||
/*
|
||||
** Generate N bytes of pseudo-randomness using a FastPrng
|
||||
*/
|
||||
void sqlite3FastRandomness(FastPrng *pPrng, int N, void *P){
|
||||
unsigned char *pOut = (unsigned char*)P;
|
||||
while( N-->0 ){
|
||||
/* "x" is a variant of LFSR called "Xorshift" by George Marsaglia */
|
||||
pPrng->x ^= pPrng->x <<13;
|
||||
pPrng->x ^= pPrng->x >>7;
|
||||
pPrng->x ^= pPrng->x <<17;
|
||||
/* "y" is a LCG using Don Kunth's constants from MMIX */
|
||||
pPrng->y = (pPrng->y)*6364136223846793005LL + 1442695040888963407LL;
|
||||
/* XOR the two streams together to give the final result */
|
||||
*(pOut++) = (pPrng->x ^ pPrng->y) & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SQLITE_UNTESTABLE
|
||||
/*
|
||||
** For testing purposes, we sometimes want to preserve the state of
|
||||
|
||||
+8
-18
@@ -85,33 +85,23 @@ static void resolveAlias(
|
||||
sqlite3ExprDelete(db, pDup);
|
||||
pDup = 0;
|
||||
}else{
|
||||
Expr temp;
|
||||
incrAggFunctionDepth(pDup, nSubquery);
|
||||
if( pExpr->op==TK_COLLATE ){
|
||||
assert( !ExprHasProperty(pExpr, EP_IntValue) );
|
||||
pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);
|
||||
}
|
||||
|
||||
/* Before calling sqlite3ExprDelete(), set the EP_Static flag. This
|
||||
** prevents ExprDelete() from deleting the Expr structure itself,
|
||||
** allowing it to be repopulated by the memcpy() on the following line.
|
||||
** The pExpr->u.zToken might point into memory that will be freed by the
|
||||
** sqlite3DbFree(db, pDup) on the last line of this block, so be sure to
|
||||
** make a copy of the token before doing the sqlite3DbFree().
|
||||
*/
|
||||
ExprSetProperty(pExpr, EP_Static);
|
||||
sqlite3ExprDelete(db, pExpr);
|
||||
memcpy(pExpr, pDup, sizeof(*pExpr));
|
||||
if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){
|
||||
assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 );
|
||||
pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken);
|
||||
pExpr->flags |= EP_MemToken;
|
||||
}
|
||||
memcpy(&temp, pDup, sizeof(Expr));
|
||||
memcpy(pDup, pExpr, sizeof(Expr));
|
||||
memcpy(pExpr, &temp, sizeof(Expr));
|
||||
if( ExprHasProperty(pExpr, EP_WinFunc) ){
|
||||
if( ALWAYS(pExpr->y.pWin!=0) ){
|
||||
pExpr->y.pWin->pOwner = pExpr;
|
||||
}
|
||||
}
|
||||
sqlite3DbFree(db, pDup);
|
||||
sqlite3ParserAddCleanup(pParse,
|
||||
(void(*)(sqlite3*,void*))sqlite3ExprDelete,
|
||||
pDup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +304,7 @@ static int lookupName(
|
||||
pTab = pItem->pTab;
|
||||
assert( pTab!=0 && pTab->zName!=0 );
|
||||
assert( pTab->nCol>0 || pParse->nErr );
|
||||
assert( pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) );
|
||||
assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) );
|
||||
if( pItem->fg.isNestedFrom ){
|
||||
/* In this case, pItem is a subquery that has been formed from a
|
||||
** parenthesized subset of the FROM clause terms. Example:
|
||||
|
||||
+30
-10
@@ -324,7 +324,7 @@ int sqlite3ColumnIndex(Table *pTab, const char *zCol){
|
||||
*/
|
||||
void sqlite3SrcItemColumnUsed(SrcItem *pItem, int iCol){
|
||||
assert( pItem!=0 );
|
||||
assert( pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) );
|
||||
assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) );
|
||||
if( pItem->fg.isNestedFrom ){
|
||||
ExprList *pResults;
|
||||
assert( pItem->pSelect!=0 );
|
||||
@@ -1688,7 +1688,7 @@ static void generateSortTail(
|
||||
if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce);
|
||||
addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);
|
||||
VdbeCoverage(v);
|
||||
codeOffset(v, p->iOffset, addrContinue);
|
||||
assert( p->iLimit==0 && p->iOffset==0 );
|
||||
sqlite3VdbeAddOp3(v, OP_SorterData, iTab, regSortOut, iSortTab);
|
||||
bSeq = 0;
|
||||
}else{
|
||||
@@ -1696,6 +1696,9 @@ static void generateSortTail(
|
||||
codeOffset(v, p->iOffset, addrContinue);
|
||||
iSortTab = iTab;
|
||||
bSeq = 1;
|
||||
if( p->iOffset>0 ){
|
||||
sqlite3VdbeAddOp2(v, OP_AddImm, p->iLimit, -1);
|
||||
}
|
||||
}
|
||||
for(i=0, iCol=nKey+bSeq-1; i<nColumn; i++){
|
||||
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
|
||||
@@ -2236,7 +2239,7 @@ int sqlite3ColumnsFromExprList(
|
||||
if( zName[j]==':' ) nName = j;
|
||||
}
|
||||
zName = sqlite3MPrintf(db, "%.*z:%u", nName, zName, ++cnt);
|
||||
if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt);
|
||||
if( cnt>3 ) sqlite3FastRandomness(&db->sPrng, sizeof(cnt), &cnt);
|
||||
}
|
||||
pCol->zCnName = zName;
|
||||
pCol->hName = sqlite3StrIHash(zName);
|
||||
@@ -3688,10 +3691,11 @@ static int multiSelectOrderBy(
|
||||
*/
|
||||
sqlite3VdbeResolveLabel(v, labelEnd);
|
||||
|
||||
/* Reassembly the compound query so that it will be freed correctly
|
||||
/* Reassemble the compound query so that it will be freed correctly
|
||||
** by the calling function */
|
||||
if( pSplit->pPrior ){
|
||||
sqlite3SelectDelete(db, pSplit->pPrior);
|
||||
sqlite3ParserAddCleanup(pParse,
|
||||
(void(*)(sqlite3*,void*))sqlite3SelectDelete, pSplit->pPrior);
|
||||
}
|
||||
pSplit->pPrior = pPrior;
|
||||
pPrior->pNext = pSplit;
|
||||
@@ -4122,6 +4126,9 @@ static void renumberCursors(
|
||||
** (17d2) DISTINCT
|
||||
** (17e) the subquery may not contain window functions, and
|
||||
** (17f) the subquery must not be the RHS of a LEFT JOIN.
|
||||
** (17g) either the subquery is the first element of the outer
|
||||
** query or there are no RIGHT or FULL JOINs in any arm
|
||||
** of the subquery. (This is a duplicate of condition (27b).)
|
||||
**
|
||||
** The parent and sub-query may contain WHERE clauses. Subject to
|
||||
** rules (11), (13) and (14), they may also contain ORDER BY,
|
||||
@@ -4173,7 +4180,11 @@ static void renumberCursors(
|
||||
** See also (3) for restrictions on LEFT JOIN.
|
||||
**
|
||||
** (27) The subquery may not contain a FULL or RIGHT JOIN unless it
|
||||
** is the first element of the parent query.
|
||||
** is the first element of the parent query. This must be the
|
||||
** the case if:
|
||||
** (27a) the subquery is not compound query, and
|
||||
** (27b) the subquery is a compound query and the RIGHT JOIN occurs
|
||||
** in any arm of the compound query. (See also (17g).)
|
||||
**
|
||||
** (28) The subquery is not a MATERIALIZED CTE.
|
||||
**
|
||||
@@ -4303,7 +4314,7 @@ static int flattenSubquery(
|
||||
|
||||
assert( pSubSrc->nSrc>0 ); /* True by restriction (7) */
|
||||
if( iFrom>0 && (pSubSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){
|
||||
return 0; /* Restriction (27) */
|
||||
return 0; /* Restriction (27a) */
|
||||
}
|
||||
if( pSubitem->fg.isCte && pSubitem->u2.pCteUse->eM10d==M10d_Yes ){
|
||||
return 0; /* (28) */
|
||||
@@ -4323,7 +4334,7 @@ static int flattenSubquery(
|
||||
** NATURAL join or a join that as an ON or USING clause.
|
||||
**
|
||||
** These conditions are sufficient to keep an EP_OuterON from being
|
||||
** flattened into an EP_InnerON. Restrictions (3a) and (27) prevent
|
||||
** flattened into an EP_InnerON. Restrictions (3a) and (27a) prevent
|
||||
** an EP_InnerON from being flattened into an EP_OuterON.
|
||||
*/
|
||||
if( pSubSrc->nSrc>=2
|
||||
@@ -4365,6 +4376,12 @@ static int flattenSubquery(
|
||||
){
|
||||
return 0;
|
||||
}
|
||||
if( iFrom>0 && (pSub1->pSrc->a[0].fg.jointype & JT_LTORJ)!=0 ){
|
||||
/* Without this restriction, the JT_LTORJ flag would end up being
|
||||
** omitted on left-hand tables of the right join that is being
|
||||
** flattened. */
|
||||
return 0; /* Restrictions (17g), (27b) */
|
||||
}
|
||||
testcase( pSub1->pSrc->nSrc>1 );
|
||||
}
|
||||
|
||||
@@ -5197,6 +5214,7 @@ static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
|
||||
|| p->pSrc->nSrc!=1
|
||||
|| p->pSrc->a[0].pSelect
|
||||
|| pAggInfo->nFunc!=1
|
||||
|| p->pHaving
|
||||
){
|
||||
return 0;
|
||||
}
|
||||
@@ -5898,7 +5916,7 @@ static int selectExpander(Walker *pWalker, Select *p){
|
||||
zTabName = pTab->zName;
|
||||
}
|
||||
if( db->mallocFailed ) break;
|
||||
assert( pFrom->fg.isNestedFrom == IsNestedFrom(pFrom->pSelect) );
|
||||
assert( (int)pFrom->fg.isNestedFrom == IsNestedFrom(pFrom->pSelect) );
|
||||
if( pFrom->fg.isNestedFrom ){
|
||||
assert( pFrom->pSelect!=0 );
|
||||
pNestedFrom = pFrom->pSelect->pEList;
|
||||
@@ -6827,7 +6845,9 @@ int sqlite3Select(
|
||||
){
|
||||
SELECTTRACE(0x100,pParse,p,
|
||||
("omit superfluous ORDER BY on %r FROM-clause subquery\n",i+1));
|
||||
sqlite3ExprListDelete(db, pSub->pOrderBy);
|
||||
sqlite3ParserAddCleanup(pParse,
|
||||
(void(*)(sqlite3*,void*))sqlite3ExprListDelete,
|
||||
pSub->pOrderBy);
|
||||
pSub->pOrderBy = 0;
|
||||
}
|
||||
|
||||
|
||||
+1
-10
@@ -11990,7 +11990,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
||||
char **argv;
|
||||
#endif
|
||||
#ifdef SQLITE_DEBUG
|
||||
sqlite3_uint64 mem_main_enter = sqlite3_memory_used();
|
||||
sqlite3_int64 mem_main_enter = sqlite3_memory_used();
|
||||
#endif
|
||||
char *zErrMsg = 0;
|
||||
#ifdef SQLITE_SHELL_WASM_MODE
|
||||
@@ -12169,15 +12169,6 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
||||
n = (int)integerValue(cmdline_option_value(argc,argv,++i));
|
||||
if( n<0 ) n = 0;
|
||||
sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, n);
|
||||
if( sz*n==0 ) data.shellFlgs &= ~SHFLG_Lookaside;
|
||||
}else if( strcmp(z,"-threadsafe")==0 ){
|
||||
int n;
|
||||
n = (int)integerValue(cmdline_option_value(argc,argv,++i));
|
||||
switch( n ){
|
||||
case 0: sqlite3_config(SQLITE_CONFIG_SINGLETHREAD); break;
|
||||
case 2: sqlite3_config(SQLITE_CONFIG_MULTITHREAD); break;
|
||||
default: sqlite3_config(SQLITE_CONFIG_SERIALIZED); break;
|
||||
}
|
||||
#ifdef SQLITE_ENABLE_VFSTRACE
|
||||
}else if( strcmp(z,"-vfstrace")==0 ){
|
||||
extern int vfstrace_register(
|
||||
|
||||
+26
-1
@@ -6282,7 +6282,7 @@ sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
|
||||
**
|
||||
** ^The sqlite3_db_name(D,N) interface returns a pointer to the schema name
|
||||
** for the N-th database on database connection D, or a NULL pointer of N is
|
||||
** out of range. An N alue of 0 means the main database file. An N of 1 is
|
||||
** out of range. An N value of 0 means the main database file. An N of 1 is
|
||||
** the "temp" schema. Larger values of N correspond to various ATTACH-ed
|
||||
** databases.
|
||||
**
|
||||
@@ -10276,6 +10276,31 @@ SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
|
||||
*/
|
||||
SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Wal related information regarding the most recent COMMIT
|
||||
** EXPERIMENTAL
|
||||
**
|
||||
** This function reports on the state of the wal file (if any) for database
|
||||
** zDb, which should be "main", "temp", or the name of the attached database.
|
||||
** Its results - the values written to the output parameters - are only
|
||||
** defined if the most recent SQL command on the connection was a successful
|
||||
** COMMIT that wrote data to wal-mode database zDb.
|
||||
**
|
||||
** Assuming the above conditions are met, output parameter (*pnFrame) is set
|
||||
** to the total number of frames in the wal file. Parameter (*pnPrior) is
|
||||
** set to the number of frames that were present in the wal file before the
|
||||
** most recent transaction was committed. So that the number of frames written
|
||||
** by the most recent transaction is (*pnFrame)-(*pnPrior).
|
||||
**
|
||||
** If successful, SQLITE_OK is returned. Otherwise, an SQLite error code. It
|
||||
** is not an error if this function is called at a time when the results
|
||||
** are undefined.
|
||||
*/
|
||||
SQLITE_EXPERIMENTAL int sqlite3_wal_info(
|
||||
sqlite3 *db, const char *zDb,
|
||||
unsigned int *pnPrior, unsigned int *pnFrame
|
||||
);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Serialize a database
|
||||
**
|
||||
|
||||
@@ -198,6 +198,11 @@
|
||||
*/
|
||||
#include "sqlite3.h"
|
||||
|
||||
/*
|
||||
** Reuse the STATIC_LRU for mutex access to sqlite3_temp_directory.
|
||||
*/
|
||||
#define SQLITE_MUTEX_STATIC_TEMPDIR SQLITE_MUTEX_STATIC_VFS1
|
||||
|
||||
/*
|
||||
** Include the configuration header output by 'configure' if we're using the
|
||||
** autoconf-based build
|
||||
@@ -1178,6 +1183,7 @@ typedef struct DbFixer DbFixer;
|
||||
typedef struct Schema Schema;
|
||||
typedef struct Expr Expr;
|
||||
typedef struct ExprList ExprList;
|
||||
typedef struct FastPrng FastPrng;
|
||||
typedef struct FKey FKey;
|
||||
typedef struct FuncDestructor FuncDestructor;
|
||||
typedef struct FuncDef FuncDef;
|
||||
@@ -1301,6 +1307,14 @@ typedef int VList;
|
||||
# define SQLITE_DEFAULT_WAL_SYNCHRONOUS SQLITE_DEFAULT_SYNCHRONOUS
|
||||
#endif
|
||||
|
||||
/*
|
||||
** State of a simple PRNG used for the per-connection and per-pager
|
||||
** pseudo-random number generators.
|
||||
*/
|
||||
struct FastPrng {
|
||||
sqlite3_uint64 x, y;
|
||||
};
|
||||
|
||||
/*
|
||||
** Each database file to be accessed by the system is an instance
|
||||
** of the following structure. There are normally two of these structures
|
||||
@@ -1547,6 +1561,7 @@ struct sqlite3 {
|
||||
u32 dbOptFlags; /* Flags to enable/disable optimizations */
|
||||
u8 enc; /* Text encoding */
|
||||
u8 autoCommit; /* The auto-commit flag. */
|
||||
u8 eConcurrent; /* CONCURRENT_* value */
|
||||
u8 temp_store; /* 1: file 2: memory 0: default */
|
||||
u8 mallocFailed; /* True if we have seen a malloc failure */
|
||||
u8 bBenignMalloc; /* Do not require OOMs if true */
|
||||
@@ -1560,6 +1575,7 @@ struct sqlite3 {
|
||||
u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
|
||||
u8 eOpenState; /* Current condition of the connection */
|
||||
int nextPagesize; /* Pagesize after VACUUM if >0 */
|
||||
FastPrng sPrng; /* State of the per-connection PRNG */
|
||||
i64 nChange; /* Value returned by sqlite3_changes() */
|
||||
i64 nTotalChange; /* Value returned by sqlite3_total_changes() */
|
||||
int aLimit[SQLITE_N_LIMIT]; /* Limits */
|
||||
@@ -1669,6 +1685,13 @@ struct sqlite3 {
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
** Candidate values for sqlite3.eConcurrent
|
||||
*/
|
||||
#define CONCURRENT_NONE 0
|
||||
#define CONCURRENT_OPEN 1
|
||||
#define CONCURRENT_SCHEMA 2
|
||||
|
||||
/*
|
||||
** A macro to discover the encoding of a database.
|
||||
*/
|
||||
@@ -1729,6 +1752,9 @@ struct sqlite3 {
|
||||
/* the count using a callback. */
|
||||
#define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */
|
||||
|
||||
/* Flags used by the Pragma noop_update enhancement */
|
||||
#define SQLITE_NoopUpdate HI(0x0001000) /* UPDATE operations are no-ops */
|
||||
|
||||
/* Flags used only if debugging */
|
||||
#ifdef SQLITE_DEBUG
|
||||
#define SQLITE_SqlTrace HI(0x0100000) /* Debug print SQL as it executes */
|
||||
@@ -4474,6 +4500,7 @@ char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
|
||||
void sqlite3TreeViewSelect(TreeView*, const Select*, u8);
|
||||
void sqlite3TreeViewWith(TreeView*, const With*, u8);
|
||||
void sqlite3TreeViewUpsert(TreeView*, const Upsert*, u8);
|
||||
#if TREETRACE_ENABLED
|
||||
void sqlite3TreeViewDelete(const With*, const SrcList*, const Expr*,
|
||||
const ExprList*,const Expr*, const Trigger*);
|
||||
void sqlite3TreeViewInsert(const With*, const SrcList*,
|
||||
@@ -4482,6 +4509,7 @@ char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
|
||||
void sqlite3TreeViewUpdate(const With*, const SrcList*, const ExprList*,
|
||||
const Expr*, int, const ExprList*, const Expr*,
|
||||
const Upsert*, const Trigger*);
|
||||
#endif
|
||||
#ifndef SQLITE_OMIT_TRIGGER
|
||||
void sqlite3TreeViewTriggerStep(TreeView*, const TriggerStep*, u8, u8);
|
||||
void sqlite3TreeViewTrigger(TreeView*, const Trigger*, u8, u8);
|
||||
@@ -4747,6 +4775,8 @@ Vdbe *sqlite3GetVdbe(Parse*);
|
||||
void sqlite3PrngSaveState(void);
|
||||
void sqlite3PrngRestoreState(void);
|
||||
#endif
|
||||
void sqlite3FastPrngInit(FastPrng*);
|
||||
void sqlite3FastRandomness(FastPrng*, int N, void *P);
|
||||
void sqlite3RollbackAll(sqlite3*,int);
|
||||
void sqlite3CodeVerifySchema(Parse*, int);
|
||||
void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);
|
||||
|
||||
+38
-2
@@ -8227,6 +8227,41 @@ static int SQLITE_TCLAPI test_dbconfig_maindbname_icecube(
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: sqlite3_wal_info DB DBNAME
|
||||
*/
|
||||
static int SQLITE_TCLAPI test_wal_info(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
int rc;
|
||||
sqlite3 *db;
|
||||
char *zName;
|
||||
unsigned int nPrior;
|
||||
unsigned int nFrame;
|
||||
|
||||
if( objc!=3 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
||||
zName = Tcl_GetString(objv[2]);
|
||||
|
||||
rc = sqlite3_wal_info(db, zName, &nPrior, &nFrame);
|
||||
if( rc!=SQLITE_OK ){
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
|
||||
return TCL_ERROR;
|
||||
}else{
|
||||
Tcl_Obj *pNew = Tcl_NewObj();
|
||||
Tcl_ListObjAppendElement(interp, pNew, Tcl_NewWideIntObj((i64)nPrior));
|
||||
Tcl_ListObjAppendElement(interp, pNew, Tcl_NewWideIntObj((i64)nFrame));
|
||||
Tcl_SetObjResult(interp, pNew);
|
||||
}
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Usage: sqlite3_mmap_warm DB DBNAME
|
||||
*/
|
||||
@@ -8790,8 +8825,9 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
||||
{ "sqlite3_snapshot_open_blob", test_snapshot_open_blob, 0 },
|
||||
{ "sqlite3_snapshot_cmp_blob", test_snapshot_cmp_blob, 0 },
|
||||
#endif
|
||||
{ "sqlite3_delete_database", test_delete_database, 0 },
|
||||
{ "atomic_batch_write", test_atomic_batch_write, 0 },
|
||||
{ "sqlite3_delete_database", test_delete_database, 0 },
|
||||
{ "sqlite3_wal_info", test_wal_info, 0 },
|
||||
{ "atomic_batch_write", test_atomic_batch_write, 0 },
|
||||
{ "sqlite3_mmap_warm", test_mmap_warm, 0 },
|
||||
{ "sqlite3_config_sorterref", test_config_sorterref, 0 },
|
||||
{ "sqlite3_autovacuum_pages", test_autovacuum_pages, 0 },
|
||||
|
||||
@@ -681,6 +681,12 @@ Tcl_SetVar2(interp, "sqlite_options", "mergesort", "1", TCL_GLOBAL_ONLY);
|
||||
Tcl_SetVar2(interp, "sqlite_options", "truncate_opt", "1", TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
Tcl_SetVar2(interp, "sqlite_options", "concurrent", "1", TCL_GLOBAL_ONLY);
|
||||
#else
|
||||
Tcl_SetVar2(interp, "sqlite_options", "concurrent", "0", TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_OMIT_UTF16
|
||||
Tcl_SetVar2(interp, "sqlite_options", "utf16", "0", TCL_GLOBAL_ONLY);
|
||||
#else
|
||||
|
||||
@@ -614,6 +614,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql){
|
||||
mxSqlLen -= n;
|
||||
if( mxSqlLen<0 ){
|
||||
pParse->rc = SQLITE_TOOBIG;
|
||||
pParse->nErr++;
|
||||
break;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_WINDOWFUNC
|
||||
|
||||
+9
-3
@@ -100,8 +100,8 @@ void sqlite3TreeViewColumnList(
|
||||
sqlite3TreeViewLine(pView, "COLUMNS");
|
||||
for(i=0; i<nCol; i++){
|
||||
u16 flg = aCol[i].colFlags;
|
||||
int moreToFollow = i<(nCol - 1);
|
||||
sqlite3TreeViewPush(&pView, moreToFollow);
|
||||
int colMoreToFollow = i<(nCol - 1);
|
||||
sqlite3TreeViewPush(&pView, colMoreToFollow);
|
||||
sqlite3TreeViewLine(pView, 0);
|
||||
printf(" %s", aCol[i].zCnName);
|
||||
switch( aCol[i].eCType ){
|
||||
@@ -232,7 +232,7 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){
|
||||
Table *pTab = pItem->pTab;
|
||||
sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1);
|
||||
}
|
||||
assert( pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) );
|
||||
assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem->pSelect) );
|
||||
sqlite3TreeViewSelect(pView, pItem->pSelect, (--n)>0);
|
||||
}
|
||||
if( pItem->fg.isTabFunc ){
|
||||
@@ -999,6 +999,7 @@ void sqlite3TreeViewUpsert(
|
||||
sqlite3TreeViewPop(&pView);
|
||||
}
|
||||
|
||||
#if TREETRACE_ENABLED
|
||||
/*
|
||||
** Generate a human-readable diagram of the data structure that go
|
||||
** into generating an DELETE statement.
|
||||
@@ -1052,7 +1053,9 @@ void sqlite3TreeViewDelete(
|
||||
}
|
||||
sqlite3TreeViewPop(&pView);
|
||||
}
|
||||
#endif /* TREETRACE_ENABLED */
|
||||
|
||||
#if TREETRACE_ENABLED
|
||||
/*
|
||||
** Generate a human-readable diagram of the data structure that go
|
||||
** into generating an INSERT statement.
|
||||
@@ -1120,7 +1123,9 @@ void sqlite3TreeViewInsert(
|
||||
}
|
||||
sqlite3TreeViewPop(&pView);
|
||||
}
|
||||
#endif /* TREETRACE_ENABLED */
|
||||
|
||||
#if TREETRACE_ENABLED
|
||||
/*
|
||||
** Generate a human-readable diagram of the data structure that go
|
||||
** into generating an UPDATE statement.
|
||||
@@ -1196,6 +1201,7 @@ void sqlite3TreeViewUpdate(
|
||||
}
|
||||
sqlite3TreeViewPop(&pView);
|
||||
}
|
||||
#endif /* TREETRACE_ENABLED */
|
||||
|
||||
#ifndef SQLITE_OMIT_TRIGGER
|
||||
/*
|
||||
|
||||
@@ -461,6 +461,17 @@ void sqlite3Update(
|
||||
*/
|
||||
chngRowid = chngPk = 0;
|
||||
for(i=0; i<pChanges->nExpr; i++){
|
||||
#if defined(SQLITE_ENABLE_NOOP_UPDATE) && !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
if( db->flags & SQLITE_NoopUpdate ){
|
||||
Token x;
|
||||
sqlite3ExprDelete(db, pChanges->a[i].pExpr);
|
||||
x.z = pChanges->a[i].zEName;
|
||||
x.n = sqlite3Strlen30(x.z);
|
||||
pChanges->a[i].pExpr =
|
||||
sqlite3PExpr(pParse, TK_UPLUS, sqlite3ExprAlloc(db, TK_ID, &x, 0), 0);
|
||||
if( db->mallocFailed ) goto update_cleanup;
|
||||
}
|
||||
#endif
|
||||
u8 hCol = sqlite3StrIHash(pChanges->a[i].zEName);
|
||||
/* If this is an UPDATE with a FROM clause, do not resolve expressions
|
||||
** here. The call to sqlite3Select() below will do that. */
|
||||
|
||||
+1
-1
@@ -190,7 +190,7 @@ void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){
|
||||
va_list ap;
|
||||
sqlite3 *db = pParse->db;
|
||||
assert( db!=0 );
|
||||
assert( db->pParse==pParse );
|
||||
assert( db->pParse==pParse || db->pParse->pToplevel==pParse );
|
||||
db->errByteOffset = -2;
|
||||
va_start(ap, zFormat);
|
||||
zMsg = sqlite3VMPrintf(db, zFormat, ap);
|
||||
|
||||
@@ -390,6 +390,7 @@ end_of_vacuum:
|
||||
** is closed by the DETACH.
|
||||
*/
|
||||
db->autoCommit = 1;
|
||||
assert( db->eConcurrent==0 );
|
||||
|
||||
if( pDb ){
|
||||
sqlite3BtreeClose(pDb->pBt);
|
||||
|
||||
+48
-7
@@ -3613,6 +3613,7 @@ case OP_Savepoint: {
|
||||
** is committed.
|
||||
*/
|
||||
int isTransaction = pSavepoint->pNext==0 && db->isTransactionSavepoint;
|
||||
assert( db->eConcurrent==0 || db->isTransactionSavepoint==0 );
|
||||
if( isTransaction && p1==SAVEPOINT_RELEASE ){
|
||||
if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
|
||||
goto vdbe_return;
|
||||
@@ -3699,23 +3700,31 @@ case OP_Savepoint: {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: AutoCommit P1 P2 * * *
|
||||
/* Opcode: AutoCommit P1 P2 P3 * *
|
||||
**
|
||||
** Set the database auto-commit flag to P1 (1 or 0). If P2 is true, roll
|
||||
** back any currently active btree transactions. If there are any active
|
||||
** VMs (apart from this one), then a ROLLBACK fails. A COMMIT fails if
|
||||
** there are active writing VMs or active VMs that use shared cache.
|
||||
**
|
||||
** If P3 is non-zero, then this instruction is being executed as part of
|
||||
** a "BEGIN CONCURRENT" command.
|
||||
**
|
||||
** This instruction causes the VM to halt.
|
||||
*/
|
||||
case OP_AutoCommit: {
|
||||
int desiredAutoCommit;
|
||||
int iRollback;
|
||||
int bConcurrent;
|
||||
int hrc;
|
||||
|
||||
desiredAutoCommit = pOp->p1;
|
||||
iRollback = pOp->p2;
|
||||
bConcurrent = pOp->p3;
|
||||
assert( desiredAutoCommit==1 || desiredAutoCommit==0 );
|
||||
assert( desiredAutoCommit==1 || iRollback==0 );
|
||||
assert( desiredAutoCommit==0 || bConcurrent==0 );
|
||||
assert( db->autoCommit==0 || db->eConcurrent==CONCURRENT_NONE );
|
||||
assert( db->nVdbeActive>0 ); /* At least this one VM is active */
|
||||
assert( p->bIsReader );
|
||||
|
||||
@@ -3724,10 +3733,17 @@ case OP_AutoCommit: {
|
||||
assert( desiredAutoCommit==1 );
|
||||
sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
|
||||
db->autoCommit = 1;
|
||||
}else if( desiredAutoCommit && db->nVdbeWrite>0 ){
|
||||
/* If this instruction implements a COMMIT and other VMs are writing
|
||||
** return an error indicating that the other VMs must complete first.
|
||||
*/
|
||||
db->eConcurrent = CONCURRENT_NONE;
|
||||
}else if( desiredAutoCommit
|
||||
&& (db->nVdbeWrite>0 || (db->eConcurrent && db->nVdbeActive>1)) ){
|
||||
/* A transaction may only be committed if there are no other active
|
||||
** writer VMs. If the transaction is CONCURRENT, then it may only be
|
||||
** committed if there are no active VMs at all (readers or writers).
|
||||
**
|
||||
** If this instruction is a COMMIT and the transaction may not be
|
||||
** committed due to one of the conditions above, return an error
|
||||
** indicating that other VMs must complete before the COMMIT can
|
||||
** be processed. */
|
||||
sqlite3VdbeError(p, "cannot commit transaction - "
|
||||
"SQL statements in progress");
|
||||
rc = SQLITE_BUSY;
|
||||
@@ -3737,12 +3753,16 @@ case OP_AutoCommit: {
|
||||
}else{
|
||||
db->autoCommit = (u8)desiredAutoCommit;
|
||||
}
|
||||
if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
|
||||
hrc = sqlite3VdbeHalt(p);
|
||||
if( (hrc & 0xFF)==SQLITE_BUSY ){
|
||||
p->pc = (int)(pOp - aOp);
|
||||
db->autoCommit = (u8)(1-desiredAutoCommit);
|
||||
p->rc = rc = SQLITE_BUSY;
|
||||
p->rc = hrc;
|
||||
rc = SQLITE_BUSY;
|
||||
goto vdbe_return;
|
||||
}
|
||||
assert( bConcurrent==CONCURRENT_NONE || bConcurrent==CONCURRENT_OPEN );
|
||||
db->eConcurrent = (u8)bConcurrent;
|
||||
sqlite3CloseSavepoints(db);
|
||||
if( p->rc==SQLITE_OK ){
|
||||
rc = SQLITE_DONE;
|
||||
@@ -3955,6 +3975,17 @@ case OP_SetCookie: {
|
||||
pDb = &db->aDb[pOp->p1];
|
||||
assert( pDb->pBt!=0 );
|
||||
assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) );
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
if( db->eConcurrent
|
||||
&& (pOp->p2==BTREE_USER_VERSION || pOp->p2==BTREE_APPLICATION_ID)
|
||||
){
|
||||
rc = SQLITE_ERROR;
|
||||
sqlite3VdbeError(p, "cannot modify %s within CONCURRENT transaction",
|
||||
pOp->p2==BTREE_USER_VERSION ? "user_version" : "application_id"
|
||||
);
|
||||
goto abort_due_to_error;
|
||||
}
|
||||
#endif
|
||||
/* See note about index shifting on OP_ReadCookie */
|
||||
rc = sqlite3BtreeUpdateMeta(pDb->pBt, pOp->p2, pOp->p3);
|
||||
if( pOp->p2==BTREE_SCHEMA_VERSION ){
|
||||
@@ -4104,6 +4135,11 @@ case OP_OpenWrite:
|
||||
pX = pDb->pBt;
|
||||
assert( pX!=0 );
|
||||
if( pOp->opcode==OP_OpenWrite ){
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
if( db->eConcurrent==CONCURRENT_OPEN && p2==1 && iDb!=1 ){
|
||||
db->eConcurrent = CONCURRENT_SCHEMA;
|
||||
}
|
||||
#endif
|
||||
assert( OPFLAG_FORDELETE==BTREE_FORDELETE );
|
||||
wrFlag = BTREE_WRCSR | (pOp->p5 & OPFLAG_FORDELETE);
|
||||
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
|
||||
@@ -7738,6 +7774,11 @@ case OP_CursorUnlock: {
|
||||
*/
|
||||
case OP_TableLock: {
|
||||
u8 isWriteLock = (u8)pOp->p3;
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
if( isWriteLock && db->eConcurrent && pOp->p2==1 && pOp->p1!=1 ){
|
||||
db->eConcurrent = CONCURRENT_SCHEMA;
|
||||
}
|
||||
#endif
|
||||
if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommit) ){
|
||||
int p1 = pOp->p1;
|
||||
assert( p1>=0 && p1<db->nDb );
|
||||
|
||||
+25
-3
@@ -381,6 +381,7 @@ int sqlite3VdbeAddFunctionCall(
|
||||
addr = sqlite3VdbeAddOp4(v, eCallCtx ? OP_PureFunc : OP_Function,
|
||||
p1, p2, p3, (char*)pCtx, P4_FUNCCTX);
|
||||
sqlite3VdbeChangeP5(v, eCallCtx & NC_SelfRef);
|
||||
sqlite3MayAbort(pParse);
|
||||
return addr;
|
||||
}
|
||||
|
||||
@@ -716,6 +717,7 @@ int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
|
||||
|| opcode==OP_VDestroy
|
||||
|| opcode==OP_VCreate
|
||||
|| opcode==OP_ParseSchema
|
||||
|| opcode==OP_Function || opcode==OP_PureFunc
|
||||
|| ((opcode==OP_Halt || opcode==OP_HaltIfNull)
|
||||
&& ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
|
||||
){
|
||||
@@ -2776,10 +2778,27 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
||||
assert( i!=1 );
|
||||
nTrans++;
|
||||
}
|
||||
rc = sqlite3PagerExclusiveLock(pPager);
|
||||
rc = sqlite3BtreeExclusiveLock(pBt);
|
||||
sqlite3BtreeLeave(pBt);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
if( db->eConcurrent && (rc & 0xFF)==SQLITE_BUSY ){
|
||||
/* An SQLITE_BUSY or SQLITE_BUSY_SNAPSHOT was encountered while
|
||||
** attempting to take the WRITER lock on a wal file. Release the
|
||||
** WRITER locks on all wal files and return early. */
|
||||
for(i=0; i<db->nDb; i++){
|
||||
Btree *pBt = db->aDb[i].pBt;
|
||||
if( sqlite3BtreeTxnState(pBt)==SQLITE_TXN_WRITE ){
|
||||
sqlite3BtreeEnter(pBt);
|
||||
sqlite3PagerDropExclusiveLock(sqlite3BtreePager(pBt));
|
||||
sqlite3BtreeLeave(pBt);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
@@ -3181,6 +3200,7 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
|
||||
sqlite3CloseSavepoints(db);
|
||||
db->autoCommit = 1;
|
||||
db->eConcurrent = CONCURRENT_NONE;
|
||||
p->nChange = 0;
|
||||
}
|
||||
}
|
||||
@@ -3219,9 +3239,9 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
** is required. */
|
||||
rc = vdbeCommit(db, p);
|
||||
}
|
||||
if( rc==SQLITE_BUSY && p->readOnly ){
|
||||
if( (rc & 0xFF)==SQLITE_BUSY && p->readOnly ){
|
||||
sqlite3VdbeLeave(p);
|
||||
return SQLITE_BUSY;
|
||||
return rc;
|
||||
}else if( rc!=SQLITE_OK ){
|
||||
p->rc = rc;
|
||||
sqlite3RollbackAll(db, SQLITE_OK);
|
||||
@@ -3246,6 +3266,7 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
|
||||
sqlite3CloseSavepoints(db);
|
||||
db->autoCommit = 1;
|
||||
db->eConcurrent = CONCURRENT_NONE;
|
||||
p->nChange = 0;
|
||||
}
|
||||
}
|
||||
@@ -3267,6 +3288,7 @@ int sqlite3VdbeHalt(Vdbe *p){
|
||||
sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
|
||||
sqlite3CloseSavepoints(db);
|
||||
db->autoCommit = 1;
|
||||
db->eConcurrent = CONCURRENT_NONE;
|
||||
p->nChange = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,8 +526,10 @@ struct Wal {
|
||||
WalIndexHdr hdr; /* Wal-index header for current transaction */
|
||||
u32 minFrame; /* Ignore wal frames before this one */
|
||||
u32 iReCksum; /* On commit, recalculate checksums from here */
|
||||
u32 nPriorFrame; /* For sqlite3WalInfo() */
|
||||
const char *zWalName; /* Name of WAL file */
|
||||
u32 nCkpt; /* Checkpoint sequence counter in the wal-header */
|
||||
FastPrng sPrng; /* Random number generator */
|
||||
#ifdef SQLITE_DEBUG
|
||||
u8 lockError; /* True if a locking error has occurred */
|
||||
#endif
|
||||
@@ -925,7 +927,7 @@ static const char *walLockName(int lockIdx){
|
||||
/*
|
||||
** Set or release locks on the WAL. Locks are either shared or exclusive.
|
||||
** A lock cannot be moved directly between shared and exclusive - it must go
|
||||
** through the unlocked state first.
|
||||
** through the concurrent state first.
|
||||
**
|
||||
** In locking_mode=EXCLUSIVE, all of these routines become no-ops.
|
||||
*/
|
||||
@@ -1228,7 +1230,7 @@ static int walIndexRecover(Wal *pWal){
|
||||
/* Obtain an exclusive lock on all byte in the locking range not already
|
||||
** locked by the caller. The caller is guaranteed to have locked the
|
||||
** WAL_WRITE_LOCK byte, and may have also locked the WAL_CKPT_LOCK byte.
|
||||
** If successful, the same bytes that are locked here are unlocked before
|
||||
** If successful, the same bytes that are locked here are concurrent before
|
||||
** this function returns.
|
||||
*/
|
||||
assert( pWal->ckptLock==1 || pWal->ckptLock==0 );
|
||||
@@ -1546,6 +1548,7 @@ int sqlite3WalOpen(
|
||||
pRet->syncHeader = 1;
|
||||
pRet->padToSectorBoundary = 1;
|
||||
pRet->exclusiveMode = (bNoShm ? WAL_HEAPMEMORY_MODE: WAL_NORMAL_MODE);
|
||||
sqlite3FastPrngInit(&pRet->sPrng);
|
||||
|
||||
/* Open file handle on the write-ahead log file. */
|
||||
flags = (SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_WAL);
|
||||
@@ -2183,7 +2186,7 @@ static int walCheckpoint(
|
||||
rc = SQLITE_BUSY;
|
||||
}else if( eMode>=SQLITE_CHECKPOINT_RESTART ){
|
||||
u32 salt1;
|
||||
sqlite3_randomness(4, &salt1);
|
||||
sqlite3FastRandomness(&pWal->sPrng, 4, &salt1);
|
||||
assert( pInfo->nBackfill==pWal->hdr.mxFrame );
|
||||
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);
|
||||
if( rc==SQLITE_OK ){
|
||||
@@ -2299,6 +2302,49 @@ int sqlite3WalClose(
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Try to copy the wal-index header from shared-memory into (*pHdr). Return
|
||||
** zero if successful or non-zero otherwise. If the header is corrupted
|
||||
** (either because the two copies are inconsistent or because the checksum
|
||||
** values are incorrect), the read fails and non-zero is returned.
|
||||
*/
|
||||
static int walIndexLoadHdr(Wal *pWal, WalIndexHdr *pHdr){
|
||||
u32 aCksum[2]; /* Checksum on the header content */
|
||||
WalIndexHdr h2; /* Second copy of the header content */
|
||||
WalIndexHdr volatile *aHdr; /* Header in shared memory */
|
||||
|
||||
/* The first page of the wal-index must be mapped at this point. */
|
||||
assert( pWal->nWiData>0 && pWal->apWiData[0] );
|
||||
|
||||
/* Read the header. This might happen concurrently with a write to the
|
||||
** same area of shared memory on a different CPU in a SMP,
|
||||
** meaning it is possible that an inconsistent snapshot is read
|
||||
** from the file. If this happens, return non-zero.
|
||||
**
|
||||
** There are two copies of the header at the beginning of the wal-index.
|
||||
** When reading, read [0] first then [1]. Writes are in the reverse order.
|
||||
** Memory barriers are used to prevent the compiler or the hardware from
|
||||
** reordering the reads and writes.
|
||||
*/
|
||||
aHdr = walIndexHdr(pWal);
|
||||
memcpy(pHdr, (void *)&aHdr[0], sizeof(h2));
|
||||
walShmBarrier(pWal);
|
||||
memcpy(&h2, (void *)&aHdr[1], sizeof(h2));
|
||||
|
||||
if( memcmp(&h2, pHdr, sizeof(h2))!=0 ){
|
||||
return 1; /* Dirty read */
|
||||
}
|
||||
if( h2.isInit==0 ){
|
||||
return 1; /* Malformed header - probably all zeros */
|
||||
}
|
||||
walChecksumBytes(1, (u8*)&h2, sizeof(h2)-sizeof(h2.aCksum), 0, aCksum);
|
||||
if( aCksum[0]!=h2.aCksum[0] || aCksum[1]!=h2.aCksum[1] ){
|
||||
return 1; /* Checksum does not match */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Try to read the wal-index header. Return 0 on success and 1 if
|
||||
** there is a problem.
|
||||
@@ -2317,43 +2363,10 @@ int sqlite3WalClose(
|
||||
** is read successfully and the checksum verified, return zero.
|
||||
*/
|
||||
static SQLITE_NO_TSAN int walIndexTryHdr(Wal *pWal, int *pChanged){
|
||||
u32 aCksum[2]; /* Checksum on the header content */
|
||||
WalIndexHdr h1, h2; /* Two copies of the header content */
|
||||
WalIndexHdr volatile *aHdr; /* Header in shared memory */
|
||||
WalIndexHdr h1; /* Copy of the header content */
|
||||
|
||||
/* The first page of the wal-index must be mapped at this point. */
|
||||
assert( pWal->nWiData>0 && pWal->apWiData[0] );
|
||||
|
||||
/* Read the header. This might happen concurrently with a write to the
|
||||
** same area of shared memory on a different CPU in a SMP,
|
||||
** meaning it is possible that an inconsistent snapshot is read
|
||||
** from the file. If this happens, return non-zero.
|
||||
**
|
||||
** tag-20200519-1:
|
||||
** There are two copies of the header at the beginning of the wal-index.
|
||||
** When reading, read [0] first then [1]. Writes are in the reverse order.
|
||||
** Memory barriers are used to prevent the compiler or the hardware from
|
||||
** reordering the reads and writes. TSAN and similar tools can sometimes
|
||||
** give false-positive warnings about these accesses because the tools do not
|
||||
** account for the double-read and the memory barrier. The use of mutexes
|
||||
** here would be problematic as the memory being accessed is potentially
|
||||
** shared among multiple processes and not all mutex implementions work
|
||||
** reliably in that environment.
|
||||
*/
|
||||
aHdr = walIndexHdr(pWal);
|
||||
memcpy(&h1, (void *)&aHdr[0], sizeof(h1)); /* Possible TSAN false-positive */
|
||||
walShmBarrier(pWal);
|
||||
memcpy(&h2, (void *)&aHdr[1], sizeof(h2));
|
||||
|
||||
if( memcmp(&h1, &h2, sizeof(h1))!=0 ){
|
||||
return 1; /* Dirty read */
|
||||
}
|
||||
if( h1.isInit==0 ){
|
||||
return 1; /* Malformed header - probably all zeros */
|
||||
}
|
||||
walChecksumBytes(1, (u8*)&h1, sizeof(h1)-sizeof(h1.aCksum), 0, aCksum);
|
||||
if( aCksum[0]!=h1.aCksum[0] || aCksum[1]!=h1.aCksum[1] ){
|
||||
return 1; /* Checksum does not match */
|
||||
if( walIndexLoadHdr(pWal, &h1) ){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( memcmp(&pWal->hdr, &h1, sizeof(WalIndexHdr)) ){
|
||||
@@ -3051,6 +3064,7 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
|
||||
testcase( rc==SQLITE_PROTOCOL );
|
||||
testcase( rc==SQLITE_OK );
|
||||
|
||||
pWal->nPriorFrame = pWal->hdr.mxFrame;
|
||||
#ifdef SQLITE_ENABLE_SNAPSHOT
|
||||
if( rc==SQLITE_OK ){
|
||||
if( pSnapshot && memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){
|
||||
@@ -3156,8 +3170,7 @@ int sqlite3WalFindFrame(
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/* Search the hash table or tables for an entry matching page number
|
||||
** pgno. Each iteration of the following for() loop searches one
|
||||
/* Each iteration of the following for() loop searches one
|
||||
** hash table (each hash table indexes up to HASHTABLE_NPAGE frames).
|
||||
**
|
||||
** This code might run concurrently to the code in walIndexAppend()
|
||||
@@ -3263,6 +3276,35 @@ Pgno sqlite3WalDbsize(Wal *pWal){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** Take the WRITER lock on the WAL file. Return SQLITE_OK if successful,
|
||||
** or an SQLite error code otherwise. This routine does not invoke any
|
||||
** busy-handler callbacks, that is done at a higher level.
|
||||
*/
|
||||
static int walWriteLock(Wal *pWal){
|
||||
int rc;
|
||||
|
||||
/* Cannot start a write transaction without first holding a read lock */
|
||||
assert( pWal->readLock>=0 );
|
||||
assert( pWal->writeLock==0 );
|
||||
assert( pWal->iReCksum==0 );
|
||||
|
||||
/* If this is a read-only connection, obtaining a write-lock is not
|
||||
** possible. In this case return SQLITE_READONLY. Otherwise, attempt
|
||||
** to grab the WRITER lock. Set Wal.writeLock to true and return
|
||||
** SQLITE_OK if successful, or leave Wal.writeLock clear and return
|
||||
** an SQLite error code (possibly SQLITE_BUSY) otherwise. */
|
||||
if( pWal->readOnly ){
|
||||
rc = SQLITE_READONLY;
|
||||
}else{
|
||||
rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);
|
||||
if( rc==SQLITE_OK ){
|
||||
pWal->writeLock = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** This function starts a write transaction on the WAL.
|
||||
@@ -3289,38 +3331,209 @@ int sqlite3WalBeginWriteTransaction(Wal *pWal){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Cannot start a write transaction without first holding a read
|
||||
** transaction. */
|
||||
assert( pWal->readLock>=0 );
|
||||
assert( pWal->writeLock==0 && pWal->iReCksum==0 );
|
||||
|
||||
if( pWal->readOnly ){
|
||||
return SQLITE_READONLY;
|
||||
|
||||
rc = walWriteLock(pWal);
|
||||
if( rc==SQLITE_OK ){
|
||||
/* If another connection has written to the database file since the
|
||||
** time the read transaction on this connection was started, then
|
||||
** the write is disallowed. Release the WRITER lock and return
|
||||
** SQLITE_BUSY_SNAPSHOT in this case. */
|
||||
if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){
|
||||
walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
|
||||
pWal->writeLock = 0;
|
||||
rc = SQLITE_BUSY_SNAPSHOT;
|
||||
}
|
||||
}
|
||||
|
||||
/* Only one writer allowed at a time. Get the write lock. Return
|
||||
** SQLITE_BUSY if unable.
|
||||
*/
|
||||
rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);
|
||||
if( rc ){
|
||||
return rc;
|
||||
}
|
||||
pWal->writeLock = 1;
|
||||
|
||||
/* If another connection has written to the database file since the
|
||||
** time the read transaction on this connection was started, then
|
||||
** the write is disallowed.
|
||||
*/
|
||||
if( memcmp(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr))!=0 ){
|
||||
walUnlockExclusive(pWal, WAL_WRITE_LOCK, 1);
|
||||
pWal->writeLock = 0;
|
||||
rc = SQLITE_BUSY_SNAPSHOT;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is called by a writer that has a read-lock on aReadmark[0]
|
||||
** (pWal->readLock==0). This function relinquishes that lock and takes a
|
||||
** lock on a different aReadmark[] slot.
|
||||
**
|
||||
** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
|
||||
*/
|
||||
static int walUpgradeReadlock(Wal *pWal){
|
||||
int cnt;
|
||||
int rc;
|
||||
assert( pWal->writeLock && pWal->readLock==0 );
|
||||
walUnlockShared(pWal, WAL_READ_LOCK(0));
|
||||
pWal->readLock = -1;
|
||||
cnt = 0;
|
||||
do{
|
||||
int notUsed;
|
||||
rc = walTryBeginRead(pWal, ¬Used, 1, ++cnt);
|
||||
}while( rc==WAL_RETRY );
|
||||
assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */
|
||||
testcase( (rc&0xff)==SQLITE_IOERR );
|
||||
testcase( rc==SQLITE_PROTOCOL );
|
||||
testcase( rc==SQLITE_OK );
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
/*
|
||||
** This function is only ever called when committing a "BEGIN CONCURRENT"
|
||||
** transaction. It may be assumed that no frames have been written to
|
||||
** the wal file. The second parameter is a pointer to the in-memory
|
||||
** representation of page 1 of the database (which may or may not be
|
||||
** dirty). The third is a bitvec with a bit set for each page in the
|
||||
** database file that was read by the current concurrent transaction.
|
||||
**
|
||||
** This function performs three tasks:
|
||||
**
|
||||
** 1) It obtains the WRITER lock on the wal file,
|
||||
**
|
||||
** 2) It checks that there are no conflicts between the current
|
||||
** transaction and any transactions committed to the wal file since
|
||||
** it was opened, and
|
||||
**
|
||||
** 3) It ejects any non-dirty pages from the page-cache that have been
|
||||
** written by another client since the CONCURRENT transaction was started
|
||||
** (so as to avoid ending up with an inconsistent cache after the
|
||||
** current transaction is committed).
|
||||
**
|
||||
** If no error occurs and the caller may proceed with committing the
|
||||
** transaction, SQLITE_OK is returned. SQLITE_BUSY is returned if the WRITER
|
||||
** lock cannot be obtained. Or, if the WRITER lock can be obtained but there
|
||||
** are conflicts with a committed transaction, SQLITE_BUSY_SNAPSHOT. Finally,
|
||||
** if an error (i.e. an OOM condition or IO error), an SQLite error code
|
||||
** is returned.
|
||||
*/
|
||||
int sqlite3WalLockForCommit(
|
||||
Wal *pWal,
|
||||
PgHdr *pPg1,
|
||||
Bitvec *pAllRead,
|
||||
Pgno *piConflict
|
||||
){
|
||||
int rc = walWriteLock(pWal);
|
||||
|
||||
/* If the database has been modified since this transaction was started,
|
||||
** check if it is still possible to commit. The transaction can be
|
||||
** committed if:
|
||||
**
|
||||
** a) None of the pages in pList have been modified since the
|
||||
** transaction opened, and
|
||||
**
|
||||
** b) The database schema cookie has not been modified since the
|
||||
** transaction was started.
|
||||
*/
|
||||
if( rc==SQLITE_OK ){
|
||||
WalIndexHdr head;
|
||||
|
||||
if( walIndexLoadHdr(pWal, &head) ){
|
||||
/* This branch is taken if the wal-index header is corrupted. This
|
||||
** occurs if some other writer has crashed while committing a
|
||||
** transaction to this database since the current concurrent transaction
|
||||
** was opened. */
|
||||
rc = SQLITE_BUSY_SNAPSHOT;
|
||||
}else if( memcmp(&pWal->hdr, (void*)&head, sizeof(WalIndexHdr))!=0 ){
|
||||
int iHash;
|
||||
int iLast = walFramePage(head.mxFrame);
|
||||
u32 iFirst = pWal->hdr.mxFrame+1; /* First wal frame to check */
|
||||
if( memcmp(pWal->hdr.aSalt, (u32*)head.aSalt, sizeof(u32)*2) ){
|
||||
assert( pWal->readLock==0 );
|
||||
iFirst = 1;
|
||||
}
|
||||
if( pPg1==0 ){
|
||||
/* If pPg1==0, then the current transaction modified the database
|
||||
** schema. This means it conflicts with all other transactions. */
|
||||
*piConflict = 1;
|
||||
rc = SQLITE_BUSY_SNAPSHOT;
|
||||
}
|
||||
for(iHash=walFramePage(iFirst); rc==SQLITE_OK && iHash<=iLast; iHash++){
|
||||
WalHashLoc sLoc;
|
||||
|
||||
rc = walHashGet(pWal, iHash, &sLoc);
|
||||
if( rc==SQLITE_OK ){
|
||||
u32 i, iMin, iMax;
|
||||
assert( head.mxFrame>=sLoc.iZero );
|
||||
iMin = (sLoc.iZero >= iFirst) ? 1 : (iFirst - sLoc.iZero);
|
||||
iMax = (iHash==0) ? HASHTABLE_NPAGE_ONE : HASHTABLE_NPAGE;
|
||||
if( iMax>(head.mxFrame-sLoc.iZero) ) iMax = (head.mxFrame-sLoc.iZero);
|
||||
for(i=iMin; rc==SQLITE_OK && i<=iMax; i++){
|
||||
PgHdr *pPg;
|
||||
if( sLoc.aPgno[i-1]==1 ){
|
||||
/* Check that the schema cookie has not been modified. If
|
||||
** it has not, the commit can proceed. */
|
||||
u8 aNew[4];
|
||||
u8 *aOld = &((u8*)pPg1->pData)[40];
|
||||
int sz;
|
||||
i64 iOffset;
|
||||
sz = pWal->hdr.szPage;
|
||||
sz = (sz&0xfe00) + ((sz&0x0001)<<16);
|
||||
iOffset = walFrameOffset(i+sLoc.iZero, sz) + WAL_FRAME_HDRSIZE+40;
|
||||
rc = sqlite3OsRead(pWal->pWalFd, aNew, sizeof(aNew), iOffset);
|
||||
if( rc==SQLITE_OK && memcmp(aOld, aNew, sizeof(aNew)) ){
|
||||
rc = SQLITE_BUSY_SNAPSHOT;
|
||||
}
|
||||
}else if( sqlite3BitvecTestNotNull(pAllRead, sLoc.aPgno[i-1]) ){
|
||||
*piConflict = sLoc.aPgno[i-1];
|
||||
rc = SQLITE_BUSY_SNAPSHOT;
|
||||
}else
|
||||
if( (pPg = sqlite3PagerLookup(pPg1->pPager, sLoc.aPgno[i-1])) ){
|
||||
/* Page aPgno[i-1], which is present in the pager cache, has been
|
||||
** modified since the current CONCURRENT transaction was started.
|
||||
** However it was not read by the current transaction, so is not
|
||||
** a conflict. There are two possibilities: (a) the page was
|
||||
** allocated at the of the file by the current transaction or
|
||||
** (b) was present in the cache at the start of the transaction.
|
||||
**
|
||||
** For case (a), do nothing. This page will be moved within the
|
||||
** database file by the commit code to avoid the conflict. The
|
||||
** call to PagerUnref() is to release the reference grabbed by
|
||||
** the sqlite3PagerLookup() above.
|
||||
**
|
||||
** In case (b), drop the page from the cache - otherwise
|
||||
** following the snapshot upgrade the cache would be inconsistent
|
||||
** with the database as stored on disk. */
|
||||
if( sqlite3PagerIswriteable(pPg) ){
|
||||
sqlite3PagerUnref(pPg);
|
||||
}else{
|
||||
sqlite3PcacheDrop(pPg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pWal->nPriorFrame = pWal->hdr.mxFrame;
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* !defined(SQLITE_OMIT_CONCURRENT)
|
||||
**
|
||||
** This function is called as part of committing an CONCURRENT transaction.
|
||||
** It is assumed that sqlite3WalLockForCommit() has already been successfully
|
||||
** called and so (a) the WRITER lock is held and (b) it is known that the
|
||||
** wal-index-header stored in shared memory is not corrupt.
|
||||
**
|
||||
** Before returning, this function upgrades the client so that it is
|
||||
** operating on the database snapshot currently at the head of the wal file
|
||||
** (even if the CONCURRENT transaction ran against an older snapshot).
|
||||
**
|
||||
** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
|
||||
*/
|
||||
int sqlite3WalUpgradeSnapshot(Wal *pWal){
|
||||
int rc = SQLITE_OK;
|
||||
assert( pWal->writeLock );
|
||||
memcpy(&pWal->hdr, (void*)walIndexHdr(pWal), sizeof(WalIndexHdr));
|
||||
|
||||
/* If this client has its read-lock on slot aReadmark[0] and the entire
|
||||
** wal has not been checkpointed, switch it to a different slot. Otherwise
|
||||
** any reads performed between now and committing the transaction will
|
||||
** read from the old snapshot - not the one just upgraded to. */
|
||||
if( pWal->readLock==0 && pWal->hdr.mxFrame!=walCkptInfo(pWal)->nBackfill ){
|
||||
rc = walUpgradeReadlock(pWal);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_CONCURRENT */
|
||||
|
||||
/*
|
||||
** End a write transaction. The commit has already been done. This
|
||||
** routine merely releases the lock.
|
||||
@@ -3347,9 +3560,14 @@ int sqlite3WalEndWriteTransaction(Wal *pWal){
|
||||
** Otherwise, if the callback function does not return an error, this
|
||||
** function returns SQLITE_OK.
|
||||
*/
|
||||
int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){
|
||||
int sqlite3WalUndo(
|
||||
Wal *pWal,
|
||||
int (*xUndo)(void *, Pgno),
|
||||
void *pUndoCtx,
|
||||
int bConcurrent /* True if this is a CONCURRENT transaction */
|
||||
){
|
||||
int rc = SQLITE_OK;
|
||||
if( ALWAYS(pWal->writeLock) ){
|
||||
if( pWal->writeLock ){
|
||||
Pgno iMax = pWal->hdr.mxFrame;
|
||||
Pgno iFrame;
|
||||
|
||||
@@ -3357,6 +3575,13 @@ int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){
|
||||
** was in before the client began writing to the database.
|
||||
*/
|
||||
memcpy(&pWal->hdr, (void *)walIndexHdr(pWal), sizeof(WalIndexHdr));
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
if( bConcurrent ){
|
||||
pWal->hdr.aCksum[0]++;
|
||||
}
|
||||
#else
|
||||
UNUSED_PARAMETER(bConcurrent);
|
||||
#endif
|
||||
|
||||
for(iFrame=pWal->hdr.mxFrame+1;
|
||||
ALWAYS(rc==SQLITE_OK) && iFrame<=iMax;
|
||||
@@ -3388,7 +3613,6 @@ int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx){
|
||||
** point in the event of a savepoint rollback (via WalSavepointUndo()).
|
||||
*/
|
||||
void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData){
|
||||
assert( pWal->writeLock );
|
||||
aWalData[0] = pWal->hdr.mxFrame;
|
||||
aWalData[1] = pWal->hdr.aFrameCksum[0];
|
||||
aWalData[2] = pWal->hdr.aFrameCksum[1];
|
||||
@@ -3404,7 +3628,7 @@ void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData){
|
||||
int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
|
||||
int rc = SQLITE_OK;
|
||||
|
||||
assert( pWal->writeLock );
|
||||
assert( pWal->writeLock || aWalData[0]==pWal->hdr.mxFrame );
|
||||
assert( aWalData[3]!=pWal->nCkpt || aWalData[0]<=pWal->hdr.mxFrame );
|
||||
|
||||
if( aWalData[3]!=pWal->nCkpt ){
|
||||
@@ -3440,14 +3664,13 @@ int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
|
||||
*/
|
||||
static int walRestartLog(Wal *pWal){
|
||||
int rc = SQLITE_OK;
|
||||
int cnt;
|
||||
|
||||
if( pWal->readLock==0 ){
|
||||
volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
|
||||
assert( pInfo->nBackfill==pWal->hdr.mxFrame );
|
||||
if( pInfo->nBackfill>0 ){
|
||||
u32 salt1;
|
||||
sqlite3_randomness(4, &salt1);
|
||||
sqlite3FastRandomness(&pWal->sPrng, 4, &salt1);
|
||||
rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
|
||||
if( rc==SQLITE_OK ){
|
||||
/* If all readers are using WAL_READ_LOCK(0) (in other words if no
|
||||
@@ -3461,21 +3684,21 @@ static int walRestartLog(Wal *pWal){
|
||||
** to handle if this transaction is rolled back. */
|
||||
walRestartHdr(pWal, salt1);
|
||||
walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
|
||||
pWal->nPriorFrame = 0;
|
||||
}else if( rc!=SQLITE_BUSY ){
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
walUnlockShared(pWal, WAL_READ_LOCK(0));
|
||||
pWal->readLock = -1;
|
||||
cnt = 0;
|
||||
do{
|
||||
int notUsed;
|
||||
rc = walTryBeginRead(pWal, ¬Used, 1, ++cnt);
|
||||
}while( rc==WAL_RETRY );
|
||||
assert( (rc&0xff)!=SQLITE_BUSY ); /* BUSY not possible when useWal==1 */
|
||||
testcase( (rc&0xff)==SQLITE_IOERR );
|
||||
testcase( rc==SQLITE_PROTOCOL );
|
||||
testcase( rc==SQLITE_OK );
|
||||
|
||||
/* Regardless of whether or not the wal file was restarted, change the
|
||||
** read-lock held by this client to a slot other than aReadmark[0].
|
||||
** Clients with a lock on aReadmark[0] read from the database file
|
||||
** only - never from the wal file. This means that if a writer holding
|
||||
** a lock on aReadmark[0] were to commit a transaction but not close the
|
||||
** read-transaction, subsequent read operations would read directly from
|
||||
** the database file - ignoring the new pages just appended
|
||||
** to the wal file. */
|
||||
rc = walUpgradeReadlock(pWal);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@@ -3659,7 +3882,7 @@ int sqlite3WalFrames(
|
||||
sqlite3Put4byte(&aWalHdr[4], WAL_MAX_VERSION);
|
||||
sqlite3Put4byte(&aWalHdr[8], szPage);
|
||||
sqlite3Put4byte(&aWalHdr[12], pWal->nCkpt);
|
||||
if( pWal->nCkpt==0 ) sqlite3_randomness(8, pWal->hdr.aSalt);
|
||||
if( pWal->nCkpt==0 ) sqlite3FastRandomness(&pWal->sPrng, 8, pWal->hdr.aSalt);
|
||||
memcpy(&aWalHdr[16], pWal->hdr.aSalt, 8);
|
||||
walChecksumBytes(1, aWalHdr, WAL_HDRSIZE-2*4, 0, aCksum);
|
||||
sqlite3Put4byte(&aWalHdr[24], aCksum[0]);
|
||||
@@ -3736,6 +3959,7 @@ int sqlite3WalFrames(
|
||||
p->flags |= PGHDR_WAL_APPEND;
|
||||
}
|
||||
|
||||
|
||||
/* Recalculate checksums within the wal file if required. */
|
||||
if( isCommit && pWal->iReCksum ){
|
||||
rc = walRewriteChecksums(pWal, iFrame);
|
||||
@@ -3919,7 +4143,6 @@ int sqlite3WalCheckpoint(
|
||||
|
||||
/* Copy data from the log to the database file. */
|
||||
if( rc==SQLITE_OK ){
|
||||
|
||||
if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
}else{
|
||||
@@ -4152,4 +4375,16 @@ sqlite3_file *sqlite3WalFile(Wal *pWal){
|
||||
return pWal->pWalFd;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the values required by sqlite3_wal_info().
|
||||
*/
|
||||
int sqlite3WalInfo(Wal *pWal, u32 *pnPrior, u32 *pnFrame){
|
||||
int rc = SQLITE_OK;
|
||||
if( pWal ){
|
||||
*pnFrame = pWal->hdr.mxFrame;
|
||||
*pnPrior = pWal->nPriorFrame;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
#endif /* #ifndef SQLITE_OMIT_WAL */
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
# define sqlite3WalDbsize(y) 0
|
||||
# define sqlite3WalBeginWriteTransaction(y) 0
|
||||
# define sqlite3WalEndWriteTransaction(x) 0
|
||||
# define sqlite3WalUndo(x,y,z) 0
|
||||
# define sqlite3WalUndo(w,x,y,z) 0
|
||||
# define sqlite3WalSavepoint(y,z)
|
||||
# define sqlite3WalSavepointUndo(y,z) 0
|
||||
# define sqlite3WalFrames(u,v,w,x,y,z) 0
|
||||
@@ -83,7 +83,7 @@ int sqlite3WalBeginWriteTransaction(Wal *pWal);
|
||||
int sqlite3WalEndWriteTransaction(Wal *pWal);
|
||||
|
||||
/* Undo any frames written (but not committed) to the log */
|
||||
int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx);
|
||||
int sqlite3WalUndo(Wal *pWal, int (*xUndo)(void *, Pgno), void *pUndoCtx, int);
|
||||
|
||||
/* Return an integer that records the current (uncommitted) write
|
||||
** position in the WAL */
|
||||
@@ -136,6 +136,15 @@ int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot);
|
||||
void sqlite3WalSnapshotUnlock(Wal *pWal);
|
||||
#endif
|
||||
|
||||
#ifndef SQLITE_OMIT_CONCURRENT
|
||||
/* Tell the wal layer that we want to commit a concurrent transaction */
|
||||
int sqlite3WalLockForCommit(Wal *pWal, PgHdr *pPg, Bitvec *pRead, Pgno*);
|
||||
|
||||
/* Upgrade the state of the client to take into account changes written
|
||||
** by other connections */
|
||||
int sqlite3WalUpgradeSnapshot(Wal *pWal);
|
||||
#endif /* SQLITE_OMIT_CONCURRENT */
|
||||
|
||||
#ifdef SQLITE_ENABLE_ZIPVFS
|
||||
/* If the WAL file is not empty, return the number of bytes of content
|
||||
** stored in each frame (i.e. the db page-size when the WAL was created).
|
||||
@@ -151,5 +160,8 @@ int sqlite3WalWriteLock(Wal *pWal, int bLock);
|
||||
void sqlite3WalDb(Wal *pWal, sqlite3 *db);
|
||||
#endif
|
||||
|
||||
/* sqlite3_wal_info() data */
|
||||
int sqlite3WalInfo(Wal *pWal, u32 *pnPrior, u32 *pnFrame);
|
||||
|
||||
#endif /* ifndef SQLITE_OMIT_WAL */
|
||||
#endif /* SQLITE_WAL_H */
|
||||
|
||||
+10
-8
@@ -1433,7 +1433,7 @@ static int whereKeyStats(
|
||||
#endif
|
||||
assert( pRec!=0 );
|
||||
assert( pIdx->nSample>0 );
|
||||
assert( pRec->nField>0 && pRec->nField<=pIdx->nSampleCol );
|
||||
assert( pRec->nField>0 );
|
||||
|
||||
/* Do a binary search to find the first sample greater than or equal
|
||||
** to pRec. If pRec contains a single field, the set of samples to search
|
||||
@@ -1479,7 +1479,7 @@ static int whereKeyStats(
|
||||
** it is extended to two fields. The duplicates that this creates do not
|
||||
** cause any problems.
|
||||
*/
|
||||
nField = pRec->nField;
|
||||
nField = MIN(pRec->nField, pIdx->nSample);
|
||||
iCol = 0;
|
||||
iSample = pIdx->nSample * nField;
|
||||
do{
|
||||
@@ -4168,6 +4168,7 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){
|
||||
sqlite3 *db = pWInfo->pParse->db;
|
||||
int rc = SQLITE_OK;
|
||||
int bFirstPastRJ = 0;
|
||||
int hasRightJoin = 0;
|
||||
WhereLoop *pNew;
|
||||
|
||||
|
||||
@@ -4188,15 +4189,16 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){
|
||||
** prevents the right operand of a RIGHT JOIN from being swapped with
|
||||
** other elements even further to the right.
|
||||
**
|
||||
** The JT_LTORJ term prevents any FROM-clause term reordering for terms
|
||||
** to the left of a RIGHT JOIN. This is conservative. Relaxing this
|
||||
** constraint somewhat to prevent terms from crossing from the right
|
||||
** side of a LEFT JOIN over to the left side when they are on the
|
||||
** left side of a RIGHT JOIN would be sufficient for all known failure
|
||||
** cases. FIX ME: Implement this optimization.
|
||||
** The JT_LTORJ case and the hasRightJoin flag work together to
|
||||
** prevent FROM-clause terms from moving from the right side of
|
||||
** a LEFT JOIN over to the left side of that join if the LEFT JOIN
|
||||
** is itself on the left side of a RIGHT JOIN.
|
||||
*/
|
||||
if( pItem->fg.jointype & JT_LTORJ ) hasRightJoin = 1;
|
||||
mPrereq |= mPrior;
|
||||
bFirstPastRJ = (pItem->fg.jointype & JT_RIGHT)!=0;
|
||||
}else if( !hasRightJoin ){
|
||||
mPrereq = 0;
|
||||
}
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
if( IsVirtual(pItem->pTab) ){
|
||||
|
||||
+2
-1
@@ -622,7 +622,8 @@ static int codeEqualityTerm(
|
||||
}
|
||||
sqlite3ExprDelete(db, pX);
|
||||
}else{
|
||||
aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*nEq);
|
||||
int n = sqlite3ExprVectorSize(pX->pLeft);
|
||||
aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*MAX(nEq,n));
|
||||
eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap, &iTab);
|
||||
}
|
||||
pX = pExpr;
|
||||
|
||||
+556
@@ -0,0 +1,556 @@
|
||||
/*
|
||||
** 2016-05-07
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include <sqlite3.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include "tt3_core.c"
|
||||
|
||||
#ifdef USE_OSINST
|
||||
# include "../src/test_osinst.c"
|
||||
#else
|
||||
# define vfslog_time() 0
|
||||
#endif
|
||||
|
||||
typedef struct Config Config;
|
||||
typedef struct ThreadCtx ThreadCtx;
|
||||
|
||||
#define THREAD_TIME_INSERT 0
|
||||
#define THREAD_TIME_COMMIT 1
|
||||
#define THREAD_TIME_ROLLBACK 2
|
||||
#define THREAD_TIME_WRITER 3
|
||||
#define THREAD_TIME_CKPT 4
|
||||
|
||||
struct ThreadCtx {
|
||||
Config *pConfig;
|
||||
Sqlite *pDb;
|
||||
Error *pErr;
|
||||
sqlite3_int64 aTime[5];
|
||||
};
|
||||
|
||||
struct Config {
|
||||
int nIPT; /* --inserts-per-transaction */
|
||||
int nThread; /* --threads */
|
||||
int nSecond; /* --seconds */
|
||||
int bMutex; /* --mutex */
|
||||
int nAutoCkpt; /* --autockpt */
|
||||
int bRm; /* --rm */
|
||||
int bClearCache; /* --clear-cache */
|
||||
int nMmap; /* mmap limit in MB */
|
||||
char *zFile;
|
||||
int bOsinst; /* True to use osinst */
|
||||
|
||||
ThreadCtx *aCtx; /* Array of size nThread */
|
||||
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
int nCondWait; /* Number of threads waiting on hCond */
|
||||
sqlite3_vfs *pVfs;
|
||||
};
|
||||
|
||||
|
||||
typedef struct VfsWrapperFd VfsWrapperFd;
|
||||
struct VfsWrapperFd {
|
||||
sqlite3_file base; /* Base class */
|
||||
int bWriter; /* True if holding shm WRITER lock */
|
||||
int iTid;
|
||||
Config *pConfig;
|
||||
sqlite3_file *pFd; /* Underlying file descriptor */
|
||||
};
|
||||
|
||||
/* Methods of the wrapper VFS */
|
||||
static int vfsWrapOpen(sqlite3_vfs*, const char*, sqlite3_file*, int, int*);
|
||||
static int vfsWrapDelete(sqlite3_vfs*, const char*, int);
|
||||
static int vfsWrapAccess(sqlite3_vfs*, const char*, int, int*);
|
||||
static int vfsWrapFullPathname(sqlite3_vfs*, const char *, int, char*);
|
||||
static void *vfsWrapDlOpen(sqlite3_vfs*, const char*);
|
||||
static void vfsWrapDlError(sqlite3_vfs*, int, char*);
|
||||
static void (*vfsWrapDlSym(sqlite3_vfs*,void*, const char*))(void);
|
||||
static void vfsWrapDlClose(sqlite3_vfs*, void*);
|
||||
static int vfsWrapRandomness(sqlite3_vfs*, int, char*);
|
||||
static int vfsWrapSleep(sqlite3_vfs*, int);
|
||||
static int vfsWrapCurrentTime(sqlite3_vfs*, double*);
|
||||
static int vfsWrapGetLastError(sqlite3_vfs*, int, char*);
|
||||
static int vfsWrapCurrentTimeInt64(sqlite3_vfs*, sqlite3_int64*);
|
||||
static int vfsWrapSetSystemCall(sqlite3_vfs*, const char*, sqlite3_syscall_ptr);
|
||||
static sqlite3_syscall_ptr vfsWrapGetSystemCall(sqlite3_vfs*, const char*);
|
||||
static const char *vfsWrapNextSystemCall(sqlite3_vfs*, const char*);
|
||||
|
||||
/* Methods of wrapper sqlite3_io_methods object (see vfsWrapOpen()) */
|
||||
static int vfsWrapClose(sqlite3_file*);
|
||||
static int vfsWrapRead(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst);
|
||||
static int vfsWrapWrite(sqlite3_file*, const void*, int iAmt, sqlite3_int64);
|
||||
static int vfsWrapTruncate(sqlite3_file*, sqlite3_int64 size);
|
||||
static int vfsWrapSync(sqlite3_file*, int flags);
|
||||
static int vfsWrapFileSize(sqlite3_file*, sqlite3_int64 *pSize);
|
||||
static int vfsWrapLock(sqlite3_file*, int);
|
||||
static int vfsWrapUnlock(sqlite3_file*, int);
|
||||
static int vfsWrapCheckReservedLock(sqlite3_file*, int *pResOut);
|
||||
static int vfsWrapFileControl(sqlite3_file*, int op, void *pArg);
|
||||
static int vfsWrapSectorSize(sqlite3_file*);
|
||||
static int vfsWrapDeviceCharacteristics(sqlite3_file*);
|
||||
static int vfsWrapShmMap(sqlite3_file*, int iPg, int, int, void volatile**);
|
||||
static int vfsWrapShmLock(sqlite3_file*, int offset, int n, int flags);
|
||||
static void vfsWrapShmBarrier(sqlite3_file*);
|
||||
static int vfsWrapShmUnmap(sqlite3_file*, int deleteFlag);
|
||||
static int vfsWrapFetch(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **);
|
||||
static int vfsWrapUnfetch(sqlite3_file*, sqlite3_int64 iOfst, void *p);
|
||||
|
||||
static int vfsWrapOpen(
|
||||
sqlite3_vfs *pVfs,
|
||||
const char *zName,
|
||||
sqlite3_file *pFd,
|
||||
int flags,
|
||||
int *fout
|
||||
){
|
||||
static sqlite3_io_methods methods = {
|
||||
3,
|
||||
vfsWrapClose, vfsWrapRead, vfsWrapWrite,
|
||||
vfsWrapTruncate, vfsWrapSync, vfsWrapFileSize,
|
||||
vfsWrapLock, vfsWrapUnlock, vfsWrapCheckReservedLock,
|
||||
vfsWrapFileControl, vfsWrapSectorSize, vfsWrapDeviceCharacteristics,
|
||||
vfsWrapShmMap, vfsWrapShmLock, vfsWrapShmBarrier,
|
||||
vfsWrapShmUnmap, vfsWrapFetch, vfsWrapUnfetch
|
||||
};
|
||||
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
int rc;
|
||||
|
||||
memset(pWrapper, 0, sizeof(VfsWrapperFd));
|
||||
if( flags & SQLITE_OPEN_MAIN_DB ){
|
||||
pWrapper->iTid = (int)sqlite3_uri_int64(zName, "tid", 0);
|
||||
}
|
||||
|
||||
pWrapper->pFd = (sqlite3_file*)&pWrapper[1];
|
||||
pWrapper->pConfig = pConfig;
|
||||
rc = pConfig->pVfs->xOpen(pConfig->pVfs, zName, pWrapper->pFd, flags, fout);
|
||||
if( rc==SQLITE_OK ){
|
||||
pWrapper->base.pMethods = &methods;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int vfsWrapDelete(sqlite3_vfs *pVfs, const char *a, int b){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xDelete(pConfig->pVfs, a, b);
|
||||
}
|
||||
static int vfsWrapAccess(sqlite3_vfs *pVfs, const char *a, int b, int *c){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xAccess(pConfig->pVfs, a, b, c);
|
||||
}
|
||||
static int vfsWrapFullPathname(sqlite3_vfs *pVfs, const char *a, int b, char*c){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xFullPathname(pConfig->pVfs, a, b, c);
|
||||
}
|
||||
static void *vfsWrapDlOpen(sqlite3_vfs *pVfs, const char *a){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xDlOpen(pConfig->pVfs, a);
|
||||
}
|
||||
static void vfsWrapDlError(sqlite3_vfs *pVfs, int a, char *b){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xDlError(pConfig->pVfs, a, b);
|
||||
}
|
||||
static void (*vfsWrapDlSym(sqlite3_vfs *pVfs, void *a, const char *b))(void){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xDlSym(pConfig->pVfs, a, b);
|
||||
}
|
||||
static void vfsWrapDlClose(sqlite3_vfs *pVfs, void *a){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xDlClose(pConfig->pVfs, a);
|
||||
}
|
||||
static int vfsWrapRandomness(sqlite3_vfs *pVfs, int a, char *b){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xRandomness(pConfig->pVfs, a, b);
|
||||
}
|
||||
static int vfsWrapSleep(sqlite3_vfs *pVfs, int a){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xSleep(pConfig->pVfs, a);
|
||||
}
|
||||
static int vfsWrapCurrentTime(sqlite3_vfs *pVfs, double *a){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xCurrentTime(pConfig->pVfs, a);
|
||||
}
|
||||
static int vfsWrapGetLastError(sqlite3_vfs *pVfs, int a, char *b){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xGetLastError(pConfig->pVfs, a, b);
|
||||
}
|
||||
static int vfsWrapCurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *a){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xCurrentTimeInt64(pConfig->pVfs, a);
|
||||
}
|
||||
static int vfsWrapSetSystemCall(
|
||||
sqlite3_vfs *pVfs,
|
||||
const char *a,
|
||||
sqlite3_syscall_ptr b
|
||||
){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xSetSystemCall(pConfig->pVfs, a, b);
|
||||
}
|
||||
static sqlite3_syscall_ptr vfsWrapGetSystemCall(
|
||||
sqlite3_vfs *pVfs,
|
||||
const char *a
|
||||
){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xGetSystemCall(pConfig->pVfs, a);
|
||||
}
|
||||
static const char *vfsWrapNextSystemCall(sqlite3_vfs *pVfs, const char *a){
|
||||
Config *pConfig = (Config*)pVfs->pAppData;
|
||||
return pConfig->pVfs->xNextSystemCall(pConfig->pVfs, a);
|
||||
}
|
||||
|
||||
static int vfsWrapClose(sqlite3_file *pFd){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
pWrapper->pFd->pMethods->xClose(pWrapper->pFd);
|
||||
pWrapper->pFd = 0;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
static int vfsWrapRead(sqlite3_file *pFd, void *a, int b, sqlite3_int64 c){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xRead(pWrapper->pFd, a, b, c);
|
||||
}
|
||||
static int vfsWrapWrite(
|
||||
sqlite3_file *pFd,
|
||||
const void *a, int b,
|
||||
sqlite3_int64 c
|
||||
){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xWrite(pWrapper->pFd, a, b, c);
|
||||
}
|
||||
static int vfsWrapTruncate(sqlite3_file *pFd, sqlite3_int64 a){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xTruncate(pWrapper->pFd, a);
|
||||
}
|
||||
static int vfsWrapSync(sqlite3_file *pFd, int a){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xSync(pWrapper->pFd, a);
|
||||
}
|
||||
static int vfsWrapFileSize(sqlite3_file *pFd, sqlite3_int64 *a){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xFileSize(pWrapper->pFd, a);
|
||||
}
|
||||
static int vfsWrapLock(sqlite3_file *pFd, int a){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xLock(pWrapper->pFd, a);
|
||||
}
|
||||
static int vfsWrapUnlock(sqlite3_file *pFd, int a){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xUnlock(pWrapper->pFd, a);
|
||||
}
|
||||
static int vfsWrapCheckReservedLock(sqlite3_file *pFd, int *a){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xCheckReservedLock(pWrapper->pFd, a);
|
||||
}
|
||||
static int vfsWrapFileControl(sqlite3_file *pFd, int a, void *b){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xFileControl(pWrapper->pFd, a, b);
|
||||
}
|
||||
static int vfsWrapSectorSize(sqlite3_file *pFd){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xSectorSize(pWrapper->pFd);
|
||||
}
|
||||
static int vfsWrapDeviceCharacteristics(sqlite3_file *pFd){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xDeviceCharacteristics(pWrapper->pFd);
|
||||
}
|
||||
static int vfsWrapShmMap(
|
||||
sqlite3_file *pFd,
|
||||
int a, int b, int c,
|
||||
void volatile **d
|
||||
){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xShmMap(pWrapper->pFd, a, b, c, d);
|
||||
}
|
||||
static int vfsWrapShmLock(sqlite3_file *pFd, int offset, int n, int flags){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
Config *pConfig = pWrapper->pConfig;
|
||||
int bMutex = 0;
|
||||
int rc;
|
||||
|
||||
if( (offset==0 && n==1)
|
||||
&& (flags & SQLITE_SHM_LOCK) && (flags & SQLITE_SHM_EXCLUSIVE)
|
||||
){
|
||||
pthread_mutex_lock(&pConfig->mutex);
|
||||
pWrapper->bWriter = 1;
|
||||
bMutex = 1;
|
||||
if( pWrapper->iTid ){
|
||||
sqlite3_int64 t = vfslog_time();
|
||||
pConfig->aCtx[pWrapper->iTid-1].aTime[THREAD_TIME_WRITER] -= t;
|
||||
}
|
||||
}
|
||||
|
||||
rc = pWrapper->pFd->pMethods->xShmLock(pWrapper->pFd, offset, n, flags);
|
||||
|
||||
if( (rc!=SQLITE_OK && bMutex)
|
||||
|| (offset==0 && (flags & SQLITE_SHM_UNLOCK) && pWrapper->bWriter)
|
||||
){
|
||||
assert( pWrapper->bWriter );
|
||||
pthread_mutex_unlock(&pConfig->mutex);
|
||||
pWrapper->bWriter = 0;
|
||||
if( pWrapper->iTid ){
|
||||
sqlite3_int64 t = vfslog_time();
|
||||
pConfig->aCtx[pWrapper->iTid-1].aTime[THREAD_TIME_WRITER] += t;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
static void vfsWrapShmBarrier(sqlite3_file *pFd){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xShmBarrier(pWrapper->pFd);
|
||||
}
|
||||
static int vfsWrapShmUnmap(sqlite3_file *pFd, int a){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xShmUnmap(pWrapper->pFd, a);
|
||||
}
|
||||
static int vfsWrapFetch(sqlite3_file *pFd, sqlite3_int64 a, int b, void **c){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xFetch(pWrapper->pFd, a, b, c);
|
||||
}
|
||||
static int vfsWrapUnfetch(sqlite3_file *pFd, sqlite3_int64 a, void *b){
|
||||
VfsWrapperFd *pWrapper = (VfsWrapperFd*)pFd;
|
||||
return pWrapper->pFd->pMethods->xUnfetch(pWrapper->pFd, a, b);
|
||||
}
|
||||
|
||||
static void create_vfs(Config *pConfig){
|
||||
static sqlite3_vfs vfs = {
|
||||
3, 0, 0, 0, "wrapper", 0,
|
||||
vfsWrapOpen, vfsWrapDelete, vfsWrapAccess,
|
||||
vfsWrapFullPathname, vfsWrapDlOpen, vfsWrapDlError,
|
||||
vfsWrapDlSym, vfsWrapDlClose, vfsWrapRandomness,
|
||||
vfsWrapSleep, vfsWrapCurrentTime, vfsWrapGetLastError,
|
||||
vfsWrapCurrentTimeInt64, vfsWrapSetSystemCall, vfsWrapGetSystemCall,
|
||||
vfsWrapNextSystemCall
|
||||
};
|
||||
sqlite3_vfs *pVfs;
|
||||
|
||||
pVfs = sqlite3_vfs_find(0);
|
||||
vfs.mxPathname = pVfs->mxPathname;
|
||||
vfs.szOsFile = pVfs->szOsFile + sizeof(VfsWrapperFd);
|
||||
vfs.pAppData = (void*)pConfig;
|
||||
pConfig->pVfs = pVfs;
|
||||
|
||||
sqlite3_vfs_register(&vfs, 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Wal hook used by connections in thread_main().
|
||||
*/
|
||||
static int thread_wal_hook(
|
||||
void *pArg, /* Pointer to ThreadCtx object */
|
||||
sqlite3 *db,
|
||||
const char *zDb,
|
||||
int nFrame
|
||||
){
|
||||
ThreadCtx *pCtx = (ThreadCtx*)pArg;
|
||||
Config *pConfig = pCtx->pConfig;
|
||||
|
||||
if( pConfig->nAutoCkpt && nFrame>=pConfig->nAutoCkpt ){
|
||||
pCtx->aTime[THREAD_TIME_CKPT] -= vfslog_time();
|
||||
pthread_mutex_lock(&pConfig->mutex);
|
||||
if( pConfig->nCondWait>=0 ){
|
||||
pConfig->nCondWait++;
|
||||
if( pConfig->nCondWait==pConfig->nThread ){
|
||||
execsql(pCtx->pErr, pCtx->pDb, "PRAGMA wal_checkpoint");
|
||||
pthread_cond_broadcast(&pConfig->cond);
|
||||
}else{
|
||||
pthread_cond_wait(&pConfig->cond, &pConfig->mutex);
|
||||
}
|
||||
pConfig->nCondWait--;
|
||||
}
|
||||
pthread_mutex_unlock(&pConfig->mutex);
|
||||
pCtx->aTime[THREAD_TIME_CKPT] += vfslog_time();
|
||||
}
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
|
||||
static char *thread_main(int iTid, void *pArg){
|
||||
Config *pConfig = (Config*)pArg;
|
||||
Error err = {0}; /* Error code and message */
|
||||
Sqlite db = {0}; /* SQLite database connection */
|
||||
int nAttempt = 0; /* Attempted transactions */
|
||||
int nCommit = 0; /* Successful transactions */
|
||||
int j;
|
||||
ThreadCtx *pCtx = &pConfig->aCtx[iTid-1];
|
||||
char *zUri = 0;
|
||||
|
||||
#ifdef USE_OSINST
|
||||
char *zOsinstName = 0;
|
||||
char *zLogName = 0;
|
||||
if( pConfig->bOsinst ){
|
||||
zOsinstName = sqlite3_mprintf("osinst%d", iTid);
|
||||
zLogName = sqlite3_mprintf("bc_test1.log.%d.%d", (int)getpid(), iTid);
|
||||
zUri = sqlite3_mprintf(
|
||||
"file:%s?vfs=%s&tid=%d", pConfig->zFile, zOsinstName, iTid
|
||||
);
|
||||
sqlite3_vfslog_new(zOsinstName, 0, zLogName);
|
||||
opendb(&err, &db, zUri, 0);
|
||||
}else
|
||||
#endif
|
||||
{
|
||||
zUri = sqlite3_mprintf("file:%s?tid=%d", pConfig->zFile, iTid);
|
||||
opendb(&err, &db, zUri, 0);
|
||||
}
|
||||
|
||||
sqlite3_busy_handler(db.db, 0, 0);
|
||||
sql_script_printf(&err, &db,
|
||||
"PRAGMA wal_autocheckpoint = 0;"
|
||||
"PRAGMA synchronous = 0;"
|
||||
"PRAGMA mmap_size = %lld;",
|
||||
(i64)(pConfig->nMmap) * 1024 * 1024
|
||||
);
|
||||
|
||||
pCtx->pConfig = pConfig;
|
||||
pCtx->pErr = &err;
|
||||
pCtx->pDb = &db;
|
||||
sqlite3_wal_hook(db.db, thread_wal_hook, (void*)pCtx);
|
||||
|
||||
while( !timetostop(&err) ){
|
||||
execsql(&err, &db, "BEGIN CONCURRENT");
|
||||
|
||||
pCtx->aTime[THREAD_TIME_INSERT] -= vfslog_time();
|
||||
for(j=0; j<pConfig->nIPT; j++){
|
||||
execsql(&err, &db,
|
||||
"INSERT INTO t1 VALUES"
|
||||
"(randomblob(10), randomblob(20), randomblob(30), randomblob(200))"
|
||||
);
|
||||
}
|
||||
pCtx->aTime[THREAD_TIME_INSERT] += vfslog_time();
|
||||
|
||||
pCtx->aTime[THREAD_TIME_COMMIT] -= vfslog_time();
|
||||
execsql(&err, &db, "COMMIT");
|
||||
pCtx->aTime[THREAD_TIME_COMMIT] += vfslog_time();
|
||||
|
||||
pCtx->aTime[THREAD_TIME_ROLLBACK] -= vfslog_time();
|
||||
nAttempt++;
|
||||
if( err.rc==SQLITE_OK ){
|
||||
nCommit++;
|
||||
}else{
|
||||
clear_error(&err, SQLITE_BUSY);
|
||||
execsql(&err, &db, "ROLLBACK");
|
||||
}
|
||||
pCtx->aTime[THREAD_TIME_ROLLBACK] += vfslog_time();
|
||||
|
||||
if( pConfig->bClearCache ){
|
||||
sqlite3_db_release_memory(db.db);
|
||||
}
|
||||
}
|
||||
|
||||
closedb(&err, &db);
|
||||
|
||||
#ifdef USE_OSINST
|
||||
if( pConfig->bOsinst ){
|
||||
sqlite3_vfslog_finalize(zOsinstName);
|
||||
sqlite3_free(zOsinstName);
|
||||
sqlite3_free(zLogName);
|
||||
}
|
||||
#endif
|
||||
sqlite3_free(zUri);
|
||||
|
||||
pthread_mutex_lock(&pConfig->mutex);
|
||||
pConfig->nCondWait = -1;
|
||||
pthread_cond_broadcast(&pConfig->cond);
|
||||
pthread_mutex_unlock(&pConfig->mutex);
|
||||
|
||||
return sqlite3_mprintf("commits: %d/%d insert: %dms"
|
||||
" commit: %dms"
|
||||
" rollback: %dms"
|
||||
" writer: %dms"
|
||||
" checkpoint: %dms",
|
||||
nCommit, nAttempt,
|
||||
(int)(pCtx->aTime[THREAD_TIME_INSERT]/1000),
|
||||
(int)(pCtx->aTime[THREAD_TIME_COMMIT]/1000),
|
||||
(int)(pCtx->aTime[THREAD_TIME_ROLLBACK]/1000),
|
||||
(int)(pCtx->aTime[THREAD_TIME_WRITER]/1000),
|
||||
(int)(pCtx->aTime[THREAD_TIME_CKPT]/1000)
|
||||
);
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv){
|
||||
Error err = {0}; /* Error code and message */
|
||||
Sqlite db = {0}; /* SQLite database connection */
|
||||
Threadset threads = {0}; /* Test threads */
|
||||
Config conf = {5, 3, 5};
|
||||
int i;
|
||||
|
||||
CmdlineArg apArg[] = {
|
||||
{ "-seconds", CMDLINE_INT, offsetof(Config, nSecond) },
|
||||
{ "-inserts", CMDLINE_INT, offsetof(Config, nIPT) },
|
||||
{ "-threads", CMDLINE_INT, offsetof(Config, nThread) },
|
||||
{ "-mutex", CMDLINE_BOOL, offsetof(Config, bMutex) },
|
||||
{ "-rm", CMDLINE_BOOL, offsetof(Config, bRm) },
|
||||
{ "-autockpt",CMDLINE_INT, offsetof(Config, nAutoCkpt) },
|
||||
{ "-mmap", CMDLINE_INT, offsetof(Config, nMmap) },
|
||||
{ "-clear-cache", CMDLINE_BOOL, offsetof(Config, bClearCache) },
|
||||
{ "-file", CMDLINE_STRING, offsetof(Config, zFile) },
|
||||
{ "-osinst", CMDLINE_BOOL, offsetof(Config, bOsinst) },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
conf.nAutoCkpt = 1000;
|
||||
cmdline_process(apArg, argc, argv, (void*)&conf);
|
||||
if( err.rc==SQLITE_OK ){
|
||||
char *z = cmdline_construct(apArg, (void*)&conf);
|
||||
printf("With: %s\n", z);
|
||||
sqlite3_free(z);
|
||||
}
|
||||
if( conf.zFile==0 ){
|
||||
conf.zFile = "xyz.db";
|
||||
}
|
||||
|
||||
/* Create the special VFS - "wrapper". And the mutex and condition
|
||||
** variable. */
|
||||
create_vfs(&conf);
|
||||
pthread_mutex_init(&conf.mutex, 0);
|
||||
pthread_cond_init(&conf.cond, 0);
|
||||
|
||||
conf.aCtx = sqlite3_malloc(sizeof(ThreadCtx) * conf.nThread);
|
||||
memset(conf.aCtx, 0, sizeof(ThreadCtx) * conf.nThread);
|
||||
|
||||
/* Ensure the schema has been created */
|
||||
opendb(&err, &db, conf.zFile, conf.bRm);
|
||||
sql_script(&err, &db,
|
||||
"PRAGMA journal_mode = wal;"
|
||||
"CREATE TABLE IF NOT EXISTS t1(a PRIMARY KEY, b, c, d) WITHOUT ROWID;"
|
||||
"CREATE INDEX IF NOT EXISTS t1b ON t1(b);"
|
||||
"CREATE INDEX IF NOT EXISTS t1c ON t1(c);"
|
||||
);
|
||||
|
||||
setstoptime(&err, conf.nSecond*1000);
|
||||
if( conf.nThread==1 ){
|
||||
char *z = thread_main(1, (void*)&conf);
|
||||
printf("Thread 0 says: %s\n", (z==0 ? "..." : z));
|
||||
fflush(stdout);
|
||||
}else{
|
||||
for(i=0; i<conf.nThread; i++){
|
||||
launch_thread(&err, &threads, thread_main, (void*)&conf);
|
||||
}
|
||||
join_all_threads(&err, &threads);
|
||||
}
|
||||
|
||||
if( err.rc==SQLITE_OK ){
|
||||
printf("Database is %dK\n", (int)(filesize(&err, conf.zFile) / 1024));
|
||||
}
|
||||
if( err.rc==SQLITE_OK ){
|
||||
char *zWal = sqlite3_mprintf("%s-wal", conf.zFile);
|
||||
printf("Wal file is %dK\n", (int)(filesize(&err, zWal) / 1024));
|
||||
}
|
||||
|
||||
closedb(&err, &db);
|
||||
print_and_free_err(&err);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
# 2015 Aug 25
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# This file contains fault injection tests designed to test the concurrent
|
||||
# transactions feature.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/malloc_common.tcl
|
||||
set testprefix concfault
|
||||
|
||||
# This test will not work with an in-memory journal, as the database will
|
||||
# become corrupt if an error is injected into a transaction after it starts
|
||||
# writing data out to the db file.
|
||||
ifcapable !concurrent {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_test 1-pre1 {
|
||||
execsql {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(a PRIMARY KEY, b);
|
||||
INSERT INTO t1 VALUES(randomblob(1000), randomblob(100));
|
||||
INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
|
||||
DELETE FROM t1 WHERE rowid%2;
|
||||
}
|
||||
faultsim_save_and_close
|
||||
} {}
|
||||
|
||||
do_faultsim_test 1.1 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(randomblob(1000), randomblob(100));
|
||||
COMMIT;
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
catchsql { ROLLBACK }
|
||||
faultsim_integrity_check
|
||||
}
|
||||
|
||||
do_faultsim_test 1.2 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(randomblob(1000), randomblob(100));
|
||||
ROLLBACK;
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
catchsql { ROLLBACK }
|
||||
faultsim_integrity_check
|
||||
}
|
||||
|
||||
do_faultsim_test 1.3 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql {
|
||||
BEGIN CONCURRENT;
|
||||
DELETE FROM t1;
|
||||
COMMIT;
|
||||
}
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
catchsql { ROLLBACK }
|
||||
faultsim_integrity_check
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
reset_db
|
||||
|
||||
do_execsql_test 2.0 {
|
||||
PRAGMA auto_vacuum = 0;
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(a PRIMARY KEY, b);
|
||||
CREATE TABLE t2(a PRIMARY KEY, b);
|
||||
INSERT INTO t1 VALUES(randomblob(1000), randomblob(100));
|
||||
INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
|
||||
INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
|
||||
DELETE FROM t1 WHERE rowid%2;
|
||||
} {wal}
|
||||
|
||||
faultsim_save_and_close
|
||||
do_faultsim_test 1 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
execsql {
|
||||
SELECT * FROM t1;
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t2 VALUES(1, 2);
|
||||
}
|
||||
sqlite3 db2 test.db
|
||||
execsql {
|
||||
PRAGMA journal_size_limit = 10000;
|
||||
INSERT INTO t1 VALUES(randomblob(1000), randomblob(1000));
|
||||
} db2
|
||||
db2 close
|
||||
} -body {
|
||||
execsql { COMMIT }
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
catchsql { ROLLBACK }
|
||||
set res [catchsql { SELECT count(*) FROM t1 }]
|
||||
if {$res!="0 9"} { error "expected {0 9} got {$res}" }
|
||||
faultsim_integrity_check
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -0,0 +1,687 @@
|
||||
# 2015 July 26
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
set ::testprefix concurrent
|
||||
|
||||
ifcapable !concurrent {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
PRAGMA journal_mode = wal;
|
||||
} {wal}
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
CREATE TABLE t1(k INTEGER PRIMARY KEY, v);
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(1, 'abcd');
|
||||
COMMIT;
|
||||
}
|
||||
|
||||
do_execsql_test 1.2 {
|
||||
SELECT * FROM t1;
|
||||
} {1 abcd}
|
||||
|
||||
do_execsql_test 1.3 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(2, 'efgh');
|
||||
ROLLBACK;
|
||||
}
|
||||
|
||||
do_execsql_test 1.4 {
|
||||
SELECT * FROM t1;
|
||||
} {1 abcd}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# CONCURRENT transactions cannot do cache spills.
|
||||
#
|
||||
foreach {tn trans spill} {
|
||||
1 {BEGIN CONCURRENT} 0
|
||||
2 {BEGIN} 1
|
||||
} {
|
||||
do_test 1.5.$tn {
|
||||
sqlite3 db2 test.db
|
||||
set walsz [file size test.db-wal]
|
||||
|
||||
execsql { PRAGMA cache_size = 10 } db2
|
||||
execsql $trans db2
|
||||
execsql {
|
||||
WITH cnt(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM cnt WHERE i<50)
|
||||
INSERT INTO t1(v) SELECT randomblob(900) FROM cnt;
|
||||
} db2
|
||||
|
||||
expr {[file size test.db-wal]==$walsz}
|
||||
} [expr !$spill]
|
||||
|
||||
execsql ROLLBACK db2
|
||||
db2 close
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# CONCURRENT transactions man not be committed while there are active
|
||||
# readers.
|
||||
do_execsql_test 1.6.setup {
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1(a, b);
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
INSERT INTO t1 VALUES(5, 6);
|
||||
}
|
||||
foreach {tn trans commit_ok} {
|
||||
1 {BEGIN CONCURRENT} 0
|
||||
2 {BEGIN} 1
|
||||
} {
|
||||
do_test 1.6.$tn.1 {
|
||||
set stmt [sqlite3_prepare db "SELECT * FROM t1" -1 dummy]
|
||||
sqlite3_step $stmt
|
||||
} SQLITE_ROW
|
||||
do_test 1.6.$tn.2 {
|
||||
execsql $trans
|
||||
execsql { INSERT INTO t1 VALUES(7, 8) }
|
||||
} {}
|
||||
|
||||
if { $commit_ok } {
|
||||
do_test 1.6.$tn.3 { catchsql COMMIT } {0 {}}
|
||||
} else {
|
||||
do_test 1.6.$tn.4 { catchsql COMMIT } {/1 {cannot commit transaction .*}/}
|
||||
}
|
||||
|
||||
sqlite3_finalize $stmt
|
||||
catchsql ROLLBACK
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# CONCURRENT transactions may not modify the db schema.
|
||||
#
|
||||
sqlite3 db2 test.db
|
||||
foreach {tn sql} {
|
||||
1 { CREATE TABLE xx(a, b) }
|
||||
2 { DROP TABLE t1 }
|
||||
3 { CREATE INDEX i1 ON t1(a) }
|
||||
4 { CREATE VIEW v1 AS SELECT * FROM t1 }
|
||||
} {
|
||||
do_catchsql_test 1.7.0.$tn.1 "
|
||||
BEGIN CONCURRENT;
|
||||
$sql
|
||||
" {0 {}}
|
||||
|
||||
db2 eval {INSERT INTO t1 DEFAULT VALUES}
|
||||
|
||||
do_catchsql_test 1.7.0.$tn.2 {
|
||||
COMMIT
|
||||
} {1 {database is locked}}
|
||||
|
||||
do_execsql_test 1.7.0.$tn.2 ROLLBACK
|
||||
|
||||
do_execsql_test 1.7.0.$tn.3 {
|
||||
SELECT sql FROM sqlite_master;
|
||||
SELECT sql FROM sqlite_temp_master;
|
||||
} {{CREATE TABLE t1(a, b)}}
|
||||
|
||||
#do_execsql_test 1.7.0.$tn.3 COMMIT
|
||||
}
|
||||
|
||||
# Except the temp db schema.
|
||||
foreach {tn sql} {
|
||||
1 { CREATE TEMP TABLE xx(a, b) }
|
||||
2 { DROP TABLE xx }
|
||||
3 { CREATE TEMP TABLE yy(a, b) }
|
||||
4 { CREATE VIEW temp.v1 AS SELECT * FROM t1 }
|
||||
5 { CREATE INDEX yyi1 ON yy(a); }
|
||||
6 { CREATE TABLE temp.zz(a, b) }
|
||||
} {
|
||||
do_catchsql_test 1.7.1.$tn.1 "
|
||||
BEGIN CONCURRENT;
|
||||
$sql
|
||||
" {0 {}}
|
||||
|
||||
do_execsql_test 1.7.1.$tn.2 COMMIT
|
||||
}
|
||||
|
||||
|
||||
do_execsql_test 1.7.1.x {
|
||||
SELECT sql FROM sqlite_master;
|
||||
SELECT sql FROM sqlite_temp_master;
|
||||
} {
|
||||
{CREATE TABLE t1(a, b)}
|
||||
{CREATE TABLE yy(a, b)}
|
||||
{CREATE VIEW v1 AS SELECT * FROM t1}
|
||||
{CREATE INDEX yyi1 ON yy(a)}
|
||||
{CREATE TABLE zz(a, b)}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# If an auto-vacuum database is written within an CONCURRENT transaction, it
|
||||
# is handled in the same way as for a non-CONCURRENT transaction.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 1.8.1 {
|
||||
PRAGMA auto_vacuum = 1;
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x, y);
|
||||
INSERT INTO t1 VALUES('x', 'y');
|
||||
} {wal}
|
||||
|
||||
do_execsql_test 1.8.2 {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t1;
|
||||
COMMIT;
|
||||
} {x y}
|
||||
|
||||
do_catchsql_test 1.8.3 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES('a', 'b');
|
||||
} {0 {}}
|
||||
|
||||
do_test 1.8.4 {
|
||||
sqlite3 db2 test.db
|
||||
catchsql {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES('c', 'd');
|
||||
} db2
|
||||
} {1 {database is locked}}
|
||||
|
||||
do_test 1.8.5 {
|
||||
db eval COMMIT
|
||||
db2 eval COMMIT
|
||||
} {}
|
||||
db close
|
||||
db2 close
|
||||
|
||||
do_multiclient_test tn {
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# 1. Start an CONCURRENT transaction using [db1].
|
||||
#
|
||||
# 2. Start and then rollback a regular transaction using [db2]. This
|
||||
# can be done as the ongoing [db1] transaction is CONCURRENT.
|
||||
#
|
||||
# 3. The [db1] transaction can now be committed, as [db2] has relinquished
|
||||
# the write lock.
|
||||
#
|
||||
do_test 2.$tn.1.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(k INTEGER PRIMARY KEY, v);
|
||||
INSERT INTO t1 VALUES(1, 'one');
|
||||
}
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(2, 'two');
|
||||
}
|
||||
code1 { sqlite3_get_autocommit db }
|
||||
} 0
|
||||
|
||||
do_test 2.$tn.1.2 {
|
||||
sql2 {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(3, 'three');
|
||||
ROLLBACK;
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.1.3 {
|
||||
sql1 COMMIT
|
||||
sql2 { SELECT * FROM t1 }
|
||||
} {1 one 2 two}
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# 1. Start an CONCURRENT transaction using [db1].
|
||||
#
|
||||
# 2. Commit a transaction using [db2].
|
||||
#
|
||||
# 3. Try to commit with [db1]. Check that SQLITE_BUSY_SNAPSHOT is returned,
|
||||
# and the transaction is not rolled back.
|
||||
#
|
||||
do_test 2.$tn.2.1 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(-1, 'hello world');
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.2.2 {
|
||||
sql2 {
|
||||
INSERT INTO t1 VALUES(3, 'three');
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.2.3.1 {
|
||||
set rc [catch { sql1 COMMIT } msg]
|
||||
list $rc $msg
|
||||
} {1 {database is locked}}
|
||||
|
||||
do_test 2.$tn.2.3.2 {
|
||||
code1 { list [sqlite3_extended_errcode db] [sqlite3_get_autocommit db] }
|
||||
} {SQLITE_BUSY_SNAPSHOT 0}
|
||||
|
||||
do_test 2.$tn.2.3.3 {
|
||||
sql1 {
|
||||
SELECT * FROM t1;
|
||||
ROLLBACK;
|
||||
}
|
||||
} {-1 {hello world} 1 one 2 two}
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# 1. Start an CONCURRENT transaction using [db1].
|
||||
#
|
||||
# 2. Open a transaction using [db2].
|
||||
#
|
||||
# 3. Try to commit with [db1]. Check that SQLITE_BUSY is returned,
|
||||
# and the transaction is not rolled back.
|
||||
#
|
||||
# 4. Have [db2] roll its transaction back. Then check that [db1] can
|
||||
# commit.
|
||||
#
|
||||
do_test 2.$tn.3.1 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(4, 'four');
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.3.2 {
|
||||
sql2 {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(-1, 'xyz');
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.3.3.1 {
|
||||
set rc [catch { sql1 COMMIT } msg]
|
||||
list $rc $msg
|
||||
} {1 {database is locked}}
|
||||
|
||||
do_test 2.$tn.3.3.2 {
|
||||
code1 { list [sqlite3_extended_errcode db] [sqlite3_get_autocommit db] }
|
||||
} {SQLITE_BUSY 0}
|
||||
|
||||
do_test 2.$tn.3.3.3 {
|
||||
sql1 { SELECT * FROM t1; }
|
||||
} {1 one 2 two 3 three 4 four}
|
||||
|
||||
do_test 2.$tn.3.4 {
|
||||
sql2 ROLLBACK
|
||||
sql1 COMMIT
|
||||
sql1 { SELECT * FROM t1; }
|
||||
} {1 one 2 two 3 three 4 four}
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# 1. Create a second table - t2.
|
||||
#
|
||||
# 2. Write to t1 with [db] and t2 with [db2].
|
||||
#
|
||||
# 3. See if it worked.
|
||||
#
|
||||
do_test 2.$tn.4.1 {
|
||||
sql1 { CREATE TABLE t2(a, b) }
|
||||
} {}
|
||||
do_test 2.$tn.4.2 {
|
||||
sql2 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t2 VALUES('i', 'n');
|
||||
}
|
||||
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(5, 'five');
|
||||
COMMIT;
|
||||
}
|
||||
|
||||
sql2 COMMIT
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.4.3.1 {
|
||||
sql2 {SELECT * FROM t1}
|
||||
} {1 one 2 two 3 three 4 four 5 five}
|
||||
do_test 2.$tn.4.3.2 {
|
||||
sql1 {SELECT * FROM t1}
|
||||
} {1 one 2 two 3 three 4 four 5 five}
|
||||
|
||||
do_test 2.$tn.4.3.3 { sql2 {SELECT * FROM t2} } {i n}
|
||||
do_test 2.$tn.4.3.4 { sql1 {SELECT * FROM t2} } {i n}
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# The "schema cookie" issue.
|
||||
#
|
||||
# 1. Begin and CONCURRENT write to "t1" using [db]
|
||||
#
|
||||
# 2. Create an index on t1 using [db2].
|
||||
#
|
||||
# 3. Attempt to commit the CONCURRENT write. This is an SQLITE_BUSY_SNAPSHOT,
|
||||
# even though there is no page collision.
|
||||
#
|
||||
do_test 2.$tn.5.1 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(6, 'six');
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.5.2 {
|
||||
sql2 { CREATE INDEX i1 ON t1(v); }
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.5.3 {
|
||||
list [catch { sql1 { COMMIT } } msg] $msg [sqlite3_errcode db]
|
||||
} {1 {database is locked} SQLITE_BUSY_SNAPSHOT}
|
||||
|
||||
do_test 2.$tn.5.4 {
|
||||
sql2 { PRAGMA integrity_check }
|
||||
} {ok}
|
||||
catch { sql1 ROLLBACK }
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#
|
||||
# 1. Begin an CONCURRENT write to "t1" using [db]
|
||||
#
|
||||
# 2. Lots of inserts into t2. Enough to grow the db file and modify page 1.
|
||||
#
|
||||
# 3. Check that the CONCURRENT transaction can not be committed.
|
||||
#
|
||||
do_test 2.$tn.6.1 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(6, 'six');
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.6.2 {
|
||||
sql2 {
|
||||
WITH src(a,b) AS (
|
||||
VALUES(1,1) UNION ALL SELECT a+1,b+1 FROM src WHERE a<10000
|
||||
) INSERT INTO t2 SELECT * FROM src;
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.6.3 {
|
||||
sql1 { SELECT count(*) FROM t2 }
|
||||
list [catch { sql1 { COMMIT } } msg] $msg [sqlite3_errcode db]
|
||||
} {1 {database is locked} SQLITE_BUSY_SNAPSHOT}
|
||||
sql1 ROLLBACK
|
||||
|
||||
do_test 2.$tn.6.4 {
|
||||
sql1 {
|
||||
SELECT count(*) FROM t1;
|
||||
SELECT count(*) FROM t2;
|
||||
}
|
||||
} {5 10001}
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#
|
||||
# 1. Begin an big CONCURRENT write to "t1" using [db] - large enough to
|
||||
# grow the db file.
|
||||
#
|
||||
# 2. Lots of inserts into t2. Also enough to grow the db file.
|
||||
#
|
||||
# 3. Check that the CONCURRENT transaction cannot be committed (due to a clash
|
||||
# on page 1 - the db size field).
|
||||
#
|
||||
do_test 2.$tn.7.1 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
WITH src(a,b) AS (
|
||||
VALUES(10000,10000) UNION ALL SELECT a+1,b+1 FROM src WHERE a<20000
|
||||
) INSERT INTO t1 SELECT * FROM src;
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.7.2 {
|
||||
sql2 {
|
||||
WITH src(a,b) AS (
|
||||
VALUES(1,1) UNION ALL SELECT a+1,b+1 FROM src WHERE a<10000
|
||||
) INSERT INTO t2 SELECT * FROM src;
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.7.3 {
|
||||
list [catch { sql1 { COMMIT } } msg] $msg [sqlite3_errcode db]
|
||||
} {0 {} SQLITE_OK}
|
||||
|
||||
do_test 2.$tn.7.4 { sql3 { PRAGMA integrity_check } } ok
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Concurrent transactions may not modify the user_version or application_id.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 3.0 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x, y);
|
||||
INSERT INTO t1 VALUES('a', 'b');
|
||||
PRAGMA user_version = 10;
|
||||
} {wal}
|
||||
do_execsql_test 3.1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES('c', 'd');
|
||||
SELECT * FROM t1;
|
||||
} {a b c d}
|
||||
do_catchsql_test 3.2 {
|
||||
PRAGMA user_version = 11;
|
||||
} {1 {cannot modify user_version within CONCURRENT transaction}}
|
||||
do_execsql_test 3.3 {
|
||||
PRAGMA user_version;
|
||||
SELECT * FROM t1;
|
||||
} {10 a b c d}
|
||||
do_catchsql_test 3.4 {
|
||||
PRAGMA application_id = 11;
|
||||
} {1 {cannot modify application_id within CONCURRENT transaction}}
|
||||
do_execsql_test 3.5 {
|
||||
COMMIT;
|
||||
PRAGMA user_version;
|
||||
PRAGMA application_id;
|
||||
SELECT * FROM t1;
|
||||
} {10 0 a b c d}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# However, another transaction modifying the user_version or application_id
|
||||
# should not cause a conflict. And committing a concurrent transaction does not
|
||||
# clobber the modification - even if the concurrent transaction allocates or
|
||||
# frees database pages.
|
||||
#
|
||||
do_multiclient_test tn {
|
||||
do_test 4.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE ttt(y UNIQUE, z UNIQUE);
|
||||
PRAGMA user_version = 14;
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO ttt VALUES('y', 'z');
|
||||
}
|
||||
} {wal}
|
||||
do_test 4.$tn.2 {
|
||||
sql2 { PRAGMA user_version = 16 }
|
||||
sql1 COMMIT
|
||||
sql1 { PRAGMA user_version }
|
||||
} {16}
|
||||
|
||||
do_test 4.$tn.3 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO ttt VALUES(randomblob(10000), randomblob(4));
|
||||
PRAGMA user_version;
|
||||
}
|
||||
} {16}
|
||||
do_test 4.$tn.4 {
|
||||
sql2 { PRAGMA user_version = 1234 }
|
||||
sql1 {
|
||||
PRAGMA user_version;
|
||||
COMMIT;
|
||||
PRAGMA user_version;
|
||||
PRAGMA integrity_check;
|
||||
}
|
||||
} {16 1234 ok}
|
||||
|
||||
do_test 4.$tn.5 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
DELETE FROM ttt;
|
||||
PRAGMA user_version;
|
||||
}
|
||||
} {1234}
|
||||
do_test 4.$tn.4 {
|
||||
sql2 { PRAGMA user_version = 5678 }
|
||||
sql1 {
|
||||
PRAGMA user_version;
|
||||
COMMIT;
|
||||
PRAGMA user_version;
|
||||
PRAGMA integrity_check;
|
||||
}
|
||||
} {1234 5678 ok}
|
||||
}
|
||||
|
||||
do_multiclient_test tn {
|
||||
do_test 5.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE tt(a INTEGER PRIMARY KEY, b);
|
||||
CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
|
||||
INSERT INTO tt VALUES(1, randomblob(400));
|
||||
BEGIN CONCURRENT;
|
||||
}
|
||||
} {wal}
|
||||
|
||||
do_test 5.$tn.2 {
|
||||
sql1 { UPDATE t2 SET b=5 WHERE a=3 }
|
||||
sql2 { INSERT INTO tt VALUES(2, randomblob(6000)) }
|
||||
} {}
|
||||
|
||||
do_test 5.$tn.3 {
|
||||
sql1 { COMMIT }
|
||||
} {}
|
||||
}
|
||||
|
||||
do_multiclient_test tn {
|
||||
do_test 6.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
|
||||
CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
|
||||
INSERT INTO t1 VALUES(1, 'one');
|
||||
INSERT INTO t2 VALUES(2, 'two');
|
||||
}
|
||||
} {wal}
|
||||
|
||||
do_test 6.$tn.2 {
|
||||
sql2 {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t2;
|
||||
INSERT INTO t1 VALUES(3, 'three');
|
||||
}
|
||||
} {2 two}
|
||||
|
||||
do_test 6.$tn.3 {
|
||||
sql1 {
|
||||
INSERT INTO t2 VALUES(3, 'three');
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 6.$tn.2 {
|
||||
list [catch { sql2 { COMMIT } } msg] $msg
|
||||
} {1 {database is locked}}
|
||||
}
|
||||
|
||||
do_multiclient_test tn {
|
||||
do_test 7.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
|
||||
WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t1 SELECT NULL, randomblob(400) FROM s;
|
||||
|
||||
CREATE TABLE t2(a INTEGER PRIMARY KEY, b);
|
||||
WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<50000)
|
||||
INSERT INTO t2 SELECT NULL, randomblob(400) FROM s;
|
||||
|
||||
CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
|
||||
WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t3 SELECT NULL, randomblob(400) FROM s;
|
||||
|
||||
CREATE TABLE t4(a INTEGER PRIMARY KEY, b);
|
||||
|
||||
}
|
||||
set {} {}
|
||||
} {}
|
||||
|
||||
do_test 7.$tn.2 {
|
||||
sql2 {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t1;
|
||||
INSERT INTO t4 VALUES(1, 2);
|
||||
}
|
||||
set {} {}
|
||||
} {}
|
||||
|
||||
do_test 7.$tn.3 {
|
||||
sql3 {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t3;
|
||||
INSERT INTO t4 VALUES(1, 2);
|
||||
}
|
||||
set {} {}
|
||||
} {}
|
||||
|
||||
do_test 7.$tn.4 {
|
||||
sql1 {
|
||||
UPDATE t1 SET b=randomblob(400);
|
||||
UPDATE t2 SET b=randomblob(400);
|
||||
UPDATE t3 SET b=randomblob(400);
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 7.$tn.5 {
|
||||
csql2 { COMMIT }
|
||||
} {1 {database is locked}}
|
||||
|
||||
do_test 7.$tn.6 {
|
||||
csql3 { COMMIT }
|
||||
} {1 {database is locked}}
|
||||
|
||||
|
||||
csql2 ROLLBACK
|
||||
csql3 ROLLBACK
|
||||
|
||||
# The following test works with $tn==1 (sql2 and sql3 use separate
|
||||
# processes), but is quite slow. So only run it with $tn==2 (all
|
||||
# connections in the same process).
|
||||
#
|
||||
if {$tn==2} {
|
||||
do_test 7.$tn.7 {
|
||||
for {set i 1} {$i < 10000} {incr i} {
|
||||
sql3 {
|
||||
PRAGMA wal_checkpoint;
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t3;
|
||||
INSERT INTO t4 VALUES(1, 2);
|
||||
}
|
||||
|
||||
sql1 {
|
||||
UPDATE t2 SET b = randomblob(400) WHERE rowid <= $i;
|
||||
UPDATE t3 SET b = randomblob(400) WHERE rowid = 1;
|
||||
}
|
||||
|
||||
if {[csql3 COMMIT]!={1 {database is locked}}} {
|
||||
error "Failed at i=$i"
|
||||
}
|
||||
csql3 ROLLBACK
|
||||
}
|
||||
} {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
finish_test
|
||||
@@ -0,0 +1,626 @@
|
||||
# 2015 July 26
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# Miscellaneous tests for transactions started with BEGIN CONCURRENT.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
source $testdir/wal_common.tcl
|
||||
set ::testprefix concurrent2
|
||||
|
||||
ifcapable !concurrent {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_multiclient_test tn {
|
||||
|
||||
do_test 1.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x);
|
||||
CREATE TABLE t2(y);
|
||||
}
|
||||
} {wal}
|
||||
do_test 1.$tn.5 { sql3 { PRAGMA integrity_check } } {ok}
|
||||
|
||||
# Test that an CONCURRENT transaction that allocates/frees no pages does
|
||||
# not conflict with a transaction that does allocate pages.
|
||||
do_test 1.$tn.2 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(4);
|
||||
}
|
||||
sql2 {
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
}
|
||||
sql1 {
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
do_test 1.$tn.5 { sql3 { PRAGMA integrity_check } } {ok}
|
||||
|
||||
# But that an CONCURRENT transaction does conflict with a transaction
|
||||
# that modifies the db schema.
|
||||
do_test 1.$tn.3 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(5);
|
||||
}
|
||||
sql2 {
|
||||
CREATE TABLE t3(z);
|
||||
}
|
||||
list [catch { sql1 COMMIT } msg] $msg
|
||||
} {1 {database is locked}}
|
||||
do_test 1.$tn.5 { sql3 { PRAGMA integrity_check } } {ok}
|
||||
|
||||
# Test that an CONCURRENT transaction that allocates at least one page
|
||||
# does not conflict with a transaction that allocates no pages.
|
||||
do_test 1.$tn.4 {
|
||||
sql1 {
|
||||
ROLLBACK;
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
}
|
||||
sql2 {
|
||||
INSERT INTO t2 VALUES(8);
|
||||
}
|
||||
sql1 {
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 1.$tn.5 { sql3 { PRAGMA integrity_check } } {ok}
|
||||
}
|
||||
|
||||
do_multiclient_test tn {
|
||||
do_test 2.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x UNIQUE);
|
||||
CREATE TABLE t2(y UNIQUE);
|
||||
}
|
||||
} {wal}
|
||||
|
||||
do_test 2.$tn.2 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
}
|
||||
sql2 {
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
}
|
||||
sql1 COMMIT
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.3 { sql3 { PRAGMA integrity_check } } {ok}
|
||||
|
||||
do_test 2.$tn.4 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
DELETE FROM t1;
|
||||
}
|
||||
sql2 {
|
||||
DELETE FROM t2;
|
||||
}
|
||||
sql1 COMMIT
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.5 { sql3 { PRAGMA integrity_check } } {ok}
|
||||
|
||||
do_test 2.$tn.6 {
|
||||
sql1 {
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
DELETE FROM t1 WHERE rowid=1;
|
||||
}
|
||||
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
DELETE FROM t1 WHERE rowid=2;
|
||||
}
|
||||
|
||||
sql2 {
|
||||
DELETE FROM t2;
|
||||
}
|
||||
|
||||
sql1 COMMIT
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.7 { sql3 { PRAGMA integrity_check } } {ok}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# When an CONCURRENT transaction is opened on a database, the nFree and
|
||||
# iTrunk header fields of the cached version of page 1 are both set
|
||||
# to 0. This allows an CONCURRENT transaction to use its own private
|
||||
# free-page-list, which is merged with the main database free-list when
|
||||
# the transaction is committed.
|
||||
#
|
||||
# The following tests check that nFree/iTrunk are correctly restored if
|
||||
# an CONCURRENT transaction is rolled back, and that savepoint rollbacks
|
||||
# that occur within CONCURRENT transactions do not incorrectly restore
|
||||
# these fields to their on-disk values.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 3.0 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x, y);
|
||||
INSERT INTO t1 VALUES(randomblob(1500), randomblob(1500));
|
||||
DELETE FROM t1;
|
||||
} {wal}
|
||||
|
||||
do_execsql_test 3.1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
ROLLBACK;
|
||||
}
|
||||
|
||||
do_execsql_test 3.2 { PRAGMA integrity_check } {ok}
|
||||
do_execsql_test 3.3 { PRAGMA freelist_count } {2}
|
||||
|
||||
do_execsql_test 3.4.1 {
|
||||
BEGIN CONCURRENT;
|
||||
PRAGMA freelist_count;
|
||||
} {2}
|
||||
do_execsql_test 3.4.2 {
|
||||
SAVEPOINT xyz;
|
||||
INSERT INTO t1 VALUES(randomblob(1500), NULL);
|
||||
PRAGMA freelist_count;
|
||||
} {0}
|
||||
do_execsql_test 3.4.3 {
|
||||
ROLLBACK TO xyz;
|
||||
} {}
|
||||
do_execsql_test 3.4.4 { PRAGMA freelist_count } {0}
|
||||
do_execsql_test 3.4.5 { COMMIT; PRAGMA freelist_count } {2}
|
||||
do_execsql_test 3.4.6 { PRAGMA integrity_check } {ok}
|
||||
|
||||
do_execsql_test 3.5.1 {
|
||||
BEGIN CONCURRENT;
|
||||
UPDATE t1 SET x=randomblob(10) WHERE y=555;
|
||||
PRAGMA freelist_count;
|
||||
} {0}
|
||||
do_execsql_test 3.5.2 {
|
||||
ROLLBACK;
|
||||
PRAGMA freelist_count;
|
||||
} {2}
|
||||
do_execsql_test 3.5.3 { PRAGMA integrity_check } {ok}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that nothing goes wrong if an CONCURRENT transaction allocates a
|
||||
# page at the end of the file, frees it within the same transaction, and
|
||||
# then has to move the same page to avoid a conflict on COMMIT.
|
||||
#
|
||||
do_multiclient_test tn {
|
||||
do_test 4.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x);
|
||||
CREATE TABLE t2(x);
|
||||
}
|
||||
} {wal}
|
||||
|
||||
do_test 4.$tn.2 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
DELETE FROM t1 WHERE rowid = 1;
|
||||
}
|
||||
|
||||
sql2 {
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
DELETE FROM t2 WHERE rowid IN (1, 2);
|
||||
}
|
||||
|
||||
sql1 COMMIT
|
||||
} {}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
do_multiclient_test tn {
|
||||
do_test 5.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x);
|
||||
CREATE TABLE t2(x);
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
PRAGMA page_count;
|
||||
}
|
||||
} {wal 4}
|
||||
|
||||
do_test 5.$tn.2 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
PRAGMA page_count;
|
||||
}
|
||||
} {5}
|
||||
|
||||
do_test 5.$tn.3 {
|
||||
sql2 {
|
||||
DELETE FROM t1;
|
||||
PRAGMA freelist_count;
|
||||
PRAGMA page_count;
|
||||
}
|
||||
} {1 4}
|
||||
|
||||
do_test 5.$tn.4 { sql1 COMMIT } {}
|
||||
do_test 5.$tn.5 { sql3 { PRAGMA integrity_check } } {ok}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
do_multiclient_test tn {
|
||||
do_test 6.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
PRAGMA wal_checkpoint;
|
||||
}
|
||||
} {wal 0 5 5}
|
||||
|
||||
do_test 6.$tn.2 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 6.$tn.3 {
|
||||
sql2 {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 6.$tn.4 {
|
||||
list [catch { sql1 COMMIT } msg] $msg
|
||||
} {1 {database is locked}}
|
||||
do_test 6.$tn.5 { sql3 { PRAGMA integrity_check } } {ok}
|
||||
do_test 6.$tn.5 { sql3 { SELECT count(*) from t1 } } {3}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that if a corrupt wal-index-header is encountered when attempting
|
||||
# to commit a CONCURRENT transaction, the transaction is not committed
|
||||
# (or rolled back) and that SQLITE_BUSY_SNAPSHOT is returned to the user.
|
||||
#
|
||||
catch { db close }
|
||||
forcedelete test.db
|
||||
testvfs tvfs
|
||||
sqlite3 db test.db -vfs tvfs
|
||||
do_execsql_test 7.1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
BEGIN;
|
||||
CREATE TABLE t1(a, b, PRIMARY KEY(a));
|
||||
INSERT INTO t1 VALUES(1, 2);
|
||||
INSERT INTO t1 VALUES(3, 4);
|
||||
COMMIT;
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(5, 6);
|
||||
INSERT INTO t1 VALUES(7, 8);
|
||||
SELECT * FROM t1;
|
||||
} {wal 1 2 3 4 5 6 7 8}
|
||||
|
||||
# Corrupt the wal-index header
|
||||
incr_tvfs_hdr test.db 11 1
|
||||
|
||||
do_catchsql_test 7.2.1 { COMMIT } {1 {database is locked}}
|
||||
do_test 7.2.2 { sqlite3_extended_errcode db } SQLITE_BUSY_SNAPSHOT
|
||||
|
||||
do_execsql_test 7.3.1 {
|
||||
SELECT * FROM t1;
|
||||
ROLLBACK;
|
||||
} {1 2 3 4 5 6 7 8}
|
||||
do_execsql_test 7.3.2 {
|
||||
SELECT * FROM t1;
|
||||
} {1 2 3 4}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that "PRAGMA integrity_check" works within a concurrent
|
||||
# transaction. Within a concurrent transaction, "PRAGMA integrity_check"
|
||||
# is unable to detect unused database pages, but can detect other types
|
||||
# of corruption.
|
||||
#
|
||||
reset_db
|
||||
do_test 8.1 {
|
||||
execsql {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE kv(k INTEGER PRIMARY KEY, v UNIQUE);
|
||||
INSERT INTO kv VALUES(NULL, randomblob(750));
|
||||
INSERT INTO kv SELECT NULL, randomblob(750) FROM kv;
|
||||
INSERT INTO kv SELECT NULL, randomblob(750) FROM kv;
|
||||
INSERT INTO kv SELECT NULL, randomblob(750) FROM kv;
|
||||
INSERT INTO kv SELECT NULL, randomblob(750) FROM kv;
|
||||
INSERT INTO kv SELECT NULL, randomblob(750) FROM kv;
|
||||
DELETE FROM kv WHERE rowid%2;
|
||||
}
|
||||
set v [db one {PRAGMA freelist_count}]
|
||||
expr $v==33 || $v==34
|
||||
} {1}
|
||||
do_execsql_test 8.2 { PRAGMA integrity_check } ok
|
||||
do_execsql_test 8.3 {
|
||||
BEGIN CONCURRENT;
|
||||
PRAGMA integrity_check;
|
||||
} {ok}
|
||||
do_execsql_test 8.4 {
|
||||
INSERT INTO kv VALUES(1100, 1100);
|
||||
PRAGMA integrity_check;
|
||||
} {ok}
|
||||
do_execsql_test 8.5 {
|
||||
COMMIT;
|
||||
PRAGMA integrity_check;
|
||||
} {ok}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that concurrent transactions do not allow foreign-key constraints
|
||||
# to be bypassed.
|
||||
#
|
||||
do_multiclient_test tn {
|
||||
do_test 9.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE pp(i INTEGER PRIMARY KEY, j);
|
||||
CREATE TABLE cc(a, b REFERENCES pp);
|
||||
|
||||
WITH seq(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM seq WHERE i<100)
|
||||
INSERT INTO pp SELECT i, randomblob(1000) FROM seq;
|
||||
|
||||
PRAGMA foreign_keys = 1;
|
||||
}
|
||||
} {wal}
|
||||
|
||||
|
||||
do_test 9.$tn.2.1 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO cc VALUES(42, 42);
|
||||
}
|
||||
} {}
|
||||
do_test 9.$tn.2.2 {
|
||||
sql2 { DELETE FROM pp WHERE i=42 }
|
||||
list [catch { sql1 COMMIT } msg] $msg
|
||||
} {1 {database is locked}}
|
||||
do_test 9.$tn.2.3 {
|
||||
sql1 ROLLBACK
|
||||
} {}
|
||||
|
||||
do_test 9.$tn.3.1 {
|
||||
sql1 {
|
||||
PRAGMA foreign_keys = 0;
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO cc VALUES(43, 43);
|
||||
}
|
||||
} {}
|
||||
do_test 9.$tn.3.2 {
|
||||
sql2 { DELETE FROM pp WHERE i=43 }
|
||||
list [catch { sql1 COMMIT } msg] $msg
|
||||
} {0 {}}
|
||||
|
||||
do_test 9.$tn.4.1 {
|
||||
sql1 {
|
||||
PRAGMA foreign_keys = on;
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO cc VALUES(44, 44);
|
||||
}
|
||||
} {}
|
||||
do_test 9.$tn.4.2 {
|
||||
sql2 { DELETE FROM pp WHERE i=1 }
|
||||
list [catch { sql1 COMMIT } msg] $msg
|
||||
} {0 {}}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that even if a SELECT statement appears before all writes within
|
||||
# a CONCURRENT transaction, the pages it reads are still considered when
|
||||
# considering whether or not the transaction may be committed.
|
||||
#
|
||||
do_multiclient_test tn {
|
||||
do_test 10.$tn.1.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(a);
|
||||
CREATE TABLE t2(b);
|
||||
CREATE TABLE t3(c);
|
||||
INSERT INTO t1 VALUES(1), (2), (3);
|
||||
INSERT INTO t2 VALUES(1), (2), (3);
|
||||
INSERT INTO t3 VALUES(1), (2), (3);
|
||||
}
|
||||
} {wal}
|
||||
|
||||
do_test 10.$tn.1.2 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t1;
|
||||
INSERT INTO t2 VALUES(4);
|
||||
}
|
||||
} {1 2 3}
|
||||
|
||||
do_test 10.$tn.1.3 {
|
||||
sql2 { INSERT INTO t1 VALUES(4) }
|
||||
list [catch {sql1 COMMIT} msg] $msg
|
||||
} {1 {database is locked}}
|
||||
sql1 ROLLBACK
|
||||
|
||||
# In this case, because the "SELECT * FROM t1" is first stepped before
|
||||
# the "BEGIN CONCURRENT", the pages it reads are not recorded by the
|
||||
# pager object. And so the transaction can be committed. Technically
|
||||
# this behaviour (the effect of an ongoing SELECT on a BEGIN CONCURRENT
|
||||
# transacation) is undefined.
|
||||
#
|
||||
do_test 10.$tn.2.1 {
|
||||
code1 {
|
||||
set ::stmt [sqlite3_prepare db "SELECT * FROM t1" -1 dummy]
|
||||
sqlite3_step $::stmt
|
||||
}
|
||||
} {SQLITE_ROW}
|
||||
do_test 10.$tn.2.2 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t2 VALUES(4);
|
||||
}
|
||||
code1 {
|
||||
set res [list]
|
||||
lappend res [sqlite3_column_int $::stmt 0]
|
||||
while {[sqlite3_step $::stmt]=="SQLITE_ROW"} {
|
||||
lappend res [sqlite3_column_int $::stmt 0]
|
||||
}
|
||||
sqlite3_finalize $::stmt
|
||||
set res
|
||||
}
|
||||
} {1 2 3 4}
|
||||
do_test 10.$tn.2.3 {
|
||||
sql2 { INSERT INTO t1 VALUES(5) }
|
||||
sql1 COMMIT
|
||||
} {}
|
||||
|
||||
# More tests surrounding long-lived prepared statements and concurrent
|
||||
# transactions.
|
||||
do_test 10.$tn.3.1 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t1;
|
||||
COMMIT;
|
||||
}
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t2 VALUES(5);
|
||||
}
|
||||
sql2 {
|
||||
INSERT INTO t1 VALUES(5);
|
||||
}
|
||||
sql1 COMMIT
|
||||
sql3 {
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} {1 2 3 4 5}
|
||||
do_test 10.$tn.3.2 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t1;
|
||||
ROLLBACK;
|
||||
}
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t2 VALUES(6);
|
||||
}
|
||||
sql2 {
|
||||
INSERT INTO t1 VALUES(6);
|
||||
}
|
||||
sql1 COMMIT
|
||||
sql3 { SELECT * FROM t2 }
|
||||
} {1 2 3 4 5 6}
|
||||
do_test 10.$tn.3.3 {
|
||||
sql1 { BEGIN CONCURRENT }
|
||||
code1 {
|
||||
set ::stmt [sqlite3_prepare db "SELECT * FROM t1" -1 dummy]
|
||||
sqlite3_step $::stmt
|
||||
}
|
||||
sql1 {
|
||||
INSERT INTO t2 VALUES(7);
|
||||
SELECT * FROM t3;
|
||||
ROLLBACK;
|
||||
BEGIN CONCURRENT;
|
||||
}
|
||||
sql2 { INSERT INTO t3 VALUES(5) }
|
||||
code1 { sqlite3_finalize $::stmt }
|
||||
sql1 {
|
||||
INSERT INTO t2 VALUES(8);
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
}
|
||||
|
||||
do_multiclient_test tn {
|
||||
do_test 11.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(a);
|
||||
}
|
||||
} {wal}
|
||||
|
||||
do_test 11.$tn.2 {
|
||||
code1 { sqlite3_wal_info db main }
|
||||
} {0 2}
|
||||
|
||||
do_test 11.$tn.3 {
|
||||
sql1 { INSERT INTO t1 VALUES(1) }
|
||||
code1 { sqlite3_wal_info db main }
|
||||
} {2 3}
|
||||
|
||||
do_test 11.$tn.4 {
|
||||
sql2 { INSERT INTO t1 VALUES(2) }
|
||||
code2 { sqlite3_wal_info db2 main }
|
||||
} {3 4}
|
||||
|
||||
do_test 11.$tn.5 {
|
||||
sql1 { PRAGMA wal_checkpoint }
|
||||
sql2 { INSERT INTO t1 VALUES(3) }
|
||||
code2 { sqlite3_wal_info db2 main }
|
||||
} {0 1}
|
||||
}
|
||||
|
||||
reset_db
|
||||
do_execsql_test 12.0 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE tx(a INTEGER PRIMARY KEY, b);
|
||||
} {wal}
|
||||
do_test 12.1 {
|
||||
for {set i 0} {$i < 50} {incr i} {
|
||||
execsql {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO tx(b) VALUES( randomblob( 1200 ) );
|
||||
COMMIT;
|
||||
}
|
||||
}
|
||||
execsql { PRAGMA page_size }
|
||||
} {1024}
|
||||
do_execsql_test 12.2 {
|
||||
DELETE FROM tx;
|
||||
}
|
||||
do_test 12.3 {
|
||||
for {set i 0} {$i < 50} {incr i} {
|
||||
execsql {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO tx(b) VALUES( randomblob( 1200 ) );
|
||||
COMMIT;
|
||||
}
|
||||
}
|
||||
execsql { PRAGMA page_size }
|
||||
} {1024}
|
||||
do_execsql_test 12.4 {
|
||||
DELETE FROM tx;
|
||||
}
|
||||
do_test 12.5 {
|
||||
execsql { BEGIN CONCURRENT }
|
||||
for {set i 0} {$i < 5000} {incr i} {
|
||||
execsql {
|
||||
INSERT INTO tx(b) VALUES( randomblob( 1200 ) );
|
||||
}
|
||||
}
|
||||
execsql { COMMIT }
|
||||
execsql { PRAGMA page_size }
|
||||
} {1024}
|
||||
|
||||
|
||||
finish_test
|
||||
@@ -0,0 +1,231 @@
|
||||
# 2015 July 26
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# Tests for transactions started with BEGIN CONCURRENT. The tests in this
|
||||
# file focus on testing that deferred page allocation works properly.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
set ::testprefix concurrent3
|
||||
|
||||
if {$AUTOVACUUM} { finish_test ; return }
|
||||
ifcapable !concurrent {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
db close
|
||||
sqlite3_shutdown
|
||||
test_sqlite3_log xLog
|
||||
proc xLog {error_code msg} {
|
||||
# puts "$error_code: $msg"
|
||||
# Enable the previous for debugging
|
||||
}
|
||||
reset_db
|
||||
|
||||
proc create_schema {} {
|
||||
db eval {
|
||||
PRAGMA journal_mode = wal;
|
||||
|
||||
CREATE TABLE t1(x, y);
|
||||
CREATE TABLE t2(x, y);
|
||||
CREATE TABLE t3(x, y);
|
||||
CREATE TABLE t4(x, y);
|
||||
|
||||
CREATE INDEX i1 ON t1(y, x);
|
||||
CREATE INDEX i2 ON t2(y, x);
|
||||
CREATE INDEX i3 ON t3(y, x);
|
||||
CREATE INDEX i4 ON t4(y, x);
|
||||
}
|
||||
}
|
||||
|
||||
proc do_sql_op {iTbl iOp} {
|
||||
set db "db$iTbl"
|
||||
|
||||
switch $iOp {
|
||||
"i" {
|
||||
set sql "
|
||||
WITH cnt(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM cnt WHERE i<10)
|
||||
INSERT INTO t$iTbl SELECT randomblob(800), randomblob(800) FROM cnt;
|
||||
"
|
||||
}
|
||||
|
||||
"d" {
|
||||
set sql "
|
||||
DELETE FROM t$iTbl WHERE rowid IN (
|
||||
SELECT rowid FROM t$iTbl ORDER BY 1 ASC LIMIT 10
|
||||
)
|
||||
"
|
||||
}
|
||||
|
||||
"D" {
|
||||
set sql "
|
||||
DELETE FROM t$iTbl WHERE rowid IN (
|
||||
SELECT rowid FROM t$iTbl o WHERE (
|
||||
SELECT count(*) FROM t$iTbl i WHERE i.rowid<o.rowid
|
||||
) % 2
|
||||
)
|
||||
"
|
||||
}
|
||||
|
||||
"I" {
|
||||
set sql "
|
||||
INSERT INTO t$iTbl SELECT randomblob(800), randomblob(800) FROM t$iTbl;
|
||||
"
|
||||
}
|
||||
|
||||
default {
|
||||
error "bad iOp parameter: $iOp"
|
||||
}
|
||||
}
|
||||
|
||||
$db eval $sql
|
||||
}
|
||||
|
||||
|
||||
set DBLIST {db1 db2 db3 db4}
|
||||
|
||||
create_schema
|
||||
foreach {tn oplist} {
|
||||
1 {1i 2i 3i 4i}
|
||||
2 {1iii 2iii 3iii 4iii}
|
||||
3 {1d 2d 3d 4d}
|
||||
. -----------------------
|
||||
4 {1i}
|
||||
5 {1d 2i}
|
||||
. -----------------------
|
||||
6 {1iii 2iii 3iii 4iii}
|
||||
7 {1di 2id 3iii 4ddd}
|
||||
8 {1iii 2iii 3iii 4iii}
|
||||
9 {1D 2II}
|
||||
10 {1I 2D 3I 4D}
|
||||
11 {1III 3dddddd 4III}
|
||||
} {
|
||||
if {[string range $oplist 0 0]=="-"} {
|
||||
reset_db
|
||||
create_schema
|
||||
continue
|
||||
}
|
||||
foreach db $DBLIST { sqlite3 $db test.db }
|
||||
|
||||
do_test 1.$tn {
|
||||
foreach db $DBLIST { $db eval "BEGIN CONCURRENT" }
|
||||
|
||||
foreach op $oplist {
|
||||
set iTbl [string range $op 0 0]
|
||||
foreach char [split [string range $op 1 end] {}] {
|
||||
do_sql_op $iTbl $char
|
||||
}
|
||||
}
|
||||
|
||||
foreach db $DBLIST { $db eval "COMMIT" }
|
||||
db eval {PRAGMA integrity_check}
|
||||
} {ok}
|
||||
|
||||
foreach db $DBLIST {
|
||||
$db close
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
proc create_schema2 {} {
|
||||
db eval {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
|
||||
CREATE INDEX i1 ON t1(y);
|
||||
}
|
||||
}
|
||||
|
||||
proc randint {nMax} {
|
||||
db eval {SELECT abs(random() % $nMax)}
|
||||
}
|
||||
|
||||
proc do_sql_op2 {db iOp} {
|
||||
switch -- $iOp {
|
||||
i {
|
||||
# Insert 1 rows.
|
||||
set r [randint 1000000000]
|
||||
set ::rows($r) 1
|
||||
#puts "insert row $r"
|
||||
$db eval { INSERT OR IGNORE INTO t1 VALUES($r, randomblob(50)); }
|
||||
}
|
||||
|
||||
d {
|
||||
# Insert 1 row
|
||||
set keys [array names ::rows]
|
||||
set r [randint [llength $keys]]
|
||||
set rowid [lindex $keys $r]
|
||||
$db eval { DELETE FROM t1 WHERE x=$rowid }
|
||||
unset ::rows($rowid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach {tn nRepeat oplist} {
|
||||
- - ----------------------------
|
||||
1 100 { 1iiiiiiiiii }
|
||||
2 100 { 1i 2d }
|
||||
3 100 { 1d 2i }
|
||||
4 50 { 1d 2i 3d }
|
||||
5 500 { 1i 2i 3i 4i }
|
||||
6 500 { 1i 2d 3d 4d }
|
||||
} {
|
||||
if {[string range $oplist 0 0]=="-"} {
|
||||
array unset rows
|
||||
reset_db
|
||||
create_schema2
|
||||
continue
|
||||
}
|
||||
|
||||
foreach db $DBLIST {
|
||||
sqlite3 $db test.db
|
||||
set stats($db,0) 0
|
||||
set stats($db,1) 0
|
||||
}
|
||||
array unset used
|
||||
|
||||
do_test 2.$tn {
|
||||
|
||||
for {set i 0} {$i < $nRepeat} {incr i} {
|
||||
foreach db $DBLIST { $db eval "BEGIN CONCURRENT" }
|
||||
|
||||
foreach op $oplist {
|
||||
set iDb [string range $op 0 0]
|
||||
set used(db$iDb) 1
|
||||
foreach char [split [string range $op 1 end] {}] {
|
||||
do_sql_op2 "db$iDb" $char
|
||||
}
|
||||
}
|
||||
|
||||
foreach db $DBLIST {
|
||||
set rc [catch { $db eval COMMIT } msg]
|
||||
if {$rc} { $db eval ROLLBACK }
|
||||
incr stats($db,$rc)
|
||||
}
|
||||
set res [db eval {PRAGMA integrity_check}]
|
||||
if {$res != "ok"} { puts "after $db $rc: $res" ; after 1000000 }
|
||||
}
|
||||
} {}
|
||||
|
||||
foreach db $DBLIST {
|
||||
$db close
|
||||
}
|
||||
# foreach k [lsort [array names used]] {
|
||||
# puts "$k: $stats($k,0) committed, $stats($k,1) rolled back"
|
||||
# }
|
||||
}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
@@ -0,0 +1,194 @@
|
||||
# 2017 May 26
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
# Miscellaneous tests for transactions started with BEGIN CONCURRENT.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
source $testdir/wal_common.tcl
|
||||
set ::testprefix concurrent4
|
||||
|
||||
ifcapable !concurrent {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x PRIMARY KEY, y UNIQUE);
|
||||
WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
|
||||
DELETE FROM t1 WHERE rowid<2;
|
||||
} {wal}
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1(rowid, x, y) VALUES(1000, randomblob(3000), randomblob(3000));
|
||||
SAVEPOINT abc;
|
||||
DELETE FROM t1 WHERE rowid = 1000;
|
||||
}
|
||||
|
||||
do_execsql_test 1.2 { ROLLBACK TO abc }
|
||||
do_execsql_test 1.3 { COMMIT }
|
||||
do_execsql_test 1.4 { PRAGMA integrity_check } {ok}
|
||||
|
||||
do_multiclient_test tn {
|
||||
do_test 2.$tn.1 {
|
||||
sql1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(a, b);
|
||||
WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
|
||||
|
||||
CREATE TABLE t2(a, b);
|
||||
WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t2 SELECT randomblob(400), randomblob(400) FROM s;
|
||||
}
|
||||
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(randomblob(3000), randomblob(3000));
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.2 {
|
||||
sql2 {
|
||||
WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10)
|
||||
INSERT INTO t2 SELECT randomblob(400), randomblob(400) FROM s;
|
||||
}
|
||||
sql2 {
|
||||
DELETE FROM t2 WHERE rowid<10;
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 2.$tn.3 {
|
||||
sql1 {
|
||||
COMMIT;
|
||||
PRAGMA integrity_check;
|
||||
}
|
||||
} {ok}
|
||||
do_test 2.$tn.4 {
|
||||
sql2 {
|
||||
PRAGMA integrity_check;
|
||||
}
|
||||
} {ok}
|
||||
}
|
||||
|
||||
reset_db
|
||||
do_execsql_test 3.1 {
|
||||
PRAGMA page_size = 1024;
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t2(x);
|
||||
INSERT INTO t2 VALUES(randomblob(5000));
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
|
||||
INSERT INTO t1 VALUES(25, randomblob(104));
|
||||
DELETE FROM t2;
|
||||
} {wal}
|
||||
|
||||
do_execsql_test 3.2 {
|
||||
BEGIN CONCURRENT;
|
||||
REPLACE INTO t1 VALUES(25, randomblob(1117));
|
||||
COMMIT;
|
||||
} {}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test the effect of BEGIN CONCURRENT transactions that consist entirely
|
||||
# of read-only statements.
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 4.0 {
|
||||
PRAGMA page_size = 1024;
|
||||
PRAGMA journal_mode = wal;
|
||||
|
||||
CREATE TABLE t4(a, b);
|
||||
INSERT INTO t4 VALUES(1, 2);
|
||||
INSERT INTO t4 VALUES(3, 4);
|
||||
} {wal}
|
||||
|
||||
sqlite3 db2 test.db
|
||||
do_test 4.1.1 {
|
||||
db eval {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t4 VALUES(5, 6);
|
||||
}
|
||||
|
||||
db2 eval {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t4;
|
||||
ROLLBACK;
|
||||
}
|
||||
} {1 2 3 4}
|
||||
|
||||
do_test 4.1.2 {
|
||||
db eval { COMMIT }
|
||||
db2 eval { SELECT * FROM t4 }
|
||||
} {1 2 3 4 5 6}
|
||||
|
||||
do_test 4.2.1 {
|
||||
db eval {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t4 VALUES(7, 8);
|
||||
}
|
||||
|
||||
db2 eval {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t4;
|
||||
COMMIT;
|
||||
}
|
||||
} {1 2 3 4 5 6}
|
||||
|
||||
do_test 4.2.2 {
|
||||
db eval { COMMIT }
|
||||
db2 eval { SELECT * FROM t4 }
|
||||
} {1 2 3 4 5 6 7 8}
|
||||
|
||||
do_test 4.3 {
|
||||
db2 eval {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t4;
|
||||
}
|
||||
|
||||
db eval {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t4 VALUES(9, 10);
|
||||
COMMIT;
|
||||
}
|
||||
db2 eval {
|
||||
SELECT * FROM t4;
|
||||
COMMIT;
|
||||
}
|
||||
} {1 2 3 4 5 6 7 8}
|
||||
|
||||
set sz [file size test.db-wal]
|
||||
do_test 4.4.1 {
|
||||
db eval {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t4;
|
||||
SELECT * FROM sqlite_master;
|
||||
}
|
||||
|
||||
db eval COMMIT
|
||||
file size test.db-wal
|
||||
} $sz
|
||||
do_test 4.4.2 {
|
||||
db eval {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT * FROM t4;
|
||||
SELECT * FROM sqlite_master;
|
||||
ROLLBACK;
|
||||
}
|
||||
file size test.db-wal
|
||||
} $sz
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
# 2017 May 26
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
source $testdir/wal_common.tcl
|
||||
set ::testprefix concurrent5
|
||||
|
||||
ifcapable !concurrent {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
db close
|
||||
sqlite3_shutdown
|
||||
test_sqlite3_log [list lappend ::log]
|
||||
set ::log [list]
|
||||
|
||||
sqlite3 db test.db
|
||||
|
||||
proc do_test_conflict_msg {tn msg} {
|
||||
set msg "cannot commit CONCURRENT transaction - [string trim $msg]"
|
||||
uplevel [list do_test $tn {lindex $::log end} $msg]
|
||||
}
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x, y);
|
||||
CREATE TABLE t2(c);
|
||||
WITH s(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM s;
|
||||
} {wal}
|
||||
|
||||
sqlite3 db2 test.db
|
||||
|
||||
do_test 1.1.1 {
|
||||
set ::log [list]
|
||||
db2 eval {
|
||||
BEGIN CONCURRENT;
|
||||
SELECT count(*) FROM t1;
|
||||
INSERT INTO t2 VALUES(10);
|
||||
}
|
||||
|
||||
db eval {
|
||||
INSERT INTO t1 VALUES(randomblob(200), randomblob(200));
|
||||
}
|
||||
|
||||
catchsql COMMIT db2
|
||||
} {1 {database is locked}}
|
||||
do_test_conflict_msg 1.1.2 {
|
||||
conflict at page 2 (read-only page; part of db table t1; content=0500000063021100...)
|
||||
}
|
||||
|
||||
do_test 1.2.1 {
|
||||
set ::log [list]
|
||||
db2 eval {
|
||||
ROLLBACK;
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(11, 12);
|
||||
}
|
||||
|
||||
db eval {
|
||||
INSERT INTO t1 VALUES(12, 11);
|
||||
}
|
||||
|
||||
catchsql COMMIT db2
|
||||
} {1 {database is locked}}
|
||||
|
||||
do_test_conflict_msg 1.2.2 {
|
||||
conflict at page 105 (read/write page; part of db table t1; content=0D00000002026100...)
|
||||
}
|
||||
|
||||
do_test 1.3.1 {
|
||||
set ::log [list]
|
||||
db2 eval {
|
||||
ROLLBACK;
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t2 VALUES('x');
|
||||
}
|
||||
|
||||
db eval {
|
||||
INSERT INTO t2 VALUES('y');
|
||||
}
|
||||
|
||||
catchsql COMMIT db2
|
||||
} {1 {database is locked}}
|
||||
|
||||
do_test_conflict_msg 1.3.2 {
|
||||
conflict at page 3 (read/write page; part of db table t2; content=0D0000000103FB00...)
|
||||
}
|
||||
|
||||
do_test 1.4.1 {
|
||||
set ::log [list]
|
||||
|
||||
execsql {
|
||||
ROLLBACK;
|
||||
CREATE TABLE t3(a INTEGER PRIMARY KEY, b INTEGER);
|
||||
CREATE INDEX i3 ON t3(b);
|
||||
|
||||
WITH s(i) AS (
|
||||
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<5000
|
||||
) INSERT INTO t3 SELECT i, i FROM s;
|
||||
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t3 VALUES(0, 5001);
|
||||
} db2
|
||||
|
||||
execsql { INSERT INTO t3 VALUES(NULL, 5002) } db
|
||||
catchsql COMMIT db2
|
||||
} {1 {database is locked}}
|
||||
|
||||
do_test_conflict_msg 1.3.2 {
|
||||
conflict at page 211 (read/write page; part of db index t3.i3; content=0A0310006300D800...)
|
||||
}
|
||||
|
||||
db close
|
||||
db2 close
|
||||
sqlite3_shutdown
|
||||
test_sqlite3_log
|
||||
sqlite3_initialize
|
||||
finish_test
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
# 2017 May 26
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
source $testdir/wal_common.tcl
|
||||
set ::testprefix concurrent6
|
||||
|
||||
ifcapable !concurrent {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
sqlite3 db2 test.db
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
PRAGMA page_size = 1024;
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x);
|
||||
CREATE TABLE t2(x);
|
||||
CREATE TABLE t3(x);
|
||||
CREATE TABLE t4(x);
|
||||
|
||||
INSERT INTO t1 VALUES(zeroblob(1500));
|
||||
} {wal}
|
||||
|
||||
do_execsql_test -db db2 1.1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t3 VALUES(zeroblob(4000));
|
||||
DELETE FROM t1;
|
||||
}
|
||||
|
||||
do_execsql_test 1.2 {
|
||||
WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t2 SELECT zeroblob(1000) FROM s;
|
||||
|
||||
WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t4 SELECT zeroblob(1000) FROM s;
|
||||
|
||||
DELETE FROM t4;
|
||||
}
|
||||
|
||||
do_execsql_test -db db2 1.3 {
|
||||
COMMIT;
|
||||
}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# 2018 Jan 5
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set ::testprefix concurrent7
|
||||
|
||||
sqlite3 db2 test.db
|
||||
|
||||
do_execsql_test 1 {
|
||||
PRAGMA journal_mode = wal;
|
||||
CREATE TABLE t1(x);
|
||||
CREATE TABLE t2(x);
|
||||
} {wal}
|
||||
|
||||
do_execsql_test -db db2 2 {
|
||||
SELECT * FROM t1;
|
||||
}
|
||||
|
||||
do_execsql_test 3 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
INSERT INTO t1 VALUES(randomblob(1500));
|
||||
DELETE FROM t1 WHERE rowid = 1;
|
||||
}
|
||||
|
||||
do_execsql_test -db db2 4 {
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
INSERT INTO t2 VALUES(randomblob(1500));
|
||||
DELETE FROM t2 WHERE rowid IN (1, 2);
|
||||
}
|
||||
|
||||
do_execsql_test 5 {
|
||||
COMMIT;
|
||||
PRAGMA integrity_check;
|
||||
} {ok}
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
# 2020 July 17
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set ::testprefix concurrent8
|
||||
|
||||
source $testdir/lock_common.tcl
|
||||
|
||||
ifcapable !concurrent {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_multiclient_test tn {
|
||||
|
||||
do_test 1.$tn.0 {
|
||||
sql1 {
|
||||
CREATE TABLE t1(x, y);
|
||||
PRAGMA journal_mode = wal;
|
||||
}
|
||||
} {wal}
|
||||
|
||||
do_test 1.$tn.1 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
INSERT INTO t1 VALUES(1, 1);
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 1.$tn.2 {
|
||||
sql2 {
|
||||
CREATE TABLE t2(a, b);
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 1.$tn.3 {
|
||||
list [catch { sql1 { COMMIT } } msg] $msg
|
||||
} {1 {database is locked}}
|
||||
|
||||
do_test 1.$tn.4 {
|
||||
code1 { db errorcode }
|
||||
} {517} ;# SQLITE_BUSY_SNAPSHOT
|
||||
|
||||
do_test 1.$tn.5 {
|
||||
sql1 {
|
||||
ROLLBACK;
|
||||
BEGIN CONCURRENT;
|
||||
CREATE TABLE t3(a, b);
|
||||
COMMIT;
|
||||
}
|
||||
} {}
|
||||
|
||||
do_test 1.$tn.6 {
|
||||
set nPg [sql1 {PRAGMA page_count}]
|
||||
sql1 "BEGIN CONCURRENT"
|
||||
for {set i 0} {$i<250} {incr i} {
|
||||
sql1 "CREATE TABLE z$i (a, b, c)"
|
||||
}
|
||||
sql1 "COMMIT"
|
||||
set nPg2 [sql1 {PRAGMA page_count}]
|
||||
expr $nPg2>$nPg
|
||||
} {1}
|
||||
|
||||
do_test 1.$tn.7 {
|
||||
sql2 { PRAGMA integrity_check }
|
||||
} {ok}
|
||||
|
||||
do_test 1.$tn.8 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
CREATE TABLE t4(a, b);
|
||||
}
|
||||
sql2 {
|
||||
INSERT INTO t1 VALUES(2, 2);
|
||||
}
|
||||
list [catch { sql1 COMMIT } msg] $msg
|
||||
} {1 {database is locked}}
|
||||
sql1 ROLLBACK
|
||||
|
||||
do_test 1.$tn.9 {
|
||||
sql1 {
|
||||
BEGIN CONCURRENT;
|
||||
CREATE TEMP TABLE t5(a, b);
|
||||
INSERT INTO t2 VALUES('x', 'x');
|
||||
}
|
||||
sql2 {
|
||||
INSERT INTO t1 VALUES(3, 3);
|
||||
CREATE TEMP TABLE t1(x, y);
|
||||
}
|
||||
sql1 COMMIT
|
||||
} {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ do_catchsql_test 2.1 {
|
||||
SELECT count(*) FROM sqlite_schema;
|
||||
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<1000)
|
||||
INSERT INTO t1(a) SELECT randomblob(null) FROM c;
|
||||
} {1 {database disk image is malformed}}
|
||||
} {0 4}
|
||||
|
||||
reset_db
|
||||
if {![info exists ::G(perm:presql)]} {
|
||||
|
||||
@@ -7033,6 +7033,8 @@ set sqlite_fts3_enable_parentheses $saved
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
set saved $sqlite_fts3_enable_parentheses
|
||||
set sqlite_fts3_enable_parentheses 1
|
||||
reset_db
|
||||
do_test 52.0 {
|
||||
sqlite3 db {}
|
||||
@@ -7228,5 +7230,438 @@ do_catchsql_test 52.1 {
|
||||
SELECT * FROM t1, t2;
|
||||
} {1 {database disk image is malformed}}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
reset_db
|
||||
do_test 53.0 {
|
||||
sqlite3 db {}
|
||||
db deserialize [decode_hexdb {
|
||||
.open --hexdb
|
||||
| size 8192 pagesize 1024 filename crash-7bc.txt.db
|
||||
| page 1 offset 0
|
||||
| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
|
||||
| 16: 04 00 01 01 00 40 20 20 00 00 00 00 00 00 00 08 .....@ ........
|
||||
| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................
|
||||
| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
|
||||
| 96: 00 00 00 00 0d 02 f3 00 07 01 51 00 03 c8 03 63 ..........Q....c
|
||||
| 112: 02 fb 02 0a 02 c0 01 a8 01 51 00 00 00 00 00 00 .........Q......
|
||||
| 336: 00 55 07 07 17 1b 1b 01 81 01 74 61 62 6c 65 74 .U........tablet
|
||||
| 352: 31 5f 73 74 61 74 74 31 5f 73 74 61 74 07 43 52 1_statt1_stat.CR
|
||||
| 368: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
|
||||
| 384: 74 61 74 27 28 69 64 20 49 4e 54 45 47 45 52 20 tat'(id INTEGER
|
||||
| 400: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 61 6c PRIMARY KEY, val
|
||||
| 416: 75 65 20 42 4c 4f 42 29 60 06 07 17 21 21 01 81 ue BLOB)`...!!..
|
||||
| 432: 0b 74 61 62 6c 65 74 31 5f 64 6f 63 73 69 7a 65 .tablet1_docsize
|
||||
| 448: 74 31 5f 64 6f 63 73 69 7a 65 06 43 52 45 41 54 t1_docsize.CREAT
|
||||
| 464: 45 20 54 41 42 4c 45 20 27 74 31 5f 64 6f 63 73 E TABLE 't1_docs
|
||||
| 480: 69 7a 65 27 28 64 6f 63 69 64 20 49 4e 54 45 47 ize'(docid INTEG
|
||||
| 496: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 ER PRIMARY KEY,
|
||||
| 512: 73 69 7a 65 20 42 4c 4f 42 29 81 33 04 07 17 1f size BLOB).3....
|
||||
| 528: 1f 01 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 ...5tablet1_segd
|
||||
| 544: 69 72 74 31 5f 73 65 67 64 69 72 04 43 52 45 41 irt1_segdir.CREA
|
||||
| 560: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg
|
||||
| 576: 64 69 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 dir'(level INTEG
|
||||
| 592: 45 52 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 ER,idx INTEGER,s
|
||||
| 608: 74 61 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 tart_block INTEG
|
||||
| 624: 45 52 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c ER,leaves_end_bl
|
||||
| 640: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f ock INTEGER,end_
|
||||
| 656: 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f block INTEGER,ro
|
||||
| 672: 6f 74 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 ot BLOB,PRIMARY
|
||||
| 688: 4b 45 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 KEY(level, idx))
|
||||
| 704: 31 05 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 1...E...indexsql
|
||||
| 720: 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 ite_autoindex_t1
|
||||
| 736: 5f 73 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 _segdir_1t1_segd
|
||||
| 752: 69 72 05 00 00 00 08 00 00 00 00 66 03 07 17 23 ir.........f...#
|
||||
| 768: 23 01 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d #...tablet1_segm
|
||||
| 784: 65 6e 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 03 entst1_segments.
|
||||
| 800: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 CREATE TABLE 't1
|
||||
| 816: 5f 73 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b _segments'(block
|
||||
| 832: 69 64 20 49 4e 53 45 47 45 52 20 50 52 49 4d 41 id INSEGER PRIMA
|
||||
| 848: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c RY KEY, block BL
|
||||
| 864: 4f 42 29 63 02 07 17 21 21 01 81 11 74 61 62 6c OB)c...!!...tabl
|
||||
| 880: 65 74 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f et1_contentt1_co
|
||||
| 896: 6e 74 65 6e 74 02 43 52 45 41 54 45 20 54 41 42 ntent.CREATE TAB
|
||||
| 912: 4c 45 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 LE 't1_content'(
|
||||
| 928: 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 docid INTEGER PR
|
||||
| 944: 49 4d 41 52 59 20 4b 45 59 2c 20 27 63 30 30 27 IMARY KEY, 'c00'
|
||||
| 960: 2c 20 27 63 31 62 27 29 36 01 06 17 11 11 08 5b , 'c1b')6......[
|
||||
| 976: 74 61 62 6c 65 74 31 74 31 43 52 45 41 54 45 20 tablet1t1CREATE
|
||||
| 992: 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 74 31 VIRTUAL TABLE t1
|
||||
| 1008: 20 55 53 49 4e 47 20 66 74 73 34 28 30 2c 62 29 USING fts4(0,b)
|
||||
| page 2 offset 1024
|
||||
| 0: 0d 00 00 00 03 00 0f 00 00 23 00 16 00 0f 00 05 .........#......
|
||||
| 16: 03 04 00 08 0f 61 0b 02 04 00 08 1b 41 54 45 20 .....a......ATE
|
||||
| 32: 32 3a 50 87 5a 01 05 00 08 8f 37 66 30 30 30 30 2:P.Z.....7f0000
|
||||
| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 256: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 496: 30 40 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0@00000000000000
|
||||
| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 624: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 688: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 880: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 896: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 912: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 928: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 1008: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| page 3 offset 2048
|
||||
| 0: 0d 00 00 00 02 03 86 00 03 f4 03 86 00 00 00 00 ................
|
||||
| 896: 00 00 00 00 00 00 87 62 02 04 00 8f 48 00 d5 07 .......b....H...
|
||||
| 912: 66 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 f000000000000000
|
||||
| 928: 30 30 30 30 3a 30 30 30 30 30 30 30 30 30 30 30 0000:00000000000
|
||||
| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 1008: 00 00 00 08 0a 01 03 00 1a 00 01 30 03 01 02 00 ...........0....
|
||||
| page 4 offset 3072
|
||||
| 0: 0d 00 00 00 03 03 9e 00 03 ed 03 bc 03 9e 00 00 ................
|
||||
| 912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c 03 ................
|
||||
| 928: 07 08 01 08 08 15 2c 02 30 20 31 36 00 01 30 03 ......,.0 16..0.
|
||||
| 944: 03 02 00 00 01 61 05 03 01 01 02 00 2f 02 07 08 .....a....../...
|
||||
| 960: 09 08 08 15 54 30 20 33 36 00 01 30 03 02 02 00 ....T0 36..0....
|
||||
| 976: 00 01 32 05 02 01 01 03 00 00 03 61 74 65 05 02 ..2........ate..
|
||||
| 992: 01 01 02 00 00 01 70 05 02 01 01 04 00 11 01 07 ......p.........
|
||||
| 1008: 08 08 09 01 17 14 02 32 20 39 39 37 01 01 01 66 .......2 997...f
|
||||
| page 5 offset 4096
|
||||
| 0: 0a 00 00 00 03 03 ee 00 03 fb 03 f5 03 ee 00 00 ................
|
||||
| 992: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 04 ................
|
||||
| 1008: 08 01 01 02 03 05 04 08 09 01 02 04 04 08 08 09 ................
|
||||
| page 6 offset 5120
|
||||
| 0: 0d 00 00 00 03 03 eb 00 00 00 00 00 00 00 00 00 ................
|
||||
| 992: 00 00 00 00 00 00 00 00 00 00 00 05 03 03 00 10 ................
|
||||
| 1008: 01 01 05 02 03 00 10 01 03 05 01 03 00 10 01 01 ................
|
||||
| page 7 offset 6144
|
||||
| 0: 0d 00 00 00 01 03 f6 00 03 f6 00 00 00 00 00 00 ................
|
||||
| 1008: 00 00 00 00 00 00 08 00 03 00 16 03 08 c5 e0 07 ................
|
||||
| page 8 offset 7168
|
||||
| 0: 00 00 00 00 30 30 30 30 30 30 30 30 30 30 30 30 ....000000000000
|
||||
| 16: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 32: 30 30 30 30 30 30 30 30 30 30 30 30 30 bc 30 30 0000000000000.00
|
||||
| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 c0 30 00000000000000.0
|
||||
| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 256: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 496: 30 30 30 30 30 30 30 30 30 30 30 40 30 30 30 30 00000000000@0000
|
||||
| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 624: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 688: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 880: 30 30 30 30 30 30 30 30 30 05 01 00 00 00 00 00 000000000.......
|
||||
| end crash-7bc.txt.db
|
||||
}]} {}
|
||||
|
||||
do_execsql_test 53.1 {
|
||||
SELECT*FROM t1 WHERE t1 MATCH'ATE"0"OR"2D:P"""ATE"0"OR"2:P"""';
|
||||
} {0 {ATE 2:P}}
|
||||
set sqlite_fts3_enable_parentheses $saved
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
reset_db
|
||||
do_test 54.0 {
|
||||
sqlite3 db {}
|
||||
db deserialize [decode_hexdb {
|
||||
.open --hexdb
|
||||
| size 8192 pagesize 1024 filename crash-365.txt.db
|
||||
| page 1 offset 0
|
||||
| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
|
||||
| 16: 04 00 01 01 00 40 20 20 00 00 00 00 00 00 00 08 .....@ ........
|
||||
| 32: 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 04 ................
|
||||
| 96: 00 00 00 00 0d 02 f3 00 07 01 51 00 03 c8 03 63 ..........Q....c
|
||||
| 112: 02 fb 02 0a 02 c0 01 a8 01 51 00 00 00 00 00 00 .........Q......
|
||||
| 336: 00 55 07 07 17 1b 1b 01 81 01 74 61 62 6c 65 74 .U........tablet
|
||||
| 352: 31 5f 73 74 61 74 74 31 5f 73 74 61 74 07 43 52 1_statt1_stat.CR
|
||||
| 368: 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 EATE TABLE 't1_s
|
||||
| 384: 74 61 74 27 28 69 64 20 49 4e 54 45 47 45 52 20 tat'(id INTEGER
|
||||
| 400: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 61 6c PRIMARY KEY, val
|
||||
| 416: 75 65 20 42 4c 4f 42 29 60 06 07 17 21 21 01 81 ue BLOB)`...!!..
|
||||
| 432: 0b 74 61 62 6c 65 74 31 5f 64 6f 63 73 69 7a 65 .tablet1_docsize
|
||||
| 448: 74 31 5f 64 6f 63 73 69 7a 65 06 43 52 45 41 54 t1_docsize.CREAT
|
||||
| 464: 45 20 54 41 42 4c 45 20 27 74 31 5f 64 6f 63 73 E TABLE 't1_docs
|
||||
| 480: 69 7a 65 27 28 64 6f 63 69 64 20 49 4e 54 45 47 ize'(docid INTEG
|
||||
| 496: 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 ER PRIMARY KEY,
|
||||
| 512: 73 69 7a 65 20 42 4c 4f 42 29 81 33 04 07 17 1f size BLOB).3....
|
||||
| 528: 1f 01 82 35 74 61 62 6c 65 74 31 5f 73 65 67 64 ...5tablet1_segd
|
||||
| 544: 69 72 74 31 5f 73 65 67 64 69 72 04 43 52 45 41 irt1_segdir.CREA
|
||||
| 560: 54 45 20 54 41 42 4c 45 20 27 74 31 5f 73 65 67 TE TABLE 't1_seg
|
||||
| 576: 64 69 72 27 28 6c 65 76 65 6c 20 49 4e 54 45 47 dir'(level INTEG
|
||||
| 592: 45 52 2c 69 64 78 20 49 4e 54 45 47 45 52 2c 73 ER,idx INTEGER,s
|
||||
| 608: 74 61 72 74 5f 62 6c 6f 63 6b 20 49 4e 54 45 47 tart_block INTEG
|
||||
| 624: 45 52 2c 6c 65 61 76 65 73 5f 65 6e 64 5f 62 6c ER,leaves_end_bl
|
||||
| 640: 6f 63 6b 20 49 4e 54 45 47 45 52 2c 65 6e 64 5f ock INTEGER,end_
|
||||
| 656: 62 6c 6f 63 6b 20 49 4e 54 45 47 45 52 2c 72 6f block INTEGER,ro
|
||||
| 672: 6f 74 20 42 4c 4f 42 2c 50 52 49 4d 41 52 59 20 ot BLOB,PRIMARY
|
||||
| 688: 4b 45 59 28 6c 65 76 65 6c 2c 20 69 64 78 29 29 KEY(level, idx))
|
||||
| 704: 31 05 06 17 45 1f 01 00 69 6e 64 65 78 73 71 6c 1...E...indexsql
|
||||
| 720: 69 74 65 5f 61 75 74 6f 69 6e 64 65 78 5f 74 31 ite_autoindex_t1
|
||||
| 736: 5f 73 65 67 64 69 72 5f 31 74 31 5f 73 65 67 64 _segdir_1t1_segd
|
||||
| 752: 69 72 05 00 00 00 08 00 00 00 00 66 03 07 17 23 ir.........f...#
|
||||
| 768: 23 01 81 13 74 61 62 6c 65 74 31 5f 73 65 67 6d #...tablet1_segm
|
||||
| 784: 65 6e 74 73 74 31 5f 73 65 67 6d 65 6e 74 73 03 entst1_segments.
|
||||
| 800: 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 74 31 CREATE TABLE 't1
|
||||
| 816: 5f 73 65 67 6d 65 6e 74 73 27 28 62 6c 6f 63 6b _segments'(block
|
||||
| 832: 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 id INTEGER PRIMA
|
||||
| 848: 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42 4c RY KEY, block BL
|
||||
| 864: 4f 42 29 63 02 07 17 21 21 01 81 11 74 61 62 6c OB)c...!!...tabl
|
||||
| 880: 65 74 31 5f 63 6f 6e 74 65 6e 74 74 31 5f 63 6f et1_contentt1_co
|
||||
| 896: 6e 74 65 6e 74 02 43 52 45 41 54 45 20 54 41 42 ntent.CREATE TAB
|
||||
| 912: 4c 45 20 27 74 31 5f 63 6f 6e 74 65 6e 74 27 28 LE 't1_content'(
|
||||
| 928: 64 6f 63 69 64 20 49 4e 54 45 47 45 52 20 50 52 docid INTEGER PR
|
||||
| 944: 49 4d 41 52 59 20 4b 45 59 2c 20 27 63 30 30 27 IMARY KEY, 'c00'
|
||||
| 960: 2c 20 27 63 31 62 27 29 36 01 06 17 11 11 08 5b , 'c1b')6......[
|
||||
| 976: 74 61 62 6c 65 74 31 74 31 43 52 45 41 54 45 20 tablet1t1CREATE
|
||||
| 992: 56 49 52 54 55 41 4c 20 54 41 42 4c 45 20 74 31 VIRTUAL TABLE t1
|
||||
| 1008: 20 55 53 49 4e 47 20 66 74 73 34 28 30 2c 62 29 USING fts4(0,b)
|
||||
| page 2 offset 1024
|
||||
| 0: 0d 00 00 00 03 00 0f 00 00 23 00 16 00 0f 00 05 .........#......
|
||||
| 16: 03 04 00 08 0f 61 0b 02 04 00 08 1b 41 54 45 20 .....a......ATE
|
||||
| 32: 32 3a 50 87 5a 01 05 00 08 8f 37 66 30 30 30 30 2:P.Z.....7f0000
|
||||
| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 256: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 496: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 624: 30 30 30 30 30 30 30 30 30 30 1b 30 30 30 30 30 0000000000.00000
|
||||
| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 688: 30 30 30 30 30 30 30 30 2f 30 30 30 30 30 30 30 00000000/0000000
|
||||
| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 880: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 896: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 912: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 928: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 1008: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| page 3 offset 2048
|
||||
| 0: 0d 00 00 00 02 03 86 00 03 f4 03 86 00 00 00 00 ................
|
||||
| 896: 00 00 00 00 00 00 87 62 02 04 00 8f 48 00 d5 07 .......b....H...
|
||||
| 912: 66 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 f000000000000000
|
||||
| 928: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 944: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 960: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 976: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 992: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 1008: 00 00 00 08 0a 01 03 00 1a 00 01 30 03 01 02 00 ...........0....
|
||||
| page 4 offset 3072
|
||||
| 0: 0d 00 00 00 03 03 9e 00 03 ed 03 bc 03 9e 00 01 ................
|
||||
| 912: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1c 03 ................
|
||||
| 928: 07 08 01 08 08 15 2c 02 30 20 31 36 00 01 30 03 ......,.0 16..0.
|
||||
| 944: 03 02 00 00 01 61 05 03 01 01 02 00 2f 02 07 08 .....a....../...
|
||||
| 960: 09 08 08 15 54 30 20 33 36 00 01 30 03 02 02 00 ....T0 36..0....
|
||||
| 976: 00 01 32 05 02 01 01 03 00 00 03 61 74 65 05 02 ..2........ate..
|
||||
| 992: 01 01 02 00 00 01 70 05 02 01 01 04 00 11 01 07 ......p.........
|
||||
| 1008: 08 08 09 01 17 14 02 32 20 39 39 37 01 01 01 66 .......2 997...f
|
||||
| page 5 offset 4096
|
||||
| 0: 0a 00 00 00 03 03 ee 00 03 fb 03 f5 03 ee 00 00 ................
|
||||
| 992: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 04 ................
|
||||
| 1008: 08 01 01 02 03 05 04 08 09 01 02 04 04 08 08 09 ................
|
||||
| page 6 offset 5120
|
||||
| 0: 0d 00 00 00 03 03 eb 00 03 f9 03 f2 00 00 00 00 ................
|
||||
| 992: 00 00 00 00 00 00 00 00 00 00 00 05 03 03 00 10 ................
|
||||
| 1008: 01 01 05 02 03 00 10 01 03 05 01 03 00 10 01 01 ................
|
||||
| page 7 offset 6144
|
||||
| 0: 0d 00 00 00 01 03 f6 00 03 f6 00 00 00 00 00 00 ................
|
||||
| 1008: 00 00 00 00 00 00 08 00 03 00 16 03 03 05 e0 07 ................
|
||||
| page 8 offset 7168
|
||||
| 0: 00 00 00 00 30 30 30 30 30 30 30 30 30 30 30 30 ....000000000000
|
||||
| 16: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 32: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 48: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 64: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 80: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 96: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 112: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 128: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 144: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 160: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 176: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 192: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 208: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 224: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 240: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 256: 30 30 30 30 30 2f 30 30 30 30 30 30 30 30 30 30 00000/0000000000
|
||||
| 272: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 288: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 304: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 320: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 336: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 352: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 368: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 384: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 400: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 416: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 432: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 448: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 464: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 480: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 496: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 512: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 528: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 544: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 560: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 576: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 592: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 608: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 624: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 640: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 656: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 672: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 688: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 704: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 720: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 736: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 752: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 768: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 784: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 800: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 816: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 832: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 848: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 864: 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 0000000000000000
|
||||
| 880: 30 30 30 30 30 30 30 30 30 05 01 01 01 02 00 00 000000000.......
|
||||
| end crash-365.txt.db
|
||||
}]} {}
|
||||
|
||||
do_execsql_test 54.1 {
|
||||
SELECT rowid, quote(matchinfo(t1,'pcxybspcxybs')) FROM t1 WHERE t1 MATCH'ATE"0"OR"2:P"""';
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
+6
-2
@@ -18,6 +18,10 @@ set ::testprefix fts3fault
|
||||
# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
|
||||
ifcapable !fts3 { finish_test ; return }
|
||||
|
||||
set ::TMPDBERROR [list 1 \
|
||||
{unable to open a temporary database file for storing temporary tables}
|
||||
]
|
||||
|
||||
# Test error handling in the sqlite3Fts3Init() function. This is the
|
||||
# function that registers the FTS3 module and various support functions
|
||||
# with SQLite.
|
||||
@@ -49,7 +53,7 @@ do_faultsim_test 2 -prep {
|
||||
} -body {
|
||||
execsql { ALTER TABLE t1 RENAME TO t2 }
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_test_result {0 {}} $::TMPDBERROR
|
||||
}
|
||||
|
||||
# Test error handling in the special case where a single prefix query
|
||||
@@ -194,7 +198,7 @@ do_faultsim_test 8.2 -faults oom-t* -prep {
|
||||
} -body {
|
||||
execsql { SELECT mit(matchinfo(t8, 's')) FROM t8 WHERE t8 MATCH 'a b c' }
|
||||
} -test {
|
||||
faultsim_test_result {0 3}
|
||||
faultsim_test_result {0 3} $::TMPDBERROR
|
||||
}
|
||||
do_faultsim_test 8.3 -prep {
|
||||
faultsim_restore_and_reopen
|
||||
|
||||
@@ -215,12 +215,15 @@ do_faultsim_test 8.1 -faults oom* -prep {
|
||||
faultsim_test_result {0 {}}
|
||||
}
|
||||
|
||||
set ::TMPDBERROR [list 1 \
|
||||
{unable to open a temporary database file for storing temporary tables}
|
||||
]
|
||||
do_faultsim_test 8.2 -faults oom* -prep {
|
||||
faultsim_restore_and_reopen
|
||||
} -body {
|
||||
execsql { ALTER TABLE t8 RENAME TO t8ii }
|
||||
} -test {
|
||||
faultsim_test_result {0 {}}
|
||||
faultsim_test_result {0 {}} $::TMPDBERROR
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -786,4 +786,19 @@ do_execsql_test join8-25020 {
|
||||
SELECT 1 FROM t1 LEFT JOIN t2 ON true JOIN t3 ON (b2 IN (a1)) FULL JOIN t4 ON true;
|
||||
} {1}
|
||||
|
||||
# 2022-07-13
|
||||
# forum/forumpost/174afeae57
|
||||
#
|
||||
reset_db
|
||||
db null -
|
||||
do_execsql_test join8-26000 {
|
||||
CREATE TABLE t1(a INT);
|
||||
CREATE TABLE t2(b INT, c INT);
|
||||
CREATE VIEW t3(d) AS SELECT NULL FROM t2 FULL OUTER JOIN t1 ON c=a UNION ALL SELECT b FROM t2;
|
||||
INSERT INTO t1(a) VALUES (NULL);
|
||||
INSERT INTO t2(b, c) VALUES (99, NULL);
|
||||
SELECT DISTINCT b, c, d FROM t2, t3 WHERE b<>0
|
||||
UNION SELECT DISTINCT b, c, d FROM t2, t3 WHERE b ISNULL;
|
||||
} {99 - - 99 - 99}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -867,4 +867,22 @@ do_catchsql_test json-18.5 {
|
||||
SELECT json_extract('{"":8}', '$.');
|
||||
} {1 {JSON path error near ''}}
|
||||
|
||||
# 2022-08-29 https://sqlite.org/forum/forumpost/9b9e4716c0d7bbd1
|
||||
# This is not a problem specifically with JSON functions. It is
|
||||
# a problem with transaction control. But the json() function makes
|
||||
# the problem more easily accessible, so it is tested here.
|
||||
#
|
||||
do_execsql_test json-19.1 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(x);
|
||||
} {}
|
||||
do_catchsql_test json-19.2 {
|
||||
BEGIN;
|
||||
INSERT INTO t1 VALUES(0), (json('not-valid-json'));
|
||||
} {1 {malformed JSON}}
|
||||
do_execsql_test json-19.3 {
|
||||
COMMIT;
|
||||
SELECT * FROM t1;
|
||||
} {}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -664,6 +664,7 @@ proc do_write_test {name tbl sql} {
|
||||
|
||||
if {$::DO_MALLOC_TEST } {
|
||||
set answers [list {1 {out of memory}} {0 {}}]
|
||||
lappend answers [list 1 {unable to open a temporary database file for storing temporary tables}]
|
||||
if {$::DO_MALLOC_TEST==1} {
|
||||
set modes {100000 persistent}
|
||||
} else {
|
||||
|
||||
@@ -141,3 +141,5 @@ do_eqp_test 111 {
|
||||
`--RIGHT
|
||||
`--SCAN generate_series VIRTUAL TABLE INDEX 23:
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# 2020 September 01
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix noop_update
|
||||
|
||||
if {[db eval {PRAGMA noop_update}]==""} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(x, y);
|
||||
INSERT INTO t1 VALUES('a', 111);
|
||||
}
|
||||
do_execsql_test 1.1 {
|
||||
UPDATE t1 SET y=222 WHERE x='a';
|
||||
SELECT * FROM t1;
|
||||
} {a 222}
|
||||
do_execsql_test 1.2 {
|
||||
PRAGMA noop_update = 1;
|
||||
UPDATE t1 SET y=333 WHERE x='a';
|
||||
SELECT * FROM t1;
|
||||
} {a 222}
|
||||
|
||||
finish_test
|
||||
+42
-1
@@ -156,6 +156,47 @@ do_execsql_test offset1-1.4.9 {
|
||||
LIMIT 9 OFFSET 1;
|
||||
} {2 b 3 c 4 d 5 e 6 w 7 x 8 y 9 z}
|
||||
|
||||
|
||||
# 2022-08-04
|
||||
# https://sqlite.org/forum/forumpost/6b5e9188f0657616
|
||||
#
|
||||
do_execsql_test offset1-2.0 {
|
||||
CREATE TABLE employees (
|
||||
id integer primary key,
|
||||
name text,
|
||||
city text,
|
||||
department text,
|
||||
salary integer
|
||||
);
|
||||
INSERT INTO employees VALUES
|
||||
(11,'Diane','London','hr',70),
|
||||
(12,'Bob','London','hr',78),
|
||||
(21,'Emma','London','it',84),
|
||||
(22,'Grace','Berlin','it',90),
|
||||
(23,'Henry','London','it',104),
|
||||
(24,'Irene','Berlin','it',104),
|
||||
(25,'Frank','Berlin','it',120),
|
||||
(31,'Cindy','Berlin','sales',96),
|
||||
(32,'Dave','London','sales',96),
|
||||
(33,'Alice','Berlin','sales',100);
|
||||
CREATE VIEW v AS
|
||||
SELECT * FROM (
|
||||
SELECT * FROM employees
|
||||
WHERE salary < 100
|
||||
ORDER BY salary desc)
|
||||
UNION ALL
|
||||
SELECT * FROM (
|
||||
SELECT * FROM employees
|
||||
WHERE salary >= 100
|
||||
ORDER BY salary asc);
|
||||
} {}
|
||||
do_execsql_test offset1-2.1 {
|
||||
SELECT * FROM v LIMIT 5 OFFSET 2;
|
||||
} {
|
||||
22 Grace Berlin it 90
|
||||
21 Emma London it 84
|
||||
12 Bob London hr 78
|
||||
11 Diane London hr 70
|
||||
33 Alice Berlin sales 100
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
# 2014-08-24
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
# The focus of this script is testing details of the SQL language parser.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
do_catchsql_test parser1-1.1 {
|
||||
CREATE TABLE t1(
|
||||
a TEXT PRIMARY KEY,
|
||||
b TEXT,
|
||||
FOREIGN KEY(b COLLATE nocase DESC) REFERENCES t1(a COLLATE binary ASC)
|
||||
);
|
||||
} {1 {syntax error after column name "b"}}
|
||||
|
||||
|
||||
# Verify that a legacy schema in the sqlite_master file is allowed to have
|
||||
# COLLATE, ASC, and DESC keywords on the id list of a FK constraint, and that
|
||||
# those keywords are silently ignored.
|
||||
#
|
||||
sqlite3_db_config db DEFENSIVE 0
|
||||
do_execsql_test parser1-1.2 {
|
||||
CREATE TABLE t1(
|
||||
a TEXT PRIMARY KEY,
|
||||
b TEXT,
|
||||
FOREIGN KEY(b) REFERENCES t1(a)
|
||||
);
|
||||
INSERT INTO t1 VALUES('abc',NULL),('xyz','abc');
|
||||
PRAGMA writable_schema=on;
|
||||
UPDATE sqlite_master SET sql='CREATE TABLE t1(
|
||||
a TEXT PRIMARY KEY,
|
||||
b TEXT,
|
||||
FOREIGN KEY(b COLLATE nocase) REFERENCES t1(a)
|
||||
)' WHERE name='t1';
|
||||
SELECT name FROM sqlite_master WHERE sql LIKE '%collate%';
|
||||
} {t1}
|
||||
sqlite3 db2 test.db
|
||||
do_test parser1-1.3 {
|
||||
sqlite3 db2 test.db
|
||||
db2 eval {SELECT * FROM t1 ORDER BY 1}
|
||||
} {abc {} xyz abc}
|
||||
db2 close
|
||||
|
||||
do_execsql_test parser1-1.4 {
|
||||
UPDATE sqlite_master SET sql='CREATE TABLE t1(
|
||||
a TEXT PRIMARY KEY,
|
||||
b TEXT,
|
||||
FOREIGN KEY(b ASC) REFERENCES t1(a)
|
||||
)' WHERE name='t1';
|
||||
SELECT name FROM sqlite_master WHERE sql LIKE '%ASC%';
|
||||
} {t1}
|
||||
sqlite3 db2 test.db
|
||||
do_test parser1-1.5 {
|
||||
sqlite3 db2 test.db
|
||||
db2 eval {SELECT * FROM t1 ORDER BY 1}
|
||||
} {abc {} xyz abc}
|
||||
db2 close
|
||||
|
||||
do_catchsql_test parser1-2.1 {
|
||||
WITH RECURSIVE
|
||||
c(x COLLATE binary) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<5)
|
||||
SELECT x FROM c;
|
||||
} {1 {syntax error after column name "x"}}
|
||||
do_catchsql_test parser1-2.2 {
|
||||
WITH RECURSIVE
|
||||
c(x ASC) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<5)
|
||||
SELECT x FROM c;
|
||||
} {1 {syntax error after column name "x"}}
|
||||
|
||||
# Verify that the comma between multiple table constraints is
|
||||
# optional.
|
||||
#
|
||||
# The missing comma is technically a syntax error. But we have to support
|
||||
# it because there might be legacy databases that omit the commas in their
|
||||
# sqlite_master tables.
|
||||
#
|
||||
do_execsql_test parser1-3.1 {
|
||||
CREATE TABLE t300(id INTEGER PRIMARY KEY);
|
||||
CREATE TABLE t301(
|
||||
id INTEGER PRIMARY KEY,
|
||||
c1 INTEGER NOT NULL,
|
||||
c2 INTEGER NOT NULL,
|
||||
c3 BOOLEAN NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY(c1) REFERENCES t300(id) ON DELETE CASCADE ON UPDATE RESTRICT
|
||||
/* no comma */
|
||||
FOREIGN KEY(c2) REFERENCES t300(id) ON DELETE CASCADE ON UPDATE RESTRICT
|
||||
/* no comma */
|
||||
UNIQUE(c1, c2)
|
||||
);
|
||||
PRAGMA foreign_key_list(t301);
|
||||
} {0 0 t300 c2 id RESTRICT CASCADE NONE 1 0 t300 c1 id RESTRICT CASCADE NONE}
|
||||
|
||||
finish_test
|
||||
@@ -239,4 +239,26 @@ do_execsql_test regexp1-2.22 {
|
||||
SELECT 'abc$¢€xyz' REGEXP '^abc[^\u0025-X][^ -\u007f][^\u20ab]xyz$'
|
||||
} {1}
|
||||
|
||||
# 2022-07-03
|
||||
# https://sqlite.org/forum/forumpost/96692f8ba5
|
||||
# The REGEXP extension mishandles the prefix search optimization when
|
||||
# the prefix contains 3-byte UTF8 characters.
|
||||
#
|
||||
reset_db
|
||||
load_static_extension db regexp
|
||||
do_execsql_test regexp1-3.1 {
|
||||
CREATE TABLE t1(id INTEGER PRIMARY KEY, a TEXT);
|
||||
INSERT INTO t1(id, a) VALUES(1, '日本語');
|
||||
SELECT a, hex(a), length(a) FROM t1;
|
||||
} {日本語 E697A5E69CACE8AA9E 3}
|
||||
do_execsql_test regexp1-3.2 {
|
||||
SELECT * FROM t1 WHERE a='日本語';
|
||||
} {1 日本語}
|
||||
do_execsql_test regexp1-3.3 {
|
||||
SELECT * FROM t1 WHERE a LIKE '日本語';
|
||||
} {1 日本語}
|
||||
do_execsql_test regexp1-3.4 {
|
||||
SELECT * FROM t1 wHERE a REGEXP '日本語';
|
||||
} {1 日本語}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -751,4 +751,35 @@ do_execsql_test 32.1 {
|
||||
WHERE a=1234 OR a<=567;
|
||||
} {500 502}
|
||||
|
||||
# 2022-07-15
|
||||
# https://sqlite.org/forum/forumpost/3607259d3c
|
||||
#
|
||||
reset_db
|
||||
do_execsql_test 33.1 {
|
||||
CREATE TABLE t1(a INT, b INT PRIMARY KEY) WITHOUT ROWID;
|
||||
INSERT INTO t1(a, b) VALUES (0, 1),(15,-7),(3,100);
|
||||
ANALYZE;
|
||||
} {}
|
||||
do_execsql_test 33.2 {
|
||||
SELECT * FROM t1 WHERE (b,a) BETWEEN (0,5) AND (99,-2);
|
||||
} {0 1}
|
||||
do_execsql_test 33.3 {
|
||||
SELECT * FROM t1 WHERE (b,a) BETWEEN (-8,5) AND (0,-2);
|
||||
} {15 -7}
|
||||
do_execsql_test 33.3 {
|
||||
SELECT * FROM t1 WHERE (b,a) BETWEEN (3,5) AND (100,4);
|
||||
} {3 100}
|
||||
do_execsql_test 33.3 {
|
||||
SELECT * FROM t1 WHERE (b,a) BETWEEN (3,5) AND (100,2);
|
||||
} {}
|
||||
do_execsql_test 33.3 {
|
||||
SELECT * FROM t1 WHERE (a,b) BETWEEN (-2,99) AND (1,0);
|
||||
} {0 1}
|
||||
do_execsql_test 33.3 {
|
||||
SELECT * FROM t1 WHERE (a,b) BETWEEN (14,99) AND (16,0);
|
||||
} {15 -7}
|
||||
do_execsql_test 33.3 {
|
||||
SELECT * FROM t1 WHERE (a,b) BETWEEN (2,99) AND (4,0);
|
||||
} {3 100}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -118,10 +118,18 @@ do_test select3-2.14 {
|
||||
} {1 {near ";": syntax error}}
|
||||
|
||||
# Cannot have a HAVING without a GROUP BY
|
||||
#
|
||||
# Update: As of 3.39.0, you can.
|
||||
#
|
||||
do_execsql_test select3-3.1 {
|
||||
SELECT log, count(*) FROM t1 HAVING log>=4
|
||||
} {}
|
||||
do_execsql_test select3-3.2 {
|
||||
SELECT count(*) FROM t1 HAVING log>=4
|
||||
} {}
|
||||
do_execsql_test select3-3.3 {
|
||||
SELECT count(*) FROM t1 HAVING log!=400
|
||||
} {31}
|
||||
|
||||
# Toss in some HAVING clauses
|
||||
#
|
||||
|
||||
+1035
File diff suppressed because it is too large
Load Diff
@@ -35,43 +35,6 @@ proc cond_incr_sync_count {adj} {
|
||||
}
|
||||
}
|
||||
|
||||
proc set_tvfs_hdr {file args} {
|
||||
|
||||
# Set $nHdr to the number of bytes in the wal-index header:
|
||||
set nHdr 48
|
||||
set nInt [expr {$nHdr/4}]
|
||||
|
||||
if {[llength $args]>2} {
|
||||
error {wrong # args: should be "set_tvfs_hdr fileName ?val1? ?val2?"}
|
||||
}
|
||||
|
||||
set blob [tvfs shm $file]
|
||||
if {$::tcl_platform(byteOrder)=="bigEndian"} {set fmt I} {set fmt i}
|
||||
|
||||
if {[llength $args]} {
|
||||
set ia [lindex $args 0]
|
||||
set ib $ia
|
||||
if {[llength $args]==2} {
|
||||
set ib [lindex $args 1]
|
||||
}
|
||||
binary scan $blob a[expr $nHdr*2]a* dummy tail
|
||||
set blob [binary format ${fmt}${nInt}${fmt}${nInt}a* $ia $ib $tail]
|
||||
tvfs shm $file $blob
|
||||
}
|
||||
|
||||
binary scan $blob ${fmt}${nInt} ints
|
||||
return $ints
|
||||
}
|
||||
|
||||
proc incr_tvfs_hdr {file idx incrval} {
|
||||
set ints [set_tvfs_hdr $file]
|
||||
set v [lindex $ints $idx]
|
||||
incr v $incrval
|
||||
lset ints $idx $v
|
||||
set_tvfs_hdr $file $ints
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test case wal2-1.*:
|
||||
#
|
||||
|
||||
@@ -90,4 +90,44 @@ proc wal_fix_walindex_cksum {hdrvar} {
|
||||
lset hdr 11 $c2
|
||||
}
|
||||
|
||||
# This command assumes that $file is the name of a database file opened
|
||||
# in wal mode using a [testvfs] VFS. It returns a list of the 12 32-bit
|
||||
# integers that make up the wal-index-header for the named file.
|
||||
#
|
||||
proc set_tvfs_hdr {file args} {
|
||||
|
||||
# Set $nHdr to the number of bytes in the wal-index header:
|
||||
set nHdr 48
|
||||
set nInt [expr {$nHdr/4}]
|
||||
|
||||
if {[llength $args]>2} {
|
||||
error {wrong # args: should be "set_tvfs_hdr fileName ?val1? ?val2?"}
|
||||
}
|
||||
|
||||
set blob [tvfs shm $file]
|
||||
if {$::tcl_platform(byteOrder)=="bigEndian"} {set fmt I} {set fmt i}
|
||||
|
||||
if {[llength $args]} {
|
||||
set ia [lindex $args 0]
|
||||
set ib $ia
|
||||
if {[llength $args]==2} {
|
||||
set ib [lindex $args 1]
|
||||
}
|
||||
binary scan $blob a[expr $nHdr*2]a* dummy tail
|
||||
set blob [binary format ${fmt}${nInt}${fmt}${nInt}a* $ia $ib $tail]
|
||||
tvfs shm $file $blob
|
||||
}
|
||||
|
||||
binary scan $blob ${fmt}${nInt} ints
|
||||
return $ints
|
||||
}
|
||||
|
||||
proc incr_tvfs_hdr {file idx incrval} {
|
||||
set ints [set_tvfs_hdr $file]
|
||||
set v [lindex $ints $idx]
|
||||
incr v $incrval
|
||||
lset ints $idx $v
|
||||
set_tvfs_hdr $file $ints
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -107,6 +107,12 @@ set pragma_def {
|
||||
IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
IF: defined(SQLITE_DEBUG)
|
||||
|
||||
NAME: noop_update
|
||||
TYPE: FLAG
|
||||
ARG: SQLITE_NoopUpdate
|
||||
IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
IF: defined(SQLITE_ENABLE_NOOP_UPDATE)
|
||||
|
||||
NAME: ignore_check_constraints
|
||||
TYPE: FLAG
|
||||
ARG: SQLITE_IgnoreChecks
|
||||
|
||||
Reference in New Issue
Block a user