Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 529dc02492 |
@@ -425,8 +425,6 @@ TESTSRC = \
|
||||
# Statically linked extensions
|
||||
#
|
||||
TESTSRC += \
|
||||
$(TOP)/ext/expert/sqlite3expert.c \
|
||||
$(TOP)/ext/expert/test_expert.c \
|
||||
$(TOP)/ext/misc/amatch.c \
|
||||
$(TOP)/ext/misc/carray.c \
|
||||
$(TOP)/ext/misc/closure.c \
|
||||
@@ -582,7 +580,6 @@ SHELL_OPT += -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
|
||||
SHELL_OPT += -DSQLITE_ENABLE_STMTVTAB
|
||||
SHELL_OPT += -DSQLITE_ENABLE_DBPAGE_VTAB
|
||||
SHELL_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
|
||||
SHELL_OPT += -DSQLITE_ENABLE_OFFSET_SQL_FUNC
|
||||
FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1
|
||||
FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
|
||||
FUZZCHECK_OPT += -DSQLITE_MAX_MEMORY=50000000
|
||||
@@ -1193,9 +1190,6 @@ sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $
|
||||
sqlite3_analyzer$(TEXE): sqlite3_analyzer.c
|
||||
$(LTLINK) sqlite3_analyzer.c -o $@ $(LIBTCL) $(TLIBS)
|
||||
|
||||
sqlite3_expert$(TEXE): $(TOP)/ext/expert/sqlite3expert.h $(TOP)/ext/expert/sqlite3expert.c $(TOP)/ext/expert/expert.c sqlite3.c
|
||||
$(LTLINK) $(TOP)/ext/expert/sqlite3expert.h $(TOP)/ext/expert/sqlite3expert.c $(TOP)/ext/expert/expert.c sqlite3.c -o sqlite3_expert $(TLIBS)
|
||||
|
||||
CHECKER_DEPS =\
|
||||
$(TOP)/tool/mkccode.tcl \
|
||||
sqlite3.c \
|
||||
|
||||
@@ -1400,8 +1400,6 @@ TESTSRC = \
|
||||
# Statically linked extensions.
|
||||
#
|
||||
TESTEXT = \
|
||||
$(TOP)\ext\expert\sqlite3expert.c \
|
||||
$(TOP)\ext\expert\test_expert.c \
|
||||
$(TOP)\ext\misc\amatch.c \
|
||||
$(TOP)\ext\misc\carray.c \
|
||||
$(TOP)\ext\misc\closure.c \
|
||||
@@ -1513,7 +1511,6 @@ FUZZDATA = \
|
||||
!IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0
|
||||
SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_STMTVTAB
|
||||
SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB
|
||||
SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_OFFSET_SQL_FUNC
|
||||
!ENDIF
|
||||
|
||||
# <<mark>>
|
||||
@@ -2078,24 +2075,6 @@ FTS5_SRC = \
|
||||
$(TOP)\ext\fts5\fts5_varint.c \
|
||||
$(TOP)\ext\fts5\fts5_vocab.c
|
||||
|
||||
LSM1_SRC = \
|
||||
$(TOP)\ext\lsm1\lsm.h \
|
||||
$(TOP)\ext\lsm1\lsmInt.h \
|
||||
$(TOP)\ext\lsm1\lsm_ckpt.c \
|
||||
$(TOP)\ext\lsm1\lsm_file.c \
|
||||
$(TOP)\ext\lsm1\lsm_log.c \
|
||||
$(TOP)\ext\lsm1\lsm_main.c \
|
||||
$(TOP)\ext\lsm1\lsm_mem.c \
|
||||
$(TOP)\ext\lsm1\lsm_mutex.c \
|
||||
$(TOP)\ext\lsm1\lsm_shared.c \
|
||||
$(TOP)\ext\lsm1\lsm_sorted.c \
|
||||
$(TOP)\ext\lsm1\lsm_str.c \
|
||||
$(TOP)\ext\lsm1\lsm_tree.c \
|
||||
$(TOP)\ext\lsm1\lsm_unix.c \
|
||||
$(TOP)\ext\lsm1\lsm_varint.c \
|
||||
$(TOP)\ext\lsm1\lsm_vtab.c \
|
||||
$(TOP)\ext\lsm1\lsm_win32.c
|
||||
|
||||
fts5parse.c: $(TOP)\ext\fts5\fts5parse.y lemon.exe
|
||||
copy $(TOP)\ext\fts5\fts5parse.y .
|
||||
del /Q fts5parse.h 2>NUL
|
||||
@@ -2107,10 +2086,6 @@ fts5.c: $(FTS5_SRC)
|
||||
$(TCLSH_CMD) $(TOP)\ext\fts5\tool\mkfts5c.tcl
|
||||
copy $(TOP)\ext\fts5\fts5.h .
|
||||
|
||||
lsm1.c: $(LSM1_SRC)
|
||||
$(TCLSH_CMD) $(TOP)\ext\lsm1\tool\mklsm1c.tcl
|
||||
copy $(TOP)\ext\lsm1\lsm.h .
|
||||
|
||||
fts5.lo: fts5.c $(HDR) $(EXTHDR)
|
||||
$(LTCOMPILE) $(CORE_COMPILE_OPTS) $(NO_WARN) -DSQLITE_CORE -c fts5.c
|
||||
|
||||
@@ -2223,9 +2198,6 @@ sqlite3_analyzer.exe: sqlite3_analyzer.c $(LIBRESOBJS)
|
||||
$(LTLINK) $(NO_WARN) -DBUILD_sqlite -I$(TCLINCDIR) sqlite3_analyzer.c \
|
||||
/link $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LTLIBS) $(TLIBS)
|
||||
|
||||
sqlite3_expert.exe: $(SQLITE3C) $(TOP)\ext\expert\sqlite3expert.h $(TOP)\ext\expert\sqlite3expert.c $(TOP)\ext\expert\expert.c
|
||||
$(LTLINK) $(NO_WARN) $(TOP)\ext\expert\sqlite3expert.c $(TOP)\ext\expert\expert.c $(SQLITE3C) $(TLIBS)
|
||||
|
||||
CHECKER_DEPS =\
|
||||
$(TOP)/tool/mkccode.tcl \
|
||||
sqlite3.c \
|
||||
@@ -2343,5 +2315,4 @@ clean:
|
||||
del /Q sqlite-*-output.vsix 2>NUL
|
||||
del /Q fuzzershell.exe fuzzcheck.exe sqldiff.exe dbhash.exe 2>NUL
|
||||
del /Q fts5.* fts5parse.* 2>NUL
|
||||
del /Q lsm.h lsm1.c 2>NUL
|
||||
# <</mark>>
|
||||
|
||||
@@ -207,8 +207,8 @@ The amalgamation source file is more than 200K lines long. Some symbolic
|
||||
debuggers (most notably MSVC) are unable to deal with files longer than 64K
|
||||
lines. To work around this, a separate Tcl script, tool/split-sqlite3c.tcl,
|
||||
can be run on the amalgamation to break it up into a single small C file
|
||||
called **sqlite3-all.c** that does #include on about seven other files
|
||||
named **sqlite3-1.c**, **sqlite3-2.c**, ..., **sqlite3-7.c**. In this way,
|
||||
called **sqlite3-all.c** that does #include on about five other files
|
||||
named **sqlite3-1.c**, **sqlite3-2.c**, ..., **sqlite3-5.c**. In this way,
|
||||
all of the source code is contained within a single translation unit so
|
||||
that the compiler can do extra cross-procedure optimization, but no
|
||||
individual source file exceeds 32K lines in length.
|
||||
@@ -237,8 +237,7 @@ Key files:
|
||||
trying to understand how the library works internally.
|
||||
|
||||
* **sqliteInt.h** - this header file defines many of the data objects
|
||||
used internally by SQLite. In addition to "sqliteInt.h", some
|
||||
subsystems have their own header files.
|
||||
used internally by SQLite.
|
||||
|
||||
* **parse.y** - This file describes the LALR(1) grammar that SQLite uses
|
||||
to parse SQL statements, and the actions that are taken at each step
|
||||
@@ -250,44 +249,29 @@ Key files:
|
||||
which defines internal data objects. The rest of SQLite interacts
|
||||
with the VDBE through an interface defined by vdbe.h.
|
||||
|
||||
* **where.c** - This file (together with its helper files named
|
||||
by "where*.c") analyzes the WHERE clause and generates
|
||||
* **where.c** - This file analyzes the WHERE clause and generates
|
||||
virtual machine code to run queries efficiently. This file is
|
||||
sometimes called the "query optimizer". It has its own private
|
||||
header file, whereInt.h, that defines data objects used internally.
|
||||
|
||||
* **btree.c** - This file contains the implementation of the B-Tree
|
||||
storage engine used by SQLite. The interface to the rest of the system
|
||||
is defined by "btree.h". The "btreeInt.h" header defines objects
|
||||
used internally by btree.c and not published to the rest of the system.
|
||||
storage engine used by SQLite.
|
||||
|
||||
* **pager.c** - This file contains the "pager" implementation, the
|
||||
module that implements transactions. The "pager.h" header file
|
||||
defines the interface between pager.c and the rest of the system.
|
||||
module that implements transactions.
|
||||
|
||||
* **os_unix.c** and **os_win.c** - These two files implement the interface
|
||||
between SQLite and the underlying operating system using the run-time
|
||||
pluggable VFS interface.
|
||||
|
||||
* **shell.c.in** - This file is not part of the core SQLite library. This
|
||||
* **shell.c** - This file is not part of the core SQLite library. This
|
||||
is the file that, when linked against sqlite3.a, generates the
|
||||
"sqlite3.exe" command-line shell. The "shell.c.in" file is transformed
|
||||
into "shell.c" as part of the build process.
|
||||
"sqlite3.exe" command-line shell.
|
||||
|
||||
* **tclsqlite.c** - This file implements the Tcl bindings for SQLite. It
|
||||
is not part of the core SQLite library. But as most of the tests in this
|
||||
repository are written in Tcl, the Tcl language bindings are important.
|
||||
|
||||
* **test*.c** - Files in the src/ folder that begin with "test" go into
|
||||
building the "testfixture.exe" program. The testfixture.exe program is
|
||||
an enhanced TCL shell. The testfixture.exe program runs scripts in the
|
||||
test/ folder to validate the core SQLite code. The testfixture program
|
||||
(and some other test programs too) is build and run when you type
|
||||
"make test".
|
||||
|
||||
* **ext/misc/json1.c** - This file implements the various JSON functions
|
||||
that are build into SQLite.
|
||||
|
||||
There are many other source files. Each has a succinct header comment that
|
||||
describes its purpose and role within the larger system.
|
||||
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
## SQLite Expert Extension
|
||||
|
||||
This folder contains code for a simple system to propose useful indexes
|
||||
given a database and a set of SQL queries. It works as follows:
|
||||
|
||||
1. The user database schema is copied to a temporary database.
|
||||
|
||||
1. All SQL queries are prepared against the temporary database.
|
||||
Information regarding the WHERE and ORDER BY clauses, and other query
|
||||
features that affect index selection are recorded.
|
||||
|
||||
1. The information gathered in step 2 is used to create candidate
|
||||
indexes - indexes that the planner might have made use of in the previous
|
||||
step, had they been available.
|
||||
|
||||
1. A subset of the data in the user database is used to generate statistics
|
||||
for all existing indexes and the candidate indexes generated in step 3
|
||||
above.
|
||||
|
||||
1. The SQL queries are prepared a second time. If the planner uses any
|
||||
of the indexes created in step 3, they are recommended to the user.
|
||||
|
||||
# C API
|
||||
|
||||
The SQLite expert C API is defined in sqlite3expert.h. Most uses will proceed
|
||||
as follows:
|
||||
|
||||
1. An sqlite3expert object is created by calling **sqlite3\_expert\_new()**.
|
||||
A database handle opened by the user is passed as an argument.
|
||||
|
||||
1. The sqlite3expert object is configured with one or more SQL statements
|
||||
by making one or more calls to **sqlite3\_expert\_sql()**. Each call may
|
||||
specify a single SQL statement, or multiple statements separated by
|
||||
semi-colons.
|
||||
|
||||
1. Optionally, the **sqlite3\_expert\_config()** API may be used to
|
||||
configure the size of the data subset used to generate index statistics.
|
||||
Using a smaller subset of the data can speed up the analysis.
|
||||
|
||||
1. **sqlite3\_expert\_analyze()** is called to run the analysis.
|
||||
|
||||
1. One or more calls are made to **sqlite3\_expert\_report()** to extract
|
||||
components of the results of the analysis.
|
||||
|
||||
1. **sqlite3\_expert\_destroy()** is called to free all resources.
|
||||
|
||||
Refer to comments in sqlite3expert.h for further details.
|
||||
|
||||
# sqlite3_expert application
|
||||
|
||||
The file "expert.c" contains the code for a command line application that
|
||||
uses the API described above. It can be compiled with (for example):
|
||||
|
||||
<pre>
|
||||
gcc -O2 sqlite3.c expert.c sqlite3expert.c -o sqlite3_expert
|
||||
</pre>
|
||||
|
||||
Assuming the database is named "test.db", it can then be run to analyze a
|
||||
single query:
|
||||
|
||||
<pre>
|
||||
./sqlite3_expert -sql <sql-query> test.db
|
||||
</pre>
|
||||
|
||||
Or an entire text file worth of queries with:
|
||||
|
||||
<pre>
|
||||
./sqlite3_expert -file <text-file> test.db
|
||||
</pre>
|
||||
|
||||
By default, sqlite3\_expert generates index statistics using all the data in
|
||||
the user database. For a large database, this may be prohibitively time
|
||||
consuming. The "-sample" option may be used to configure sqlite3\_expert to
|
||||
generate statistics based on an integer percentage of the user database as
|
||||
follows:
|
||||
|
||||
<pre>
|
||||
# Generate statistics based on 25% of the user database rows:
|
||||
./sqlite3_expert -sample 25 -sql <sql-query> test.db
|
||||
|
||||
# Do not generate any statistics at all:
|
||||
./sqlite3_expert -sample 0 -sql <sql-query> test.db
|
||||
</pre>
|
||||
@@ -1,155 +0,0 @@
|
||||
/*
|
||||
** 2017 April 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "sqlite3expert.h"
|
||||
|
||||
|
||||
static void option_requires_argument(const char *zOpt){
|
||||
fprintf(stderr, "Option requires an argument: %s\n", zOpt);
|
||||
exit(-3);
|
||||
}
|
||||
|
||||
static int option_integer_arg(const char *zVal){
|
||||
return atoi(zVal);
|
||||
}
|
||||
|
||||
static void usage(char **argv){
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Usage %s ?OPTIONS? DATABASE\n", argv[0]);
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, "Options are:\n");
|
||||
fprintf(stderr, " -sql SQL (analyze SQL statements passed as argument)\n");
|
||||
fprintf(stderr, " -file FILE (read SQL statements from file FILE)\n");
|
||||
fprintf(stderr, " -verbose LEVEL (integer verbosity level. default 1)\n");
|
||||
fprintf(stderr, " -sample PERCENT (percent of db to sample. default 100)\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
static int readSqlFromFile(sqlite3expert *p, const char *zFile, char **pzErr){
|
||||
FILE *in = fopen(zFile, "rb");
|
||||
long nIn;
|
||||
size_t nRead;
|
||||
char *pBuf;
|
||||
int rc;
|
||||
if( in==0 ){
|
||||
*pzErr = sqlite3_mprintf("failed to open file %s\n", zFile);
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
fseek(in, 0, SEEK_END);
|
||||
nIn = ftell(in);
|
||||
rewind(in);
|
||||
pBuf = sqlite3_malloc64( nIn+1 );
|
||||
nRead = fread(pBuf, nIn, 1, in);
|
||||
fclose(in);
|
||||
if( nRead!=1 ){
|
||||
sqlite3_free(pBuf);
|
||||
*pzErr = sqlite3_mprintf("failed to read file %s\n", zFile);
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
pBuf[nIn] = 0;
|
||||
rc = sqlite3_expert_sql(p, pBuf, pzErr);
|
||||
sqlite3_free(pBuf);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv){
|
||||
const char *zDb;
|
||||
int rc = 0;
|
||||
char *zErr = 0;
|
||||
int i;
|
||||
int iVerbose = 1; /* -verbose option */
|
||||
|
||||
sqlite3 *db = 0;
|
||||
sqlite3expert *p = 0;
|
||||
|
||||
if( argc<2 ) usage(argv);
|
||||
zDb = argv[argc-1];
|
||||
if( zDb[0]=='-' ) usage(argv);
|
||||
rc = sqlite3_open(zDb, &db);
|
||||
if( rc!=SQLITE_OK ){
|
||||
fprintf(stderr, "Cannot open db file: %s - %s\n", zDb, sqlite3_errmsg(db));
|
||||
exit(-2);
|
||||
}
|
||||
|
||||
p = sqlite3_expert_new(db, &zErr);
|
||||
if( p==0 ){
|
||||
fprintf(stderr, "Cannot run analysis: %s\n", zErr);
|
||||
rc = 1;
|
||||
}else{
|
||||
for(i=1; i<(argc-1); i++){
|
||||
char *zArg = argv[i];
|
||||
if( zArg[0]=='-' && zArg[1]=='-' && zArg[2]!=0 ) zArg++;
|
||||
int nArg = (int)strlen(zArg);
|
||||
if( nArg>=2 && 0==sqlite3_strnicmp(zArg, "-file", nArg) ){
|
||||
if( ++i==(argc-1) ) option_requires_argument("-file");
|
||||
rc = readSqlFromFile(p, argv[i], &zErr);
|
||||
}
|
||||
|
||||
else if( nArg>=3 && 0==sqlite3_strnicmp(zArg, "-sql", nArg) ){
|
||||
if( ++i==(argc-1) ) option_requires_argument("-sql");
|
||||
rc = sqlite3_expert_sql(p, argv[i], &zErr);
|
||||
}
|
||||
|
||||
else if( nArg>=3 && 0==sqlite3_strnicmp(zArg, "-sample", nArg) ){
|
||||
int iSample;
|
||||
if( ++i==(argc-1) ) option_requires_argument("-sample");
|
||||
iSample = option_integer_arg(argv[i]);
|
||||
sqlite3_expert_config(p, EXPERT_CONFIG_SAMPLE, iSample);
|
||||
}
|
||||
|
||||
else if( nArg>=2 && 0==sqlite3_strnicmp(zArg, "-verbose", nArg) ){
|
||||
if( ++i==(argc-1) ) option_requires_argument("-verbose");
|
||||
iVerbose = option_integer_arg(argv[i]);
|
||||
}
|
||||
|
||||
else{
|
||||
usage(argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3_expert_analyze(p, &zErr);
|
||||
}
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
int nQuery = sqlite3_expert_count(p);
|
||||
if( iVerbose>0 ){
|
||||
const char *zCand = sqlite3_expert_report(p,0,EXPERT_REPORT_CANDIDATES);
|
||||
fprintf(stdout, "-- Candidates -------------------------------\n");
|
||||
fprintf(stdout, "%s\n", zCand);
|
||||
}
|
||||
for(i=0; i<nQuery; i++){
|
||||
const char *zSql = sqlite3_expert_report(p, i, EXPERT_REPORT_SQL);
|
||||
const char *zIdx = sqlite3_expert_report(p, i, EXPERT_REPORT_INDEXES);
|
||||
const char *zEQP = sqlite3_expert_report(p, i, EXPERT_REPORT_PLAN);
|
||||
if( zIdx==0 ) zIdx = "(no new indexes)\n";
|
||||
if( iVerbose>0 ){
|
||||
fprintf(stdout, "-- Query %d ----------------------------------\n",i+1);
|
||||
fprintf(stdout, "%s\n\n", zSql);
|
||||
}
|
||||
fprintf(stdout, "%s\n%s\n", zIdx, zEQP);
|
||||
}
|
||||
}else{
|
||||
fprintf(stderr, "Error: %s\n", zErr ? zErr : "?");
|
||||
}
|
||||
|
||||
sqlite3_expert_destroy(p);
|
||||
sqlite3_free(zErr);
|
||||
return rc;
|
||||
}
|
||||
@@ -1,377 +0,0 @@
|
||||
# 2009 Nov 11
|
||||
#
|
||||
# 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 CLI shell tool. Specifically,
|
||||
# the ".recommend" command.
|
||||
#
|
||||
#
|
||||
|
||||
# Test plan:
|
||||
#
|
||||
#
|
||||
if {![info exists testdir]} {
|
||||
set testdir [file join [file dirname [info script]] .. .. test]
|
||||
}
|
||||
source $testdir/tester.tcl
|
||||
set testprefix expert1
|
||||
|
||||
set CLI [test_binary_name sqlite3]
|
||||
set CMD [test_binary_name sqlite3_expert]
|
||||
|
||||
proc squish {txt} {
|
||||
regsub -all {[[:space:]]+} $txt { }
|
||||
}
|
||||
|
||||
proc do_setup_rec_test {tn setup sql res} {
|
||||
reset_db
|
||||
db eval $setup
|
||||
uplevel [list do_rec_test $tn $sql $res]
|
||||
}
|
||||
|
||||
foreach {tn setup} {
|
||||
1 {
|
||||
if {![file executable $CMD]} { continue }
|
||||
|
||||
proc do_rec_test {tn sql res} {
|
||||
set res [squish [string trim $res]]
|
||||
set tst [subst -nocommands {
|
||||
squish [string trim [exec $::CMD -verbose 0 -sql {$sql;} test.db]]
|
||||
}]
|
||||
uplevel [list do_test $tn $tst $res]
|
||||
}
|
||||
}
|
||||
2 {
|
||||
if {[info commands sqlite3_expert_new]==""} { continue }
|
||||
|
||||
proc do_rec_test {tn sql res} {
|
||||
set expert [sqlite3_expert_new db]
|
||||
$expert sql $sql
|
||||
$expert analyze
|
||||
|
||||
set result [list]
|
||||
for {set i 0} {$i < [$expert count]} {incr i} {
|
||||
set idx [string trim [$expert report $i indexes]]
|
||||
if {$idx==""} {set idx "(no new indexes)"}
|
||||
lappend result $idx
|
||||
lappend result [string trim [$expert report $i plan]]
|
||||
}
|
||||
|
||||
$expert destroy
|
||||
|
||||
set tst [subst -nocommands {set {} [squish [join {$result}]]}]
|
||||
uplevel [list do_test $tn $tst [string trim [squish $res]]]
|
||||
}
|
||||
}
|
||||
3 {
|
||||
if {![file executable $CLI]} { continue }
|
||||
|
||||
proc do_rec_test {tn sql res} {
|
||||
set res [squish [string trim $res]]
|
||||
set tst [subst -nocommands {
|
||||
squish [string trim [exec $::CLI test.db ".expert" {$sql;}]]
|
||||
}]
|
||||
uplevel [list do_test $tn $tst $res]
|
||||
}
|
||||
}
|
||||
} {
|
||||
|
||||
eval $setup
|
||||
|
||||
|
||||
do_setup_rec_test $tn.1 { CREATE TABLE t1(a, b, c) } {
|
||||
SELECT * FROM t1
|
||||
} {
|
||||
(no new indexes)
|
||||
0|0|0|SCAN TABLE t1
|
||||
}
|
||||
|
||||
do_setup_rec_test $tn.2 {
|
||||
CREATE TABLE t1(a, b, c);
|
||||
} {
|
||||
SELECT * FROM t1 WHERE b>?;
|
||||
} {
|
||||
CREATE INDEX t1_idx_00000062 ON t1(b);
|
||||
0|0|0|SEARCH TABLE t1 USING INDEX t1_idx_00000062 (b>?)
|
||||
}
|
||||
|
||||
do_setup_rec_test $tn.3 {
|
||||
CREATE TABLE t1(a, b, c);
|
||||
} {
|
||||
SELECT * FROM t1 WHERE b COLLATE nocase BETWEEN ? AND ?
|
||||
} {
|
||||
CREATE INDEX t1_idx_3e094c27 ON t1(b COLLATE NOCASE);
|
||||
0|0|0|SEARCH TABLE t1 USING INDEX t1_idx_3e094c27 (b>? AND b<?)
|
||||
}
|
||||
|
||||
do_setup_rec_test $tn.4 {
|
||||
CREATE TABLE t1(a, b, c);
|
||||
} {
|
||||
SELECT a FROM t1 ORDER BY b;
|
||||
} {
|
||||
CREATE INDEX t1_idx_00000062 ON t1(b);
|
||||
0|0|0|SCAN TABLE t1 USING INDEX t1_idx_00000062
|
||||
}
|
||||
|
||||
do_setup_rec_test $tn.5 {
|
||||
CREATE TABLE t1(a, b, c);
|
||||
} {
|
||||
SELECT a FROM t1 WHERE a=? ORDER BY b;
|
||||
} {
|
||||
CREATE INDEX t1_idx_000123a7 ON t1(a, b);
|
||||
0|0|0|SEARCH TABLE t1 USING COVERING INDEX t1_idx_000123a7 (a=?)
|
||||
}
|
||||
|
||||
do_setup_rec_test $tn.6 {
|
||||
CREATE TABLE t1(a, b, c);
|
||||
} {
|
||||
SELECT min(a) FROM t1
|
||||
} {
|
||||
CREATE INDEX t1_idx_00000061 ON t1(a);
|
||||
0|0|0|SEARCH TABLE t1 USING COVERING INDEX t1_idx_00000061
|
||||
}
|
||||
|
||||
do_setup_rec_test $tn.7 {
|
||||
CREATE TABLE t1(a, b, c);
|
||||
} {
|
||||
SELECT * FROM t1 ORDER BY a, b, c;
|
||||
} {
|
||||
CREATE INDEX t1_idx_033e95fe ON t1(a, b, c);
|
||||
0|0|0|SCAN TABLE t1 USING COVERING INDEX t1_idx_033e95fe
|
||||
}
|
||||
|
||||
#do_setup_rec_test $tn.1.8 {
|
||||
# CREATE TABLE t1(a, b, c);
|
||||
#} {
|
||||
# SELECT * FROM t1 ORDER BY a ASC, b COLLATE nocase DESC, c ASC;
|
||||
#} {
|
||||
# CREATE INDEX t1_idx_5be6e222 ON t1(a, b COLLATE NOCASE DESC, c);
|
||||
# 0|0|0|SCAN TABLE t1 USING COVERING INDEX t1_idx_5be6e222
|
||||
#}
|
||||
|
||||
do_setup_rec_test $tn.8.1 {
|
||||
CREATE TABLE t1(a COLLATE NOCase, b, c);
|
||||
} {
|
||||
SELECT * FROM t1 WHERE a=?
|
||||
} {
|
||||
CREATE INDEX t1_idx_00000061 ON t1(a);
|
||||
0|0|0|SEARCH TABLE t1 USING INDEX t1_idx_00000061 (a=?)
|
||||
}
|
||||
do_setup_rec_test $tn.8.2 {
|
||||
CREATE TABLE t1(a, b COLLATE nocase, c);
|
||||
} {
|
||||
SELECT * FROM t1 ORDER BY a ASC, b DESC, c ASC;
|
||||
} {
|
||||
CREATE INDEX t1_idx_5cb97285 ON t1(a, b DESC, c);
|
||||
0|0|0|SCAN TABLE t1 USING COVERING INDEX t1_idx_5cb97285
|
||||
}
|
||||
|
||||
|
||||
# Tables with names that require quotes.
|
||||
#
|
||||
do_setup_rec_test $tn.9.1 {
|
||||
CREATE TABLE "t t"(a, b, c);
|
||||
} {
|
||||
SELECT * FROM "t t" WHERE a=?
|
||||
} {
|
||||
CREATE INDEX 't t_idx_00000061' ON 't t'(a);
|
||||
0|0|0|SEARCH TABLE t t USING INDEX t t_idx_00000061 (a=?)
|
||||
}
|
||||
|
||||
do_setup_rec_test $tn.9.2 {
|
||||
CREATE TABLE "t t"(a, b, c);
|
||||
} {
|
||||
SELECT * FROM "t t" WHERE b BETWEEN ? AND ?
|
||||
} {
|
||||
CREATE INDEX 't t_idx_00000062' ON 't t'(b);
|
||||
0|0|0|SEARCH TABLE t t USING INDEX t t_idx_00000062 (b>? AND b<?)
|
||||
}
|
||||
|
||||
# Columns with names that require quotes.
|
||||
#
|
||||
do_setup_rec_test $tn.10.1 {
|
||||
CREATE TABLE t3(a, "b b", c);
|
||||
} {
|
||||
SELECT * FROM t3 WHERE "b b" = ?
|
||||
} {
|
||||
CREATE INDEX t3_idx_00050c52 ON t3('b b');
|
||||
0|0|0|SEARCH TABLE t3 USING INDEX t3_idx_00050c52 (b b=?)
|
||||
}
|
||||
|
||||
do_setup_rec_test $tn.10.2 {
|
||||
CREATE TABLE t3(a, "b b", c);
|
||||
} {
|
||||
SELECT * FROM t3 ORDER BY "b b"
|
||||
} {
|
||||
CREATE INDEX t3_idx_00050c52 ON t3('b b');
|
||||
0|0|0|SCAN TABLE t3 USING INDEX t3_idx_00050c52
|
||||
}
|
||||
|
||||
# Transitive constraints
|
||||
#
|
||||
do_setup_rec_test $tn.11.1 {
|
||||
CREATE TABLE t5(a, b);
|
||||
CREATE TABLE t6(c, d);
|
||||
} {
|
||||
SELECT * FROM t5, t6 WHERE a=? AND b=c AND c=?
|
||||
} {
|
||||
CREATE INDEX t5_idx_000123a7 ON t5(a, b);
|
||||
CREATE INDEX t6_idx_00000063 ON t6(c);
|
||||
0|0|1|SEARCH TABLE t6 USING INDEX t6_idx_00000063 (c=?)
|
||||
0|1|0|SEARCH TABLE t5 USING COVERING INDEX t5_idx_000123a7 (a=? AND b=?)
|
||||
}
|
||||
|
||||
# OR terms.
|
||||
#
|
||||
do_setup_rec_test $tn.12.1 {
|
||||
CREATE TABLE t7(a, b);
|
||||
} {
|
||||
SELECT * FROM t7 WHERE a=? OR b=?
|
||||
} {
|
||||
CREATE INDEX t7_idx_00000062 ON t7(b);
|
||||
CREATE INDEX t7_idx_00000061 ON t7(a);
|
||||
0|0|0|SEARCH TABLE t7 USING INDEX t7_idx_00000061 (a=?)
|
||||
0|0|0|SEARCH TABLE t7 USING INDEX t7_idx_00000062 (b=?)
|
||||
}
|
||||
|
||||
# rowid terms.
|
||||
#
|
||||
do_setup_rec_test $tn.13.1 {
|
||||
CREATE TABLE t8(a, b);
|
||||
} {
|
||||
SELECT * FROM t8 WHERE rowid=?
|
||||
} {
|
||||
(no new indexes)
|
||||
0|0|0|SEARCH TABLE t8 USING INTEGER PRIMARY KEY (rowid=?)
|
||||
}
|
||||
do_setup_rec_test $tn.13.2 {
|
||||
CREATE TABLE t8(a, b);
|
||||
} {
|
||||
SELECT * FROM t8 ORDER BY rowid
|
||||
} {
|
||||
(no new indexes)
|
||||
0|0|0|SCAN TABLE t8
|
||||
}
|
||||
do_setup_rec_test $tn.13.3 {
|
||||
CREATE TABLE t8(a, b);
|
||||
} {
|
||||
SELECT * FROM t8 WHERE a=? ORDER BY rowid
|
||||
} {
|
||||
CREATE INDEX t8_idx_00000061 ON t8(a);
|
||||
0|0|0|SEARCH TABLE t8 USING INDEX t8_idx_00000061 (a=?)
|
||||
}
|
||||
|
||||
# Triggers
|
||||
#
|
||||
do_setup_rec_test $tn.14 {
|
||||
CREATE TABLE t9(a, b, c);
|
||||
CREATE TABLE t10(a, b, c);
|
||||
CREATE TRIGGER t9t AFTER INSERT ON t9 BEGIN
|
||||
UPDATE t10 SET a=new.a WHERE b = new.b;
|
||||
END;
|
||||
} {
|
||||
INSERT INTO t9 VALUES(?, ?, ?);
|
||||
} {
|
||||
CREATE INDEX t10_idx_00000062 ON t10(b);
|
||||
0|0|0|SEARCH TABLE t10 USING INDEX t10_idx_00000062 (b=?)
|
||||
}
|
||||
|
||||
do_setup_rec_test $tn.15 {
|
||||
CREATE TABLE t1(a, b);
|
||||
CREATE TABLE t2(c, d);
|
||||
|
||||
WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t1 SELECT (i-1)/50, (i-1)/20 FROM s;
|
||||
|
||||
WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t2 SELECT (i-1)/20, (i-1)/5 FROM s;
|
||||
} {
|
||||
SELECT * FROM t2, t1 WHERE b=? AND d=? AND t2.rowid=t1.rowid
|
||||
} {
|
||||
CREATE INDEX t2_idx_00000064 ON t2(d);
|
||||
0|0|0|SEARCH TABLE t2 USING INDEX t2_idx_00000064 (d=?)
|
||||
0|1|1|SEARCH TABLE t1 USING INTEGER PRIMARY KEY (rowid=?)
|
||||
}
|
||||
|
||||
do_setup_rec_test $tn.16 {
|
||||
CREATE TABLE t1(a, b);
|
||||
} {
|
||||
SELECT * FROM t1 WHERE b IS NOT NULL;
|
||||
} {
|
||||
(no new indexes)
|
||||
0|0|0|SCAN TABLE t1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
proc do_candidates_test {tn sql res} {
|
||||
set res [squish [string trim $res]]
|
||||
|
||||
set expert [sqlite3_expert_new db]
|
||||
$expert sql $sql
|
||||
$expert analyze
|
||||
|
||||
set candidates [squish [string trim [$expert report 0 candidates]]]
|
||||
$expert destroy
|
||||
|
||||
uplevel [list do_test $tn [list set {} $candidates] $res]
|
||||
}
|
||||
|
||||
|
||||
reset_db
|
||||
do_execsql_test 3.0 {
|
||||
CREATE TABLE t1(a, b);
|
||||
CREATE TABLE t2(c, d);
|
||||
|
||||
WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t1 SELECT (i-1)/50, (i-1)/20 FROM s;
|
||||
|
||||
WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100)
|
||||
INSERT INTO t2 SELECT (i-1)/20, (i-1)/5 FROM s;
|
||||
}
|
||||
do_candidates_test 3.1 {
|
||||
SELECT * FROM t1,t2 WHERE (b=? OR a=?) AND (c=? OR d=?)
|
||||
} {
|
||||
CREATE INDEX t1_idx_00000062 ON t1(b); -- stat1: 100 20
|
||||
CREATE INDEX t1_idx_00000061 ON t1(a); -- stat1: 100 50
|
||||
CREATE INDEX t2_idx_00000063 ON t2(c); -- stat1: 100 20
|
||||
CREATE INDEX t2_idx_00000064 ON t2(d); -- stat1: 100 5
|
||||
}
|
||||
|
||||
do_candidates_test 3.2 {
|
||||
SELECT * FROM t1,t2 WHERE a=? AND b=? AND c=? AND d=?
|
||||
} {
|
||||
CREATE INDEX t1_idx_000123a7 ON t1(a, b); -- stat1: 100 50 17
|
||||
CREATE INDEX t2_idx_0001295b ON t2(c, d); -- stat1: 100 20 5
|
||||
}
|
||||
|
||||
do_execsql_test 3.2 {
|
||||
CREATE INDEX t1_idx_00000061 ON t1(a); -- stat1: 100 50
|
||||
CREATE INDEX t1_idx_00000062 ON t1(b); -- stat1: 100 20
|
||||
CREATE INDEX t1_idx_000123a7 ON t1(a, b); -- stat1: 100 50 16
|
||||
|
||||
CREATE INDEX t2_idx_00000063 ON t2(c); -- stat1: 100 20
|
||||
CREATE INDEX t2_idx_00000064 ON t2(d); -- stat1: 100 5
|
||||
CREATE INDEX t2_idx_0001295b ON t2(c, d); -- stat1: 100 20 5
|
||||
|
||||
ANALYZE;
|
||||
SELECT * FROM sqlite_stat1 ORDER BY 1, 2;
|
||||
} {
|
||||
t1 t1_idx_00000061 {100 50}
|
||||
t1 t1_idx_00000062 {100 20}
|
||||
t1 t1_idx_000123a7 {100 50 17}
|
||||
t2 t2_idx_00000063 {100 20}
|
||||
t2 t2_idx_00000064 {100 5}
|
||||
t2 t2_idx_0001295b {100 20 5}
|
||||
}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,168 +0,0 @@
|
||||
/*
|
||||
** 2017 April 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"
|
||||
|
||||
typedef struct sqlite3expert sqlite3expert;
|
||||
|
||||
/*
|
||||
** Create a new sqlite3expert object.
|
||||
**
|
||||
** If successful, a pointer to the new object is returned and (*pzErr) set
|
||||
** to NULL. Or, if an error occurs, NULL is returned and (*pzErr) set to
|
||||
** an English-language error message. In this case it is the responsibility
|
||||
** of the caller to eventually free the error message buffer using
|
||||
** sqlite3_free().
|
||||
*/
|
||||
sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErr);
|
||||
|
||||
/*
|
||||
** Configure an sqlite3expert object.
|
||||
**
|
||||
** EXPERT_CONFIG_SAMPLE:
|
||||
** By default, sqlite3_expert_analyze() generates sqlite_stat1 data for
|
||||
** each candidate index. This involves scanning and sorting the entire
|
||||
** contents of each user database table once for each candidate index
|
||||
** associated with the table. For large databases, this can be
|
||||
** prohibitively slow. This option allows the sqlite3expert object to
|
||||
** be configured so that sqlite_stat1 data is instead generated based on a
|
||||
** subset of each table, or so that no sqlite_stat1 data is used at all.
|
||||
**
|
||||
** A single integer argument is passed to this option. If the value is less
|
||||
** than or equal to zero, then no sqlite_stat1 data is generated or used by
|
||||
** the analysis - indexes are recommended based on the database schema only.
|
||||
** Or, if the value is 100 or greater, complete sqlite_stat1 data is
|
||||
** generated for each candidate index (this is the default). Finally, if the
|
||||
** value falls between 0 and 100, then it represents the percentage of user
|
||||
** table rows that should be considered when generating sqlite_stat1 data.
|
||||
**
|
||||
** Examples:
|
||||
**
|
||||
** // Do not generate any sqlite_stat1 data
|
||||
** sqlite3_expert_config(pExpert, EXPERT_CONFIG_SAMPLE, 0);
|
||||
**
|
||||
** // Generate sqlite_stat1 data based on 10% of the rows in each table.
|
||||
** sqlite3_expert_config(pExpert, EXPERT_CONFIG_SAMPLE, 10);
|
||||
*/
|
||||
int sqlite3_expert_config(sqlite3expert *p, int op, ...);
|
||||
|
||||
#define EXPERT_CONFIG_SAMPLE 1 /* int */
|
||||
|
||||
/*
|
||||
** Specify zero or more SQL statements to be included in the analysis.
|
||||
**
|
||||
** Buffer zSql must contain zero or more complete SQL statements. This
|
||||
** function parses all statements contained in the buffer and adds them
|
||||
** to the internal list of statements to analyze. If successful, SQLITE_OK
|
||||
** is returned and (*pzErr) set to NULL. Or, if an error occurs - for example
|
||||
** due to a error in the SQL - an SQLite error code is returned and (*pzErr)
|
||||
** may be set to point to an English language error message. In this case
|
||||
** the caller is responsible for eventually freeing the error message buffer
|
||||
** using sqlite3_free().
|
||||
**
|
||||
** If an error does occur while processing one of the statements in the
|
||||
** buffer passed as the second argument, none of the statements in the
|
||||
** buffer are added to the analysis.
|
||||
**
|
||||
** This function must be called before sqlite3_expert_analyze(). If a call
|
||||
** to this function is made on an sqlite3expert object that has already
|
||||
** been passed to sqlite3_expert_analyze() SQLITE_MISUSE is returned
|
||||
** immediately and no statements are added to the analysis.
|
||||
*/
|
||||
int sqlite3_expert_sql(
|
||||
sqlite3expert *p, /* From a successful sqlite3_expert_new() */
|
||||
const char *zSql, /* SQL statement(s) to add */
|
||||
char **pzErr /* OUT: Error message (if any) */
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
** This function is called after the sqlite3expert object has been configured
|
||||
** with all SQL statements using sqlite3_expert_sql() to actually perform
|
||||
** the analysis. Once this function has been called, it is not possible to
|
||||
** add further SQL statements to the analysis.
|
||||
**
|
||||
** If successful, SQLITE_OK is returned and (*pzErr) is set to NULL. Or, if
|
||||
** an error occurs, an SQLite error code is returned and (*pzErr) set to
|
||||
** point to a buffer containing an English language error message. In this
|
||||
** case it is the responsibility of the caller to eventually free the buffer
|
||||
** using sqlite3_free().
|
||||
**
|
||||
** If an error does occur within this function, the sqlite3expert object
|
||||
** is no longer useful for any purpose. At that point it is no longer
|
||||
** possible to add further SQL statements to the object or to re-attempt
|
||||
** the analysis. The sqlite3expert object must still be freed using a call
|
||||
** sqlite3_expert_destroy().
|
||||
*/
|
||||
int sqlite3_expert_analyze(sqlite3expert *p, char **pzErr);
|
||||
|
||||
/*
|
||||
** Return the total number of statements loaded using sqlite3_expert_sql().
|
||||
** The total number of SQL statements may be different from the total number
|
||||
** to calls to sqlite3_expert_sql().
|
||||
*/
|
||||
int sqlite3_expert_count(sqlite3expert*);
|
||||
|
||||
/*
|
||||
** Return a component of the report.
|
||||
**
|
||||
** This function is called after sqlite3_expert_analyze() to extract the
|
||||
** results of the analysis. Each call to this function returns either a
|
||||
** NULL pointer or a pointer to a buffer containing a nul-terminated string.
|
||||
** The value passed as the third argument must be one of the EXPERT_REPORT_*
|
||||
** #define constants defined below.
|
||||
**
|
||||
** For some EXPERT_REPORT_* parameters, the buffer returned contains
|
||||
** information relating to a specific SQL statement. In these cases that
|
||||
** SQL statement is identified by the value passed as the second argument.
|
||||
** SQL statements are numbered from 0 in the order in which they are parsed.
|
||||
** If an out-of-range value (less than zero or equal to or greater than the
|
||||
** value returned by sqlite3_expert_count()) is passed as the second argument
|
||||
** along with such an EXPERT_REPORT_* parameter, NULL is always returned.
|
||||
**
|
||||
** EXPERT_REPORT_SQL:
|
||||
** Return the text of SQL statement iStmt.
|
||||
**
|
||||
** EXPERT_REPORT_INDEXES:
|
||||
** Return a buffer containing the CREATE INDEX statements for all recommended
|
||||
** indexes for statement iStmt. If there are no new recommeded indexes, NULL
|
||||
** is returned.
|
||||
**
|
||||
** EXPERT_REPORT_PLAN:
|
||||
** Return a buffer containing the EXPLAIN QUERY PLAN output for SQL query
|
||||
** iStmt after the proposed indexes have been added to the database schema.
|
||||
**
|
||||
** EXPERT_REPORT_CANDIDATES:
|
||||
** Return a pointer to a buffer containing the CREATE INDEX statements
|
||||
** for all indexes that were tested (for all SQL statements). The iStmt
|
||||
** parameter is ignored for EXPERT_REPORT_CANDIDATES calls.
|
||||
*/
|
||||
const char *sqlite3_expert_report(sqlite3expert*, int iStmt, int eReport);
|
||||
|
||||
/*
|
||||
** Values for the third argument passed to sqlite3_expert_report().
|
||||
*/
|
||||
#define EXPERT_REPORT_SQL 1
|
||||
#define EXPERT_REPORT_INDEXES 2
|
||||
#define EXPERT_REPORT_PLAN 3
|
||||
#define EXPERT_REPORT_CANDIDATES 4
|
||||
|
||||
/*
|
||||
** Free an (sqlite3expert*) handle and all associated resources. There
|
||||
** should be one call to this function for each successful call to
|
||||
** sqlite3-expert_new().
|
||||
*/
|
||||
void sqlite3_expert_destroy(sqlite3expert*);
|
||||
|
||||
|
||||
@@ -1,215 +0,0 @@
|
||||
/*
|
||||
** 2017 April 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.
|
||||
**
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
#if defined(SQLITE_TEST)
|
||||
|
||||
#include "sqlite3expert.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(INCLUDE_SQLITE_TCL_H)
|
||||
# include "sqlite_tcl.h"
|
||||
#else
|
||||
# include "tcl.h"
|
||||
# ifndef SQLITE_TCLAPI
|
||||
# define SQLITE_TCLAPI
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Extract an sqlite3* db handle from the object passed as the second
|
||||
** argument. If successful, set *pDb to point to the db handle and return
|
||||
** TCL_OK. Otherwise, return TCL_ERROR.
|
||||
*/
|
||||
static int dbHandleFromObj(Tcl_Interp *interp, Tcl_Obj *pObj, sqlite3 **pDb){
|
||||
Tcl_CmdInfo info;
|
||||
if( 0==Tcl_GetCommandInfo(interp, Tcl_GetString(pObj), &info) ){
|
||||
Tcl_AppendResult(interp, "no such handle: ", Tcl_GetString(pObj), 0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
*pDb = *(sqlite3 **)info.objClientData;
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Tclcmd: $expert sql SQL
|
||||
** $expert analyze
|
||||
** $expert count
|
||||
** $expert report STMT EREPORT
|
||||
** $expert destroy
|
||||
*/
|
||||
static int SQLITE_TCLAPI testExpertCmd(
|
||||
void *clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
sqlite3expert *pExpert = (sqlite3expert*)clientData;
|
||||
struct Subcmd {
|
||||
const char *zSub;
|
||||
int nArg;
|
||||
const char *zMsg;
|
||||
} aSub[] = {
|
||||
{ "sql", 1, "TABLE", }, /* 0 */
|
||||
{ "analyze", 0, "", }, /* 1 */
|
||||
{ "count", 0, "", }, /* 2 */
|
||||
{ "report", 2, "STMT EREPORT", }, /* 3 */
|
||||
{ "destroy", 0, "", }, /* 4 */
|
||||
{ 0 }
|
||||
};
|
||||
int iSub;
|
||||
int rc = TCL_OK;
|
||||
char *zErr = 0;
|
||||
|
||||
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: { /* sql */
|
||||
char *zArg = Tcl_GetString(objv[2]);
|
||||
rc = sqlite3_expert_sql(pExpert, zArg, &zErr);
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: { /* analyze */
|
||||
rc = sqlite3_expert_analyze(pExpert, &zErr);
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: { /* count */
|
||||
int n = sqlite3_expert_count(pExpert);
|
||||
Tcl_SetObjResult(interp, Tcl_NewIntObj(n));
|
||||
break;
|
||||
}
|
||||
|
||||
case 3: { /* report */
|
||||
const char *aEnum[] = {
|
||||
"sql", "indexes", "plan", "candidates", 0
|
||||
};
|
||||
int iEnum;
|
||||
int iStmt;
|
||||
const char *zReport;
|
||||
|
||||
if( Tcl_GetIntFromObj(interp, objv[2], &iStmt)
|
||||
|| Tcl_GetIndexFromObj(interp, objv[3], aEnum, "report", 0, &iEnum)
|
||||
){
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
assert( EXPERT_REPORT_SQL==1 );
|
||||
assert( EXPERT_REPORT_INDEXES==2 );
|
||||
assert( EXPERT_REPORT_PLAN==3 );
|
||||
assert( EXPERT_REPORT_CANDIDATES==4 );
|
||||
zReport = sqlite3_expert_report(pExpert, iStmt, 1+iEnum);
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(zReport, -1));
|
||||
break;
|
||||
}
|
||||
|
||||
default: /* destroy */
|
||||
assert( iSub==4 );
|
||||
Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));
|
||||
break;
|
||||
}
|
||||
|
||||
if( rc!=TCL_OK ){
|
||||
if( zErr ){
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(zErr, -1));
|
||||
}else{
|
||||
extern const char *sqlite3ErrName(int);
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
|
||||
}
|
||||
}
|
||||
sqlite3_free(zErr);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void SQLITE_TCLAPI testExpertDel(void *clientData){
|
||||
sqlite3expert *pExpert = (sqlite3expert*)clientData;
|
||||
sqlite3_expert_destroy(pExpert);
|
||||
}
|
||||
|
||||
/*
|
||||
** sqlite3_expert_new DB
|
||||
*/
|
||||
static int SQLITE_TCLAPI test_sqlite3_expert_new(
|
||||
void * clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc,
|
||||
Tcl_Obj *CONST objv[]
|
||||
){
|
||||
static int iCmd = 0;
|
||||
sqlite3 *db;
|
||||
char *zCmd = 0;
|
||||
char *zErr = 0;
|
||||
sqlite3expert *pExpert;
|
||||
int rc = TCL_OK;
|
||||
|
||||
if( objc!=2 ){
|
||||
Tcl_WrongNumArgs(interp, 1, objv, "DB");
|
||||
return TCL_ERROR;
|
||||
}
|
||||
if( dbHandleFromObj(interp, objv[1], &db) ){
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
zCmd = sqlite3_mprintf("sqlite3expert%d", ++iCmd);
|
||||
if( zCmd==0 ){
|
||||
Tcl_AppendResult(interp, "out of memory", (char*)0);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
pExpert = sqlite3_expert_new(db, &zErr);
|
||||
if( pExpert==0 ){
|
||||
Tcl_AppendResult(interp, zErr, (char*)0);
|
||||
rc = TCL_ERROR;
|
||||
}else{
|
||||
void *p = (void*)pExpert;
|
||||
Tcl_CreateObjCommand(interp, zCmd, testExpertCmd, p, testExpertDel);
|
||||
Tcl_SetObjResult(interp, Tcl_NewStringObj(zCmd, -1));
|
||||
}
|
||||
|
||||
sqlite3_free(zCmd);
|
||||
sqlite3_free(zErr);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int TestExpert_Init(Tcl_Interp *interp){
|
||||
struct Cmd {
|
||||
const char *zCmd;
|
||||
Tcl_ObjCmdProc *xProc;
|
||||
} aCmd[] = {
|
||||
{ "sqlite3_expert_new", test_sqlite3_expert_new },
|
||||
};
|
||||
int i;
|
||||
|
||||
for(i=0; i<sizeof(aCmd)/sizeof(struct Cmd); i++){
|
||||
struct Cmd *p = &aCmd[i];
|
||||
Tcl_CreateObjCommand(interp, p->zCmd, p->xProc, 0, 0);
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
+3
-13
@@ -358,16 +358,6 @@ static int fts5SnippetScore(
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the value in pVal interpreted as utf-8 text. Except, if pVal
|
||||
** contains a NULL value, return a pointer to a static string zero
|
||||
** bytes in length instead of a NULL pointer.
|
||||
*/
|
||||
static const char *fts5ValueToText(sqlite3_value *pVal){
|
||||
const char *zRet = (const char*)sqlite3_value_text(pVal);
|
||||
return zRet ? zRet : "";
|
||||
}
|
||||
|
||||
/*
|
||||
** Implementation of snippet() function.
|
||||
*/
|
||||
@@ -403,9 +393,9 @@ static void fts5SnippetFunction(
|
||||
nCol = pApi->xColumnCount(pFts);
|
||||
memset(&ctx, 0, sizeof(HighlightContext));
|
||||
iCol = sqlite3_value_int(apVal[0]);
|
||||
ctx.zOpen = fts5ValueToText(apVal[1]);
|
||||
ctx.zClose = fts5ValueToText(apVal[2]);
|
||||
zEllips = fts5ValueToText(apVal[3]);
|
||||
ctx.zOpen = (const char*)sqlite3_value_text(apVal[1]);
|
||||
ctx.zClose = (const char*)sqlite3_value_text(apVal[2]);
|
||||
zEllips = (const char*)sqlite3_value_text(apVal[3]);
|
||||
nToken = sqlite3_value_int(apVal[4]);
|
||||
|
||||
iBestCol = (iCol>=0 ? iCol : 0);
|
||||
|
||||
@@ -4909,13 +4909,7 @@ static void fts5MergePrefixLists(
|
||||
Fts5Buffer out = {0, 0, 0};
|
||||
Fts5Buffer tmp = {0, 0, 0};
|
||||
|
||||
/* The maximum size of the output is equal to the sum of the two
|
||||
** input sizes + 1 varint (9 bytes). The extra varint is because if the
|
||||
** first rowid in one input is a large negative number, and the first in
|
||||
** the other a non-negative number, the delta for the non-negative
|
||||
** number will be larger on disk than the literal integer value
|
||||
** was. */
|
||||
if( sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n + 9) ) return;
|
||||
if( sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n) ) return;
|
||||
fts5DoclistIterInit(p1, &i1);
|
||||
fts5DoclistIterInit(p2, &i2);
|
||||
|
||||
@@ -5009,7 +5003,6 @@ static void fts5MergePrefixLists(
|
||||
fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid);
|
||||
fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.aEof - i2.aPoslist);
|
||||
}
|
||||
assert( out.n<=(p1->n+p2->n+9) );
|
||||
|
||||
fts5BufferSet(&p->rc, p1, out.n, out.p);
|
||||
fts5BufferFree(&tmp);
|
||||
|
||||
@@ -175,16 +175,6 @@ do_execsql_test 5.1 {
|
||||
SELECT snippet(p1, 0, '[', ']', '...', 6) FROM p1('x');
|
||||
} {{[x] a a a a a...}}
|
||||
|
||||
do_execsql_test 5.2 {
|
||||
SELECT snippet(p1, 0, '[', ']', NULL, 6) FROM p1('x');
|
||||
} {{[x] a a a a a}}
|
||||
do_execsql_test 5.3 {
|
||||
SELECT snippet(p1, 0, NULL, ']', '...', 6) FROM p1('x');
|
||||
} {{x] a a a a a...}}
|
||||
do_execsql_test 5.4 {
|
||||
SELECT snippet(p1, 0, '[', NULL, '...', 6) FROM p1('x');
|
||||
} {{[x a a a a a...}}
|
||||
|
||||
} ;# foreach_detail_mode
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -64,7 +64,7 @@ for {set tn 1 ; set pgsz 64} {$tn<32} {incr tn; incr pgsz 16} {
|
||||
execsql COMMIT
|
||||
} {}
|
||||
|
||||
do_execsql_test 2.$tn.2 {
|
||||
do_execsql_test 1.$tn.2 {
|
||||
INSERT INTO t1(t1) VALUES('integrity-check');
|
||||
}
|
||||
|
||||
@@ -77,15 +77,5 @@ for {set tn 1 ; set pgsz 64} {$tn<32} {incr tn; incr pgsz 16} {
|
||||
}
|
||||
}
|
||||
|
||||
reset_db
|
||||
do_execsql_test 3.0 {
|
||||
CREATE VIRTUAL TABLE x1 USING fts5(a);
|
||||
INSERT INTO x1(rowid, a) VALUES(-1000000000000, 'toyota');
|
||||
INSERT INTO x1(rowid, a) VALUES(1, 'tarago');
|
||||
}
|
||||
do_execsql_test 3.1 {
|
||||
SELECT rowid FROM x1('t*');
|
||||
} {-1000000000000 1}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
+20
-27
@@ -28,9 +28,7 @@
|
||||
** provide case-independent matching.
|
||||
*/
|
||||
|
||||
#if !defined(SQLITE_CORE) \
|
||||
|| defined(SQLITE_ENABLE_ICU) \
|
||||
|| defined(SQLITE_ENABLE_ICU_COLLATIONS)
|
||||
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
|
||||
|
||||
/* Include ICU headers */
|
||||
#include <unicode/utypes.h>
|
||||
@@ -47,26 +45,6 @@
|
||||
#include "sqlite3.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
** This function is called when an ICU function called from within
|
||||
** the implementation of an SQL scalar function returns an error.
|
||||
**
|
||||
** The scalar function context passed as the first argument is
|
||||
** loaded with an error message based on the following two args.
|
||||
*/
|
||||
static void icuFunctionError(
|
||||
sqlite3_context *pCtx, /* SQLite scalar function context */
|
||||
const char *zName, /* Name of ICU function that failed */
|
||||
UErrorCode e /* Error code returned by ICU function */
|
||||
){
|
||||
char zBuf[128];
|
||||
sqlite3_snprintf(128, zBuf, "ICU error: %s(): %s", zName, u_errorName(e));
|
||||
zBuf[127] = '\0';
|
||||
sqlite3_result_error(pCtx, zBuf, -1);
|
||||
}
|
||||
|
||||
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
|
||||
|
||||
/*
|
||||
** Maximum length (in bytes) of the pattern in a LIKE or GLOB
|
||||
** operator.
|
||||
@@ -246,6 +224,24 @@ static void icuLikeFunc(
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is called when an ICU function called from within
|
||||
** the implementation of an SQL scalar function returns an error.
|
||||
**
|
||||
** The scalar function context passed as the first argument is
|
||||
** loaded with an error message based on the following two args.
|
||||
*/
|
||||
static void icuFunctionError(
|
||||
sqlite3_context *pCtx, /* SQLite scalar function context */
|
||||
const char *zName, /* Name of ICU function that failed */
|
||||
UErrorCode e /* Error code returned by ICU function */
|
||||
){
|
||||
char zBuf[128];
|
||||
sqlite3_snprintf(128, zBuf, "ICU error: %s(): %s", zName, u_errorName(e));
|
||||
zBuf[127] = '\0';
|
||||
sqlite3_result_error(pCtx, zBuf, -1);
|
||||
}
|
||||
|
||||
/*
|
||||
** Function to delete compiled regexp objects. Registered as
|
||||
** a destructor function with sqlite3_set_auxdata().
|
||||
@@ -411,8 +407,6 @@ static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
|
||||
assert( 0 ); /* Unreachable */
|
||||
}
|
||||
|
||||
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU) */
|
||||
|
||||
/*
|
||||
** Collation sequence destructor function. The pCtx argument points to
|
||||
** a UCollator structure previously allocated using ucol_open().
|
||||
@@ -507,7 +501,6 @@ int sqlite3IcuInit(sqlite3 *db){
|
||||
void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
|
||||
} scalars[] = {
|
||||
{"icu_load_collation", 2, SQLITE_UTF8, 1, icuLoadCollation},
|
||||
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU)
|
||||
{"regexp", 2, SQLITE_ANY|SQLITE_DETERMINISTIC, 0, icuRegexpFunc},
|
||||
{"lower", 1, SQLITE_UTF16|SQLITE_DETERMINISTIC, 0, icuCaseFunc16},
|
||||
{"lower", 2, SQLITE_UTF16|SQLITE_DETERMINISTIC, 0, icuCaseFunc16},
|
||||
@@ -519,10 +512,10 @@ int sqlite3IcuInit(sqlite3 *db){
|
||||
{"upper", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 1, icuCaseFunc16},
|
||||
{"like", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuLikeFunc},
|
||||
{"like", 3, SQLITE_UTF8|SQLITE_DETERMINISTIC, 0, icuLikeFunc},
|
||||
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ICU) */
|
||||
};
|
||||
int rc = SQLITE_OK;
|
||||
int i;
|
||||
|
||||
|
||||
for(i=0; rc==SQLITE_OK && i<(int)(sizeof(scalars)/sizeof(scalars[0])); i++){
|
||||
const struct IcuScalar *p = &scalars[i];
|
||||
|
||||
+18
-18
@@ -110,7 +110,7 @@ typedef unsigned long long int u64;
|
||||
#endif
|
||||
|
||||
/* A page number is a 64-bit integer. */
|
||||
typedef i64 LsmPgno;
|
||||
typedef i64 Pgno;
|
||||
|
||||
#ifdef LSM_DEBUG
|
||||
int lsmErrorBkpt(int);
|
||||
@@ -402,9 +402,9 @@ struct lsm_db {
|
||||
};
|
||||
|
||||
struct Segment {
|
||||
LsmPgno iFirst; /* First page of this run */
|
||||
LsmPgno iLastPg; /* Last page of this run */
|
||||
LsmPgno iRoot; /* Root page number (if any) */
|
||||
Pgno iFirst; /* First page of this run */
|
||||
Pgno iLastPg; /* Last page of this run */
|
||||
Pgno iRoot; /* Root page number (if any) */
|
||||
int nSize; /* Size of this run in pages */
|
||||
|
||||
Redirect *pRedirect; /* Block redirects (or NULL) */
|
||||
@@ -456,7 +456,7 @@ struct Level {
|
||||
** output segment.
|
||||
*/
|
||||
struct MergeInput {
|
||||
LsmPgno iPg; /* Page on which next input is stored */
|
||||
Pgno iPg; /* Page on which next input is stored */
|
||||
int iCell; /* Cell containing next input to merge */
|
||||
};
|
||||
struct Merge {
|
||||
@@ -465,7 +465,7 @@ struct Merge {
|
||||
MergeInput splitkey; /* Location in file of current splitkey */
|
||||
int nSkip; /* Number of separators entries to skip */
|
||||
int iOutputOff; /* Write offset on output page */
|
||||
LsmPgno iCurrentPtr; /* Current pointer value */
|
||||
Pgno iCurrentPtr; /* Current pointer value */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -579,10 +579,10 @@ struct Snapshot {
|
||||
Redirect redirect; /* Block redirection array */
|
||||
|
||||
/* Used by worker snapshots only */
|
||||
int nBlock; /* Number of blocks in database file */
|
||||
LsmPgno aiAppend[LSM_APPLIST_SZ]; /* Append point list */
|
||||
Freelist freelist; /* Free block list */
|
||||
u32 nWrite; /* Total number of pages written to disk */
|
||||
int nBlock; /* Number of blocks in database file */
|
||||
Pgno aiAppend[LSM_APPLIST_SZ]; /* Append point list */
|
||||
Freelist freelist; /* Free block list */
|
||||
u32 nWrite; /* Total number of pages written to disk */
|
||||
};
|
||||
#define LSM_INITIAL_SNAPSHOT_ID 11
|
||||
|
||||
@@ -710,7 +710,7 @@ void lsmFsSetPageSize(FileSystem *, int);
|
||||
int lsmFsFileid(lsm_db *pDb, void **ppId, int *pnId);
|
||||
|
||||
/* Creating, populating, gobbling and deleting sorted runs. */
|
||||
void lsmFsGobble(lsm_db *, Segment *, LsmPgno *, int);
|
||||
void lsmFsGobble(lsm_db *, Segment *, Pgno *, int);
|
||||
int lsmFsSortedDelete(FileSystem *, Snapshot *, int, Segment *);
|
||||
int lsmFsSortedFinish(FileSystem *, Segment *);
|
||||
int lsmFsSortedAppend(FileSystem *, Snapshot *, Level *, int, Page **);
|
||||
@@ -727,14 +727,14 @@ void lsmSortedSplitkey(lsm_db *, Level *, int *);
|
||||
|
||||
/* Reading sorted run content. */
|
||||
int lsmFsDbPageLast(FileSystem *pFS, Segment *pSeg, Page **ppPg);
|
||||
int lsmFsDbPageGet(FileSystem *, Segment *, LsmPgno, Page **);
|
||||
int lsmFsDbPageGet(FileSystem *, Segment *, Pgno, Page **);
|
||||
int lsmFsDbPageNext(Segment *, Page *, int eDir, Page **);
|
||||
|
||||
u8 *lsmFsPageData(Page *, int *);
|
||||
int lsmFsPageRelease(Page *);
|
||||
int lsmFsPagePersist(Page *);
|
||||
void lsmFsPageRef(Page *);
|
||||
LsmPgno lsmFsPageNumber(Page *);
|
||||
Pgno lsmFsPageNumber(Page *);
|
||||
|
||||
int lsmFsNRead(FileSystem *);
|
||||
int lsmFsNWrite(FileSystem *);
|
||||
@@ -748,7 +748,7 @@ int lsmFsDbPageIsLast(Segment *pSeg, Page *pPg);
|
||||
int lsmFsIntegrityCheck(lsm_db *);
|
||||
#endif
|
||||
|
||||
LsmPgno lsmFsRedirectPage(FileSystem *, Redirect *, LsmPgno);
|
||||
Pgno lsmFsRedirectPage(FileSystem *, Redirect *, Pgno);
|
||||
|
||||
int lsmFsPageWritable(Page *);
|
||||
|
||||
@@ -768,8 +768,8 @@ int lsmFsSyncDb(FileSystem *, int);
|
||||
void lsmFsFlushWaiting(FileSystem *, int *);
|
||||
|
||||
/* Used by lsm_info(ARRAY_STRUCTURE) and lsm_config(MMAP) */
|
||||
int lsmInfoArrayStructure(lsm_db *pDb, int bBlock, LsmPgno iFirst, char **pz);
|
||||
int lsmInfoArrayPages(lsm_db *pDb, LsmPgno iFirst, char **pzOut);
|
||||
int lsmInfoArrayStructure(lsm_db *pDb, int bBlock, Pgno iFirst, char **pzOut);
|
||||
int lsmInfoArrayPages(lsm_db *pDb, Pgno iFirst, char **pzOut);
|
||||
int lsmConfigMmap(lsm_db *pDb, int *piParam);
|
||||
|
||||
int lsmEnvOpen(lsm_env *, const char *, int, lsm_file **);
|
||||
@@ -785,7 +785,7 @@ void lsmEnvSleep(lsm_env *, int);
|
||||
|
||||
int lsmFsReadSyncedId(lsm_db *db, int, i64 *piVal);
|
||||
|
||||
int lsmFsSegmentContainsPg(FileSystem *pFS, Segment *, LsmPgno, int *);
|
||||
int lsmFsSegmentContainsPg(FileSystem *pFS, Segment *, Pgno, int *);
|
||||
|
||||
void lsmFsPurgeCache(FileSystem *);
|
||||
|
||||
@@ -796,7 +796,7 @@ void lsmFsPurgeCache(FileSystem *);
|
||||
/*
|
||||
** Functions from file "lsm_sorted.c".
|
||||
*/
|
||||
int lsmInfoPageDump(lsm_db *, LsmPgno, int, char **);
|
||||
int lsmInfoPageDump(lsm_db *, Pgno, int, char **);
|
||||
void lsmSortedCleanup(lsm_db *);
|
||||
int lsmSortedAutoWork(lsm_db *, int nUnit);
|
||||
|
||||
|
||||
+1
-1
@@ -389,7 +389,7 @@ static void ckptExportAppendlist(
|
||||
int *pRc /* IN/OUT: Error code */
|
||||
){
|
||||
int i;
|
||||
LsmPgno *aiAppend = db->pWorker->aiAppend;
|
||||
Pgno *aiAppend = db->pWorker->aiAppend;
|
||||
|
||||
for(i=0; i<LSM_APPLIST_SZ; i++){
|
||||
ckptAppend64(p, piOut, aiAppend[i], pRc);
|
||||
|
||||
+68
-73
@@ -269,7 +269,7 @@ struct FileSystem {
|
||||
struct Page {
|
||||
u8 *aData; /* Buffer containing page data */
|
||||
int nData; /* Bytes of usable data at aData[] */
|
||||
LsmPgno iPg; /* Page number */
|
||||
Pgno iPg; /* Page number */
|
||||
int nRef; /* Number of outstanding references */
|
||||
int flags; /* Combination of PAGE_XXX flags */
|
||||
Page *pHashNext; /* Next page in hash table slot */
|
||||
@@ -332,7 +332,7 @@ static int IOERR_WRAPPER(int rc){
|
||||
#ifdef NDEBUG
|
||||
# define assert_lists_are_ok(x)
|
||||
#else
|
||||
static Page *fsPageFindInHash(FileSystem *pFS, LsmPgno iPg, int *piHash);
|
||||
static Page *fsPageFindInHash(FileSystem *pFS, Pgno iPg, int *piHash);
|
||||
|
||||
static void assert_lists_are_ok(FileSystem *pFS){
|
||||
#if 0
|
||||
@@ -532,7 +532,7 @@ int lsmFsCloseAndDeleteLog(FileSystem *pFS){
|
||||
** Return true if page iReal of the database should be accessed using mmap.
|
||||
** False otherwise.
|
||||
*/
|
||||
static int fsMmapPage(FileSystem *pFS, LsmPgno iReal){
|
||||
static int fsMmapPage(FileSystem *pFS, Pgno iReal){
|
||||
return ((i64)iReal*pFS->nPagesize <= pFS->nMapLimit);
|
||||
}
|
||||
|
||||
@@ -540,7 +540,7 @@ static int fsMmapPage(FileSystem *pFS, LsmPgno iReal){
|
||||
** Given that there are currently nHash slots in the hash table, return
|
||||
** the hash key for file iFile, page iPg.
|
||||
*/
|
||||
static int fsHashKey(int nHash, LsmPgno iPg){
|
||||
static int fsHashKey(int nHash, Pgno iPg){
|
||||
return (iPg % nHash);
|
||||
}
|
||||
|
||||
@@ -880,13 +880,13 @@ void lsmFsSetBlockSize(FileSystem *pFS, int nBlocksize){
|
||||
** page on each block is the byte offset immediately following the 4-byte
|
||||
** "previous block" pointer at the start of each block.
|
||||
*/
|
||||
static LsmPgno fsFirstPageOnBlock(FileSystem *pFS, int iBlock){
|
||||
LsmPgno iPg;
|
||||
static Pgno fsFirstPageOnBlock(FileSystem *pFS, int iBlock){
|
||||
Pgno iPg;
|
||||
if( pFS->pCompress ){
|
||||
if( iBlock==1 ){
|
||||
iPg = pFS->nMetasize * 2 + 4;
|
||||
}else{
|
||||
iPg = pFS->nBlocksize * (LsmPgno)(iBlock-1) + 4;
|
||||
iPg = pFS->nBlocksize * (Pgno)(iBlock-1) + 4;
|
||||
}
|
||||
}else{
|
||||
const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);
|
||||
@@ -907,9 +907,9 @@ static LsmPgno fsFirstPageOnBlock(FileSystem *pFS, int iBlock){
|
||||
** page on each block is the byte offset of the byte immediately before
|
||||
** the 4-byte "next block" pointer at the end of each block.
|
||||
*/
|
||||
static LsmPgno fsLastPageOnBlock(FileSystem *pFS, int iBlock){
|
||||
static Pgno fsLastPageOnBlock(FileSystem *pFS, int iBlock){
|
||||
if( pFS->pCompress ){
|
||||
return pFS->nBlocksize * (LsmPgno)iBlock - 1 - 4;
|
||||
return pFS->nBlocksize * (Pgno)iBlock - 1 - 4;
|
||||
}else{
|
||||
const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);
|
||||
return iBlock * nPagePerBlock;
|
||||
@@ -920,7 +920,7 @@ static LsmPgno fsLastPageOnBlock(FileSystem *pFS, int iBlock){
|
||||
** Return the block number of the block that page iPg is located on.
|
||||
** Blocks are numbered starting from 1.
|
||||
*/
|
||||
static int fsPageToBlock(FileSystem *pFS, LsmPgno iPg){
|
||||
static int fsPageToBlock(FileSystem *pFS, Pgno iPg){
|
||||
if( pFS->pCompress ){
|
||||
return (int)((iPg / pFS->nBlocksize) + 1);
|
||||
}else{
|
||||
@@ -933,7 +933,7 @@ static int fsPageToBlock(FileSystem *pFS, LsmPgno iPg){
|
||||
**
|
||||
** This function is only called in non-compressed database mode.
|
||||
*/
|
||||
static int fsIsLast(FileSystem *pFS, LsmPgno iPg){
|
||||
static int fsIsLast(FileSystem *pFS, Pgno iPg){
|
||||
const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);
|
||||
assert( !pFS->pCompress );
|
||||
return ( iPg && (iPg % nPagePerBlock)==0 );
|
||||
@@ -944,7 +944,7 @@ static int fsIsLast(FileSystem *pFS, LsmPgno iPg){
|
||||
**
|
||||
** This function is only called in non-compressed database mode.
|
||||
*/
|
||||
static int fsIsFirst(FileSystem *pFS, LsmPgno iPg){
|
||||
static int fsIsFirst(FileSystem *pFS, Pgno iPg){
|
||||
const int nPagePerBlock = (pFS->nBlocksize / pFS->nPagesize);
|
||||
assert( !pFS->pCompress );
|
||||
return ( (iPg % nPagePerBlock)==1
|
||||
@@ -967,7 +967,7 @@ u8 *lsmFsPageData(Page *pPage, int *pnData){
|
||||
/*
|
||||
** Return the page number of a page.
|
||||
*/
|
||||
LsmPgno lsmFsPageNumber(Page *pPage){
|
||||
Pgno lsmFsPageNumber(Page *pPage){
|
||||
/* assert( (pPage->flags & PAGE_DIRTY)==0 ); */
|
||||
return pPage ? pPage->iPg : 0;
|
||||
}
|
||||
@@ -1058,7 +1058,7 @@ void lsmFsPurgeCache(FileSystem *pFS){
|
||||
** Either way, if argument piHash is not NULL set *piHash to the hash slot
|
||||
** number that page iPg would be stored in before returning.
|
||||
*/
|
||||
static Page *fsPageFindInHash(FileSystem *pFS, LsmPgno iPg, int *piHash){
|
||||
static Page *fsPageFindInHash(FileSystem *pFS, Pgno iPg, int *piHash){
|
||||
Page *p; /* Return value */
|
||||
int iHash = fsHashKey(pFS->nHash, iPg);
|
||||
|
||||
@@ -1189,8 +1189,8 @@ static int fsRedirectBlock(Redirect *p, int iBlk){
|
||||
** object passed as the second argument, return the destination page to
|
||||
** which it is redirected. Otherwise, return a copy of iPg.
|
||||
*/
|
||||
LsmPgno lsmFsRedirectPage(FileSystem *pFS, Redirect *pRedir, LsmPgno iPg){
|
||||
LsmPgno iReal = iPg;
|
||||
Pgno lsmFsRedirectPage(FileSystem *pFS, Redirect *pRedir, Pgno iPg){
|
||||
Pgno iReal = iPg;
|
||||
|
||||
if( pRedir ){
|
||||
const int nPagePerBlock = (
|
||||
@@ -1203,7 +1203,7 @@ LsmPgno lsmFsRedirectPage(FileSystem *pFS, Redirect *pRedir, LsmPgno iPg){
|
||||
if( iFrom>iBlk ) break;
|
||||
if( iFrom==iBlk ){
|
||||
int iTo = pRedir->a[i].iTo;
|
||||
iReal = iPg - (LsmPgno)(iFrom - iTo) * nPagePerBlock;
|
||||
iReal = iPg - (Pgno)(iFrom - iTo) * nPagePerBlock;
|
||||
if( iTo==1 ){
|
||||
iReal += (fsFirstPageOnBlock(pFS, 1)-1);
|
||||
}
|
||||
@@ -1217,7 +1217,7 @@ LsmPgno lsmFsRedirectPage(FileSystem *pFS, Redirect *pRedir, LsmPgno iPg){
|
||||
}
|
||||
|
||||
/* Required by the circular fsBlockNext<->fsPageGet dependency. */
|
||||
static int fsPageGet(FileSystem *, Segment *, LsmPgno, int, Page **, int *);
|
||||
static int fsPageGet(FileSystem *, Segment *, Pgno, int, Page **, int *);
|
||||
|
||||
/*
|
||||
** Parameter iBlock is a database file block. This function reads the value
|
||||
@@ -1269,7 +1269,7 @@ static int fsBlockNext(
|
||||
/*
|
||||
** Return the page number of the last page on the same block as page iPg.
|
||||
*/
|
||||
LsmPgno fsLastPageOnPagesBlock(FileSystem *pFS, LsmPgno iPg){
|
||||
Pgno fsLastPageOnPagesBlock(FileSystem *pFS, Pgno iPg){
|
||||
return fsLastPageOnBlock(pFS, fsPageToBlock(pFS, iPg));
|
||||
}
|
||||
|
||||
@@ -1537,7 +1537,7 @@ static int fsReadPagedata(
|
||||
static int fsPageGet(
|
||||
FileSystem *pFS, /* File-system handle */
|
||||
Segment *pSeg, /* Block redirection to use (or NULL) */
|
||||
LsmPgno iPg, /* Page id */
|
||||
Pgno iPg, /* Page id */
|
||||
int noContent, /* True to not load content from disk */
|
||||
Page **ppPg, /* OUT: New page handle */
|
||||
int *pnSpace /* OUT: Bytes of free space */
|
||||
@@ -1549,7 +1549,7 @@ static int fsPageGet(
|
||||
/* In most cases iReal is the same as iPg. Except, if pSeg->pRedirect is
|
||||
** not NULL, and the block containing iPg has been redirected, then iReal
|
||||
** is the page number after redirection. */
|
||||
LsmPgno iReal = lsmFsRedirectPage(pFS, (pSeg ? pSeg->pRedirect : 0), iPg);
|
||||
Pgno iReal = lsmFsRedirectPage(pFS, (pSeg ? pSeg->pRedirect : 0), iPg);
|
||||
|
||||
assert_lists_are_ok(pFS);
|
||||
assert( iPg>=fsFirstPageOnBlock(pFS, 1) );
|
||||
@@ -1689,8 +1689,8 @@ int lsmFsReadSyncedId(lsm_db *db, int iMeta, i64 *piVal){
|
||||
static int fsRunEndsBetween(
|
||||
Segment *pRun,
|
||||
Segment *pIgnore,
|
||||
LsmPgno iFirst,
|
||||
LsmPgno iLast
|
||||
Pgno iFirst,
|
||||
Pgno iLast
|
||||
){
|
||||
return (pRun!=pIgnore && (
|
||||
(pRun->iFirst>=iFirst && pRun->iFirst<=iLast)
|
||||
@@ -1705,8 +1705,8 @@ static int fsRunEndsBetween(
|
||||
static int fsLevelEndsBetween(
|
||||
Level *pLevel,
|
||||
Segment *pIgnore,
|
||||
LsmPgno iFirst,
|
||||
LsmPgno iLast
|
||||
Pgno iFirst,
|
||||
Pgno iLast
|
||||
){
|
||||
int i;
|
||||
|
||||
@@ -1733,13 +1733,13 @@ static int fsFreeBlock(
|
||||
int iBlk /* Block number of block to free */
|
||||
){
|
||||
int rc = LSM_OK; /* Return code */
|
||||
LsmPgno iFirst; /* First page on block iBlk */
|
||||
LsmPgno iLast; /* Last page on block iBlk */
|
||||
Pgno iFirst; /* First page on block iBlk */
|
||||
Pgno iLast; /* Last page on block iBlk */
|
||||
Level *pLevel; /* Used to iterate through levels */
|
||||
|
||||
int iIn; /* Used to iterate through append points */
|
||||
int iOut = 0; /* Used to output append points */
|
||||
LsmPgno *aApp = pSnapshot->aiAppend;
|
||||
Pgno *aApp = pSnapshot->aiAppend;
|
||||
|
||||
iFirst = fsFirstPageOnBlock(pFS, iBlk);
|
||||
iLast = fsLastPageOnBlock(pFS, iBlk);
|
||||
@@ -1811,16 +1811,11 @@ int lsmFsSortedDelete(
|
||||
** number from the array that falls on block iBlk. Or, if none of the pages
|
||||
** in aPgno[] fall on block iBlk, return 0.
|
||||
*/
|
||||
static LsmPgno firstOnBlock(
|
||||
FileSystem *pFS,
|
||||
int iBlk,
|
||||
LsmPgno *aPgno,
|
||||
int nPgno
|
||||
){
|
||||
LsmPgno iRet = 0;
|
||||
static Pgno firstOnBlock(FileSystem *pFS, int iBlk, Pgno *aPgno, int nPgno){
|
||||
Pgno iRet = 0;
|
||||
int i;
|
||||
for(i=0; i<nPgno; i++){
|
||||
LsmPgno iPg = aPgno[i];
|
||||
Pgno iPg = aPgno[i];
|
||||
if( fsPageToBlock(pFS, iPg)==iBlk && (iRet==0 || iPg<iRet) ){
|
||||
iRet = iPg;
|
||||
}
|
||||
@@ -1833,7 +1828,7 @@ static LsmPgno firstOnBlock(
|
||||
** Return true if page iPg, which is a part of segment p, lies on
|
||||
** a redirected block.
|
||||
*/
|
||||
static int fsPageRedirects(FileSystem *pFS, Segment *p, LsmPgno iPg){
|
||||
static int fsPageRedirects(FileSystem *pFS, Segment *p, Pgno iPg){
|
||||
return (iPg!=0 && iPg!=lsmFsRedirectPage(pFS, p->pRedirect, iPg));
|
||||
}
|
||||
|
||||
@@ -1859,7 +1854,7 @@ static int fsSegmentRedirects(FileSystem *pFS, Segment *p){
|
||||
void lsmFsGobble(
|
||||
lsm_db *pDb,
|
||||
Segment *pRun,
|
||||
LsmPgno *aPgno,
|
||||
Pgno *aPgno,
|
||||
int nPgno
|
||||
){
|
||||
int rc = LSM_OK;
|
||||
@@ -1876,7 +1871,7 @@ void lsmFsGobble(
|
||||
|
||||
while( rc==LSM_OK ){
|
||||
int iNext = 0;
|
||||
LsmPgno iFirst = firstOnBlock(pFS, iBlk, aPgno, nPgno);
|
||||
Pgno iFirst = firstOnBlock(pFS, iBlk, aPgno, nPgno);
|
||||
if( iFirst ){
|
||||
pRun->iFirst = iFirst;
|
||||
break;
|
||||
@@ -1910,11 +1905,11 @@ void lsmFsGobble(
|
||||
static int fsNextPageOffset(
|
||||
FileSystem *pFS, /* File system object */
|
||||
Segment *pSeg, /* Segment to move within */
|
||||
LsmPgno iPg, /* Offset of current page */
|
||||
Pgno iPg, /* Offset of current page */
|
||||
int nByte, /* Size of current page including headers */
|
||||
LsmPgno *piNext /* OUT: Offset of next page. Or zero (EOF) */
|
||||
Pgno *piNext /* OUT: Offset of next page. Or zero (EOF) */
|
||||
){
|
||||
LsmPgno iNext;
|
||||
Pgno iNext;
|
||||
int rc;
|
||||
|
||||
assert( pFS->pCompress );
|
||||
@@ -1944,8 +1939,8 @@ static int fsNextPageOffset(
|
||||
static int fsGetPageBefore(
|
||||
FileSystem *pFS,
|
||||
Segment *pSeg,
|
||||
LsmPgno iPg,
|
||||
LsmPgno *piPrev
|
||||
Pgno iPg,
|
||||
Pgno *piPrev
|
||||
){
|
||||
u8 aSz[3];
|
||||
int rc;
|
||||
@@ -1995,7 +1990,7 @@ static int fsGetPageBefore(
|
||||
int lsmFsDbPageNext(Segment *pRun, Page *pPg, int eDir, Page **ppNext){
|
||||
int rc = LSM_OK;
|
||||
FileSystem *pFS = pPg->pFS;
|
||||
LsmPgno iPg = pPg->iPg;
|
||||
Pgno iPg = pPg->iPg;
|
||||
|
||||
assert( 0==fsSegmentRedirects(pFS, pRun) );
|
||||
if( pFS->pCompress ){
|
||||
@@ -2067,10 +2062,10 @@ int lsmFsDbPageNext(Segment *pRun, Page *pPg, int eDir, Page **ppNext){
|
||||
** start the new segment immediately following any segment that is part
|
||||
** of the right-hand-side of pLvl.
|
||||
*/
|
||||
static LsmPgno findAppendPoint(FileSystem *pFS, Level *pLvl){
|
||||
static Pgno findAppendPoint(FileSystem *pFS, Level *pLvl){
|
||||
int i;
|
||||
LsmPgno *aiAppend = pFS->pDb->pWorker->aiAppend;
|
||||
LsmPgno iRet = 0;
|
||||
Pgno *aiAppend = pFS->pDb->pWorker->aiAppend;
|
||||
Pgno iRet = 0;
|
||||
|
||||
for(i=LSM_APPLIST_SZ-1; iRet==0 && i>=0; i--){
|
||||
if( (iRet = aiAppend[i]) ){
|
||||
@@ -2103,10 +2098,10 @@ int lsmFsSortedAppend(
|
||||
){
|
||||
int rc = LSM_OK;
|
||||
Page *pPg = 0;
|
||||
LsmPgno iApp = 0;
|
||||
LsmPgno iNext = 0;
|
||||
Pgno iApp = 0;
|
||||
Pgno iNext = 0;
|
||||
Segment *p = &pLvl->lhs;
|
||||
LsmPgno iPrev = p->iLastPg;
|
||||
Pgno iPrev = p->iLastPg;
|
||||
|
||||
*ppOut = 0;
|
||||
assert( p->pRedirect==0 );
|
||||
@@ -2200,7 +2195,7 @@ int lsmFsSortedFinish(FileSystem *pFS, Segment *p){
|
||||
*/
|
||||
if( fsLastPageOnPagesBlock(pFS, p->iLastPg)!=p->iLastPg ){
|
||||
int i;
|
||||
LsmPgno *aiAppend = pFS->pDb->pWorker->aiAppend;
|
||||
Pgno *aiAppend = pFS->pDb->pWorker->aiAppend;
|
||||
for(i=0; i<LSM_APPLIST_SZ; i++){
|
||||
if( aiAppend[i]==0 ){
|
||||
aiAppend[i] = p->iLastPg+1;
|
||||
@@ -2231,7 +2226,7 @@ int lsmFsSortedFinish(FileSystem *pFS, Segment *p){
|
||||
**
|
||||
** Return LSM_OK if successful, or an lsm error code if an error occurs.
|
||||
*/
|
||||
int lsmFsDbPageGet(FileSystem *pFS, Segment *pSeg, LsmPgno iPg, Page **ppPg){
|
||||
int lsmFsDbPageGet(FileSystem *pFS, Segment *pSeg, Pgno iPg, Page **ppPg){
|
||||
return fsPageGet(pFS, pSeg, iPg, 0, ppPg, 0);
|
||||
}
|
||||
|
||||
@@ -2243,7 +2238,7 @@ int lsmFsDbPageGet(FileSystem *pFS, Segment *pSeg, LsmPgno iPg, Page **ppPg){
|
||||
*/
|
||||
int lsmFsDbPageLast(FileSystem *pFS, Segment *pSeg, Page **ppPg){
|
||||
int rc;
|
||||
LsmPgno iPg = pSeg->iLastPg;
|
||||
Pgno iPg = pSeg->iLastPg;
|
||||
if( pFS->pCompress ){
|
||||
int nSpace;
|
||||
iPg++;
|
||||
@@ -2371,14 +2366,14 @@ static void fsMovePage(
|
||||
FileSystem *pFS, /* File system object */
|
||||
int iTo, /* Destination block */
|
||||
int iFrom, /* Source block */
|
||||
LsmPgno *piPg /* IN/OUT: Page number */
|
||||
Pgno *piPg /* IN/OUT: Page number */
|
||||
){
|
||||
LsmPgno iPg = *piPg;
|
||||
Pgno iPg = *piPg;
|
||||
if( iFrom==fsPageToBlock(pFS, iPg) ){
|
||||
const int nPagePerBlock = (
|
||||
pFS->pCompress ? pFS ->nBlocksize : (pFS->nBlocksize / pFS->nPagesize)
|
||||
);
|
||||
*piPg = iPg - (LsmPgno)(iFrom - iTo) * nPagePerBlock;
|
||||
*piPg = iPg - (Pgno)(iFrom - iTo) * nPagePerBlock;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2462,21 +2457,21 @@ int lsmFsMoveBlock(FileSystem *pFS, Segment *pSeg, int iTo, int iFrom){
|
||||
**
|
||||
** This function is only used in compressed database mode.
|
||||
*/
|
||||
static LsmPgno fsAppendData(
|
||||
static Pgno fsAppendData(
|
||||
FileSystem *pFS, /* File-system handle */
|
||||
Segment *pSeg, /* Segment to append to */
|
||||
const u8 *aData, /* Buffer containing data to write */
|
||||
int nData, /* Size of buffer aData[] in bytes */
|
||||
int *pRc /* IN/OUT: Error code */
|
||||
){
|
||||
LsmPgno iRet = 0;
|
||||
Pgno iRet = 0;
|
||||
int rc = *pRc;
|
||||
assert( pFS->pCompress );
|
||||
if( rc==LSM_OK ){
|
||||
int nRem = 0;
|
||||
int nWrite = 0;
|
||||
LsmPgno iLastOnBlock;
|
||||
LsmPgno iApp = pSeg->iLastPg+1;
|
||||
Pgno iLastOnBlock;
|
||||
Pgno iApp = pSeg->iLastPg+1;
|
||||
|
||||
/* If this is the first data written into the segment, find an append-point
|
||||
** or allocate a new block. */
|
||||
@@ -2524,7 +2519,7 @@ static LsmPgno fsAppendData(
|
||||
|
||||
/* Set the "prev" pointer on the new block */
|
||||
if( rc==LSM_OK ){
|
||||
LsmPgno iWrite;
|
||||
Pgno iWrite;
|
||||
lsmPutU32(aPtr, fsPageToBlock(pFS, iApp));
|
||||
iWrite = fsFirstPageOnBlock(pFS, iBlk);
|
||||
rc = lsmEnvWrite(pFS->pEnv, pFS->fdDb, iWrite-4, aPtr, sizeof(aPtr));
|
||||
@@ -2593,11 +2588,11 @@ static int fsCompressIntoBuffer(FileSystem *pFS, Page *pPg){
|
||||
static int fsAppendPage(
|
||||
FileSystem *pFS,
|
||||
Segment *pSeg,
|
||||
LsmPgno *piNew,
|
||||
Pgno *piNew,
|
||||
int *piPrev,
|
||||
int *piNext
|
||||
){
|
||||
LsmPgno iPrev = pSeg->iLastPg;
|
||||
Pgno iPrev = pSeg->iLastPg;
|
||||
int rc;
|
||||
assert( iPrev!=0 );
|
||||
|
||||
@@ -2655,7 +2650,7 @@ void lsmFsFlushWaiting(FileSystem *pFS, int *pRc){
|
||||
/*
|
||||
** If there exists a hash-table entry associated with page iPg, remove it.
|
||||
*/
|
||||
static void fsRemoveHashEntry(FileSystem *pFS, LsmPgno iPg){
|
||||
static void fsRemoveHashEntry(FileSystem *pFS, Pgno iPg){
|
||||
Page *p;
|
||||
int iHash = fsHashKey(pFS->nHash, iPg);
|
||||
|
||||
@@ -2809,8 +2804,8 @@ int lsmFsSortedPadding(
|
||||
){
|
||||
int rc = LSM_OK;
|
||||
if( pFS->pCompress && pSeg->iFirst ){
|
||||
LsmPgno iLast2;
|
||||
LsmPgno iLast = pSeg->iLastPg; /* Current last page of segment */
|
||||
Pgno iLast2;
|
||||
Pgno iLast = pSeg->iLastPg; /* Current last page of segment */
|
||||
int nPad; /* Bytes of padding required */
|
||||
u8 aSz[3];
|
||||
|
||||
@@ -2940,7 +2935,7 @@ int lsmFsSectorSize(FileSystem *pFS){
|
||||
/*
|
||||
** Helper function for lsmInfoArrayStructure().
|
||||
*/
|
||||
static Segment *startsWith(Segment *pRun, LsmPgno iFirst){
|
||||
static Segment *startsWith(Segment *pRun, Pgno iFirst){
|
||||
return (iFirst==pRun->iFirst) ? pRun : 0;
|
||||
}
|
||||
|
||||
@@ -2948,7 +2943,7 @@ static Segment *startsWith(Segment *pRun, LsmPgno iFirst){
|
||||
** Return the segment that starts with page iFirst, if any. If no such segment
|
||||
** can be found, return NULL.
|
||||
*/
|
||||
static Segment *findSegment(Snapshot *pWorker, LsmPgno iFirst){
|
||||
static Segment *findSegment(Snapshot *pWorker, Pgno iFirst){
|
||||
Level *pLvl; /* Used to iterate through db levels */
|
||||
Segment *pSeg = 0; /* Pointer to segment to return */
|
||||
|
||||
@@ -2975,7 +2970,7 @@ static Segment *findSegment(Snapshot *pWorker, LsmPgno iFirst){
|
||||
int lsmInfoArrayStructure(
|
||||
lsm_db *pDb,
|
||||
int bBlock, /* True for block numbers only */
|
||||
LsmPgno iFirst,
|
||||
Pgno iFirst,
|
||||
char **pzOut
|
||||
){
|
||||
int rc = LSM_OK;
|
||||
@@ -3040,7 +3035,7 @@ int lsmInfoArrayStructure(
|
||||
int lsmFsSegmentContainsPg(
|
||||
FileSystem *pFS,
|
||||
Segment *pSeg,
|
||||
LsmPgno iPg,
|
||||
Pgno iPg,
|
||||
int *pbRes
|
||||
){
|
||||
Redirect *pRedir = pSeg->pRedirect;
|
||||
@@ -3069,7 +3064,7 @@ int lsmFsSegmentContainsPg(
|
||||
**
|
||||
** If an error occurs, *pzOut is set to NULL and an LSM error code returned.
|
||||
*/
|
||||
int lsmInfoArrayPages(lsm_db *pDb, LsmPgno iFirst, char **pzOut){
|
||||
int lsmInfoArrayPages(lsm_db *pDb, Pgno iFirst, char **pzOut){
|
||||
int rc = LSM_OK;
|
||||
Snapshot *pWorker; /* Worker snapshot */
|
||||
Segment *pSeg = 0; /* Array to report on */
|
||||
@@ -3302,7 +3297,7 @@ int lsmFsIntegrityCheck(lsm_db *pDb){
|
||||
*/
|
||||
int lsmFsDbPageIsLast(Segment *pSeg, Page *pPg){
|
||||
if( pPg->pFS->pCompress ){
|
||||
LsmPgno iNext = 0;
|
||||
Pgno iNext = 0;
|
||||
int rc;
|
||||
rc = fsNextPageOffset(pPg->pFS, pSeg, pPg->iPg, pPg->nCompress+6, &iNext);
|
||||
return (rc!=LSM_OK || iNext==0);
|
||||
|
||||
+3
-3
@@ -583,14 +583,14 @@ int lsm_info(lsm_db *pDb, int eParam, ...){
|
||||
}
|
||||
|
||||
case LSM_INFO_ARRAY_STRUCTURE: {
|
||||
LsmPgno pgno = va_arg(ap, LsmPgno);
|
||||
Pgno pgno = va_arg(ap, Pgno);
|
||||
char **pzVal = va_arg(ap, char **);
|
||||
rc = lsmInfoArrayStructure(pDb, 0, pgno, pzVal);
|
||||
break;
|
||||
}
|
||||
|
||||
case LSM_INFO_ARRAY_PAGES: {
|
||||
LsmPgno pgno = va_arg(ap, LsmPgno);
|
||||
Pgno pgno = va_arg(ap, Pgno);
|
||||
char **pzVal = va_arg(ap, char **);
|
||||
rc = lsmInfoArrayPages(pDb, pgno, pzVal);
|
||||
break;
|
||||
@@ -598,7 +598,7 @@ int lsm_info(lsm_db *pDb, int eParam, ...){
|
||||
|
||||
case LSM_INFO_PAGE_HEX_DUMP:
|
||||
case LSM_INFO_PAGE_ASCII_DUMP: {
|
||||
LsmPgno pgno = va_arg(ap, LsmPgno);
|
||||
Pgno pgno = va_arg(ap, Pgno);
|
||||
char **pzVal = va_arg(ap, char **);
|
||||
int bUnlock = 0;
|
||||
rc = infoGetWorker(pDb, 0, &bUnlock);
|
||||
|
||||
+80
-80
@@ -104,9 +104,9 @@
|
||||
#endif
|
||||
|
||||
typedef struct SegmentPtr SegmentPtr;
|
||||
typedef struct LsmBlob LsmBlob;
|
||||
typedef struct Blob Blob;
|
||||
|
||||
struct LsmBlob {
|
||||
struct Blob {
|
||||
lsm_env *pEnv;
|
||||
void *pData;
|
||||
int nData;
|
||||
@@ -129,18 +129,18 @@ struct SegmentPtr {
|
||||
Page *pPg; /* Current page */
|
||||
u16 flags; /* Copy of page flags field */
|
||||
int nCell; /* Number of cells on pPg */
|
||||
LsmPgno iPtr; /* Base cascade pointer */
|
||||
Pgno iPtr; /* Base cascade pointer */
|
||||
|
||||
/* Current cell. See segmentPtrLoadCell() */
|
||||
int iCell; /* Current record within page pPg */
|
||||
int eType; /* Type of current record */
|
||||
LsmPgno iPgPtr; /* Cascade pointer offset */
|
||||
Pgno iPgPtr; /* Cascade pointer offset */
|
||||
void *pKey; int nKey; /* Key associated with current record */
|
||||
void *pVal; int nVal; /* Current record value (eType==WRITE only) */
|
||||
|
||||
/* Blobs used to allocate buffers for pKey and pVal as required */
|
||||
LsmBlob blob1;
|
||||
LsmBlob blob2;
|
||||
Blob blob1;
|
||||
Blob blob2;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -171,10 +171,10 @@ struct BtreeCursor {
|
||||
void *pKey;
|
||||
int nKey;
|
||||
int eType;
|
||||
LsmPgno iPtr;
|
||||
Pgno iPtr;
|
||||
|
||||
/* Storage for key, if not local */
|
||||
LsmBlob blob;
|
||||
Blob blob;
|
||||
};
|
||||
|
||||
|
||||
@@ -203,8 +203,8 @@ struct MultiCursor {
|
||||
int flags; /* Mask of CURSOR_XXX flags */
|
||||
|
||||
int eType; /* Cache of current key type */
|
||||
LsmBlob key; /* Cache of current key (or NULL) */
|
||||
LsmBlob val; /* Cache of current value */
|
||||
Blob key; /* Cache of current key (or NULL) */
|
||||
Blob val; /* Cache of current value */
|
||||
|
||||
/* All the component cursors: */
|
||||
TreeCursor *apTreeCsr[2]; /* Up to two tree cursors */
|
||||
@@ -221,7 +221,7 @@ struct MultiCursor {
|
||||
void *pSystemVal; /* Pointer to buffer to free */
|
||||
|
||||
/* Used by worker cursors only */
|
||||
LsmPgno *pPrevMergePtr;
|
||||
Pgno *pPrevMergePtr;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -295,11 +295,11 @@ struct MergeWorker {
|
||||
Hierarchy hier; /* B-tree hierarchy under construction */
|
||||
Page *pPage; /* Current output page */
|
||||
int nWork; /* Number of calls to mergeWorkerNextPage() */
|
||||
LsmPgno *aGobble; /* Gobble point for each input segment */
|
||||
Pgno *aGobble; /* Gobble point for each input segment */
|
||||
|
||||
LsmPgno iIndirect;
|
||||
Pgno iIndirect;
|
||||
struct SavedPgno {
|
||||
LsmPgno iPgno;
|
||||
Pgno iPgno;
|
||||
int bStore;
|
||||
} aSave[2];
|
||||
};
|
||||
@@ -371,7 +371,7 @@ void lsmPutU64(u8 *aOut, u64 nVal){
|
||||
aOut[7] = (u8)((nVal ) & 0xFF);
|
||||
}
|
||||
|
||||
static int sortedBlobGrow(lsm_env *pEnv, LsmBlob *pBlob, int nData){
|
||||
static int sortedBlobGrow(lsm_env *pEnv, Blob *pBlob, int nData){
|
||||
assert( pBlob->pEnv==pEnv || (pBlob->pEnv==0 && pBlob->pData==0) );
|
||||
if( pBlob->nAlloc<nData ){
|
||||
pBlob->pData = lsmReallocOrFree(pEnv, pBlob->pData, nData);
|
||||
@@ -382,7 +382,7 @@ static int sortedBlobGrow(lsm_env *pEnv, LsmBlob *pBlob, int nData){
|
||||
return LSM_OK;
|
||||
}
|
||||
|
||||
static int sortedBlobSet(lsm_env *pEnv, LsmBlob *pBlob, void *pData, int nData){
|
||||
static int sortedBlobSet(lsm_env *pEnv, Blob *pBlob, void *pData, int nData){
|
||||
if( sortedBlobGrow(pEnv, pBlob, nData) ) return LSM_NOMEM;
|
||||
memcpy(pBlob->pData, pData, nData);
|
||||
pBlob->nData = nData;
|
||||
@@ -390,15 +390,15 @@ static int sortedBlobSet(lsm_env *pEnv, LsmBlob *pBlob, void *pData, int nData){
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int sortedBlobCopy(LsmBlob *pDest, LsmBlob *pSrc){
|
||||
static int sortedBlobCopy(Blob *pDest, Blob *pSrc){
|
||||
return sortedBlobSet(pDest, pSrc->pData, pSrc->nData);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void sortedBlobFree(LsmBlob *pBlob){
|
||||
static void sortedBlobFree(Blob *pBlob){
|
||||
assert( pBlob->pEnv || pBlob->pData==0 );
|
||||
if( pBlob->pData ) lsmFree(pBlob->pEnv, pBlob->pData);
|
||||
memset(pBlob, 0, sizeof(LsmBlob));
|
||||
memset(pBlob, 0, sizeof(Blob));
|
||||
}
|
||||
|
||||
static int sortedReadData(
|
||||
@@ -407,7 +407,7 @@ static int sortedReadData(
|
||||
int iOff,
|
||||
int nByte,
|
||||
void **ppData,
|
||||
LsmBlob *pBlob
|
||||
Blob *pBlob
|
||||
){
|
||||
int rc = LSM_OK;
|
||||
int iEnd;
|
||||
@@ -481,8 +481,8 @@ static int pageGetNRec(u8 *aData, int nData){
|
||||
return (int)lsmGetU16(&aData[SEGMENT_NRECORD_OFFSET(nData)]);
|
||||
}
|
||||
|
||||
static LsmPgno pageGetPtr(u8 *aData, int nData){
|
||||
return (LsmPgno)lsmGetU64(&aData[SEGMENT_POINTER_OFFSET(nData)]);
|
||||
static Pgno pageGetPtr(u8 *aData, int nData){
|
||||
return (Pgno)lsmGetU64(&aData[SEGMENT_POINTER_OFFSET(nData)]);
|
||||
}
|
||||
|
||||
static int pageGetFlags(u8 *aData, int nData){
|
||||
@@ -506,8 +506,8 @@ static int pageObjGetNRec(Page *pPg){
|
||||
** Return the decoded (possibly relative) pointer value stored in cell
|
||||
** iCell from page aData/nData.
|
||||
*/
|
||||
static LsmPgno pageGetRecordPtr(u8 *aData, int nData, int iCell){
|
||||
LsmPgno iRet; /* Return value */
|
||||
static Pgno pageGetRecordPtr(u8 *aData, int nData, int iCell){
|
||||
Pgno iRet; /* Return value */
|
||||
u8 *aCell; /* Pointer to cell iCell */
|
||||
|
||||
assert( iCell<pageGetNRec(aData, nData) && iCell>=0 );
|
||||
@@ -522,7 +522,7 @@ static u8 *pageGetKey(
|
||||
int iCell, /* Index of cell on page to read */
|
||||
int *piTopic, /* OUT: Topic associated with this key */
|
||||
int *pnKey, /* OUT: Size of key in bytes */
|
||||
LsmBlob *pBlob /* If required, use this for dynamic memory */
|
||||
Blob *pBlob /* If required, use this for dynamic memory */
|
||||
){
|
||||
u8 *pKey;
|
||||
int nDummy;
|
||||
@@ -554,7 +554,7 @@ static int pageGetKeyCopy(
|
||||
Page *pPg, /* Page to read from */
|
||||
int iCell, /* Index of cell on page to read */
|
||||
int *piTopic, /* OUT: Topic associated with this key */
|
||||
LsmBlob *pBlob /* If required, use this for dynamic memory */
|
||||
Blob *pBlob /* If required, use this for dynamic memory */
|
||||
){
|
||||
int rc = LSM_OK;
|
||||
int nKey;
|
||||
@@ -569,8 +569,8 @@ static int pageGetKeyCopy(
|
||||
return rc;
|
||||
}
|
||||
|
||||
static LsmPgno pageGetBtreeRef(Page *pPg, int iKey){
|
||||
LsmPgno iRef;
|
||||
static Pgno pageGetBtreeRef(Page *pPg, int iKey){
|
||||
Pgno iRef;
|
||||
u8 *aData;
|
||||
int nData;
|
||||
u8 *aCell;
|
||||
@@ -592,11 +592,11 @@ static int pageGetBtreeKey(
|
||||
Segment *pSeg, /* Segment page pPg belongs to */
|
||||
Page *pPg,
|
||||
int iKey,
|
||||
LsmPgno *piPtr,
|
||||
Pgno *piPtr,
|
||||
int *piTopic,
|
||||
void **ppKey,
|
||||
int *pnKey,
|
||||
LsmBlob *pBlob
|
||||
Blob *pBlob
|
||||
){
|
||||
u8 *aData;
|
||||
int nData;
|
||||
@@ -613,7 +613,7 @@ static int pageGetBtreeKey(
|
||||
|
||||
if( eType==0 ){
|
||||
int rc;
|
||||
LsmPgno iRef; /* Page number of referenced page */
|
||||
Pgno iRef; /* Page number of referenced page */
|
||||
Page *pRef;
|
||||
aCell += GETVARINT64(aCell, iRef);
|
||||
rc = lsmFsDbPageGet(lsmPageFS(pPg), pSeg, iRef, &pRef);
|
||||
@@ -638,7 +638,7 @@ static int btreeCursorLoadKey(BtreeCursor *pCsr){
|
||||
pCsr->nKey = 0;
|
||||
pCsr->eType = 0;
|
||||
}else{
|
||||
LsmPgno dummy;
|
||||
Pgno dummy;
|
||||
int iPg = pCsr->iPg;
|
||||
int iCell = pCsr->aPg[iPg].iCell;
|
||||
while( iCell<0 && (--iPg)>=0 ){
|
||||
@@ -683,7 +683,7 @@ static int btreeCursorNext(BtreeCursor *pCsr){
|
||||
assert( pPg->iCell<=nCell );
|
||||
pPg->iCell++;
|
||||
if( pPg->iCell==nCell ){
|
||||
LsmPgno iLoad;
|
||||
Pgno iLoad;
|
||||
|
||||
/* Up to parent. */
|
||||
lsmFsPageRelease(pPg->pPage);
|
||||
@@ -842,7 +842,7 @@ static int btreeCursorRestore(
|
||||
if( p->iPg ){
|
||||
lsm_env *pEnv = lsmFsEnv(pCsr->pFS);
|
||||
int iCell; /* Current cell number on leaf page */
|
||||
LsmPgno iLeaf; /* Page number of current leaf page */
|
||||
Pgno iLeaf; /* Page number of current leaf page */
|
||||
int nDepth; /* Depth of b-tree structure */
|
||||
Segment *pSeg = pCsr->pSeg;
|
||||
|
||||
@@ -866,7 +866,7 @@ static int btreeCursorRestore(
|
||||
|
||||
/* Populate any other aPg[] array entries */
|
||||
if( rc==LSM_OK && nDepth>1 ){
|
||||
LsmBlob blob = {0,0,0};
|
||||
Blob blob = {0,0,0};
|
||||
void *pSeek;
|
||||
int nSeek;
|
||||
int iTopicSeek;
|
||||
@@ -883,7 +883,7 @@ static int btreeCursorRestore(
|
||||
pSeek = 0;
|
||||
nSeek = 0;
|
||||
}else{
|
||||
LsmPgno dummy;
|
||||
Pgno dummy;
|
||||
rc = pageGetBtreeKey(pSeg, pPg,
|
||||
0, &dummy, &iTopicSeek, &pSeek, &nSeek, &pCsr->blob
|
||||
);
|
||||
@@ -912,7 +912,7 @@ static int btreeCursorRestore(
|
||||
int iTry = (iMin+iMax)/2;
|
||||
void *pKey; int nKey; /* Key for cell iTry */
|
||||
int iTopic; /* Topic for key pKeyT/nKeyT */
|
||||
LsmPgno iPtr; /* Pointer for cell iTry */
|
||||
Pgno iPtr; /* Pointer for cell iTry */
|
||||
int res; /* (pSeek - pKeyT) */
|
||||
|
||||
rc = pageGetBtreeKey(
|
||||
@@ -955,7 +955,7 @@ static int btreeCursorRestore(
|
||||
aData = fsPageData(pBtreePg->pPage, &nData);
|
||||
pCsr->iPtr = btreeCursorPtr(aData, nData, pBtreePg->iCell+1);
|
||||
if( pBtreePg->iCell<0 ){
|
||||
LsmPgno dummy;
|
||||
Pgno dummy;
|
||||
int i;
|
||||
for(i=pCsr->iPg-1; i>=0; i--){
|
||||
if( pCsr->aPg[i].iCell>0 ) break;
|
||||
@@ -1030,7 +1030,7 @@ static int segmentPtrReadData(
|
||||
int iOff,
|
||||
int nByte,
|
||||
void **ppData,
|
||||
LsmBlob *pBlob
|
||||
Blob *pBlob
|
||||
){
|
||||
return sortedReadData(pPtr->pSeg, pPtr->pPg, iOff, nByte, ppData, pBlob);
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ static void sortedSplitkey(lsm_db *pDb, Level *pLevel, int *pRc){
|
||||
}
|
||||
if( rc==LSM_OK ){
|
||||
int iTopic;
|
||||
LsmBlob blob = {0, 0, 0, 0};
|
||||
Blob blob = {0, 0, 0, 0};
|
||||
u8 *aData;
|
||||
int nData;
|
||||
|
||||
@@ -1131,7 +1131,7 @@ static void sortedSplitkey(lsm_db *pDb, Level *pLevel, int *pRc){
|
||||
if( pageGetFlags(aData, nData) & SEGMENT_BTREE_FLAG ){
|
||||
void *pKey;
|
||||
int nKey;
|
||||
LsmPgno dummy;
|
||||
Pgno dummy;
|
||||
rc = pageGetBtreeKey(pSeg,
|
||||
pPg, pMerge->splitkey.iCell, &dummy, &iTopic, &pKey, &nKey, &blob
|
||||
);
|
||||
@@ -1342,7 +1342,7 @@ static int assertKeyLocation(
|
||||
void *pKey, int nKey
|
||||
){
|
||||
lsm_env *pEnv = lsmFsEnv(pCsr->pDb->pFS);
|
||||
LsmBlob blob = {0, 0, 0};
|
||||
Blob blob = {0, 0, 0};
|
||||
int eDir;
|
||||
int iTopic = 0; /* TODO: Fix me */
|
||||
|
||||
@@ -1488,7 +1488,7 @@ static int ptrFwdPointer(
|
||||
Page *pPage,
|
||||
int iCell,
|
||||
Segment *pSeg,
|
||||
LsmPgno *piPtr,
|
||||
Pgno *piPtr,
|
||||
int *pbFound
|
||||
){
|
||||
Page *pPg = pPage;
|
||||
@@ -1573,14 +1573,14 @@ static int sortedRhsFirst(MultiCursor *pCsr, Level *pLvl, SegmentPtr *pPtr){
|
||||
static int segmentPtrFwdPointer(
|
||||
MultiCursor *pCsr, /* Multi-cursor pPtr belongs to */
|
||||
SegmentPtr *pPtr, /* Segment-pointer to extract FC ptr from */
|
||||
LsmPgno *piPtr /* OUT: FC pointer value */
|
||||
Pgno *piPtr /* OUT: FC pointer value */
|
||||
){
|
||||
Level *pLvl = pPtr->pLevel;
|
||||
Level *pNext = pLvl->pNext;
|
||||
Page *pPg = pPtr->pPg;
|
||||
int rc;
|
||||
int bFound;
|
||||
LsmPgno iOut = 0;
|
||||
Pgno iOut = 0;
|
||||
|
||||
if( pPtr->pSeg==&pLvl->lhs || pPtr->pSeg==&pLvl->aRhs[pLvl->nRight-1] ){
|
||||
if( pNext==0
|
||||
@@ -1641,7 +1641,7 @@ static int segmentPtrSeek(
|
||||
int rc = LSM_OK;
|
||||
int iMin;
|
||||
int iMax;
|
||||
LsmPgno iPtrOut = 0;
|
||||
Pgno iPtrOut = 0;
|
||||
|
||||
/* If the current page contains an oversized entry, then there are no
|
||||
** pointers to one or more of the subsequent pages in the sorted run.
|
||||
@@ -1768,18 +1768,18 @@ static int seekInBtree(
|
||||
Segment *pSeg, /* Seek within this segment */
|
||||
int iTopic,
|
||||
void *pKey, int nKey, /* Key to seek to */
|
||||
LsmPgno *aPg, /* OUT: Page numbers */
|
||||
Pgno *aPg, /* OUT: Page numbers */
|
||||
Page **ppPg /* OUT: Leaf (sorted-run) page reference */
|
||||
){
|
||||
int i = 0;
|
||||
int rc;
|
||||
int iPg;
|
||||
Page *pPg = 0;
|
||||
LsmBlob blob = {0, 0, 0};
|
||||
Blob blob = {0, 0, 0};
|
||||
|
||||
iPg = (int)pSeg->iRoot;
|
||||
do {
|
||||
LsmPgno *piFirst = 0;
|
||||
Pgno *piFirst = 0;
|
||||
if( aPg ){
|
||||
aPg[i++] = iPg;
|
||||
piFirst = &aPg[i];
|
||||
@@ -1808,7 +1808,7 @@ static int seekInBtree(
|
||||
int iTry = (iMin+iMax)/2;
|
||||
void *pKeyT; int nKeyT; /* Key for cell iTry */
|
||||
int iTopicT; /* Topic for key pKeyT/nKeyT */
|
||||
LsmPgno iPtr; /* Pointer associated with cell iTry */
|
||||
Pgno iPtr; /* Pointer associated with cell iTry */
|
||||
int res; /* (pKey - pKeyT) */
|
||||
|
||||
rc = pageGetBtreeKey(
|
||||
@@ -1899,7 +1899,7 @@ static int seekInLevel(
|
||||
int eSeek, /* Search bias - see above */
|
||||
int iTopic, /* Key topic to search for */
|
||||
void *pKey, int nKey, /* Key to search for */
|
||||
LsmPgno *piPgno, /* IN/OUT: fraction cascade pointer (or 0) */
|
||||
Pgno *piPgno, /* IN/OUT: fraction cascade pointer (or 0) */
|
||||
int *pbStop /* OUT: See above */
|
||||
){
|
||||
Level *pLvl = aPtr[0].pLevel; /* Level to seek within */
|
||||
@@ -3055,7 +3055,7 @@ int lsmMCursorSeek(
|
||||
int bStop = 0; /* Set to true to halt search operation */
|
||||
int rc = LSM_OK; /* Return code */
|
||||
int iPtr = 0; /* Used to iterate through pCsr->aPtr[] */
|
||||
LsmPgno iPgno = 0; /* FC pointer value */
|
||||
Pgno iPgno = 0; /* FC pointer value */
|
||||
|
||||
assert( pCsr->apTreeCsr[0]==0 || iTopic==0 );
|
||||
assert( pCsr->apTreeCsr[1]==0 || iTopic==0 );
|
||||
@@ -3537,7 +3537,7 @@ static int mergeWorkerLoadHierarchy(MergeWorker *pMW){
|
||||
** + Type byte (always SORTED_SEPARATOR or SORTED_SYSTEM_SEPARATOR),
|
||||
** + Absolute pointer value (varint),
|
||||
** + Number of bytes in key (varint),
|
||||
** + LsmBlob containing key data.
|
||||
** + Blob containing key data.
|
||||
**
|
||||
** 2. All pointer values are stored as absolute values (not offsets
|
||||
** relative to the footer pointer value).
|
||||
@@ -3571,8 +3571,8 @@ static int mergeWorkerLoadHierarchy(MergeWorker *pMW){
|
||||
static int mergeWorkerBtreeWrite(
|
||||
MergeWorker *pMW,
|
||||
u8 eType,
|
||||
LsmPgno iPtr,
|
||||
LsmPgno iKeyPg,
|
||||
Pgno iPtr,
|
||||
Pgno iKeyPg,
|
||||
void *pKey,
|
||||
int nKey
|
||||
){
|
||||
@@ -3682,7 +3682,7 @@ static int mergeWorkerBtreeWrite(
|
||||
static int mergeWorkerBtreeIndirect(MergeWorker *pMW){
|
||||
int rc = LSM_OK;
|
||||
if( pMW->iIndirect ){
|
||||
LsmPgno iKeyPg = pMW->aSave[1].iPgno;
|
||||
Pgno iKeyPg = pMW->aSave[1].iPgno;
|
||||
rc = mergeWorkerBtreeWrite(pMW, 0, pMW->iIndirect, iKeyPg, 0, 0);
|
||||
pMW->iIndirect = 0;
|
||||
}
|
||||
@@ -3703,7 +3703,7 @@ static int mergeWorkerPushHierarchy(
|
||||
int nKey /* Size of pKey buffer in bytes */
|
||||
){
|
||||
int rc = LSM_OK; /* Return Code */
|
||||
LsmPgno iPtr; /* Pointer value to accompany pKey/nKey */
|
||||
Pgno iPtr; /* Pointer value to accompany pKey/nKey */
|
||||
|
||||
assert( pMW->aSave[0].bStore==0 );
|
||||
assert( pMW->aSave[1].bStore==0 );
|
||||
@@ -3734,7 +3734,7 @@ static int mergeWorkerFinishHierarchy(
|
||||
){
|
||||
int i; /* Used to loop through apHier[] */
|
||||
int rc = LSM_OK; /* Return code */
|
||||
LsmPgno iPtr; /* New right-hand-child pointer value */
|
||||
Pgno iPtr; /* New right-hand-child pointer value */
|
||||
|
||||
iPtr = pMW->aSave[0].iPgno;
|
||||
for(i=0; i<pMW->hier.nHier && rc==LSM_OK; i++){
|
||||
@@ -3830,7 +3830,7 @@ static int mergeWorkerPersistAndRelease(MergeWorker *pMW){
|
||||
*/
|
||||
static int mergeWorkerNextPage(
|
||||
MergeWorker *pMW, /* Merge worker object to append page to */
|
||||
LsmPgno iFPtr /* Pointer value for footer of new page */
|
||||
Pgno iFPtr /* Pointer value for footer of new page */
|
||||
){
|
||||
int rc = LSM_OK; /* Return code */
|
||||
Page *pNext = 0; /* New page appended to run */
|
||||
@@ -4218,7 +4218,7 @@ static int mergeWorkerStep(MergeWorker *pMW){
|
||||
int rc = LSM_OK; /* Return code */
|
||||
int eType; /* SORTED_SEPARATOR, WRITE or DELETE */
|
||||
void *pKey; int nKey; /* Key */
|
||||
LsmPgno iPtr;
|
||||
Pgno iPtr;
|
||||
int iVal;
|
||||
|
||||
pCsr = pMW->pCsr;
|
||||
@@ -4371,7 +4371,7 @@ static int sortedNewToplevel(
|
||||
if( rc!=LSM_OK ){
|
||||
lsmMCursorClose(pCsr, 0);
|
||||
}else{
|
||||
LsmPgno iLeftPtr = 0;
|
||||
Pgno iLeftPtr = 0;
|
||||
Merge merge; /* Merge object used to create new level */
|
||||
MergeWorker mergeworker; /* MergeWorker object for the same purpose */
|
||||
|
||||
@@ -4548,7 +4548,7 @@ static int mergeWorkerInit(
|
||||
memset(pMW, 0, sizeof(MergeWorker));
|
||||
pMW->pDb = pDb;
|
||||
pMW->pLevel = pLevel;
|
||||
pMW->aGobble = lsmMallocZeroRc(pDb->pEnv, sizeof(LsmPgno)*pLevel->nRight,&rc);
|
||||
pMW->aGobble = lsmMallocZeroRc(pDb->pEnv, sizeof(Pgno) * pLevel->nRight, &rc);
|
||||
|
||||
/* Create a multi-cursor to read the data to write to the new
|
||||
** segment. The new segment contains:
|
||||
@@ -4630,7 +4630,7 @@ static int sortedBtreeGobble(
|
||||
int rc = LSM_OK;
|
||||
if( rtTopic(pCsr->eType)==0 ){
|
||||
Segment *pSeg = pCsr->aPtr[iGobble].pSeg;
|
||||
LsmPgno *aPg;
|
||||
Pgno *aPg;
|
||||
int nPg;
|
||||
|
||||
/* Seek from the root of the b-tree to the segment leaf that may contain
|
||||
@@ -4639,7 +4639,7 @@ static int sortedBtreeGobble(
|
||||
** gobbled up to (but not including) the first of these page numbers.
|
||||
*/
|
||||
assert( pSeg->iRoot>0 );
|
||||
aPg = lsmMallocZeroRc(pDb->pEnv, sizeof(LsmPgno)*32, &rc);
|
||||
aPg = lsmMallocZeroRc(pDb->pEnv, sizeof(Pgno)*32, &rc);
|
||||
if( rc==LSM_OK ){
|
||||
rc = seekInBtree(pCsr, pSeg,
|
||||
rtTopic(pCsr->eType), pCsr->key.pData, pCsr->key.nData, aPg, 0
|
||||
@@ -5466,9 +5466,9 @@ int lsmFlushTreeToDisk(lsm_db *pDb){
|
||||
*/
|
||||
static char *segToString(lsm_env *pEnv, Segment *pSeg, int nMin){
|
||||
int nSize = pSeg->nSize;
|
||||
LsmPgno iRoot = pSeg->iRoot;
|
||||
LsmPgno iFirst = pSeg->iFirst;
|
||||
LsmPgno iLast = pSeg->iLastPg;
|
||||
Pgno iRoot = pSeg->iRoot;
|
||||
Pgno iFirst = pSeg->iFirst;
|
||||
Pgno iLast = pSeg->iLastPg;
|
||||
char *z;
|
||||
|
||||
char *z1;
|
||||
@@ -5527,7 +5527,7 @@ static int fileToString(
|
||||
}
|
||||
|
||||
void sortedDumpPage(lsm_db *pDb, Segment *pRun, Page *pPg, int bVals){
|
||||
LsmBlob blob = {0, 0, 0}; /* LsmBlob used for keys */
|
||||
Blob blob = {0, 0, 0}; /* Blob used for keys */
|
||||
LsmString s;
|
||||
int i;
|
||||
|
||||
@@ -5563,7 +5563,7 @@ void sortedDumpPage(lsm_db *pDb, Segment *pRun, Page *pPg, int bVals){
|
||||
aCell += lsmVarintGet32(aCell, &iPgPtr);
|
||||
|
||||
if( eType==0 ){
|
||||
LsmPgno iRef; /* Page number of referenced page */
|
||||
Pgno iRef; /* Page number of referenced page */
|
||||
aCell += lsmVarintGet64(aCell, &iRef);
|
||||
lsmFsDbPageGet(pDb->pFS, pRun, iRef, &pRef);
|
||||
aKey = pageGetKey(pRun, pRef, 0, &iTopic, &nKey, &blob);
|
||||
@@ -5607,7 +5607,7 @@ static void infoCellDump(
|
||||
int *piPgPtr,
|
||||
u8 **paKey, int *pnKey,
|
||||
u8 **paVal, int *pnVal,
|
||||
LsmBlob *pBlob
|
||||
Blob *pBlob
|
||||
){
|
||||
u8 *aData; int nData; /* Page data */
|
||||
u8 *aKey; int nKey = 0; /* Key */
|
||||
@@ -5625,7 +5625,7 @@ static void infoCellDump(
|
||||
|
||||
if( eType==0 ){
|
||||
int dummy;
|
||||
LsmPgno iRef; /* Page number of referenced page */
|
||||
Pgno iRef; /* Page number of referenced page */
|
||||
aCell += lsmVarintGet64(aCell, &iRef);
|
||||
if( bIndirect ){
|
||||
lsmFsDbPageGet(pDb->pFS, pSeg, iRef, &pRef);
|
||||
@@ -5671,7 +5671,7 @@ static int infoAppendBlob(LsmString *pStr, int bHex, u8 *z, int n){
|
||||
|
||||
static int infoPageDump(
|
||||
lsm_db *pDb, /* Database handle */
|
||||
LsmPgno iPg, /* Page number of page to dump */
|
||||
Pgno iPg, /* Page number of page to dump */
|
||||
int flags,
|
||||
char **pzOut /* OUT: lsmMalloc'd string */
|
||||
){
|
||||
@@ -5712,7 +5712,7 @@ static int infoPageDump(
|
||||
}
|
||||
|
||||
if( rc==LSM_OK ){
|
||||
LsmBlob blob = {0, 0, 0, 0};
|
||||
Blob blob = {0, 0, 0, 0};
|
||||
int nKeyWidth = 0;
|
||||
LsmString str;
|
||||
int nRec;
|
||||
@@ -5747,7 +5747,7 @@ static int infoPageDump(
|
||||
u8 *aVal; int nVal = 0; /* Value */
|
||||
int iPgPtr;
|
||||
int eType;
|
||||
LsmPgno iAbsPtr;
|
||||
Pgno iAbsPtr;
|
||||
char zFlags[8];
|
||||
|
||||
infoCellDump(pDb, pSeg, bIndirect, pPg, iCell, &eType, &iPgPtr,
|
||||
@@ -5813,7 +5813,7 @@ static int infoPageDump(
|
||||
|
||||
int lsmInfoPageDump(
|
||||
lsm_db *pDb, /* Database handle */
|
||||
LsmPgno iPg, /* Page number of page to dump */
|
||||
Pgno iPg, /* Page number of page to dump */
|
||||
int bHex, /* True to output key/value in hex form */
|
||||
char **pzOut /* OUT: lsmMalloc'd string */
|
||||
){
|
||||
@@ -5989,8 +5989,8 @@ void lsmSortedExpandBtreePage(Page *pPg, int nOrig){
|
||||
#ifdef LSM_DEBUG_EXPENSIVE
|
||||
static void assertRunInOrder(lsm_db *pDb, Segment *pSeg){
|
||||
Page *pPg = 0;
|
||||
LsmBlob blob1 = {0, 0, 0, 0};
|
||||
LsmBlob blob2 = {0, 0, 0, 0};
|
||||
Blob blob1 = {0, 0, 0, 0};
|
||||
Blob blob2 = {0, 0, 0, 0};
|
||||
|
||||
lsmFsDbPageGet(pDb->pFS, pSeg, pSeg->iFirst, &pPg);
|
||||
while( pPg ){
|
||||
@@ -6052,7 +6052,7 @@ static int assertPointersOk(
|
||||
int rc = LSM_OK; /* Error code */
|
||||
SegmentPtr ptr1; /* Iterates through pOne */
|
||||
SegmentPtr ptr2; /* Iterates through pTwo */
|
||||
LsmPgno iPrev;
|
||||
Pgno iPrev;
|
||||
|
||||
assert( pOne && pTwo );
|
||||
|
||||
@@ -6075,7 +6075,7 @@ static int assertPointersOk(
|
||||
}
|
||||
|
||||
while( rc==LSM_OK && ptr2.pPg ){
|
||||
LsmPgno iThis;
|
||||
Pgno iThis;
|
||||
|
||||
/* Advance to the next page of segment pTwo that contains at least
|
||||
** one cell. Break out of the loop if the iterator reaches EOF. */
|
||||
@@ -6137,7 +6137,7 @@ static int assertBtreeOk(
|
||||
){
|
||||
int rc = LSM_OK; /* Return code */
|
||||
if( pSeg->iRoot ){
|
||||
LsmBlob blob = {0, 0, 0}; /* Buffer used to cache overflow keys */
|
||||
Blob blob = {0, 0, 0}; /* Buffer used to cache overflow keys */
|
||||
FileSystem *pFS = pDb->pFS; /* File system to read from */
|
||||
Page *pPg = 0; /* Main run page */
|
||||
BtreeCursor *pCsr = 0; /* Btree cursor */
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
#!/bin/sh
|
||||
# restart with tclsh \
|
||||
exec tclsh "$0" "$@"
|
||||
|
||||
set srcdir [file dirname [file dirname [info script]]]
|
||||
set G(src) [string map [list %dir% $srcdir] {
|
||||
%dir%/lsm.h
|
||||
%dir%/lsmInt.h
|
||||
%dir%/lsm_vtab.c
|
||||
%dir%/lsm_ckpt.c
|
||||
%dir%/lsm_file.c
|
||||
%dir%/lsm_log.c
|
||||
%dir%/lsm_main.c
|
||||
%dir%/lsm_mem.c
|
||||
%dir%/lsm_mutex.c
|
||||
%dir%/lsm_shared.c
|
||||
%dir%/lsm_sorted.c
|
||||
%dir%/lsm_str.c
|
||||
%dir%/lsm_tree.c
|
||||
%dir%/lsm_unix.c
|
||||
%dir%/lsm_varint.c
|
||||
%dir%/lsm_win32.c
|
||||
}]
|
||||
|
||||
set G(hdr) {
|
||||
|
||||
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_LSM1)
|
||||
|
||||
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
|
||||
# define NDEBUG 1
|
||||
#endif
|
||||
#if defined(NDEBUG) && defined(SQLITE_DEBUG)
|
||||
# undef NDEBUG
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
set G(footer) {
|
||||
|
||||
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_LSM1) */
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Read and return the entire contents of text file $zFile from disk.
|
||||
#
|
||||
proc readfile {zFile} {
|
||||
set fd [open $zFile]
|
||||
set data [read $fd]
|
||||
close $fd
|
||||
return $data
|
||||
}
|
||||
|
||||
proc lsm1c_init {zOut} {
|
||||
global G
|
||||
set G(fd) stdout
|
||||
set G(fd) [open $zOut w]
|
||||
|
||||
puts -nonewline $G(fd) $G(hdr)
|
||||
}
|
||||
|
||||
proc lsm1c_printfile {zIn} {
|
||||
global G
|
||||
set data [readfile $zIn]
|
||||
set zTail [file tail $zIn]
|
||||
puts $G(fd) "#line 1 \"$zTail\""
|
||||
|
||||
foreach line [split $data "\n"] {
|
||||
if {[regexp {^# *include.*lsm} $line]} {
|
||||
set line "/* $line */"
|
||||
} elseif { [regexp {^(const )?[a-zA-Z][a-zA-Z0-9]* [*]?lsm[^_]} $line] } {
|
||||
set line "static $line"
|
||||
}
|
||||
puts $G(fd) $line
|
||||
}
|
||||
}
|
||||
|
||||
proc lsm1c_close {} {
|
||||
global G
|
||||
puts -nonewline $G(fd) $G(footer)
|
||||
if {$G(fd)!="stdout"} {
|
||||
close $G(fd)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lsm1c_init lsm1.c
|
||||
foreach f $G(src) { lsm1c_printfile $f }
|
||||
lsm1c_close
|
||||
+3
-3
@@ -47,9 +47,9 @@ static void rot13func(
|
||||
const unsigned char *zIn;
|
||||
int nIn;
|
||||
unsigned char *zOut;
|
||||
unsigned char *zToFree = 0;
|
||||
char *zToFree = 0;
|
||||
int i;
|
||||
unsigned char zTemp[100];
|
||||
char zTemp[100];
|
||||
assert( argc==1 );
|
||||
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
|
||||
zIn = (const unsigned char*)sqlite3_value_text(argv[0]);
|
||||
@@ -57,7 +57,7 @@ static void rot13func(
|
||||
if( nIn<sizeof(zTemp)-1 ){
|
||||
zOut = zTemp;
|
||||
}else{
|
||||
zOut = zToFree = (unsigned char*)sqlite3_malloc64( nIn+1 );
|
||||
zOut = zToFree = sqlite3_malloc( nIn+1 );
|
||||
if( zOut==0 ){
|
||||
sqlite3_result_error_nomem(context);
|
||||
return;
|
||||
|
||||
+272
-272
@@ -78,9 +78,9 @@ struct SHA3Context {
|
||||
*/
|
||||
static void KeccakF1600Step(SHA3Context *p){
|
||||
int i;
|
||||
u64 b0, b1, b2, b3, b4;
|
||||
u64 c0, c1, c2, c3, c4;
|
||||
u64 d0, d1, d2, d3, d4;
|
||||
u64 B0, B1, B2, B3, B4;
|
||||
u64 C0, C1, C2, C3, C4;
|
||||
u64 D0, D1, D2, D3, D4;
|
||||
static const u64 RC[] = {
|
||||
0x0000000000000001ULL, 0x0000000000008082ULL,
|
||||
0x800000000000808aULL, 0x8000000080008000ULL,
|
||||
@@ -95,301 +95,301 @@ static void KeccakF1600Step(SHA3Context *p){
|
||||
0x8000000080008081ULL, 0x8000000000008080ULL,
|
||||
0x0000000080000001ULL, 0x8000000080008008ULL
|
||||
};
|
||||
# define a00 (p->u.s[0])
|
||||
# define a01 (p->u.s[1])
|
||||
# define a02 (p->u.s[2])
|
||||
# define a03 (p->u.s[3])
|
||||
# define a04 (p->u.s[4])
|
||||
# define a10 (p->u.s[5])
|
||||
# define a11 (p->u.s[6])
|
||||
# define a12 (p->u.s[7])
|
||||
# define a13 (p->u.s[8])
|
||||
# define a14 (p->u.s[9])
|
||||
# define a20 (p->u.s[10])
|
||||
# define a21 (p->u.s[11])
|
||||
# define a22 (p->u.s[12])
|
||||
# define a23 (p->u.s[13])
|
||||
# define a24 (p->u.s[14])
|
||||
# define a30 (p->u.s[15])
|
||||
# define a31 (p->u.s[16])
|
||||
# define a32 (p->u.s[17])
|
||||
# define a33 (p->u.s[18])
|
||||
# define a34 (p->u.s[19])
|
||||
# define a40 (p->u.s[20])
|
||||
# define a41 (p->u.s[21])
|
||||
# define a42 (p->u.s[22])
|
||||
# define a43 (p->u.s[23])
|
||||
# define a44 (p->u.s[24])
|
||||
# define A00 (p->u.s[0])
|
||||
# define A01 (p->u.s[1])
|
||||
# define A02 (p->u.s[2])
|
||||
# define A03 (p->u.s[3])
|
||||
# define A04 (p->u.s[4])
|
||||
# define A10 (p->u.s[5])
|
||||
# define A11 (p->u.s[6])
|
||||
# define A12 (p->u.s[7])
|
||||
# define A13 (p->u.s[8])
|
||||
# define A14 (p->u.s[9])
|
||||
# define A20 (p->u.s[10])
|
||||
# define A21 (p->u.s[11])
|
||||
# define A22 (p->u.s[12])
|
||||
# define A23 (p->u.s[13])
|
||||
# define A24 (p->u.s[14])
|
||||
# define A30 (p->u.s[15])
|
||||
# define A31 (p->u.s[16])
|
||||
# define A32 (p->u.s[17])
|
||||
# define A33 (p->u.s[18])
|
||||
# define A34 (p->u.s[19])
|
||||
# define A40 (p->u.s[20])
|
||||
# define A41 (p->u.s[21])
|
||||
# define A42 (p->u.s[22])
|
||||
# define A43 (p->u.s[23])
|
||||
# define A44 (p->u.s[24])
|
||||
# define ROL64(a,x) ((a<<x)|(a>>(64-x)))
|
||||
|
||||
for(i=0; i<24; i+=4){
|
||||
c0 = a00^a10^a20^a30^a40;
|
||||
c1 = a01^a11^a21^a31^a41;
|
||||
c2 = a02^a12^a22^a32^a42;
|
||||
c3 = a03^a13^a23^a33^a43;
|
||||
c4 = a04^a14^a24^a34^a44;
|
||||
d0 = c4^ROL64(c1, 1);
|
||||
d1 = c0^ROL64(c2, 1);
|
||||
d2 = c1^ROL64(c3, 1);
|
||||
d3 = c2^ROL64(c4, 1);
|
||||
d4 = c3^ROL64(c0, 1);
|
||||
C0 = A00^A10^A20^A30^A40;
|
||||
C1 = A01^A11^A21^A31^A41;
|
||||
C2 = A02^A12^A22^A32^A42;
|
||||
C3 = A03^A13^A23^A33^A43;
|
||||
C4 = A04^A14^A24^A34^A44;
|
||||
D0 = C4^ROL64(C1, 1);
|
||||
D1 = C0^ROL64(C2, 1);
|
||||
D2 = C1^ROL64(C3, 1);
|
||||
D3 = C2^ROL64(C4, 1);
|
||||
D4 = C3^ROL64(C0, 1);
|
||||
|
||||
b0 = (a00^d0);
|
||||
b1 = ROL64((a11^d1), 44);
|
||||
b2 = ROL64((a22^d2), 43);
|
||||
b3 = ROL64((a33^d3), 21);
|
||||
b4 = ROL64((a44^d4), 14);
|
||||
a00 = b0 ^((~b1)& b2 );
|
||||
a00 ^= RC[i];
|
||||
a11 = b1 ^((~b2)& b3 );
|
||||
a22 = b2 ^((~b3)& b4 );
|
||||
a33 = b3 ^((~b4)& b0 );
|
||||
a44 = b4 ^((~b0)& b1 );
|
||||
B0 = (A00^D0);
|
||||
B1 = ROL64((A11^D1), 44);
|
||||
B2 = ROL64((A22^D2), 43);
|
||||
B3 = ROL64((A33^D3), 21);
|
||||
B4 = ROL64((A44^D4), 14);
|
||||
A00 = B0 ^((~B1)& B2 );
|
||||
A00 ^= RC[i];
|
||||
A11 = B1 ^((~B2)& B3 );
|
||||
A22 = B2 ^((~B3)& B4 );
|
||||
A33 = B3 ^((~B4)& B0 );
|
||||
A44 = B4 ^((~B0)& B1 );
|
||||
|
||||
b2 = ROL64((a20^d0), 3);
|
||||
b3 = ROL64((a31^d1), 45);
|
||||
b4 = ROL64((a42^d2), 61);
|
||||
b0 = ROL64((a03^d3), 28);
|
||||
b1 = ROL64((a14^d4), 20);
|
||||
a20 = b0 ^((~b1)& b2 );
|
||||
a31 = b1 ^((~b2)& b3 );
|
||||
a42 = b2 ^((~b3)& b4 );
|
||||
a03 = b3 ^((~b4)& b0 );
|
||||
a14 = b4 ^((~b0)& b1 );
|
||||
B2 = ROL64((A20^D0), 3);
|
||||
B3 = ROL64((A31^D1), 45);
|
||||
B4 = ROL64((A42^D2), 61);
|
||||
B0 = ROL64((A03^D3), 28);
|
||||
B1 = ROL64((A14^D4), 20);
|
||||
A20 = B0 ^((~B1)& B2 );
|
||||
A31 = B1 ^((~B2)& B3 );
|
||||
A42 = B2 ^((~B3)& B4 );
|
||||
A03 = B3 ^((~B4)& B0 );
|
||||
A14 = B4 ^((~B0)& B1 );
|
||||
|
||||
b4 = ROL64((a40^d0), 18);
|
||||
b0 = ROL64((a01^d1), 1);
|
||||
b1 = ROL64((a12^d2), 6);
|
||||
b2 = ROL64((a23^d3), 25);
|
||||
b3 = ROL64((a34^d4), 8);
|
||||
a40 = b0 ^((~b1)& b2 );
|
||||
a01 = b1 ^((~b2)& b3 );
|
||||
a12 = b2 ^((~b3)& b4 );
|
||||
a23 = b3 ^((~b4)& b0 );
|
||||
a34 = b4 ^((~b0)& b1 );
|
||||
B4 = ROL64((A40^D0), 18);
|
||||
B0 = ROL64((A01^D1), 1);
|
||||
B1 = ROL64((A12^D2), 6);
|
||||
B2 = ROL64((A23^D3), 25);
|
||||
B3 = ROL64((A34^D4), 8);
|
||||
A40 = B0 ^((~B1)& B2 );
|
||||
A01 = B1 ^((~B2)& B3 );
|
||||
A12 = B2 ^((~B3)& B4 );
|
||||
A23 = B3 ^((~B4)& B0 );
|
||||
A34 = B4 ^((~B0)& B1 );
|
||||
|
||||
b1 = ROL64((a10^d0), 36);
|
||||
b2 = ROL64((a21^d1), 10);
|
||||
b3 = ROL64((a32^d2), 15);
|
||||
b4 = ROL64((a43^d3), 56);
|
||||
b0 = ROL64((a04^d4), 27);
|
||||
a10 = b0 ^((~b1)& b2 );
|
||||
a21 = b1 ^((~b2)& b3 );
|
||||
a32 = b2 ^((~b3)& b4 );
|
||||
a43 = b3 ^((~b4)& b0 );
|
||||
a04 = b4 ^((~b0)& b1 );
|
||||
B1 = ROL64((A10^D0), 36);
|
||||
B2 = ROL64((A21^D1), 10);
|
||||
B3 = ROL64((A32^D2), 15);
|
||||
B4 = ROL64((A43^D3), 56);
|
||||
B0 = ROL64((A04^D4), 27);
|
||||
A10 = B0 ^((~B1)& B2 );
|
||||
A21 = B1 ^((~B2)& B3 );
|
||||
A32 = B2 ^((~B3)& B4 );
|
||||
A43 = B3 ^((~B4)& B0 );
|
||||
A04 = B4 ^((~B0)& B1 );
|
||||
|
||||
b3 = ROL64((a30^d0), 41);
|
||||
b4 = ROL64((a41^d1), 2);
|
||||
b0 = ROL64((a02^d2), 62);
|
||||
b1 = ROL64((a13^d3), 55);
|
||||
b2 = ROL64((a24^d4), 39);
|
||||
a30 = b0 ^((~b1)& b2 );
|
||||
a41 = b1 ^((~b2)& b3 );
|
||||
a02 = b2 ^((~b3)& b4 );
|
||||
a13 = b3 ^((~b4)& b0 );
|
||||
a24 = b4 ^((~b0)& b1 );
|
||||
B3 = ROL64((A30^D0), 41);
|
||||
B4 = ROL64((A41^D1), 2);
|
||||
B0 = ROL64((A02^D2), 62);
|
||||
B1 = ROL64((A13^D3), 55);
|
||||
B2 = ROL64((A24^D4), 39);
|
||||
A30 = B0 ^((~B1)& B2 );
|
||||
A41 = B1 ^((~B2)& B3 );
|
||||
A02 = B2 ^((~B3)& B4 );
|
||||
A13 = B3 ^((~B4)& B0 );
|
||||
A24 = B4 ^((~B0)& B1 );
|
||||
|
||||
c0 = a00^a20^a40^a10^a30;
|
||||
c1 = a11^a31^a01^a21^a41;
|
||||
c2 = a22^a42^a12^a32^a02;
|
||||
c3 = a33^a03^a23^a43^a13;
|
||||
c4 = a44^a14^a34^a04^a24;
|
||||
d0 = c4^ROL64(c1, 1);
|
||||
d1 = c0^ROL64(c2, 1);
|
||||
d2 = c1^ROL64(c3, 1);
|
||||
d3 = c2^ROL64(c4, 1);
|
||||
d4 = c3^ROL64(c0, 1);
|
||||
C0 = A00^A20^A40^A10^A30;
|
||||
C1 = A11^A31^A01^A21^A41;
|
||||
C2 = A22^A42^A12^A32^A02;
|
||||
C3 = A33^A03^A23^A43^A13;
|
||||
C4 = A44^A14^A34^A04^A24;
|
||||
D0 = C4^ROL64(C1, 1);
|
||||
D1 = C0^ROL64(C2, 1);
|
||||
D2 = C1^ROL64(C3, 1);
|
||||
D3 = C2^ROL64(C4, 1);
|
||||
D4 = C3^ROL64(C0, 1);
|
||||
|
||||
b0 = (a00^d0);
|
||||
b1 = ROL64((a31^d1), 44);
|
||||
b2 = ROL64((a12^d2), 43);
|
||||
b3 = ROL64((a43^d3), 21);
|
||||
b4 = ROL64((a24^d4), 14);
|
||||
a00 = b0 ^((~b1)& b2 );
|
||||
a00 ^= RC[i+1];
|
||||
a31 = b1 ^((~b2)& b3 );
|
||||
a12 = b2 ^((~b3)& b4 );
|
||||
a43 = b3 ^((~b4)& b0 );
|
||||
a24 = b4 ^((~b0)& b1 );
|
||||
B0 = (A00^D0);
|
||||
B1 = ROL64((A31^D1), 44);
|
||||
B2 = ROL64((A12^D2), 43);
|
||||
B3 = ROL64((A43^D3), 21);
|
||||
B4 = ROL64((A24^D4), 14);
|
||||
A00 = B0 ^((~B1)& B2 );
|
||||
A00 ^= RC[i+1];
|
||||
A31 = B1 ^((~B2)& B3 );
|
||||
A12 = B2 ^((~B3)& B4 );
|
||||
A43 = B3 ^((~B4)& B0 );
|
||||
A24 = B4 ^((~B0)& B1 );
|
||||
|
||||
b2 = ROL64((a40^d0), 3);
|
||||
b3 = ROL64((a21^d1), 45);
|
||||
b4 = ROL64((a02^d2), 61);
|
||||
b0 = ROL64((a33^d3), 28);
|
||||
b1 = ROL64((a14^d4), 20);
|
||||
a40 = b0 ^((~b1)& b2 );
|
||||
a21 = b1 ^((~b2)& b3 );
|
||||
a02 = b2 ^((~b3)& b4 );
|
||||
a33 = b3 ^((~b4)& b0 );
|
||||
a14 = b4 ^((~b0)& b1 );
|
||||
B2 = ROL64((A40^D0), 3);
|
||||
B3 = ROL64((A21^D1), 45);
|
||||
B4 = ROL64((A02^D2), 61);
|
||||
B0 = ROL64((A33^D3), 28);
|
||||
B1 = ROL64((A14^D4), 20);
|
||||
A40 = B0 ^((~B1)& B2 );
|
||||
A21 = B1 ^((~B2)& B3 );
|
||||
A02 = B2 ^((~B3)& B4 );
|
||||
A33 = B3 ^((~B4)& B0 );
|
||||
A14 = B4 ^((~B0)& B1 );
|
||||
|
||||
b4 = ROL64((a30^d0), 18);
|
||||
b0 = ROL64((a11^d1), 1);
|
||||
b1 = ROL64((a42^d2), 6);
|
||||
b2 = ROL64((a23^d3), 25);
|
||||
b3 = ROL64((a04^d4), 8);
|
||||
a30 = b0 ^((~b1)& b2 );
|
||||
a11 = b1 ^((~b2)& b3 );
|
||||
a42 = b2 ^((~b3)& b4 );
|
||||
a23 = b3 ^((~b4)& b0 );
|
||||
a04 = b4 ^((~b0)& b1 );
|
||||
B4 = ROL64((A30^D0), 18);
|
||||
B0 = ROL64((A11^D1), 1);
|
||||
B1 = ROL64((A42^D2), 6);
|
||||
B2 = ROL64((A23^D3), 25);
|
||||
B3 = ROL64((A04^D4), 8);
|
||||
A30 = B0 ^((~B1)& B2 );
|
||||
A11 = B1 ^((~B2)& B3 );
|
||||
A42 = B2 ^((~B3)& B4 );
|
||||
A23 = B3 ^((~B4)& B0 );
|
||||
A04 = B4 ^((~B0)& B1 );
|
||||
|
||||
b1 = ROL64((a20^d0), 36);
|
||||
b2 = ROL64((a01^d1), 10);
|
||||
b3 = ROL64((a32^d2), 15);
|
||||
b4 = ROL64((a13^d3), 56);
|
||||
b0 = ROL64((a44^d4), 27);
|
||||
a20 = b0 ^((~b1)& b2 );
|
||||
a01 = b1 ^((~b2)& b3 );
|
||||
a32 = b2 ^((~b3)& b4 );
|
||||
a13 = b3 ^((~b4)& b0 );
|
||||
a44 = b4 ^((~b0)& b1 );
|
||||
B1 = ROL64((A20^D0), 36);
|
||||
B2 = ROL64((A01^D1), 10);
|
||||
B3 = ROL64((A32^D2), 15);
|
||||
B4 = ROL64((A13^D3), 56);
|
||||
B0 = ROL64((A44^D4), 27);
|
||||
A20 = B0 ^((~B1)& B2 );
|
||||
A01 = B1 ^((~B2)& B3 );
|
||||
A32 = B2 ^((~B3)& B4 );
|
||||
A13 = B3 ^((~B4)& B0 );
|
||||
A44 = B4 ^((~B0)& B1 );
|
||||
|
||||
b3 = ROL64((a10^d0), 41);
|
||||
b4 = ROL64((a41^d1), 2);
|
||||
b0 = ROL64((a22^d2), 62);
|
||||
b1 = ROL64((a03^d3), 55);
|
||||
b2 = ROL64((a34^d4), 39);
|
||||
a10 = b0 ^((~b1)& b2 );
|
||||
a41 = b1 ^((~b2)& b3 );
|
||||
a22 = b2 ^((~b3)& b4 );
|
||||
a03 = b3 ^((~b4)& b0 );
|
||||
a34 = b4 ^((~b0)& b1 );
|
||||
B3 = ROL64((A10^D0), 41);
|
||||
B4 = ROL64((A41^D1), 2);
|
||||
B0 = ROL64((A22^D2), 62);
|
||||
B1 = ROL64((A03^D3), 55);
|
||||
B2 = ROL64((A34^D4), 39);
|
||||
A10 = B0 ^((~B1)& B2 );
|
||||
A41 = B1 ^((~B2)& B3 );
|
||||
A22 = B2 ^((~B3)& B4 );
|
||||
A03 = B3 ^((~B4)& B0 );
|
||||
A34 = B4 ^((~B0)& B1 );
|
||||
|
||||
c0 = a00^a40^a30^a20^a10;
|
||||
c1 = a31^a21^a11^a01^a41;
|
||||
c2 = a12^a02^a42^a32^a22;
|
||||
c3 = a43^a33^a23^a13^a03;
|
||||
c4 = a24^a14^a04^a44^a34;
|
||||
d0 = c4^ROL64(c1, 1);
|
||||
d1 = c0^ROL64(c2, 1);
|
||||
d2 = c1^ROL64(c3, 1);
|
||||
d3 = c2^ROL64(c4, 1);
|
||||
d4 = c3^ROL64(c0, 1);
|
||||
C0 = A00^A40^A30^A20^A10;
|
||||
C1 = A31^A21^A11^A01^A41;
|
||||
C2 = A12^A02^A42^A32^A22;
|
||||
C3 = A43^A33^A23^A13^A03;
|
||||
C4 = A24^A14^A04^A44^A34;
|
||||
D0 = C4^ROL64(C1, 1);
|
||||
D1 = C0^ROL64(C2, 1);
|
||||
D2 = C1^ROL64(C3, 1);
|
||||
D3 = C2^ROL64(C4, 1);
|
||||
D4 = C3^ROL64(C0, 1);
|
||||
|
||||
b0 = (a00^d0);
|
||||
b1 = ROL64((a21^d1), 44);
|
||||
b2 = ROL64((a42^d2), 43);
|
||||
b3 = ROL64((a13^d3), 21);
|
||||
b4 = ROL64((a34^d4), 14);
|
||||
a00 = b0 ^((~b1)& b2 );
|
||||
a00 ^= RC[i+2];
|
||||
a21 = b1 ^((~b2)& b3 );
|
||||
a42 = b2 ^((~b3)& b4 );
|
||||
a13 = b3 ^((~b4)& b0 );
|
||||
a34 = b4 ^((~b0)& b1 );
|
||||
B0 = (A00^D0);
|
||||
B1 = ROL64((A21^D1), 44);
|
||||
B2 = ROL64((A42^D2), 43);
|
||||
B3 = ROL64((A13^D3), 21);
|
||||
B4 = ROL64((A34^D4), 14);
|
||||
A00 = B0 ^((~B1)& B2 );
|
||||
A00 ^= RC[i+2];
|
||||
A21 = B1 ^((~B2)& B3 );
|
||||
A42 = B2 ^((~B3)& B4 );
|
||||
A13 = B3 ^((~B4)& B0 );
|
||||
A34 = B4 ^((~B0)& B1 );
|
||||
|
||||
b2 = ROL64((a30^d0), 3);
|
||||
b3 = ROL64((a01^d1), 45);
|
||||
b4 = ROL64((a22^d2), 61);
|
||||
b0 = ROL64((a43^d3), 28);
|
||||
b1 = ROL64((a14^d4), 20);
|
||||
a30 = b0 ^((~b1)& b2 );
|
||||
a01 = b1 ^((~b2)& b3 );
|
||||
a22 = b2 ^((~b3)& b4 );
|
||||
a43 = b3 ^((~b4)& b0 );
|
||||
a14 = b4 ^((~b0)& b1 );
|
||||
B2 = ROL64((A30^D0), 3);
|
||||
B3 = ROL64((A01^D1), 45);
|
||||
B4 = ROL64((A22^D2), 61);
|
||||
B0 = ROL64((A43^D3), 28);
|
||||
B1 = ROL64((A14^D4), 20);
|
||||
A30 = B0 ^((~B1)& B2 );
|
||||
A01 = B1 ^((~B2)& B3 );
|
||||
A22 = B2 ^((~B3)& B4 );
|
||||
A43 = B3 ^((~B4)& B0 );
|
||||
A14 = B4 ^((~B0)& B1 );
|
||||
|
||||
b4 = ROL64((a10^d0), 18);
|
||||
b0 = ROL64((a31^d1), 1);
|
||||
b1 = ROL64((a02^d2), 6);
|
||||
b2 = ROL64((a23^d3), 25);
|
||||
b3 = ROL64((a44^d4), 8);
|
||||
a10 = b0 ^((~b1)& b2 );
|
||||
a31 = b1 ^((~b2)& b3 );
|
||||
a02 = b2 ^((~b3)& b4 );
|
||||
a23 = b3 ^((~b4)& b0 );
|
||||
a44 = b4 ^((~b0)& b1 );
|
||||
B4 = ROL64((A10^D0), 18);
|
||||
B0 = ROL64((A31^D1), 1);
|
||||
B1 = ROL64((A02^D2), 6);
|
||||
B2 = ROL64((A23^D3), 25);
|
||||
B3 = ROL64((A44^D4), 8);
|
||||
A10 = B0 ^((~B1)& B2 );
|
||||
A31 = B1 ^((~B2)& B3 );
|
||||
A02 = B2 ^((~B3)& B4 );
|
||||
A23 = B3 ^((~B4)& B0 );
|
||||
A44 = B4 ^((~B0)& B1 );
|
||||
|
||||
b1 = ROL64((a40^d0), 36);
|
||||
b2 = ROL64((a11^d1), 10);
|
||||
b3 = ROL64((a32^d2), 15);
|
||||
b4 = ROL64((a03^d3), 56);
|
||||
b0 = ROL64((a24^d4), 27);
|
||||
a40 = b0 ^((~b1)& b2 );
|
||||
a11 = b1 ^((~b2)& b3 );
|
||||
a32 = b2 ^((~b3)& b4 );
|
||||
a03 = b3 ^((~b4)& b0 );
|
||||
a24 = b4 ^((~b0)& b1 );
|
||||
B1 = ROL64((A40^D0), 36);
|
||||
B2 = ROL64((A11^D1), 10);
|
||||
B3 = ROL64((A32^D2), 15);
|
||||
B4 = ROL64((A03^D3), 56);
|
||||
B0 = ROL64((A24^D4), 27);
|
||||
A40 = B0 ^((~B1)& B2 );
|
||||
A11 = B1 ^((~B2)& B3 );
|
||||
A32 = B2 ^((~B3)& B4 );
|
||||
A03 = B3 ^((~B4)& B0 );
|
||||
A24 = B4 ^((~B0)& B1 );
|
||||
|
||||
b3 = ROL64((a20^d0), 41);
|
||||
b4 = ROL64((a41^d1), 2);
|
||||
b0 = ROL64((a12^d2), 62);
|
||||
b1 = ROL64((a33^d3), 55);
|
||||
b2 = ROL64((a04^d4), 39);
|
||||
a20 = b0 ^((~b1)& b2 );
|
||||
a41 = b1 ^((~b2)& b3 );
|
||||
a12 = b2 ^((~b3)& b4 );
|
||||
a33 = b3 ^((~b4)& b0 );
|
||||
a04 = b4 ^((~b0)& b1 );
|
||||
B3 = ROL64((A20^D0), 41);
|
||||
B4 = ROL64((A41^D1), 2);
|
||||
B0 = ROL64((A12^D2), 62);
|
||||
B1 = ROL64((A33^D3), 55);
|
||||
B2 = ROL64((A04^D4), 39);
|
||||
A20 = B0 ^((~B1)& B2 );
|
||||
A41 = B1 ^((~B2)& B3 );
|
||||
A12 = B2 ^((~B3)& B4 );
|
||||
A33 = B3 ^((~B4)& B0 );
|
||||
A04 = B4 ^((~B0)& B1 );
|
||||
|
||||
c0 = a00^a30^a10^a40^a20;
|
||||
c1 = a21^a01^a31^a11^a41;
|
||||
c2 = a42^a22^a02^a32^a12;
|
||||
c3 = a13^a43^a23^a03^a33;
|
||||
c4 = a34^a14^a44^a24^a04;
|
||||
d0 = c4^ROL64(c1, 1);
|
||||
d1 = c0^ROL64(c2, 1);
|
||||
d2 = c1^ROL64(c3, 1);
|
||||
d3 = c2^ROL64(c4, 1);
|
||||
d4 = c3^ROL64(c0, 1);
|
||||
C0 = A00^A30^A10^A40^A20;
|
||||
C1 = A21^A01^A31^A11^A41;
|
||||
C2 = A42^A22^A02^A32^A12;
|
||||
C3 = A13^A43^A23^A03^A33;
|
||||
C4 = A34^A14^A44^A24^A04;
|
||||
D0 = C4^ROL64(C1, 1);
|
||||
D1 = C0^ROL64(C2, 1);
|
||||
D2 = C1^ROL64(C3, 1);
|
||||
D3 = C2^ROL64(C4, 1);
|
||||
D4 = C3^ROL64(C0, 1);
|
||||
|
||||
b0 = (a00^d0);
|
||||
b1 = ROL64((a01^d1), 44);
|
||||
b2 = ROL64((a02^d2), 43);
|
||||
b3 = ROL64((a03^d3), 21);
|
||||
b4 = ROL64((a04^d4), 14);
|
||||
a00 = b0 ^((~b1)& b2 );
|
||||
a00 ^= RC[i+3];
|
||||
a01 = b1 ^((~b2)& b3 );
|
||||
a02 = b2 ^((~b3)& b4 );
|
||||
a03 = b3 ^((~b4)& b0 );
|
||||
a04 = b4 ^((~b0)& b1 );
|
||||
B0 = (A00^D0);
|
||||
B1 = ROL64((A01^D1), 44);
|
||||
B2 = ROL64((A02^D2), 43);
|
||||
B3 = ROL64((A03^D3), 21);
|
||||
B4 = ROL64((A04^D4), 14);
|
||||
A00 = B0 ^((~B1)& B2 );
|
||||
A00 ^= RC[i+3];
|
||||
A01 = B1 ^((~B2)& B3 );
|
||||
A02 = B2 ^((~B3)& B4 );
|
||||
A03 = B3 ^((~B4)& B0 );
|
||||
A04 = B4 ^((~B0)& B1 );
|
||||
|
||||
b2 = ROL64((a10^d0), 3);
|
||||
b3 = ROL64((a11^d1), 45);
|
||||
b4 = ROL64((a12^d2), 61);
|
||||
b0 = ROL64((a13^d3), 28);
|
||||
b1 = ROL64((a14^d4), 20);
|
||||
a10 = b0 ^((~b1)& b2 );
|
||||
a11 = b1 ^((~b2)& b3 );
|
||||
a12 = b2 ^((~b3)& b4 );
|
||||
a13 = b3 ^((~b4)& b0 );
|
||||
a14 = b4 ^((~b0)& b1 );
|
||||
B2 = ROL64((A10^D0), 3);
|
||||
B3 = ROL64((A11^D1), 45);
|
||||
B4 = ROL64((A12^D2), 61);
|
||||
B0 = ROL64((A13^D3), 28);
|
||||
B1 = ROL64((A14^D4), 20);
|
||||
A10 = B0 ^((~B1)& B2 );
|
||||
A11 = B1 ^((~B2)& B3 );
|
||||
A12 = B2 ^((~B3)& B4 );
|
||||
A13 = B3 ^((~B4)& B0 );
|
||||
A14 = B4 ^((~B0)& B1 );
|
||||
|
||||
b4 = ROL64((a20^d0), 18);
|
||||
b0 = ROL64((a21^d1), 1);
|
||||
b1 = ROL64((a22^d2), 6);
|
||||
b2 = ROL64((a23^d3), 25);
|
||||
b3 = ROL64((a24^d4), 8);
|
||||
a20 = b0 ^((~b1)& b2 );
|
||||
a21 = b1 ^((~b2)& b3 );
|
||||
a22 = b2 ^((~b3)& b4 );
|
||||
a23 = b3 ^((~b4)& b0 );
|
||||
a24 = b4 ^((~b0)& b1 );
|
||||
B4 = ROL64((A20^D0), 18);
|
||||
B0 = ROL64((A21^D1), 1);
|
||||
B1 = ROL64((A22^D2), 6);
|
||||
B2 = ROL64((A23^D3), 25);
|
||||
B3 = ROL64((A24^D4), 8);
|
||||
A20 = B0 ^((~B1)& B2 );
|
||||
A21 = B1 ^((~B2)& B3 );
|
||||
A22 = B2 ^((~B3)& B4 );
|
||||
A23 = B3 ^((~B4)& B0 );
|
||||
A24 = B4 ^((~B0)& B1 );
|
||||
|
||||
b1 = ROL64((a30^d0), 36);
|
||||
b2 = ROL64((a31^d1), 10);
|
||||
b3 = ROL64((a32^d2), 15);
|
||||
b4 = ROL64((a33^d3), 56);
|
||||
b0 = ROL64((a34^d4), 27);
|
||||
a30 = b0 ^((~b1)& b2 );
|
||||
a31 = b1 ^((~b2)& b3 );
|
||||
a32 = b2 ^((~b3)& b4 );
|
||||
a33 = b3 ^((~b4)& b0 );
|
||||
a34 = b4 ^((~b0)& b1 );
|
||||
B1 = ROL64((A30^D0), 36);
|
||||
B2 = ROL64((A31^D1), 10);
|
||||
B3 = ROL64((A32^D2), 15);
|
||||
B4 = ROL64((A33^D3), 56);
|
||||
B0 = ROL64((A34^D4), 27);
|
||||
A30 = B0 ^((~B1)& B2 );
|
||||
A31 = B1 ^((~B2)& B3 );
|
||||
A32 = B2 ^((~B3)& B4 );
|
||||
A33 = B3 ^((~B4)& B0 );
|
||||
A34 = B4 ^((~B0)& B1 );
|
||||
|
||||
b3 = ROL64((a40^d0), 41);
|
||||
b4 = ROL64((a41^d1), 2);
|
||||
b0 = ROL64((a42^d2), 62);
|
||||
b1 = ROL64((a43^d3), 55);
|
||||
b2 = ROL64((a44^d4), 39);
|
||||
a40 = b0 ^((~b1)& b2 );
|
||||
a41 = b1 ^((~b2)& b3 );
|
||||
a42 = b2 ^((~b3)& b4 );
|
||||
a43 = b3 ^((~b4)& b0 );
|
||||
a44 = b4 ^((~b0)& b1 );
|
||||
B3 = ROL64((A40^D0), 41);
|
||||
B4 = ROL64((A41^D1), 2);
|
||||
B0 = ROL64((A42^D2), 62);
|
||||
B1 = ROL64((A43^D3), 55);
|
||||
B2 = ROL64((A44^D4), 39);
|
||||
A40 = B0 ^((~B1)& B2 );
|
||||
A41 = B1 ^((~B2)& B3 );
|
||||
A42 = B2 ^((~B3)& B4 );
|
||||
A43 = B3 ^((~B4)& B0 );
|
||||
A44 = B4 ^((~B0)& B1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+29
-276
@@ -56,8 +56,6 @@
|
||||
**
|
||||
** SWARMVTAB
|
||||
**
|
||||
** LEGACY SYNTAX:
|
||||
**
|
||||
** A "swarmvtab" virtual table is created similarly to a unionvtab table:
|
||||
**
|
||||
** CREATE VIRTUAL TABLE <name>
|
||||
@@ -68,78 +66,13 @@
|
||||
** the database file containing the source table. The <callback> option
|
||||
** is optional. If included, it is the name of an application-defined
|
||||
** SQL function that is invoked with the URI of the file, if the file
|
||||
** does not already exist on disk when required by swarmvtab.
|
||||
**
|
||||
** NEW SYNTAX:
|
||||
**
|
||||
** Using the new syntax, a swarmvtab table is created with:
|
||||
**
|
||||
** CREATE VIRTUAL TABLE <name> USING swarmvtab(
|
||||
** <sql-statement> [, <options>]
|
||||
** );
|
||||
**
|
||||
** where valid <options> are:
|
||||
**
|
||||
** missing=<udf-function-name>
|
||||
** openclose=<udf-function-name>
|
||||
** maxopen=<integer>
|
||||
** <sql-parameter>=<text-value>
|
||||
**
|
||||
** The <sql-statement> must return the same 4 columns as for a swarmvtab
|
||||
** table in legacy mode. However, it may also return a 5th column - the
|
||||
** "context" column. The text value returned in this column is not used
|
||||
** at all by the swarmvtab implementation, except that it is passed as
|
||||
** an additional argument to the two UDF functions that may be invoked
|
||||
** (see below).
|
||||
**
|
||||
** The "missing" option, if present, specifies the name of an SQL UDF
|
||||
** function to be invoked if a database file is not already present on
|
||||
** disk when required by swarmvtab. If the <sql-statement> did not provide
|
||||
** a context column, it is invoked as:
|
||||
**
|
||||
** SELECT <missing-udf>(<database filename/uri>);
|
||||
**
|
||||
** Or, if there was a context column:
|
||||
**
|
||||
** SELECT <missing-udf>(<database filename/uri>, <context>);
|
||||
**
|
||||
** The "openclose" option may also specify a UDF function. This function
|
||||
** is invoked right before swarmvtab opens a database, and right after
|
||||
** it closes one. The first argument - or first two arguments, if
|
||||
** <sql-statement> supplied the context column - is the same as for
|
||||
** the "missing" UDF. Following this, the UDF is passed integer value
|
||||
** 0 before a db is opened, and 1 right after it is closed. If both
|
||||
** a missing and openclose UDF is supplied, the application should expect
|
||||
** the following sequence of calls (for a single database):
|
||||
**
|
||||
** SELECT <openclose-udf>(<db filename>, <context>, 0);
|
||||
** if( db not already on disk ){
|
||||
** SELECT <missing-udf>(<db filename>, <context>);
|
||||
** }
|
||||
** ... swarmvtab uses database ...
|
||||
** SELECT <openclose-udf>(<db filename>, <context>, 1);
|
||||
**
|
||||
** The "maxopen" option is used to configure the maximum number of
|
||||
** database files swarmvtab will hold open simultaneously (default 9).
|
||||
**
|
||||
** If an option name begins with a ":" character, then it is assumed
|
||||
** to be an SQL parameter. In this case, the specified text value is
|
||||
** bound to the same variable of the <sql-statement> before it is
|
||||
** executed. It is an error of the named SQL parameter does not exist.
|
||||
** For example:
|
||||
**
|
||||
** CREATE VIRTUAL TABLE swarm USING swarmvtab(
|
||||
** 'SELECT :path || localfile, tbl, min, max FROM swarmdir',
|
||||
** :path='/home/user/databases/'
|
||||
** missing='missing_func'
|
||||
** );
|
||||
** does not already exist on disk.
|
||||
*/
|
||||
|
||||
#include "sqlite3ext.h"
|
||||
SQLITE_EXTENSION_INIT1
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
|
||||
@@ -195,7 +128,6 @@ struct UnionSrc {
|
||||
|
||||
/* Fields used by swarmvtab only */
|
||||
char *zFile; /* Database file containing table zTab */
|
||||
char *zContext; /* Context string, if any */
|
||||
int nUser; /* Current number of users */
|
||||
sqlite3 *db; /* Database handle */
|
||||
UnionSrc *pNextClosable; /* Next in list of closable sources */
|
||||
@@ -213,11 +145,8 @@ struct UnionTab {
|
||||
UnionSrc *aSrc; /* Array of source tables, sorted by rowid */
|
||||
|
||||
/* Used by swarmvtab only */
|
||||
int bHasContext; /* Has context strings */
|
||||
char *zSourceStr; /* Expected unionSourceToStr() value */
|
||||
sqlite3_stmt *pNotFound; /* UDF to invoke if file not found on open */
|
||||
sqlite3_stmt *pOpenClose; /* UDF to invoke on open and close */
|
||||
|
||||
char *zNotFoundCallback; /* UDF to invoke if file not found on open */
|
||||
UnionSrc *pClosable; /* First in list of closable sources */
|
||||
int nOpen; /* Current number of open sources */
|
||||
int nMaxOpen; /* Maximum number of open sources */
|
||||
@@ -422,39 +351,6 @@ static void unionFinalize(int *pRc, sqlite3_stmt *pStmt, char **pzErr){
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** If an "openclose" UDF was supplied when this virtual table was created,
|
||||
** invoke it now. The first argument passed is the name of the database
|
||||
** file for source pSrc. The second is integer value bClose.
|
||||
**
|
||||
** If successful, return SQLITE_OK. Otherwise an SQLite error code. In this
|
||||
** case if argument pzErr is not NULL, also set (*pzErr) to an English
|
||||
** language error message. The caller is responsible for eventually freeing
|
||||
** any error message using sqlite3_free().
|
||||
*/
|
||||
static int unionInvokeOpenClose(
|
||||
UnionTab *pTab,
|
||||
UnionSrc *pSrc,
|
||||
int bClose,
|
||||
char **pzErr
|
||||
){
|
||||
int rc = SQLITE_OK;
|
||||
if( pTab->pOpenClose ){
|
||||
sqlite3_bind_text(pTab->pOpenClose, 1, pSrc->zFile, -1, SQLITE_STATIC);
|
||||
if( pTab->bHasContext ){
|
||||
sqlite3_bind_text(pTab->pOpenClose, 2, pSrc->zContext, -1, SQLITE_STATIC);
|
||||
}
|
||||
sqlite3_bind_int(pTab->pOpenClose, 2+pTab->bHasContext, bClose);
|
||||
sqlite3_step(pTab->pOpenClose);
|
||||
if( SQLITE_OK!=(rc = sqlite3_reset(pTab->pOpenClose)) ){
|
||||
if( pzErr ){
|
||||
*pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(pTab->db));
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is a no-op for unionvtab. For swarmvtab, it attempts to
|
||||
** close open database files until at most nMax are open. An SQLite error
|
||||
@@ -462,16 +358,13 @@ static int unionInvokeOpenClose(
|
||||
*/
|
||||
static void unionCloseSources(UnionTab *pTab, int nMax){
|
||||
while( pTab->pClosable && pTab->nOpen>nMax ){
|
||||
UnionSrc *p;
|
||||
UnionSrc **pp;
|
||||
for(pp=&pTab->pClosable; (*pp)->pNextClosable; pp=&(*pp)->pNextClosable);
|
||||
p = *pp;
|
||||
assert( p->db );
|
||||
sqlite3_close(p->db);
|
||||
p->db = 0;
|
||||
assert( (*pp)->db );
|
||||
sqlite3_close((*pp)->db);
|
||||
(*pp)->db = 0;
|
||||
*pp = 0;
|
||||
pTab->nOpen--;
|
||||
unionInvokeOpenClose(pTab, p, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,18 +377,13 @@ static int unionDisconnect(sqlite3_vtab *pVtab){
|
||||
int i;
|
||||
for(i=0; i<pTab->nSrc; i++){
|
||||
UnionSrc *pSrc = &pTab->aSrc[i];
|
||||
if( pSrc->db ){
|
||||
unionInvokeOpenClose(pTab, pSrc, 1, 0);
|
||||
}
|
||||
sqlite3_free(pSrc->zDb);
|
||||
sqlite3_free(pSrc->zTab);
|
||||
sqlite3_free(pSrc->zFile);
|
||||
sqlite3_free(pSrc->zContext);
|
||||
sqlite3_close(pSrc->db);
|
||||
}
|
||||
sqlite3_finalize(pTab->pNotFound);
|
||||
sqlite3_finalize(pTab->pOpenClose);
|
||||
sqlite3_free(pTab->zSourceStr);
|
||||
sqlite3_free(pTab->zNotFoundCallback);
|
||||
sqlite3_free(pTab->aSrc);
|
||||
sqlite3_free(pTab);
|
||||
}
|
||||
@@ -608,31 +496,29 @@ static int unionSourceCheck(UnionTab *pTab, char **pzErr){
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Try to open the swarmvtab database. If initially unable, invoke the
|
||||
** not-found callback UDF and then try again.
|
||||
*/
|
||||
static int unionOpenDatabaseInner(UnionTab *pTab, UnionSrc *pSrc, char **pzErr){
|
||||
static const int openFlags = SQLITE_OPEN_READONLY | SQLITE_OPEN_URI;
|
||||
int rc;
|
||||
|
||||
rc = unionInvokeOpenClose(pTab, pSrc, 0, pzErr);
|
||||
if( rc!=SQLITE_OK ) return rc;
|
||||
|
||||
int rc = SQLITE_OK;
|
||||
static const int openFlags =
|
||||
SQLITE_OPEN_READONLY | SQLITE_OPEN_URI;
|
||||
rc = sqlite3_open_v2(pSrc->zFile, &pSrc->db, openFlags, 0);
|
||||
if( rc==SQLITE_OK ) return rc;
|
||||
if( pTab->pNotFound ){
|
||||
if( pTab->zNotFoundCallback ){
|
||||
char *zSql = sqlite3_mprintf("SELECT \"%w\"(%Q);",
|
||||
pTab->zNotFoundCallback, pSrc->zFile);
|
||||
sqlite3_close(pSrc->db);
|
||||
pSrc->db = 0;
|
||||
sqlite3_bind_text(pTab->pNotFound, 1, pSrc->zFile, -1, SQLITE_STATIC);
|
||||
if( pTab->bHasContext ){
|
||||
sqlite3_bind_text(pTab->pNotFound, 2, pSrc->zContext, -1, SQLITE_STATIC);
|
||||
}
|
||||
sqlite3_step(pTab->pNotFound);
|
||||
if( SQLITE_OK!=(rc = sqlite3_reset(pTab->pNotFound)) ){
|
||||
*pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(pTab->db));
|
||||
return rc;
|
||||
if( zSql==0 ){
|
||||
*pzErr = sqlite3_mprintf("out of memory");
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
rc = sqlite3_exec(pTab->db, zSql, 0, 0, pzErr);
|
||||
sqlite3_free(zSql);
|
||||
if( rc ) return rc;
|
||||
rc = sqlite3_open_v2(pSrc->zFile, &pSrc->db, openFlags, 0);
|
||||
}
|
||||
if( rc!=SQLITE_OK ){
|
||||
@@ -686,7 +572,6 @@ static int unionOpenDatabase(UnionTab *pTab, int iSrc, char **pzErr){
|
||||
}else{
|
||||
sqlite3_close(pSrc->db);
|
||||
pSrc->db = 0;
|
||||
unionInvokeOpenClose(pTab, pSrc, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -742,132 +627,6 @@ static int unionFinalizeCsrStmt(UnionCsr *pCsr){
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return true if the argument is a space, tab, CR or LF character.
|
||||
*/
|
||||
static int union_isspace(char c){
|
||||
return (c==' ' || c=='\n' || c=='\r' || c=='\t');
|
||||
}
|
||||
|
||||
/*
|
||||
** Return true if the argument is an alphanumeric character in the
|
||||
** ASCII range.
|
||||
*/
|
||||
static int union_isidchar(char c){
|
||||
return ((c>='a' && c<='z') || (c>='A' && c<'Z') || (c>='0' && c<='9'));
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is called to handle all arguments following the first
|
||||
** (the SQL statement) passed to a swarmvtab (not unionvtab) CREATE
|
||||
** VIRTUAL TABLE statement. It may bind parameters to the SQL statement
|
||||
** or configure members of the UnionTab object passed as the second
|
||||
** argument.
|
||||
**
|
||||
** Refer to header comments at the top of this file for a description
|
||||
** of the arguments parsed.
|
||||
**
|
||||
** This function is a no-op if *pRc is other than SQLITE_OK when it is
|
||||
** called. Otherwise, if an error occurs, *pRc is set to an SQLite error
|
||||
** code. In this case *pzErr may be set to point to a buffer containing
|
||||
** an English language error message. It is the responsibility of the
|
||||
** caller to eventually free the buffer using sqlite3_free().
|
||||
*/
|
||||
static void unionConfigureVtab(
|
||||
int *pRc, /* IN/OUT: Error code */
|
||||
UnionTab *pTab, /* Table to configure */
|
||||
sqlite3_stmt *pStmt, /* SQL statement to find sources */
|
||||
int nArg, /* Number of entries in azArg[] array */
|
||||
const char * const *azArg, /* Array of arguments to consider */
|
||||
char **pzErr /* OUT: Error message */
|
||||
){
|
||||
int rc = *pRc;
|
||||
int i;
|
||||
if( rc==SQLITE_OK ){
|
||||
pTab->bHasContext = (sqlite3_column_count(pStmt)>4);
|
||||
}
|
||||
for(i=0; rc==SQLITE_OK && i<nArg; i++){
|
||||
char *zArg = unionStrdup(&rc, azArg[i]);
|
||||
if( zArg ){
|
||||
int nOpt = 0; /* Size of option name in bytes */
|
||||
char *zOpt; /* Pointer to option name */
|
||||
char *zVal; /* Pointer to value */
|
||||
|
||||
unionDequote(zArg);
|
||||
zOpt = zArg;
|
||||
while( union_isspace(*zOpt) ) zOpt++;
|
||||
zVal = zOpt;
|
||||
if( *zVal==':' ) zVal++;
|
||||
while( union_isidchar(*zVal) ) zVal++;
|
||||
nOpt = zVal-zOpt;
|
||||
|
||||
while( union_isspace(*zVal) ) zVal++;
|
||||
if( *zVal=='=' ){
|
||||
zOpt[nOpt] = '\0';
|
||||
zVal++;
|
||||
while( union_isspace(*zVal) ) zVal++;
|
||||
zVal = unionStrdup(&rc, zVal);
|
||||
if( zVal ){
|
||||
unionDequote(zVal);
|
||||
if( zOpt[0]==':' ){
|
||||
/* A value to bind to the SQL statement */
|
||||
int iParam = sqlite3_bind_parameter_index(pStmt, zOpt);
|
||||
if( iParam==0 ){
|
||||
*pzErr = sqlite3_mprintf(
|
||||
"swarmvtab: no such SQL parameter: %s", zOpt
|
||||
);
|
||||
rc = SQLITE_ERROR;
|
||||
}else{
|
||||
rc = sqlite3_bind_text(pStmt, iParam, zVal, -1, SQLITE_TRANSIENT);
|
||||
}
|
||||
}else if( nOpt==7 && 0==sqlite3_strnicmp(zOpt, "maxopen", 7) ){
|
||||
pTab->nMaxOpen = atoi(zVal);
|
||||
if( pTab->nMaxOpen<=0 ){
|
||||
*pzErr = sqlite3_mprintf("swarmvtab: illegal maxopen value");
|
||||
rc = SQLITE_ERROR;
|
||||
}
|
||||
}else if( nOpt==7 && 0==sqlite3_strnicmp(zOpt, "missing", 7) ){
|
||||
if( pTab->pNotFound ){
|
||||
*pzErr = sqlite3_mprintf(
|
||||
"swarmvtab: duplicate \"missing\" option");
|
||||
rc = SQLITE_ERROR;
|
||||
}else{
|
||||
pTab->pNotFound = unionPreparePrintf(&rc, pzErr, pTab->db,
|
||||
"SELECT \"%w\"(?%s)", zVal, pTab->bHasContext ? ",?" : ""
|
||||
);
|
||||
}
|
||||
}else if( nOpt==9 && 0==sqlite3_strnicmp(zOpt, "openclose", 9) ){
|
||||
if( pTab->pOpenClose ){
|
||||
*pzErr = sqlite3_mprintf(
|
||||
"swarmvtab: duplicate \"openclose\" option");
|
||||
rc = SQLITE_ERROR;
|
||||
}else{
|
||||
pTab->pOpenClose = unionPreparePrintf(&rc, pzErr, pTab->db,
|
||||
"SELECT \"%w\"(?,?%s)", zVal, pTab->bHasContext ? ",?" : ""
|
||||
);
|
||||
}
|
||||
}else{
|
||||
*pzErr = sqlite3_mprintf("swarmvtab: unrecognized option: %s",zOpt);
|
||||
rc = SQLITE_ERROR;
|
||||
}
|
||||
sqlite3_free(zVal);
|
||||
}
|
||||
}else{
|
||||
if( i==0 && nArg==1 ){
|
||||
pTab->pNotFound = unionPreparePrintf(&rc, pzErr, pTab->db,
|
||||
"SELECT \"%w\"(?)", zArg
|
||||
);
|
||||
}else{
|
||||
*pzErr = sqlite3_mprintf( "swarmvtab: parse error: %s", azArg[i]);
|
||||
rc = SQLITE_ERROR;
|
||||
}
|
||||
}
|
||||
sqlite3_free(zArg);
|
||||
}
|
||||
}
|
||||
*pRc = rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** xConnect/xCreate method.
|
||||
**
|
||||
@@ -895,7 +654,7 @@ static int unionConnect(
|
||||
/* unionvtab tables may only be created in the temp schema */
|
||||
*pzErr = sqlite3_mprintf("%s tables must be created in TEMP schema", zVtab);
|
||||
rc = SQLITE_ERROR;
|
||||
}else if( argc<4 || (argc>4 && bSwarm==0) ){
|
||||
}else if( argc!=4 && argc!=5 ){
|
||||
*pzErr = sqlite3_mprintf("wrong number of arguments for %s", zVtab);
|
||||
rc = SQLITE_ERROR;
|
||||
}else{
|
||||
@@ -914,17 +673,6 @@ static int unionConnect(
|
||||
|
||||
/* Allocate the UnionTab structure */
|
||||
pTab = unionMalloc(&rc, sizeof(UnionTab));
|
||||
if( pTab ){
|
||||
assert( rc==SQLITE_OK );
|
||||
pTab->db = db;
|
||||
pTab->bSwarm = bSwarm;
|
||||
pTab->nMaxOpen = SWARMVTAB_MAX_OPEN;
|
||||
}
|
||||
|
||||
/* Parse other CVT arguments, if any */
|
||||
if( bSwarm ){
|
||||
unionConfigureVtab(&rc, pTab, pStmt, argc-4, &argv[4], pzErr);
|
||||
}
|
||||
|
||||
/* Iterate through the rows returned by the SQL statement specified
|
||||
** as an argument to the CREATE VIRTUAL TABLE statement. */
|
||||
@@ -967,15 +715,17 @@ static int unionConnect(
|
||||
}else{
|
||||
pSrc->zDb = unionStrdup(&rc, zDb);
|
||||
}
|
||||
if( pTab->bHasContext ){
|
||||
const char *zContext = (const char*)sqlite3_column_text(pStmt, 4);
|
||||
pSrc->zContext = unionStrdup(&rc, zContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
unionFinalize(&rc, pStmt, pzErr);
|
||||
pStmt = 0;
|
||||
|
||||
/* Capture the not-found callback UDF name */
|
||||
if( rc==SQLITE_OK && argc>=5 ){
|
||||
pTab->zNotFoundCallback = unionStrdup(&rc, argv[4]);
|
||||
unionDequote(pTab->zNotFoundCallback);
|
||||
}
|
||||
|
||||
/* It is an error if the SELECT statement returned zero rows. If only
|
||||
** because there is no way to determine the schema of the virtual
|
||||
** table in this case. */
|
||||
@@ -988,6 +738,9 @@ static int unionConnect(
|
||||
** compatible schemas. For swarmvtab, attach the first database and
|
||||
** check that the first table is a rowid table only. */
|
||||
if( rc==SQLITE_OK ){
|
||||
pTab->db = db;
|
||||
pTab->bSwarm = bSwarm;
|
||||
pTab->nMaxOpen = SWARMVTAB_MAX_OPEN;
|
||||
if( bSwarm ){
|
||||
rc = unionOpenDatabase(pTab, 0, pzErr);
|
||||
}else{
|
||||
|
||||
+2
-2
@@ -2021,7 +2021,7 @@ static int ChooseLeaf(
|
||||
){
|
||||
int rc;
|
||||
int ii;
|
||||
RtreeNode *pNode = 0;
|
||||
RtreeNode *pNode;
|
||||
rc = nodeAcquire(pRtree, 1, 0, &pNode);
|
||||
|
||||
for(ii=0; rc==SQLITE_OK && ii<(pRtree->iDepth-iHeight); ii++){
|
||||
@@ -2896,7 +2896,7 @@ static int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){
|
||||
*/
|
||||
if( rc==SQLITE_OK && pRtree->iDepth>0 && NCELL(pRoot)==1 ){
|
||||
int rc2;
|
||||
RtreeNode *pChild = 0;
|
||||
RtreeNode *pChild;
|
||||
i64 iChild = nodeGetRowid(pRtree, pRoot, 0);
|
||||
rc = nodeAcquire(pRtree, iChild, pRoot, &pChild);
|
||||
if( rc==SQLITE_OK ){
|
||||
|
||||
@@ -263,24 +263,6 @@ FTS5_SRC = \
|
||||
$(TOP)/ext/fts5/fts5_varint.c \
|
||||
$(TOP)/ext/fts5/fts5_vocab.c \
|
||||
|
||||
LSM1_SRC = \
|
||||
$(TOP)/ext/lsm1/lsm.h \
|
||||
$(TOP)/ext/lsm1/lsmInt.h \
|
||||
$(TOP)/ext/lsm1/lsm_ckpt.c \
|
||||
$(TOP)/ext/lsm1/lsm_file.c \
|
||||
$(TOP)/ext/lsm1/lsm_log.c \
|
||||
$(TOP)/ext/lsm1/lsm_main.c \
|
||||
$(TOP)/ext/lsm1/lsm_mem.c \
|
||||
$(TOP)/ext/lsm1/lsm_mutex.c \
|
||||
$(TOP)/ext/lsm1/lsm_shared.c \
|
||||
$(TOP)/ext/lsm1/lsm_sorted.c \
|
||||
$(TOP)/ext/lsm1/lsm_str.c \
|
||||
$(TOP)/ext/lsm1/lsm_tree.c \
|
||||
$(TOP)/ext/lsm1/lsm_unix.c \
|
||||
$(TOP)/ext/lsm1/lsm_varint.c \
|
||||
$(TOP)/ext/lsm1/lsm_vtab.c \
|
||||
$(TOP)/ext/lsm1/lsm_win32.c
|
||||
|
||||
|
||||
# Generated source code files
|
||||
#
|
||||
@@ -297,8 +279,6 @@ SRC += \
|
||||
# Source code to the test files.
|
||||
#
|
||||
TESTSRC = \
|
||||
$(TOP)/ext/expert/sqlite3expert.c \
|
||||
$(TOP)/ext/expert/test_expert.c \
|
||||
$(TOP)/ext/fts3/fts3_term.c \
|
||||
$(TOP)/ext/fts3/fts3_test.c \
|
||||
$(TOP)/ext/rbu/test_rbu.c \
|
||||
@@ -509,7 +489,6 @@ SHELL_OPT += -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
|
||||
SHELL_OPT += -DSQLITE_ENABLE_STMTVTAB
|
||||
SHELL_OPT += -DSQLITE_ENABLE_DBPAGE_VTAB
|
||||
SHELL_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
|
||||
SHELL_OPT += -DSQLITE_ENABLE_OFFSET_SQL_FUNC
|
||||
FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1
|
||||
FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5
|
||||
FUZZCHECK_OPT += -DSQLITE_MAX_MEMORY=50000000
|
||||
@@ -693,9 +672,7 @@ SHELL_SRC = \
|
||||
$(TOP)/src/shell.c.in \
|
||||
$(TOP)/ext/misc/shathree.c \
|
||||
$(TOP)/ext/misc/fileio.c \
|
||||
$(TOP)/ext/misc/completion.c \
|
||||
$(TOP)/ext/expert/sqlite3expert.c \
|
||||
$(TOP)/ext/expert/sqlite3expert.h
|
||||
$(TOP)/ext/misc/completion.c
|
||||
|
||||
shell.c: $(SHELL_SRC) $(TOP)/tool/mkshellc.tcl
|
||||
tclsh $(TOP)/tool/mkshellc.tcl >shell.c
|
||||
@@ -789,10 +766,6 @@ fts5.c: $(FTS5_SRC) $(FTS5_HDR)
|
||||
tclsh $(TOP)/ext/fts5/tool/mkfts5c.tcl
|
||||
cp $(TOP)/ext/fts5/fts5.h .
|
||||
|
||||
lsm1.c: $(LSM1_SRC)
|
||||
tclsh $(TOP)/ext/lsm1/tool/mklsm1c.tcl
|
||||
cp $(TOP)/ext/lsm1/lsm.h .
|
||||
|
||||
userauth.o: $(TOP)/ext/userauth/userauth.c $(HDR) $(EXTHDR)
|
||||
$(TCCX) -DSQLITE_CORE -c $(TOP)/ext/userauth/userauth.c
|
||||
|
||||
@@ -814,9 +787,6 @@ sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $
|
||||
sqlite3_analyzer$(EXE): sqlite3_analyzer.c
|
||||
$(TCCX) $(TCL_FLAGS) sqlite3_analyzer.c -o $@ $(LIBTCL) $(THREADLIB)
|
||||
|
||||
sqlite3_expert$(EXE): $(TOP)/ext/expert/sqlite3expert.h $(TOP)/ext/expert/sqlite3expert.c $(TOP)/ext/expert/expert.c sqlite3.c
|
||||
$(TCCX) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION $(TOP)/ext/expert/sqlite3expert.c $(TOP)/ext/expert/expert.c sqlite3.c -o sqlite3_expert$(EXE) $(THREADLIB)
|
||||
|
||||
CHECKER_DEPS =\
|
||||
$(TOP)/tool/mkccode.tcl \
|
||||
sqlite3.c \
|
||||
@@ -1043,11 +1013,9 @@ clean:
|
||||
rm -f sqlite3rc.h
|
||||
rm -f shell.c sqlite3ext.h
|
||||
rm -f sqlite3_analyzer sqlite3_analyzer.exe sqlite3_analyzer.c
|
||||
rm -f sqlite3_expert sqlite3_expert.exe
|
||||
rm -f sqlite-*-output.vsix
|
||||
rm -f mptester mptester.exe
|
||||
rm -f fuzzershell fuzzershell.exe
|
||||
rm -f fuzzcheck fuzzcheck.exe
|
||||
rm -f sqldiff sqldiff.exe
|
||||
rm -f fts5.* fts5parse.*
|
||||
rm -f lsm.h lsm1.c
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
C Stricter\stest\scases.
|
||||
D 2017-12-29T16:37:33.070
|
||||
F Makefile.in 804c347948b0ad5a962aea3e59413e897227e0173d0e76910f11f473e6c7ae9b
|
||||
C Add\sthe\s"PRAGMA\stable_ipk(TABLE)"\scommand\sfor\sevaluation\spurposes.
|
||||
D 2017-11-28T02:47:42.046
|
||||
F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc 57dcce0595d4a0c4b94b6f6ba732b8e33540358adf5fb8e1aa8389d34a9677e8
|
||||
F README.md eeae1e552f93ef72ef7c5b8f6647b368a001c28820ad1df179d3dae602bef681
|
||||
F Makefile.msc e5d7606238f55816da99f719969598df5b091aa2e9a6935c9412fcae8f53fc44
|
||||
F README.md f5c87359573c4d255425e588a56554b50fdcc2afba4e017a2e02a43701456afd
|
||||
F VERSION 0c10cdfed866fdd2d80434f64f042c3330f1daaed12e54287beb104f04b3faaf
|
||||
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
|
||||
F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2
|
||||
@@ -40,12 +40,6 @@ F ext/README.md fd5f78013b0a2bc6f0067afb19e6ad040e89a10179b4f6f03eee58fac5f169bd
|
||||
F ext/async/README.txt e12275968f6fde133a80e04387d0e839b0c51f91
|
||||
F ext/async/sqlite3async.c 0f3070cc3f5ede78f2b9361fb3b629ce200d7d74
|
||||
F ext/async/sqlite3async.h f489b080af7e72aec0e1ee6f1d98ab6cf2e4dcef
|
||||
F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3
|
||||
F ext/expert/expert.c 4791c5e064aea81b2b829fa95228b22283380ee370ea88a1e580103b75516ebf
|
||||
F ext/expert/expert1.test 0c71a3453ce3a0b4dbe952713aec0ae8d416dd846820dd027b08f305f5278b30
|
||||
F ext/expert/sqlite3expert.c 252f3129f12a0e9df094a14711db98265c9c6d7afa033ec906d94e920f5c7ba7
|
||||
F ext/expert/sqlite3expert.h af6354f8ee5c9e025024e63fec3bd640a802afcc3099a44d804752cf0791d811
|
||||
F ext/expert/test_expert.c 85f5c743a899063fa48296d21de2f32c26d09a21c8582b2a0bc482e8de183e7a
|
||||
F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e
|
||||
F ext/fts1/ft_hash.c 3927bd880e65329bdc6f506555b228b28924921b
|
||||
F ext/fts1/ft_hash.h 06df7bba40dadd19597aa400a875dbc2fed705ea
|
||||
@@ -106,12 +100,12 @@ F ext/fts3/unicode/parseunicode.tcl da577d1384810fb4e2b209bf3313074353193e95
|
||||
F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0
|
||||
F ext/fts5/fts5.h 62f3e33ceeb9a428db139f9c012186b371da1cc7
|
||||
F ext/fts5/fts5Int.h eda28e3a0a5d87c412e8355fe35da875b04cb389908c8eb0d867ad662adbc491
|
||||
F ext/fts5/fts5_aux.c ca666a3bbe07c5a3bbe9fffaea19c935a1efaf337333e28bad7bdd1971ffd093
|
||||
F ext/fts5/fts5_aux.c 67acf8d51723cf28ffc3828210ba662df4b8d267
|
||||
F ext/fts5/fts5_buffer.c 1dd1ec0446b3acfc2d7d407eb894762a461613e2695273f48e449bfd13e973ff
|
||||
F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857
|
||||
F ext/fts5/fts5_expr.c 01048018d21524e2c302b063ff5c3cdcf546e03297215e577205d85b47499deb
|
||||
F ext/fts5/fts5_hash.c 32be400cf761868c9db33efe81a06eb19a17c5402ad477ee9efb51301546dd55
|
||||
F ext/fts5/fts5_index.c 5fe14375a29e8a7aa8f3e863babe180a19269206c254c8f47b216821d4ac1e15
|
||||
F ext/fts5/fts5_index.c 2ce9d50ec5508b8205615aad69e1c9b2c77f017f21d4479e1fb2079c01fdd017
|
||||
F ext/fts5/fts5_main.c 24868f88ab2a865defbba7a92eebeb726cc991eb092b71b5f5508f180c72605b
|
||||
F ext/fts5/fts5_storage.c fb5ef3c27073f67ade2e1bea08405f9e43f68f5f3676ed0ab7013bce5ba10be6
|
||||
F ext/fts5/fts5_tcl.c a7df39442ae674dde877cf06fe02ebb7658e69c179a4d223241c90df4f14b54e
|
||||
@@ -129,7 +123,7 @@ F ext/fts5/test/fts5ab.test 9205c839332c908aaad2b01ab8670ece8b161e8f2ec8a9fabf18
|
||||
F ext/fts5/test/fts5ac.test a7aa7e1fefc6e1918aa4d3111d5c44a09177168e962c5fd2cca9620de8a7ed6d
|
||||
F ext/fts5/test/fts5ad.test e8cf959dfcd57c8e46d6f5f25665686f3b6627130a9a981371dafdf6482790de
|
||||
F ext/fts5/test/fts5ae.test 1142d16d9cc193894dc13cc8f9c7a8a21411ac61b5567a878514df6f9f0d7bb7
|
||||
F ext/fts5/test/fts5af.test 724247405b13f8f06cc6ce464dc4f152dc5dd4e86b12c2099685d8f19747bf7b
|
||||
F ext/fts5/test/fts5af.test aa635947bda31ac87fbe99483eef4d9a8571f58ad89c75dfb63312a35688eceb
|
||||
F ext/fts5/test/fts5ag.test 7816f25a0707578f08145ab539fc0ca025f8951e788b28a6a18a06b2099469dd
|
||||
F ext/fts5/test/fts5ah.test 27b5a33bfd0363ca8a4dc659e6e2a5df3dea1c3c5b04bc51ca6aeb1277bd9b21
|
||||
F ext/fts5/test/fts5ai.test d837c42249c0d8ad1a2912270e22cf2f303790a611f85c0be3a58e42a3696e3d
|
||||
@@ -189,7 +183,7 @@ F ext/fts5/test/fts5plan.test e30e8378441114ef6977a3dc24ecd203caa670d782124dfc9a
|
||||
F ext/fts5/test/fts5porter.test 8d08010c28527db66bc3feebd2b8767504aaeb9b101a986342fa7833d49d0d15
|
||||
F ext/fts5/test/fts5porter2.test 0d251a673f02fa13ca7f011654873b3add20745f7402f108600a23e52d8c7457
|
||||
F ext/fts5/test/fts5prefix.test a0fa67b06650f2deaa7bf27745899d94e0fb547ad9ecbd08bfad98c04912c056
|
||||
F ext/fts5/test/fts5query.test ac363b17a442620bb0780e93c24f16a5f963dfe2f23dc85647b869efcfada728
|
||||
F ext/fts5/test/fts5query.test bdb6fd9e73268cfc07f789f1448cd71ea78acb02e481c619f286289ea18ca518
|
||||
F ext/fts5/test/fts5rank.test 6e149da77a269923a8439aaa52366e49b85be4721902662da39a5ded16ed85d9
|
||||
F ext/fts5/test/fts5rebuild.test 6d09fd54b1170a1e54fe17b808bbf17fba3154956cc2f065dd94bf1e3d254f63
|
||||
F ext/fts5/test/fts5restart.test 835ecc8f449e3919f72509ab58056d0cedca40d1fe04108ccf8ac4c2ba41f415
|
||||
@@ -216,7 +210,7 @@ F ext/fts5/tool/loadfts5.tcl 95b03429ee6b138645703c6ca192c3ac96eaf093
|
||||
F ext/fts5/tool/mkfts5c.tcl d1c2a9ab8e0ec690a52316f33dd9b1d379942f45
|
||||
F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c
|
||||
F ext/icu/README.txt d9fbbad0c2f647c3fdf715fc9fd64af53aedfc43
|
||||
F ext/icu/icu.c c2c7592574c08cd1270d909b8fb8797f6ea1f49e931e71dbcc25506b9b224580
|
||||
F ext/icu/icu.c 635775226d07c743c770888a9dd5175afc6e67d3e28a4032b7fedc3bcaa92e65
|
||||
F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37
|
||||
F ext/lsm1/Makefile 98b0a24b45e248283d6bea4b6cb3e58d7b394edd8e96a0ac28c5fa5104813bad
|
||||
F ext/lsm1/Makefile.msc f8c878b467232226de288da320e1ac71c131f5ec91e08b21f502303347260013
|
||||
@@ -245,15 +239,15 @@ F ext/lsm1/lsm-test/lsmtest_tdb4.c 47e8bb5eba266472d690fb8264f1855ebdba0ae5a0e54
|
||||
F ext/lsm1/lsm-test/lsmtest_util.c 241622db5a332a09c8e6e7606b617d288a37b557f7d3bce0bb97809f67cc2806
|
||||
F ext/lsm1/lsm-test/lsmtest_win32.c 0e0a224674c4d3170631c41b026b56c7e1672b151f5261e1b4cc19068641da2d
|
||||
F ext/lsm1/lsm.h 0f6f64ff071471cb87bf98beb8386566f30ea001
|
||||
F ext/lsm1/lsmInt.h 5983690e05e83653cc01ba9d8fbf8455e534ddf8349ed9adedbf46a7549760b0
|
||||
F ext/lsm1/lsm_ckpt.c 0eabfaf812ddb4ea43add38f05e430694cd054eb622c3e35af4c43118a2d5321
|
||||
F ext/lsm1/lsm_file.c 3c51841d5b3e7da162693cbac9a9f47eeedf6bcbbe2969a4d25e30c428c9fe36
|
||||
F ext/lsm1/lsmInt.h e9e5c5f08e35a104086102b3def94ee69cbc0d39002f6596f5c80a640439628e
|
||||
F ext/lsm1/lsm_ckpt.c ac6fb4581983291c2e0be6fbb68f12b26f0c08d606835c05417be1323d0fdd03
|
||||
F ext/lsm1/lsm_file.c 4b3fb56336fbc9d941e1b2042e809d986feebdc41e73dc7fc4fdc0dd1bd4274d
|
||||
F ext/lsm1/lsm_log.c a8bf334532109bba05b09a504ee45fc393828b0d034ca61ab45e3940709d9a7c
|
||||
F ext/lsm1/lsm_main.c 801295038b548ae2e5fae93f08c3f945154f40848a03ff26b16eab5d04ba573a
|
||||
F ext/lsm1/lsm_main.c 15e73ccdafdd44ddeefc29e332079d88ba8f00c12c797b3c2b63d3171b5afce8
|
||||
F ext/lsm1/lsm_mem.c 4c51ea9fa285ee6e35301b33491642d071740a0a
|
||||
F ext/lsm1/lsm_mutex.c 378edf0a2b142b4f7640ee982df06d50b98788ea
|
||||
F ext/lsm1/lsm_shared.c 76adfc1ed9ffebaf92746dde4b370ccc48143ca8b05b563816eadd2aadf1c525
|
||||
F ext/lsm1/lsm_sorted.c d07ff7c28758542b8b4da4b5a1fb67b22a4d33e50e7f684cffe1f6c45cf5182c
|
||||
F ext/lsm1/lsm_sorted.c 8f899fb64a4c736ff3c27d5126c7ce181129ddffde947fe5fb657a7a413f470b
|
||||
F ext/lsm1/lsm_str.c 65e361b488c87b10bf3e5c0070b14ffc602cf84f094880bece77bbf6678bca82
|
||||
F ext/lsm1/lsm_tree.c 682679d7ef2b8b6f2fe77aeb532c8d29695bca671c220b0abac77069de5fb9fb
|
||||
F ext/lsm1/lsm_unix.c 57361bcf5b1a1a028f5d66571ee490e9064d2cfb145a2cc9e5ddade467bb551b
|
||||
@@ -262,7 +256,6 @@ F ext/lsm1/lsm_vtab.c 529255dc704289001b225d97e57e0cfa14b29c3f281c7349cfa8fdb655
|
||||
F ext/lsm1/lsm_win32.c 0a4acbd7e8d136dd3a5753f0a9e7a9802263a9d96cef3278cf120bcaa724db7c
|
||||
F ext/lsm1/test/lsm1_common.tcl 5ed4bab07c93be2e4f300ebe46007ecf4b3e20bc5fbe1dedaf04a8774a6d8d82
|
||||
F ext/lsm1/test/lsm1_simple.test ca949efefa102f4644231dcd9291d8cda7699a4ce1006b26e0e3fcb72233f422
|
||||
F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f6078e07335398b0
|
||||
F ext/misc/README.md 8e008c8d2b02e09096b31dfba033253ac27c6c06a18aa5826e299fa7601d90b2
|
||||
F ext/misc/amatch.c 6db4607cb17c54b853a2d7c7c36046d004853f65b9b733e6f019d543d5dfae87
|
||||
F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb
|
||||
@@ -284,16 +277,16 @@ F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342
|
||||
F ext/misc/percentile.c 92699c8cd7d517ff610e6037e56506f8904dae2e
|
||||
F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4
|
||||
F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c
|
||||
F ext/misc/rot13.c 540a169cb0d74f15522a8930b0cccdcb37a4fd071d219a5a083a319fc6e8db77
|
||||
F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a
|
||||
F ext/misc/scrub.c 1c5bfb8b0cd18b602fcb55755e84abf0023ac2fb
|
||||
F ext/misc/series.c f3c0dba5c5c749ce1782b53076108f87cf0b71041eb6023f727a9c50681da564
|
||||
F ext/misc/sha1.c 0b9e9b855354910d3ca467bf39099d570e73db56
|
||||
F ext/misc/shathree.c 9e960ba50483214c6a7a4b1517f8d8cef799e9db381195178c3fd3ad207e10c0
|
||||
F ext/misc/shathree.c fa185d7aee0ad0aca5e091b4a2db7baff11796170e5793b5de99e511a13af448
|
||||
F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
|
||||
F ext/misc/spellfix.c 41cf26c6b89fcaa8798ae10ae64d39c1f1d9d6995152e545bd491c13058b8fac
|
||||
F ext/misc/stmt.c 6f16443abb3551e3f5813bb13ba19a30e7032830015b0f92fe0c0453045c0a11
|
||||
F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512
|
||||
F ext/misc/unionvtab.c de36c2c45583d68f99e45b392311967066b02e2651d05697da783698b245b387
|
||||
F ext/misc/unionvtab.c 1e0ebc5078e1a916db191bcd88f87e94ea7ba4aa563ee30ff706261cb4b39461
|
||||
F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95
|
||||
F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178
|
||||
F ext/misc/vtablog.c 31d0d8f4406795679dcd3a67917c213d3a2a5fb3ea5de35f6e773491ed7e13c9
|
||||
@@ -344,7 +337,7 @@ F ext/repair/test/checkfreelist01.test 3e8aa6aeb4007680c94a8d07b41c339aa635cc782
|
||||
F ext/repair/test/checkindex01.test 6945d0ffc0c1dc993b2ce88036b26e0f5d6fcc65da70fc9df27c2647bb358b0f
|
||||
F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c
|
||||
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
||||
F ext/rtree/rtree.c 2111f685ae07988622c241f819b56fea60782f56e32f97e334473c59f6083481
|
||||
F ext/rtree/rtree.c cc91b6905bf55512c6ebc7dfdd37ac81c86f1753db8cfa6d62f0ee864464044f
|
||||
F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
|
||||
F ext/rtree/rtree1.test 82a353747fcab1083d114b2ac84723dfefdbf86c1a6e1df57bf588c7d4285436
|
||||
F ext/rtree/rtree2.test 5f25b01acd03470067a2d52783b2eb0a50bf836803d4342d20ca39e541220fe2
|
||||
@@ -401,7 +394,7 @@ F ext/userauth/userauth.c 3410be31283abba70255d71fd24734e017a4497f
|
||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
|
||||
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
|
||||
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
|
||||
F main.mk b5f569262e4f8111bb8cf6110784b8210fe14ea45f6c7ea50fb4230ebe7a4880
|
||||
F main.mk fbe15be384ec172be0cc30efc91cda61ca16bd5d833e8b812cf653ccb0c74977
|
||||
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
|
||||
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
|
||||
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
|
||||
@@ -420,21 +413,21 @@ F src/auth.c 6277d63837357549fe14e723490d6dc1a38768d71c795c5eb5c0f8a99f918f73
|
||||
F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
|
||||
F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
|
||||
F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca
|
||||
F src/btree.c 0a1f63b50ab1ac5d4b1637c30cb1ae123fbc162ec8cb6336ddb9491a0bc1e363
|
||||
F src/btree.h 0866c0a08255142ea0e754aabd211c843cab32045c978a592a43152405ed0c84
|
||||
F src/btree.c b83a6b03f160528020bb965f0c3a40af5286cd4923c3870fd218177f03a120a7
|
||||
F src/btree.h 32ef5d3f25dc70ef1ee9cecf84a023c21378f06a57cd701d2e866e141b150f09
|
||||
F src/btreeInt.h 55b702efce17e5d1941865464227d3802cfc9c7c832fac81d4c94dced47a71fc
|
||||
F src/build.c a03eb5a1cfff74784c24a4478ba5455711571936f1ac9d43f94fa7df57509977
|
||||
F src/callback.c fe677cb5f5abb02f7a772a62a98c2f516426081df68856e8f2d5f950929b966a
|
||||
F src/build.c 514db9d494ed29155e552f2ec2fa7c55c0241f847c683156b7c017f4b0bad9fa
|
||||
F src/callback.c 28a8ede982fde4129b828350f78f2c01fe7d12c74d1a0a05d7108ab36f308688
|
||||
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
|
||||
F src/ctime.c ff1be3eed7bdd75aaca61ca8dc848f7c9f850ef2fb9cb56f2734e922a098f9c0
|
||||
F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957
|
||||
F src/date.c 48f743d88bbe88f848532d333cca84f26e52a4f217e86f86be7fc1b919c33d74
|
||||
F src/dbpage.c 8db4c97f630e7d83f884ea75caf1ffd0988c160e9d530194d93721c80821e0f6
|
||||
F src/dbstat.c 7a4ba8518b6369ef3600c49cf9c918ad979acba610b2aebef1b656d649b96720
|
||||
F src/delete.c 74667ad914ac143731a444a1bacf29ceb18f6eded8a0dd17aafae80baa07f8bb
|
||||
F src/expr.c ad6e7a9c34a4bab9d10cc857d647ae7ce370a633b5c0bfa71f1c29b81ae364b8
|
||||
F src/delete.c e6a70fb58f6628f0ffc6d7221a6702c0d7b342c82520385b3996b364c22e0cb3
|
||||
F src/expr.c fe11b91bb65b869143bd42023427c4429778ae42c0a0db7762f68f75b347a958
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
F src/fkey.c d617daf66b5515e2b42c1405b2b4984c30ca50fb705ab164271a9bf66c69e331
|
||||
F src/func.c 697a3ee3b8c8481db497226e9e71935727d6a9fb3d3cc049e82a1c717a0a8342
|
||||
F src/func.c 0fb9a2d678d3c8aba89b46468b309cd7e8fa9806a369a30aa89024660845bb13
|
||||
F src/global.c ac3094f1dc59fbeb919aef7cc0cc827a8459d1fb1adb7972ef75bd9e0c10b75b
|
||||
F src/hash.c a12580e143f10301ed5166ea4964ae2853d3905a511d4e0c44497245c7ce1f7a
|
||||
F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
|
||||
@@ -442,9 +435,9 @@ F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
|
||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||
F src/insert.c cb67cc56ef2ddd13e6944b2c0dd08a920bcd9503230adef8b9928d338097c722
|
||||
F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e
|
||||
F src/loadext.c 55bcc3c741059a1056859e8adaf133aa179e22be12215c0936b2f354ef71209b
|
||||
F src/main.c 690c4134f944cbd5b71d59dd6e61ce4131f6a50ab774f38108e57d07d79cf876
|
||||
F src/malloc.c 6f684fd039f53bf9195193eb0cde731a2954970fabc6ef054ba379b6052dc296
|
||||
F src/loadext.c 20865b183bb8a3723d59cf1efffc3c50217eb452c1021d077b908c94da26b0b2
|
||||
F src/main.c 99ed3d45e315afb2ada049991db7944b1210663bb30bfd0b63103537c1ac25d0
|
||||
F src/malloc.c a02c9e69bc76bee0f639416b947a946412890b606301454727feadcb313536d6
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
|
||||
F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3
|
||||
@@ -452,7 +445,7 @@ F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a
|
||||
F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944
|
||||
F src/memjournal.c 6f3d36a0a8f72f48f6c3c722f04301ac64f2515435fa42924293e46fc7994661
|
||||
F src/msvc.h 4942752b6a253116baaa8de75256c51a459a5e81
|
||||
F src/mutex.c b021263554c8a3995e9d53193b8194b96d1ed28e06c3b532dd7f7d29cf0c7d53
|
||||
F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c
|
||||
F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85
|
||||
F src/mutex_noop.c 9d4309c075ba9cc7249e19412d3d62f7f94839c4
|
||||
F src/mutex_unix.c 27bb6cc49485ee46711a6580ab7b3f1402211d23
|
||||
@@ -462,28 +455,28 @@ F src/os.c 22d31db3ca5a96a408fbf1ceeaaebcaf64c87024d2ff9fe1cf2ddbec3e75c104
|
||||
F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432
|
||||
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
|
||||
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
|
||||
F src/os_unix.c 7fc2735390a7809d5d893ed735d994ff12521224b89738226fff6f1a0aa1c932
|
||||
F src/os_win.c 0a4afa35cc8e812000df3ea2f64b476131b39e29e75d8007d0504726e4761de4
|
||||
F src/os_unix.c e87cef0bb894b94d96ee3af210be669549d111c580817d14818101b992640767
|
||||
F src/os_win.c 7f36120492e4a23c48d1dd685edf29ae459c6d555660c61f1323cea3e5a1191d
|
||||
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
|
||||
F src/pager.c 07cf850241667874fcce9d7d924c814305e499b26c804322e2261247b5921903
|
||||
F src/pager.h 581698f2177e8bd4008fe4760898ce20b6133d1df22139b9101b5155f900df7a
|
||||
F src/parse.y 44cbbc3e132ea128258eff7be7f6d5c5dfa25522f89ec8b5501276966511bd50
|
||||
F src/parse.y d79001da275bfe344b409006b85e81e486a0f6afc3762fdf0944f000f4aa0111
|
||||
F src/pcache.c 7ae91a4557a43d77d449accbfdc68846e6516f8e2eda46e8bbe4536fb669b201
|
||||
F src/pcache.h 072f94d29281cffd99e46c1539849f248c4b56ae7684c1f36626797fee375170
|
||||
F src/pcache1.c 716975564c15eb6679e97f734cec1bfd6c16ac3d4010f05f1f8e509fc7d19880
|
||||
F src/pragma.c bea56df3ae0637768c0da4fbbb8f2492f780980d95000034a105ff291bf7ca69
|
||||
F src/pragma.h bb83728944b42f6d409c77f5838a8edbdb0fe83046c5496ffc9602b40340a324
|
||||
F src/prepare.c 259f4e7960c47082c9653f3d5f0c294abd68bb9c3aab86de7630700cba1c20fb
|
||||
F src/pragma.c 021613c97a331d42c45ecc1510c8ebd222972f9679254078a7e2b5c4513c4566
|
||||
F src/pragma.h 4ce81be73b88094c23fc635643f8712178f986f776830ff8115627c810714b75
|
||||
F src/prepare.c 7cf451f903ad92a14e22de415a13e7a7d30f1bd23b3d21eeb0dc7264723244c5
|
||||
F src/printf.c 9506b4b96e59c0467047155f09015750cb2878aeda3d39e5610c1192ddc3c41c
|
||||
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
|
||||
F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730
|
||||
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
|
||||
F src/select.c 8b22abe193e4d8243befa2038e4ae2405802fed1c446e5e502d11f652e09ba74
|
||||
F src/shell.c.in f3ec8f90dd698ea98781a90642c91eacbc24f4e55bb551c7b2762000d3ef55dc
|
||||
F src/sqlite.h.in b4dc75265ed04b98e2184011a7dd0054ce2137ff84867a6be8b4f3bdfbc03d30
|
||||
F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157
|
||||
F src/shell.c.in c441d7ddfbb8120cd8a7cde838ca5c9167311a7e400b1077c3ae6090aa420be8
|
||||
F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818
|
||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||
F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34
|
||||
F src/sqliteInt.h fd8702c65994d7de3e2d8f7d85d958731da1ed29476571fdfa2290fd8ec0bf80
|
||||
F src/sqliteInt.h 9b26fbab75ef426efae70d88ab535844d59de8954542b122c1d49af580a76f58
|
||||
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
|
||||
F src/status.c 9737ed017279a9e0c5da748701c3c7bf1e8ae0dae459aad20dd64fcff97a7e35
|
||||
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
|
||||
@@ -503,7 +496,7 @@ F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0
|
||||
F src/test_bestindex.c 78809f11026f18a93fcfd798d9479cba37e1201c830260bf1edc674b2fa9b857
|
||||
F src/test_blob.c ae4a0620b478548afb67963095a7417cd06a4ec0a56adb453542203bfdcb31ce
|
||||
F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274
|
||||
F src/test_config.c cc8a1d44648d9392a14f4ecfc841d027daaf61f952b9f70792edf11373aaa3dd
|
||||
F src/test_config.c 2dad654eb81e90160f764f485bf7248e87b6d251e484c959de1aa04935acae8e
|
||||
F src/test_delete.c e2fe07646dff6300b48d49b2fee2fe192ed389e834dd635e3b3bac0ce0bf9f8f
|
||||
F src/test_demovfs.c a0c3bdd45ed044115c2c9f7779e56eafff18741e
|
||||
F src/test_devsym.c 1960abbb234b97e9b920f07e99503fc04b443f62bbc3c6ff2c2cea2133e3b8a2
|
||||
@@ -531,7 +524,7 @@ F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe
|
||||
F src/test_sqllog.c 11e6ce7575f489155c604ac4b439f2ac1d3d5aef
|
||||
F src/test_superlock.c 4839644b9201da822f181c5bc406c0b2385f672e
|
||||
F src/test_syscall.c 1073306ba2e9bfc886771871a13d3de281ed3939
|
||||
F src/test_tclsh.c 58052fe48efe8f579834f4648d239569f2efc6285f5019ebdf0040f58d16238d
|
||||
F src/test_tclsh.c 74fcfb7f3b0ff1f871e62263dd84ffba46a8e9d477439115e0fb2035e4bf69e1
|
||||
F src/test_tclvar.c 33ff42149494a39c5fbb0df3d25d6fafb2f668888e41c0688d07273dcb268dfc
|
||||
F src/test_thread.c 911d15fb14e19c0c542bdc8aabf981c2f10a4858
|
||||
F src/test_vfs.c f0186261a24de2671d080bcd8050732f0cb64f6e
|
||||
@@ -541,29 +534,29 @@ F src/test_windirent.h 5d67483a55442e31e1bde0f4a230e6e932ad5906
|
||||
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
||||
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
|
||||
F src/tokenize.c 1003d6d90c6783206c711f0a9397656fa5b055209f4d092caa43bb3bf5215db5
|
||||
F src/treeview.c eae35972ff44f67064de2eaf35f04afe94e7aea3271a8b3bcebb3f954880fec3
|
||||
F src/trigger.c a34539c69433276d37b0da9a89c117726ff2d292c0902895af1f393a983cd3a1
|
||||
F src/treeview.c 08a83195de8fad3f00542e3c8b3c1eb1222c999817c9e301ffb7f332882b96dd
|
||||
F src/trigger.c fc6be2a6e103d9e38b161e07d7db0ffb1f2218bd2f27ccdc0a3d1cc89e9cea0f
|
||||
F src/update.c 961bd1265d4d1e5cd65c9a54fa5122fb7aefcb003fcf2de0c092fceb7e58972c
|
||||
F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5
|
||||
F src/util.c 7315e97a8dc2c8e19ca64196c652cf0a65d13fd0a211b2cec082062372dc6261
|
||||
F src/util.c d01fa6f45bfad3b65fb2490513aa2e0676412c61b4b094340b513cf72c3704a4
|
||||
F src/vacuum.c 90839322fd5f00df9617eb21b68beda9b6e2a2937576b0d65985e4aeb1c53739
|
||||
F src/vdbe.c cb3b5035f337c9fed4a0170ca20325dc4500b832c57d00561310cbb78149a73c
|
||||
F src/vdbe.c 3393b508d9ad084ffce232a7c53e375ef5ac99b50b685c5131fcdfce97a9d534
|
||||
F src/vdbe.h d50cadf12bcf9fb99117ef392ce1ea283aa429270481426b6e8b0280c101fd97
|
||||
F src/vdbeInt.h 1fe00770144c12c4913128f35262d11527ef3284561baaab59b947a41c08d0d9
|
||||
F src/vdbeapi.c 9c670ca0dcc1cd86373aa353b747b26fe531ca5cd4331690c611d1f03842e2a1
|
||||
F src/vdbeaux.c 7ae48b180e5dd5d282e6752d155f1ab7929196d8e6577b82742044188152ca85
|
||||
F src/vdbeaux.c b02a1f842c0e916285643b8475b7189f10b76f9e7edb5e2353a913c7980f90b5
|
||||
F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191
|
||||
F src/vdbemem.c 8478f7fb1948bf8fdeec7c2cb59ea58155c31258b9cd43c56d485e03ed40bd07
|
||||
F src/vdbemem.c 6e6082377183b8fd8d6f2bce45250b4c2e89bfeb534a094cd8612dae8aaa2fda
|
||||
F src/vdbesort.c 731a09e5cb9e96b70c394c1b7cf3860fbe84acca7682e178615eb941a3a0ef2f
|
||||
F src/vdbetrace.c 48e11ebe040c6b41d146abed2602e3d00d621d7ebe4eb29b0a0f1617fd3c2f6c
|
||||
F src/vtab.c 0e4885495172e1bdf54b12cce23b395ac74ef5729031f15e1bc1e3e6b360ed1a
|
||||
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
||||
F src/wal.c 5a3f464edd64596f601683ed321d12e6fd93c5fb9afdfb3653d6ffd0fee9c48f
|
||||
F src/wal.c beeb71e4eab65dbf0d95f2717efc6ca3c0f5b3090ce67f3de63828f39a6ff053
|
||||
F src/wal.h 8de5d2d3de0956d6f6cb48c83a4012d5f227b8fe940f3a349a4b7e85ebcb492a
|
||||
F src/walker.c da987a20d40145c0a03c07d8fefcb2ed363becc7680d0500d9c79915591f5b1f
|
||||
F src/where.c 36b92103f726609cc3dbe07c619426bd6886bede455de56ccff54c8e567f5582
|
||||
F src/where.c 9752b68e03e2044f0faa4708fabb0189769067b660bffa931e1fd65736269659
|
||||
F src/whereInt.h 82c04c5075308abbac59180c8bad5ecb45b07453981f60a53f3c7dee21e1e971
|
||||
F src/wherecode.c af1e79154aaa88cd802d6f2e5b945f67eaca7c958d1525fbf8ee19d5bd7b9020
|
||||
F src/wherecode.c 611fcabd05592ed2febd7d182f9621425b0466c5232d70e0981c842d429356d5
|
||||
F src/whereexpr.c 427ea8e96ec24f2a7814c67b8024ad664a9c7656264c4566c34743cb23186e46
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
|
||||
@@ -658,7 +651,7 @@ F test/busy.test 510dc6daaad18bcbbc085bcc6217d6dc418def5e73f72ce1475eea0cb783472
|
||||
F test/cache.test 13bc046b26210471ca6f2889aceb1ea52dc717de
|
||||
F test/cacheflush.test af25bb1509df04c1da10e38d8f322d66eceedf61
|
||||
F test/cachespill.test 895997f84a25b323b166aecb69baab2d6380ea98f9e0bcc688c4493c535cfab9
|
||||
F test/capi2.test d3267a146df2251e7ad09a672d59e33e836d74c6fbeb843c18e87835ef646c12
|
||||
F test/capi2.test 011c16da245fdc0106a2785035de6b242c05e738
|
||||
F test/capi3.test 986e57cea8ab423b3fc8c2e3b69330394252d3d2a4496122ff3749e258305695
|
||||
F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4
|
||||
F test/capi3c.test 7ebed1d8fa2f3190149d556fe8cff5a006be62af437c5c4640db614470126098
|
||||
@@ -682,7 +675,7 @@ F test/collate9.test 3adcc799229545940df2f25308dd1ad65869145a
|
||||
F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6
|
||||
F test/collateB.test 1e68906951b846570f29f20102ed91d29e634854ee47454d725f2151ecac0b95
|
||||
F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1
|
||||
F test/colname.test 101aa39392a1f6883278f588836a3ab99178f8103f78032433400475cc05109f
|
||||
F test/colname.test c47639d26cbeba6977457e5ef2c2c55c5b6c889478dd7eb0ed858ba894e7fa93
|
||||
F test/conflict.test 029faa2d81a0d1cafb5f88614beb663d972c01db
|
||||
F test/conflict2.test bb0b94cf7196c64a3cbd815c66d3ee98c2fecd9c
|
||||
F test/conflict3.test a83db76a6c3503b2fa057c7bfb08c318d8a422202d8bc5b86226e078e5b49ff9
|
||||
@@ -788,7 +781,7 @@ F test/extraquick.test cb254400bd42bfb777ff675356aabf3287978f79
|
||||
F test/fallocate.test 87b5e43c872b7e69cd80b7b8813eb102b571a75d45dda24e38b65537bcc85733
|
||||
F test/filectrl.test 6e871c2d35dead1d9a88e176e8d2ca094fec6bb3
|
||||
F test/filefmt.test f393e80c4b8d493b7a7f8f3809a8425bbf4292af1f5140f01cb1427798a2bbd4
|
||||
F test/fkey1.test 9d7e3a0d409e7f64ab077af3b4fc5e5ce1a4e8d8f1272b65b9d93480aeb1fa2b
|
||||
F test/fkey1.test ba64806ff9a04eecab2679caad377ae99a5e94e4
|
||||
F test/fkey2.test 155809016fad6b2a1491facf2ac53a551bc57c2c
|
||||
F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49
|
||||
F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d
|
||||
@@ -917,7 +910,6 @@ F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
|
||||
F test/func3.test d202a7606d23f90988a664e88e268aed1087c11c
|
||||
F test/func4.test 6beacdfcb0e18c358e6c2dcacf1b65d1fa80955f
|
||||
F test/func5.test cdd224400bc3e48d891827cc913a57051a426fa4
|
||||
F test/func6.test 1a2bc511fedb779e2bd3154361385216c6d35080f36bfe896b8cdd1b1954294a
|
||||
F test/fuzz-oss1.test e58330d01cbbd8215ee636b17a03fe220b37dbfa
|
||||
F test/fuzz.test 96083052bf5765e4518c1ba686ce2bab785670d1
|
||||
F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1
|
||||
@@ -940,7 +932,7 @@ F test/hexlit.test 4a6a5f46e3c65c4bf1fa06f5dd5a9507a5627751
|
||||
F test/hidden.test 23c1393a79e846d68fd902d72c85d5e5dcf98711
|
||||
F test/hook.test dbc0b87756e1e20e7497b56889c9e9cd2f8cc2b5
|
||||
F test/hook2.test b9ff3b8c6519fb67f33192f1afe86e7782ee4ac8
|
||||
F test/icu.test 7fb00edc09e05d51e36be12b33e0af04e3394e3b02dbdcb2eefcb901203e28c4
|
||||
F test/icu.test 73956798bace8982909c00476b216714a6d0559a
|
||||
F test/ieee754.test 806fc0ce7f305f57e3331eaceeddcfec9339e607
|
||||
F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8
|
||||
F test/in.test 2fa2dfba1afe30eb830f327e7131dfadaa7a701d677de0eb65f9303d99e18fe0
|
||||
@@ -983,7 +975,7 @@ F test/instrfault.test 0f870b218ea17cd477bb19ed330eecdb460dd53a
|
||||
F test/intarray.test 46d95b457916638c5d8b1af21fb174804b3acf8b
|
||||
F test/interrupt.test 16ea879ec728cb76414c148c5f24afd5d1f91054
|
||||
F test/interrupt2.test e4408ca770a6feafbadb0801e54a0dcd1a8d108d
|
||||
F test/intpkey.test ac71107a49a06492b69b82aafaf225400598d3c8
|
||||
F test/intpkey.test 21290ef810c049467d9f4f3b3361178ced254ff37df62af314a0ede878009b25
|
||||
F test/io.test f95bca1783b01ea7761671560d023360d2dfa4cc
|
||||
F test/ioerr.test 2a24bd6ed5a8b062e64bfe1f6cf94fb25e92210d
|
||||
F test/ioerr2.test 2593563599e2cc6b6b4fcf5878b177bdd5d8df26
|
||||
@@ -1015,7 +1007,7 @@ F test/like.test 11cfd7d4ef8625389df9efc46735ff0b0b41d5e62047ef0f3bc24c380d28a7a
|
||||
F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da
|
||||
F test/like3.test 3608a2042b6f922f900fbfd5d3ce4e7eca57f7c4
|
||||
F test/limit.test 0c99a27a87b14c646a9d583c7c89fd06c352663e
|
||||
F test/limit2.test 360982809e03211636d2b18ddbc97d5da06826941370607e4b00e113f827cb5a
|
||||
F test/limit2.test e35f57bd3a62d7c5dcb5ac4306e675c75f974809
|
||||
F test/loadext.test d077450695ddb5c1ea3ad7d48e5f5850fe732ad9
|
||||
F test/loadext2.test 0408380b57adca04004247179837a18e866a74f7
|
||||
F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db
|
||||
@@ -1062,7 +1054,7 @@ F test/minmax.test 6751e87b409fe11b02e70a306d846fa544e25a41
|
||||
F test/minmax2.test dae92964ac87c1d2ef978c582e81a95e11c00f1cbef68980bfb2abaf10315063
|
||||
F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354
|
||||
F test/minmax4.test 936941484ebdceb8adec7c86b6cd9b6e5e897c1f
|
||||
F test/misc1.test 704ea2cc7e7b9deb622b37953f0e77d0879826e8c3bfc1d7a691528035405061
|
||||
F test/misc1.test 76737c259537586355f45e2a1e121b6e91b5476c4604ad5c53d1abfcb3acf786
|
||||
F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d
|
||||
F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d
|
||||
F test/misc4.test 0d8be3466adf123a7791a66ba2bc8e8d229e87f3
|
||||
@@ -1071,7 +1063,7 @@ F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
|
||||
F test/misc7.test edd0b63e2ee29a256900b0514f6fff27e19e9bb2
|
||||
F test/misc8.test ba03aaa08f02d62fbb8d3b2f5595c1b33aa9bbc5
|
||||
F test/misuse.test 9e7f78402005e833af71dcab32d048003869eca5abcaccc985d4f8dc1d86bcc7
|
||||
F test/mjournal.test 9d86e697dcbc5da2c4e8caba9b176b5765fe65e80c88c278b8c09a917e436795
|
||||
F test/mjournal.test 946d7161cabbc45ecc818d7fa38c1925bbf36e5534a08a81fa0203ee7ced7d54
|
||||
F test/mmap1.test d2cfc1635171c434dcff0ece2f1c8e0a658807ce
|
||||
F test/mmap2.test 9d6dd9ddb4ad2379f29cc78f38ce1e63ed418022
|
||||
F test/mmap3.test b3c297e78e6a8520aafcc1a8f140535594c9086e
|
||||
@@ -1122,7 +1114,7 @@ F test/parser1.test 391b9bf9a229547a129c61ac345ed1a6f5eb1854
|
||||
F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
|
||||
F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
|
||||
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
|
||||
F test/permutations.test 8ada8c1dee071e0fc275bc8bc2db7de537d625cad949d2200664b99a0a89eac5
|
||||
F test/permutations.test 490e3333b9b1aefb7ebc6e9ab2ae0e382b7dd8713ccc4a2786b0f75467c2ab6b
|
||||
F test/pragma.test 7c8cfc328a1717a95663cf8edb06c52ddfeaf97bb0aee69ae7457132e8d39e7d
|
||||
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
|
||||
F test/pragma3.test 14c12bc5352b1e100e0b6b44f371053a81ccf8ed
|
||||
@@ -1218,7 +1210,7 @@ F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b
|
||||
F test/shell3.test 9b95ba643eaa228376f06a898fb410ee9b6e57c1
|
||||
F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d
|
||||
F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458
|
||||
F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3
|
||||
F test/shell6.test ab1592ebe881371f651f18ee6a0df21cbfb5310f88cb832ab642d4038f679772
|
||||
F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f
|
||||
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
|
||||
F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5
|
||||
@@ -1231,7 +1223,6 @@ F test/skipscan5.test 67817a4b6857c47e0e33ba3e506da6f23ef68de2
|
||||
F test/skipscan6.test 5866039d03a56f5bd0b3d172a012074a1d90a15b
|
||||
F test/snapshot.test 85735bd997a4f6d710140c28fd860519a299649f
|
||||
F test/snapshot2.test 925e42427e923262db63c9d7155183f889e3e99feaedec4075f659e51608344f
|
||||
F test/snapshot3.test 9719443594a04778861bd20d12596c5f880af177d6cd62f111da3198cafc6096
|
||||
F test/snapshot_fault.test 52c5e97ebd218846a8ae2da4d147d3e77d71f963
|
||||
F test/soak.test 0b5b6375c9f4110c828070b826b3b4b0bb65cd5f
|
||||
F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087
|
||||
@@ -1249,7 +1240,7 @@ F test/speed3.test 694affeb9100526007436334cf7d08f3d74b85ef
|
||||
F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
|
||||
F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa
|
||||
F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b
|
||||
F test/speedtest1.c a5faf4cbe5769eee4b721b3875cb3f12520a9b99d9026b1063b47c39603375b8
|
||||
F test/speedtest1.c e44c5fccddcfe916c3bf7fe2f87dcc4b4fd66a0d923eb83515f311212670f267
|
||||
F test/spellfix.test f9c1f431e2c096c8775fec032952320c0e4700db
|
||||
F test/spellfix2.test dfc8f519a3fc204cb2dfa8b4f29821ae90f6f8c3
|
||||
F test/spellfix3.test 0f9efaaa502a0e0a09848028518a6fb096c8ad33
|
||||
@@ -1267,9 +1258,8 @@ F test/subselect.test 0966aa8e720224dbd6a5e769a3ec2a723e332303
|
||||
F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a
|
||||
F test/subtype1.test 7fe09496352f97053af1437150751be2d0a0cae8
|
||||
F test/superlock.test ec94f0556b6488d97f71c79f9061ae08d9ab8f12
|
||||
F test/swarmvtab.test 9a3fd5ab3e9b3c976ad1b3d7646aab725114f2ac26b59395d0778b33bab6cdaf
|
||||
F test/swarmvtab2.test c948cb2fdfc5b01d85e8f6d6504854202dc1a0782ab2a0ed61538f27cbd0aa5c
|
||||
F test/swarmvtab3.test c4c8d09e56ae99b90187ac225458f13f373873ea296fc442c7ad7511f25e7314
|
||||
F test/swarmvtab.test c2279311b44de032f86a8295a9b06818d864856f9428b4c99eee91a0d419cf25
|
||||
F test/swarmvtab2.test 9a3a68a1e58d00f4ed6c68d12d52f2df971b9e22a80a41f6f8c1409abba8e5b4
|
||||
F test/swarmvtabfault.test 00aec54665909490f5c383f3cae3b5d18bd97c12490b429ff8752a3027acfa42
|
||||
F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849
|
||||
F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529
|
||||
@@ -1288,7 +1278,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
|
||||
F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e
|
||||
F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637
|
||||
F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc
|
||||
F test/tester.tcl 3ed81b9e1d9718a8d9603596c8a877793d054294053c4277a3d3897eabab3866
|
||||
F test/tester.tcl 9948bd856ce8a1c127f2f7900365387a42a917ce0dc87185bdd128fa5b11aff2
|
||||
F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5
|
||||
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
|
||||
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
|
||||
@@ -1444,7 +1434,7 @@ F test/tkt3997.test a335fa41ca3985660a139df7b734a26ef53284bd
|
||||
F test/tkt4018.test 18dbc6617f7a4b90e938d1bd6d26ad18daafaf08
|
||||
F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7
|
||||
F test/tpch01.test 04adbf8d8300fa60a222f28d901abd76e7be6dd4
|
||||
F test/trace.test a659a9862957f4789e37a92b3bf6d2caf5c86b02cdeefc41e850ae53acf6992a
|
||||
F test/trace.test 6f676313e3ebd2a50585036d2f212a3319dd5836
|
||||
F test/trace2.test f5cb67ad3bc09e0c58e8cca78dfd0b5639259983
|
||||
F test/trace3.test 56ab944fddacf628b118cc298503fc45c2e50ab0
|
||||
F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6
|
||||
@@ -1466,7 +1456,7 @@ F test/triggerC.test 302d8995f5ffe63bbc15053abb3ef7a39cf5a092
|
||||
F test/triggerD.test 8e7f3921a92a5797d472732108109e44575fa650
|
||||
F test/triggerE.test 15fa63f1097db1f83dd62d121616006978063d1f
|
||||
F test/triggerF.test 6a8c22bd058cf467f0c7d112afe87f7a8c579c0c4681b914b8f19020f48528a4
|
||||
F test/triggerG.test d5caeef6144ede2426dd13211fd72248241ff2ebc68e12a4c0bf30f5faa21499
|
||||
F test/triggerG.test 175cafdc6399d85231a09e82e051b0e45a2fd1f23dd08ae715bc359716149ab6
|
||||
F test/tt3_checkpoint.c 9e75cf7c1c364f52e1c47fd0f14c4340a9db0fe1
|
||||
F test/tt3_index.c 39eec10a35f57672225be4d182862152896dee4a
|
||||
F test/tt3_lookaside1.c 0377e202c3c2a50d688cb65ba203afeda6fafeb9
|
||||
@@ -1542,9 +1532,9 @@ F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c
|
||||
F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496
|
||||
F test/waloverwrite.test dad2f26567f1b45174e54fbf9a8dc1cb876a7f03
|
||||
F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6
|
||||
F test/walprotocol.test a112aba0b79e3adeaa485fed09484b32c654e97df58e454aa8489ac2cd57bf84
|
||||
F test/walprotocol.test 0b92feb132ccebd855494d917d3f6c2d717ace20
|
||||
F test/walro.test cb438d05ba0d191f10b688e39c4f0cd5b71569a1d1f4440e5bdf3c6880e08c20
|
||||
F test/walro2.test 5cd57d192ee334c3894330303b5f8cb6789fef49b2c83ad1b50b9b132d0f7ae1
|
||||
F test/walro2.test 8812e514c968bf4ee317571fafedac43443360ae23edd7d0f4ef1eae0c13e8e8
|
||||
F test/walrofault.test c70cb6e308c443867701856cce92ad8288cd99488fa52afab77cca6cfd51af68
|
||||
F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417
|
||||
F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f
|
||||
@@ -1609,8 +1599,8 @@ F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
|
||||
F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
|
||||
F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
|
||||
F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f
|
||||
F tool/lemon.c 7f7735326ca9c3b48327b241063cee52d35d44e20ebe1b3624a81658052a4d39
|
||||
F tool/lempar.c dddd4f592b8bad36aec4500d456c5db5fe42fefc4ee384913880439d8917f87a
|
||||
F tool/lemon.c e6056373044d55296d21f81467dba7632bbb81dc49af072b3f0e76338771497e
|
||||
F tool/lempar.c 105d0d9cbe5a25d24d4769241ffbfc63ac7c09e6ccee0dc43dcc8a4c4ae4e426
|
||||
F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9
|
||||
F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
|
||||
F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca
|
||||
@@ -1623,7 +1613,7 @@ F tool/mkmsvcmin.tcl 8baf26690b80d861d0ac341b29880eec6ade39e4f11fe690271ded9cb90
|
||||
F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c
|
||||
F tool/mkopcodeh.tcl 4ee2a30ccbd900dc4d5cdb61bdab87cd2166cd2affcc78c9cc0b8d22a65b2eee
|
||||
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
|
||||
F tool/mkpragmatab.tcl 2144bc8550a6471a029db262a132d2df4b9e0db61b90398bf64f5b7b3f8d92cd
|
||||
F tool/mkpragmatab.tcl f49ae6e8cb961d36f449109badcb7020c2fcdeb6d03c7f1acda89633e10250ca
|
||||
F tool/mkshellc.tcl 574307265b49d813301fba91ccd74e6a26d33f65f74b6891c320a0ffbee07895
|
||||
F tool/mksourceid.c d458f9004c837bee87a6382228ac20d3eae3c49ea3b0a5aace936f8b60748d3b
|
||||
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
|
||||
@@ -1648,7 +1638,7 @@ F tool/showstat4.c 0682ebea7abf4d3657f53c4a243f2e7eab48eab344ed36a94bb75dcd19a5c
|
||||
F tool/showwal.c ad9d768f96ca6199ad3a8c9562d679680bd032dd01204ea3e5ea6fb931d81847
|
||||
F tool/soak1.tcl 8d407956e1a45b485a8e072470a3e629a27037fe
|
||||
F tool/spaceanal.tcl 4bfd19aad7eb3ce0372ef0255f58035e0bba4ff5e9acfd763a10c6fb365c8dec
|
||||
F tool/speed-check.sh 9ae425da8819e54e780cf494fc6d8175dfb16e109ae3214a45a5c9bb2b74e2c4
|
||||
F tool/speed-check.sh a97ae367e9172a706101901e7caef48f1a14fc8a49053b25e79f6a67296b3412
|
||||
F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355
|
||||
F tool/speedtest16.c ecb6542862151c3e6509bbc00509b234562ae81e
|
||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
@@ -1688,7 +1678,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 89e5720a8d8d46d4e2f16f15678e91336117e64abc977174e2b345a30308d0d2
|
||||
R 9cb794037b97521b258cb5fdbbf60d53
|
||||
P e6b89304695be371978e65dddd710c8bd563c66b9c94d23165142b6c235c82e1
|
||||
R 89fbad1a4c6de971034ac5f140aa2b84
|
||||
T *branch * pragma-table-ipk
|
||||
T *sym-pragma-table-ipk *
|
||||
T -sym-trunk *
|
||||
U drh
|
||||
Z 8d1ee588df9bbfd069e3afd64819112f
|
||||
Z 5a5f1ee8645506e803bde7a836253a0d
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
9406c0a685fd5ff3516a66402b0514a1440652822a5eecf0b7af85929f3079e8
|
||||
2494132a2b1221a4aec9817272c088b3c6bbf9340856927457ff6de62d469676
|
||||
-14
@@ -4432,20 +4432,6 @@ i64 sqlite3BtreeIntegerKey(BtCursor *pCur){
|
||||
return pCur->info.nKey;
|
||||
}
|
||||
|
||||
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
|
||||
/*
|
||||
** Return the offset into the database file for the start of the
|
||||
** payload to which the cursor is pointing.
|
||||
*/
|
||||
i64 sqlite3BtreeOffset(BtCursor *pCur){
|
||||
assert( cursorHoldsMutex(pCur) );
|
||||
assert( pCur->eState==CURSOR_VALID );
|
||||
getCellInfo(pCur);
|
||||
return (i64)pCur->pBt->pageSize*((i64)pCur->pPage->pgno - 1) +
|
||||
(i64)(pCur->info.pPayload - pCur->pPage->aData);
|
||||
}
|
||||
#endif /* SQLITE_ENABLE_OFFSET_SQL_FUNC */
|
||||
|
||||
/*
|
||||
** Return the number of bytes of payload for the entry that pCur is
|
||||
** currently pointing to. For table btrees, this will be the amount
|
||||
|
||||
@@ -291,9 +291,6 @@ int sqlite3BtreeNext(BtCursor*, int flags);
|
||||
int sqlite3BtreeEof(BtCursor*);
|
||||
int sqlite3BtreePrevious(BtCursor*, int flags);
|
||||
i64 sqlite3BtreeIntegerKey(BtCursor*);
|
||||
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
|
||||
i64 sqlite3BtreeOffset(BtCursor*);
|
||||
#endif
|
||||
int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
|
||||
const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
|
||||
u32 sqlite3BtreePayloadSize(BtCursor*);
|
||||
|
||||
+12
-28
@@ -1221,37 +1221,34 @@ char sqlite3AffinityType(const char *zIn, u8 *pszEst){
|
||||
** This routine is called by the parser while in the middle of
|
||||
** parsing a CREATE TABLE statement.
|
||||
*/
|
||||
void sqlite3AddDefaultValue(
|
||||
Parse *pParse, /* Parsing context */
|
||||
Expr *pExpr, /* The parsed expression of the default value */
|
||||
const char *zStart, /* Start of the default value text */
|
||||
const char *zEnd /* First character past end of defaut value text */
|
||||
){
|
||||
void sqlite3AddDefaultValue(Parse *pParse, ExprSpan *pSpan){
|
||||
Table *p;
|
||||
Column *pCol;
|
||||
sqlite3 *db = pParse->db;
|
||||
p = pParse->pNewTable;
|
||||
if( p!=0 ){
|
||||
pCol = &(p->aCol[p->nCol-1]);
|
||||
if( !sqlite3ExprIsConstantOrFunction(pExpr, db->init.busy) ){
|
||||
if( !sqlite3ExprIsConstantOrFunction(pSpan->pExpr, db->init.busy) ){
|
||||
sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant",
|
||||
pCol->zName);
|
||||
}else{
|
||||
/* A copy of pExpr is used instead of the original, as pExpr contains
|
||||
** tokens that point to volatile memory.
|
||||
** tokens that point to volatile memory. The 'span' of the expression
|
||||
** is required by pragma table_info.
|
||||
*/
|
||||
Expr x;
|
||||
sqlite3ExprDelete(db, pCol->pDflt);
|
||||
memset(&x, 0, sizeof(x));
|
||||
x.op = TK_SPAN;
|
||||
x.u.zToken = sqlite3DbSpanDup(db, zStart, zEnd);
|
||||
x.pLeft = pExpr;
|
||||
x.u.zToken = sqlite3DbStrNDup(db, (char*)pSpan->zStart,
|
||||
(int)(pSpan->zEnd - pSpan->zStart));
|
||||
x.pLeft = pSpan->pExpr;
|
||||
x.flags = EP_Skip;
|
||||
pCol->pDflt = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE);
|
||||
sqlite3DbFree(db, x.u.zToken);
|
||||
}
|
||||
}
|
||||
sqlite3ExprDelete(db, pExpr);
|
||||
sqlite3ExprDelete(db, pSpan->pExpr);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1968,6 +1965,10 @@ void sqlite3EndTable(
|
||||
pParse->nTab = 2;
|
||||
addrTop = sqlite3VdbeCurrentAddr(v) + 1;
|
||||
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
|
||||
sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
|
||||
sqlite3Select(pParse, pSelect, &dest);
|
||||
sqlite3VdbeEndCoroutine(v, regYield);
|
||||
sqlite3VdbeJumpHere(v, addrTop - 1);
|
||||
if( pParse->nErr ) return;
|
||||
pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect);
|
||||
if( pSelTab==0 ) return;
|
||||
@@ -1977,11 +1978,6 @@ void sqlite3EndTable(
|
||||
pSelTab->nCol = 0;
|
||||
pSelTab->aCol = 0;
|
||||
sqlite3DeleteTable(db, pSelTab);
|
||||
sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
|
||||
sqlite3Select(pParse, pSelect, &dest);
|
||||
if( pParse->nErr ) return;
|
||||
sqlite3VdbeEndCoroutine(v, regYield);
|
||||
sqlite3VdbeJumpHere(v, addrTop - 1);
|
||||
addrInsLoop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);
|
||||
VdbeCoverage(v);
|
||||
sqlite3VdbeAddOp3(v, OP_MakeRecord, dest.iSdst, dest.nSdst, regRec);
|
||||
@@ -4368,18 +4364,6 @@ KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
|
||||
pKey->aSortOrder[i] = pIdx->aSortOrder[i];
|
||||
}
|
||||
if( pParse->nErr ){
|
||||
assert( pParse->rc==SQLITE_ERROR_MISSING_COLLSEQ );
|
||||
if( pIdx->bNoQuery==0 ){
|
||||
/* Deactivate the index because it contains an unknown collating
|
||||
** sequence. The only way to reactive the index is to reload the
|
||||
** schema. Adding the missing collating sequence later does not
|
||||
** reactive the index. The application had the chance to register
|
||||
** the missing index using the collation-needed callback. For
|
||||
** simplicity, SQLite will not give the application a second chance.
|
||||
*/
|
||||
pIdx->bNoQuery = 1;
|
||||
pParse->rc = SQLITE_ERROR_RETRY;
|
||||
}
|
||||
sqlite3KeyInfoUnref(pKey);
|
||||
pKey = 0;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,6 @@ CollSeq *sqlite3GetCollSeq(
|
||||
assert( !p || p->xCmp );
|
||||
if( p==0 ){
|
||||
sqlite3ErrorMsg(pParse, "no such collation sequence: %s", zName);
|
||||
pParse->rc = SQLITE_ERROR_MISSING_COLLSEQ;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
**
|
||||
** Jean Meeus
|
||||
** Astronomical Algorithms, 2nd Edition, 1998
|
||||
** ISBN 0-943396-61-1
|
||||
** ISBM 0-943396-61-1
|
||||
** Willmann-Bell, Inc
|
||||
** Richmond, Virginia (USA)
|
||||
*/
|
||||
|
||||
+1
-1
@@ -283,11 +283,11 @@ void sqlite3DeleteFrom(
|
||||
#ifndef SQLITE_OMIT_TRIGGER
|
||||
pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
|
||||
isView = pTab->pSelect!=0;
|
||||
bComplex = pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0);
|
||||
#else
|
||||
# define pTrigger 0
|
||||
# define isView 0
|
||||
#endif
|
||||
bComplex = pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0);
|
||||
#ifdef SQLITE_OMIT_VIEW
|
||||
# undef isView
|
||||
# define isView 0
|
||||
|
||||
+7
-18
@@ -1654,16 +1654,17 @@ void sqlite3ExprListSetName(
|
||||
void sqlite3ExprListSetSpan(
|
||||
Parse *pParse, /* Parsing context */
|
||||
ExprList *pList, /* List to which to add the span. */
|
||||
const char *zStart, /* Start of the span */
|
||||
const char *zEnd /* End of the span */
|
||||
ExprSpan *pSpan /* The span to be added */
|
||||
){
|
||||
sqlite3 *db = pParse->db;
|
||||
assert( pList!=0 || db->mallocFailed!=0 );
|
||||
if( pList ){
|
||||
struct ExprList_item *pItem = &pList->a[pList->nExpr-1];
|
||||
assert( pList->nExpr>0 );
|
||||
assert( db->mallocFailed || pItem->pExpr==pSpan->pExpr );
|
||||
sqlite3DbFree(db, pItem->zSpan);
|
||||
pItem->zSpan = sqlite3DbSpanDup(db, zStart, zEnd);
|
||||
pItem->zSpan = sqlite3DbStrNDup(db, (char*)pSpan->zStart,
|
||||
(int)(pSpan->zEnd - pSpan->zStart));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3870,21 +3871,9 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||
if( !pColl ) pColl = db->pDfltColl;
|
||||
sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
|
||||
}
|
||||
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
|
||||
if( pDef->funcFlags & SQLITE_FUNC_OFFSET ){
|
||||
Expr *pArg = pFarg->a[0].pExpr;
|
||||
if( pArg->op==TK_COLUMN ){
|
||||
sqlite3VdbeAddOp3(v, OP_Offset, pArg->iTable, pArg->iColumn, target);
|
||||
}else{
|
||||
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
|
||||
}
|
||||
}else
|
||||
#endif
|
||||
{
|
||||
sqlite3VdbeAddOp4(v, pParse->iSelfTab ? OP_PureFunc0 : OP_Function0,
|
||||
constMask, r1, target, (char*)pDef, P4_FUNCDEF);
|
||||
sqlite3VdbeChangeP5(v, (u8)nFarg);
|
||||
}
|
||||
sqlite3VdbeAddOp4(v, pParse->iSelfTab ? OP_PureFunc0 : OP_Function0,
|
||||
constMask, r1, target, (char*)pDef, P4_FUNCDEF);
|
||||
sqlite3VdbeChangeP5(v, (u8)nFarg);
|
||||
if( nFarg && constMask==0 ){
|
||||
sqlite3ReleaseTempRange(pParse, r1, nFarg);
|
||||
}
|
||||
|
||||
@@ -1798,11 +1798,6 @@ void sqlite3RegisterBuiltinFunctions(void){
|
||||
FUNCTION2(likely, 1, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY),
|
||||
#ifdef SQLITE_DEBUG
|
||||
FUNCTION2(affinity, 1, 0, 0, noopFunc, SQLITE_FUNC_AFFINITY),
|
||||
#endif
|
||||
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
|
||||
FUNCTION2(sqlite_unsupported_offset,
|
||||
1, 0, 0, noopFunc, SQLITE_FUNC_OFFSET|
|
||||
SQLITE_FUNC_TYPEOF),
|
||||
#endif
|
||||
FUNCTION(ltrim, 1, 1, 0, trimFunc ),
|
||||
FUNCTION(ltrim, 2, 1, 0, trimFunc ),
|
||||
|
||||
+1
-3
@@ -496,10 +496,8 @@ static int sqlite3LoadExtension(
|
||||
#if SQLITE_OS_UNIX || SQLITE_OS_WIN
|
||||
for(ii=0; ii<ArraySize(azEndings) && handle==0; ii++){
|
||||
char *zAltFile = sqlite3_mprintf("%s.%s", zFile, azEndings[ii]);
|
||||
int bExists = 0;
|
||||
if( zAltFile==0 ) return SQLITE_NOMEM_BKPT;
|
||||
sqlite3OsAccess(pVfs, zAltFile, SQLITE_ACCESS_EXISTS, &bExists);
|
||||
if( bExists ) handle = sqlite3OsDlOpen(pVfs, zAltFile);
|
||||
handle = sqlite3OsDlOpen(pVfs, zAltFile);
|
||||
sqlite3_free(zAltFile);
|
||||
}
|
||||
#endif
|
||||
|
||||
+3
-28
@@ -22,7 +22,7 @@
|
||||
#ifdef SQLITE_ENABLE_RTREE
|
||||
# include "rtree.h"
|
||||
#endif
|
||||
#if defined(SQLITE_ENABLE_ICU) || defined(SQLITE_ENABLE_ICU_COLLATIONS)
|
||||
#ifdef SQLITE_ENABLE_ICU
|
||||
# include "sqliteicu.h"
|
||||
#endif
|
||||
#ifdef SQLITE_ENABLE_JSON1
|
||||
@@ -817,7 +817,6 @@ int sqlite3_db_config(sqlite3 *db, int op, ...){
|
||||
{ SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, SQLITE_LoadExtension },
|
||||
{ SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE, SQLITE_NoCkptOnClose },
|
||||
{ SQLITE_DBCONFIG_ENABLE_QPSG, SQLITE_EnableQPSG },
|
||||
{ SQLITE_DBCONFIG_TRIGGER_EQP, SQLITE_TriggerEQP },
|
||||
};
|
||||
unsigned int i;
|
||||
rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
|
||||
@@ -2823,7 +2822,6 @@ static int openDatabase(
|
||||
}else{
|
||||
isThreadsafe = sqlite3GlobalConfig.bFullMutex;
|
||||
}
|
||||
|
||||
if( flags & SQLITE_OPEN_PRIVATECACHE ){
|
||||
flags &= ~SQLITE_OPEN_SHAREDCACHE;
|
||||
}else if( sqlite3GlobalConfig.sharedCacheEnabled ){
|
||||
@@ -2856,20 +2854,13 @@ static int openDatabase(
|
||||
/* Allocate the sqlite data structure */
|
||||
db = sqlite3MallocZero( sizeof(sqlite3) );
|
||||
if( db==0 ) goto opendb_out;
|
||||
if( isThreadsafe
|
||||
#ifdef SQLITE_ENABLE_MULTITHREADED_CHECKS
|
||||
|| sqlite3GlobalConfig.bCoreMutex
|
||||
#endif
|
||||
){
|
||||
if( isThreadsafe ){
|
||||
db->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_RECURSIVE);
|
||||
if( db->mutex==0 ){
|
||||
sqlite3_free(db);
|
||||
db = 0;
|
||||
goto opendb_out;
|
||||
}
|
||||
if( isThreadsafe==0 ){
|
||||
sqlite3MutexWarnOnContention(db->mutex);
|
||||
}
|
||||
}
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
db->errMask = 0xff;
|
||||
@@ -3051,7 +3042,7 @@ static int openDatabase(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SQLITE_ENABLE_ICU) || defined(SQLITE_ENABLE_ICU_COLLATIONS)
|
||||
#ifdef SQLITE_ENABLE_ICU
|
||||
if( !db->mallocFailed && rc==SQLITE_OK ){
|
||||
rc = sqlite3IcuInit(db);
|
||||
}
|
||||
@@ -3911,22 +3902,6 @@ int sqlite3_test_control(int op, ...){
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(YYCOVERAGE)
|
||||
/* sqlite3_test_control(SQLITE_TESTCTRL_PARSER_COVERAGE, FILE *out)
|
||||
**
|
||||
** This test control (only available when SQLite is compiled with
|
||||
** -DYYCOVERAGE) writes a report onto "out" that shows all
|
||||
** state/lookahead combinations in the parser state machine
|
||||
** which are never exercised. If any state is missed, make the
|
||||
** return code SQLITE_ERROR.
|
||||
*/
|
||||
case SQLITE_TESTCTRL_PARSER_COVERAGE: {
|
||||
FILE *out = va_arg(ap, FILE*);
|
||||
if( sqlite3ParserCoverage(out) ) rc = SQLITE_ERROR;
|
||||
break;
|
||||
}
|
||||
#endif /* defined(YYCOVERAGE) */
|
||||
}
|
||||
va_end(ap);
|
||||
#endif /* SQLITE_UNTESTABLE */
|
||||
|
||||
@@ -627,19 +627,6 @@ char *sqlite3DbStrNDup(sqlite3 *db, const char *z, u64 n){
|
||||
return zNew;
|
||||
}
|
||||
|
||||
/*
|
||||
** The text between zStart and zEnd represents a phrase within a larger
|
||||
** SQL statement. Make a copy of this phrase in space obtained form
|
||||
** sqlite3DbMalloc(). Omit leading and trailing whitespace.
|
||||
*/
|
||||
char *sqlite3DbSpanDup(sqlite3 *db, const char *zStart, const char *zEnd){
|
||||
int n;
|
||||
while( sqlite3Isspace(zStart[0]) ) zStart++;
|
||||
n = (int)(zEnd - zStart);
|
||||
while( n>0 && sqlite3Isspace(zStart[n-1]) ) n--;
|
||||
return sqlite3DbStrNDup(db, zStart, n);
|
||||
}
|
||||
|
||||
/*
|
||||
** Free any prior content in *pz and replace it with a copy of zNew.
|
||||
*/
|
||||
|
||||
-192
@@ -26,193 +26,6 @@ static SQLITE_WSD int mutexIsInit = 0;
|
||||
|
||||
|
||||
#ifndef SQLITE_MUTEX_OMIT
|
||||
|
||||
#ifdef SQLITE_ENABLE_MULTITHREADED_CHECKS
|
||||
/*
|
||||
** This block (enclosed by SQLITE_ENABLE_MULTITHREADED_CHECKS) contains
|
||||
** the implementation of a wrapper around the system default mutex
|
||||
** implementation (sqlite3DefaultMutex()).
|
||||
**
|
||||
** Most calls are passed directly through to the underlying default
|
||||
** mutex implementation. Except, if a mutex is configured by calling
|
||||
** sqlite3MutexWarnOnContention() on it, then if contention is ever
|
||||
** encountered within xMutexEnter() a warning is emitted via sqlite3_log().
|
||||
**
|
||||
** This type of mutex is used as the database handle mutex when testing
|
||||
** apps that usually use SQLITE_CONFIG_MULTITHREAD mode.
|
||||
*/
|
||||
|
||||
/*
|
||||
** Type for all mutexes used when SQLITE_ENABLE_MULTITHREADED_CHECKS
|
||||
** is defined. Variable CheckMutex.mutex is a pointer to the real mutex
|
||||
** allocated by the system mutex implementation. Variable iType is usually set
|
||||
** to the type of mutex requested - SQLITE_MUTEX_RECURSIVE, SQLITE_MUTEX_FAST
|
||||
** or one of the static mutex identifiers. Or, if this is a recursive mutex
|
||||
** that has been configured using sqlite3MutexWarnOnContention(), it is
|
||||
** set to SQLITE_MUTEX_WARNONCONTENTION.
|
||||
*/
|
||||
typedef struct CheckMutex CheckMutex;
|
||||
struct CheckMutex {
|
||||
int iType;
|
||||
sqlite3_mutex *mutex;
|
||||
};
|
||||
|
||||
#define SQLITE_MUTEX_WARNONCONTENTION (-1)
|
||||
|
||||
/*
|
||||
** Pointer to real mutex methods object used by the CheckMutex
|
||||
** implementation. Set by checkMutexInit().
|
||||
*/
|
||||
static SQLITE_WSD const sqlite3_mutex_methods *pGlobalMutexMethods;
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
static int checkMutexHeld(sqlite3_mutex *p){
|
||||
return pGlobalMutexMethods->xMutexHeld(((CheckMutex*)p)->mutex);
|
||||
}
|
||||
static int checkMutexNotheld(sqlite3_mutex *p){
|
||||
return pGlobalMutexMethods->xMutexNotheld(((CheckMutex*)p)->mutex);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Initialize and deinitialize the mutex subsystem.
|
||||
*/
|
||||
static int checkMutexInit(void){
|
||||
pGlobalMutexMethods = sqlite3DefaultMutex();
|
||||
return SQLITE_OK;
|
||||
}
|
||||
static int checkMutexEnd(void){
|
||||
pGlobalMutexMethods = 0;
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Allocate a mutex.
|
||||
*/
|
||||
static sqlite3_mutex *checkMutexAlloc(int iType){
|
||||
static CheckMutex staticMutexes[] = {
|
||||
{2, 0}, {3, 0}, {4, 0}, {5, 0},
|
||||
{6, 0}, {7, 0}, {8, 0}, {9, 0},
|
||||
{10, 0}, {11, 0}, {12, 0}, {13, 0}
|
||||
};
|
||||
CheckMutex *p = 0;
|
||||
|
||||
assert( SQLITE_MUTEX_RECURSIVE==1 && SQLITE_MUTEX_FAST==0 );
|
||||
if( iType<2 ){
|
||||
p = sqlite3MallocZero(sizeof(CheckMutex));
|
||||
if( p==0 ) return 0;
|
||||
p->iType = iType;
|
||||
}else{
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( iType-2>=ArraySize(staticMutexes) ){
|
||||
(void)SQLITE_MISUSE_BKPT;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
p = &staticMutexes[iType-2];
|
||||
}
|
||||
|
||||
if( p->mutex==0 ){
|
||||
p->mutex = pGlobalMutexMethods->xMutexAlloc(iType);
|
||||
if( p->mutex==0 ){
|
||||
if( iType<2 ){
|
||||
sqlite3_free(p);
|
||||
}
|
||||
p = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return (sqlite3_mutex*)p;
|
||||
}
|
||||
|
||||
/*
|
||||
** Free a mutex.
|
||||
*/
|
||||
static void checkMutexFree(sqlite3_mutex *p){
|
||||
assert( SQLITE_MUTEX_RECURSIVE<2 );
|
||||
assert( SQLITE_MUTEX_FAST<2 );
|
||||
assert( SQLITE_MUTEX_WARNONCONTENTION<2 );
|
||||
|
||||
#if SQLITE_ENABLE_API_ARMOR
|
||||
if( ((CheckMutex*)p)->iType<2 )
|
||||
#endif
|
||||
{
|
||||
CheckMutex *pCheck = (CheckMutex*)p;
|
||||
pGlobalMutexMethods->xMutexFree(pCheck->mutex);
|
||||
sqlite3_free(pCheck);
|
||||
}
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
else{
|
||||
(void)SQLITE_MISUSE_BKPT;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** Enter the mutex.
|
||||
*/
|
||||
static void checkMutexEnter(sqlite3_mutex *p){
|
||||
CheckMutex *pCheck = (CheckMutex*)p;
|
||||
if( pCheck->iType==SQLITE_MUTEX_WARNONCONTENTION ){
|
||||
if( SQLITE_OK==pGlobalMutexMethods->xMutexTry(pCheck->mutex) ){
|
||||
return;
|
||||
}
|
||||
sqlite3_log(SQLITE_MISUSE,
|
||||
"illegal multi-threaded access to database connection"
|
||||
);
|
||||
}
|
||||
pGlobalMutexMethods->xMutexEnter(pCheck->mutex);
|
||||
}
|
||||
|
||||
/*
|
||||
** Enter the mutex (do not block).
|
||||
*/
|
||||
static int checkMutexTry(sqlite3_mutex *p){
|
||||
CheckMutex *pCheck = (CheckMutex*)p;
|
||||
return pGlobalMutexMethods->xMutexTry(pCheck->mutex);
|
||||
}
|
||||
|
||||
/*
|
||||
** Leave the mutex.
|
||||
*/
|
||||
static void checkMutexLeave(sqlite3_mutex *p){
|
||||
CheckMutex *pCheck = (CheckMutex*)p;
|
||||
pGlobalMutexMethods->xMutexLeave(pCheck->mutex);
|
||||
}
|
||||
|
||||
sqlite3_mutex_methods const *multiThreadedCheckMutex(void){
|
||||
static const sqlite3_mutex_methods sMutex = {
|
||||
checkMutexInit,
|
||||
checkMutexEnd,
|
||||
checkMutexAlloc,
|
||||
checkMutexFree,
|
||||
checkMutexEnter,
|
||||
checkMutexTry,
|
||||
checkMutexLeave,
|
||||
#ifdef SQLITE_DEBUG
|
||||
checkMutexHeld,
|
||||
checkMutexNotheld
|
||||
#else
|
||||
0,
|
||||
0
|
||||
#endif
|
||||
};
|
||||
return &sMutex;
|
||||
}
|
||||
|
||||
/*
|
||||
** Mark the SQLITE_MUTEX_RECURSIVE mutex passed as the only argument as
|
||||
** one on which there should be no contention.
|
||||
*/
|
||||
void sqlite3MutexWarnOnContention(sqlite3_mutex *p){
|
||||
if( sqlite3GlobalConfig.mutex.xMutexAlloc==checkMutexAlloc ){
|
||||
CheckMutex *pCheck = (CheckMutex*)p;
|
||||
assert( pCheck->iType==SQLITE_MUTEX_RECURSIVE );
|
||||
pCheck->iType = SQLITE_MUTEX_WARNONCONTENTION;
|
||||
}
|
||||
}
|
||||
#endif /* ifdef SQLITE_ENABLE_MULTITHREADED_CHECKS */
|
||||
|
||||
/*
|
||||
** Initialize the mutex system.
|
||||
*/
|
||||
@@ -228,11 +41,7 @@ int sqlite3MutexInit(void){
|
||||
sqlite3_mutex_methods *pTo = &sqlite3GlobalConfig.mutex;
|
||||
|
||||
if( sqlite3GlobalConfig.bCoreMutex ){
|
||||
#ifdef SQLITE_ENABLE_MULTITHREADED_CHECKS
|
||||
pFrom = multiThreadedCheckMutex();
|
||||
#else
|
||||
pFrom = sqlite3DefaultMutex();
|
||||
#endif
|
||||
}else{
|
||||
pFrom = sqlite3NoopMutex();
|
||||
}
|
||||
@@ -358,4 +167,3 @@ int sqlite3_mutex_notheld(sqlite3_mutex *p){
|
||||
#endif
|
||||
|
||||
#endif /* !defined(SQLITE_MUTEX_OMIT) */
|
||||
|
||||
|
||||
+5
-8
@@ -483,7 +483,7 @@ static struct unix_syscall {
|
||||
#else
|
||||
{ "munmap", (sqlite3_syscall_ptr)0, 0 },
|
||||
#endif
|
||||
#define osMunmap ((int(*)(void*,size_t))aSyscall[23].pCurrent)
|
||||
#define osMunmap ((void*(*)(void*,size_t))aSyscall[23].pCurrent)
|
||||
|
||||
#if HAVE_MREMAP && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
|
||||
{ "mremap", (sqlite3_syscall_ptr)mremap, 0 },
|
||||
@@ -4165,7 +4165,7 @@ static int unixShmSystemLock(
|
||||
|
||||
/* Access to the unixShmNode object is serialized by the caller */
|
||||
pShmNode = pFile->pInode->pShmNode;
|
||||
assert( pShmNode->nRef==0 || sqlite3_mutex_held(pShmNode->mutex) );
|
||||
assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );
|
||||
|
||||
/* Shared locks never span more than one byte */
|
||||
assert( n==1 || lockType!=F_RDLCK );
|
||||
@@ -5799,7 +5799,7 @@ static int unixOpen(
|
||||
** a file-descriptor on the directory too. The first time unixSync()
|
||||
** is called the directory file descriptor will be fsync()ed and close()d.
|
||||
*/
|
||||
int isNewJrnl = (isCreate && (
|
||||
int syncDir = (isCreate && (
|
||||
eType==SQLITE_OPEN_MASTER_JOURNAL
|
||||
|| eType==SQLITE_OPEN_MAIN_JOURNAL
|
||||
|| eType==SQLITE_OPEN_WAL
|
||||
@@ -5869,7 +5869,7 @@ static int unixOpen(
|
||||
|
||||
}else if( !zName ){
|
||||
/* If zName is NULL, the upper layer is requesting a temp file. */
|
||||
assert(isDelete && !isNewJrnl);
|
||||
assert(isDelete && !syncDir);
|
||||
rc = unixGetTempname(pVfs->mxPathname, zTmpname);
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
@@ -5915,9 +5915,6 @@ static int unixOpen(
|
||||
}
|
||||
if( fd<0 ){
|
||||
rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName);
|
||||
/* If unable to create a journal, change the error code to
|
||||
** indicate that the directory permissions are wrong. */
|
||||
if( isNewJrnl && osAccess(zName, F_OK) ) rc = SQLITE_READONLY_DIRECTORY;
|
||||
goto open_finished;
|
||||
}
|
||||
|
||||
@@ -5977,7 +5974,7 @@ static int unixOpen(
|
||||
if( isReadonly ) ctrlFlags |= UNIXFILE_RDONLY;
|
||||
noLock = eType!=SQLITE_OPEN_MAIN_DB;
|
||||
if( noLock ) ctrlFlags |= UNIXFILE_NOLOCK;
|
||||
if( isNewJrnl ) ctrlFlags |= UNIXFILE_DIRSYNC;
|
||||
if( syncDir ) ctrlFlags |= UNIXFILE_DIRSYNC;
|
||||
if( flags & SQLITE_OPEN_URI ) ctrlFlags |= UNIXFILE_URI;
|
||||
|
||||
#if SQLITE_ENABLE_LOCKING_STYLE
|
||||
|
||||
+1
-1
@@ -3742,7 +3742,7 @@ static int winShmSystemLock(
|
||||
int rc = 0; /* Result code form Lock/UnlockFileEx() */
|
||||
|
||||
/* Access to the winShmNode object is serialized by the caller */
|
||||
assert( pFile->nRef==0 || sqlite3_mutex_held(pFile->mutex) );
|
||||
assert( sqlite3_mutex_held(pFile->mutex) || pFile->nRef==0 );
|
||||
|
||||
OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n",
|
||||
pFile->hFile.h, lockType, ofst, nByte));
|
||||
|
||||
+247
-177
@@ -273,44 +273,26 @@ typename(A) ::= typename(A) ids(Y). {A.n=Y.n+(int)(Y.z-A.z);}
|
||||
signed ::= plus_num.
|
||||
signed ::= minus_num.
|
||||
|
||||
// The scanpt non-terminal takes a value which is a pointer to the
|
||||
// input text just past the last token that has been shifted into
|
||||
// the parser. By surrounding some phrase in the grammar with two
|
||||
// scanpt non-terminals, we can capture the input text for that phrase.
|
||||
// For example:
|
||||
//
|
||||
// something ::= .... scanpt(A) phrase scanpt(Z).
|
||||
//
|
||||
// The text that is parsed as "phrase" is a string starting at A
|
||||
// and containing (int)(Z-A) characters. There might be some extra
|
||||
// whitespace on either end of the text, but that can be removed in
|
||||
// post-processing, if needed.
|
||||
//
|
||||
%type scanpt {const char*}
|
||||
scanpt(A) ::= . {
|
||||
assert( yyLookahead!=YYNOCODE );
|
||||
A = yyLookaheadToken.z;
|
||||
}
|
||||
|
||||
// "carglist" is a list of additional constraints that come after the
|
||||
// column name and column type in a CREATE TABLE statement.
|
||||
//
|
||||
carglist ::= carglist ccons.
|
||||
carglist ::= .
|
||||
ccons ::= CONSTRAINT nm(X). {pParse->constraintName = X;}
|
||||
ccons ::= DEFAULT scanpt(A) term(X) scanpt(Z).
|
||||
{sqlite3AddDefaultValue(pParse,X,A,Z);}
|
||||
ccons ::= DEFAULT LP(A) expr(X) RP(Z).
|
||||
{sqlite3AddDefaultValue(pParse,X,A.z+1,Z.z);}
|
||||
ccons ::= DEFAULT PLUS(A) term(X) scanpt(Z).
|
||||
{sqlite3AddDefaultValue(pParse,X,A.z,Z);}
|
||||
ccons ::= DEFAULT MINUS(A) term(X) scanpt(Z). {
|
||||
Expr *p = sqlite3PExpr(pParse, TK_UMINUS, X, 0);
|
||||
sqlite3AddDefaultValue(pParse,p,A.z,Z);
|
||||
ccons ::= DEFAULT term(X). {sqlite3AddDefaultValue(pParse,&X);}
|
||||
ccons ::= DEFAULT LP expr(X) RP. {sqlite3AddDefaultValue(pParse,&X);}
|
||||
ccons ::= DEFAULT PLUS term(X). {sqlite3AddDefaultValue(pParse,&X);}
|
||||
ccons ::= DEFAULT MINUS(A) term(X). {
|
||||
ExprSpan v;
|
||||
v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, X.pExpr, 0);
|
||||
v.zStart = A.z;
|
||||
v.zEnd = X.zEnd;
|
||||
sqlite3AddDefaultValue(pParse,&v);
|
||||
}
|
||||
ccons ::= DEFAULT scanpt id(X). {
|
||||
Expr *p = tokenExpr(pParse, TK_STRING, X);
|
||||
sqlite3AddDefaultValue(pParse,p,X.z,X.z+X.n);
|
||||
ccons ::= DEFAULT id(X). {
|
||||
ExprSpan v;
|
||||
spanExpr(&v, pParse, TK_STRING, X);
|
||||
sqlite3AddDefaultValue(pParse,&v);
|
||||
}
|
||||
|
||||
// In addition to the type name, we also care about the primary key and
|
||||
@@ -322,7 +304,7 @@ ccons ::= PRIMARY KEY sortorder(Z) onconf(R) autoinc(I).
|
||||
{sqlite3AddPrimaryKey(pParse,0,R,I,Z);}
|
||||
ccons ::= UNIQUE onconf(R). {sqlite3CreateIndex(pParse,0,0,0,0,R,0,0,0,0,
|
||||
SQLITE_IDXTYPE_UNIQUE);}
|
||||
ccons ::= CHECK LP expr(X) RP. {sqlite3AddCheckConstraint(pParse,X);}
|
||||
ccons ::= CHECK LP expr(X) RP. {sqlite3AddCheckConstraint(pParse,X.pExpr);}
|
||||
ccons ::= REFERENCES nm(T) eidlist_opt(TA) refargs(R).
|
||||
{sqlite3CreateForeignKey(pParse,0,&T,TA,R);}
|
||||
ccons ::= defer_subclause(D). {sqlite3DeferForeignKey(pParse,D);}
|
||||
@@ -373,7 +355,7 @@ tcons ::= UNIQUE LP sortlist(X) RP onconf(R).
|
||||
{sqlite3CreateIndex(pParse,0,0,0,X,R,0,0,0,0,
|
||||
SQLITE_IDXTYPE_UNIQUE);}
|
||||
tcons ::= CHECK LP expr(E) RP onconf.
|
||||
{sqlite3AddCheckConstraint(pParse,E);}
|
||||
{sqlite3AddCheckConstraint(pParse,E.pExpr);}
|
||||
tcons ::= FOREIGN KEY LP eidlist(FA) RP
|
||||
REFERENCES nm(T) eidlist_opt(TA) refargs(R) defer_subclause_opt(D). {
|
||||
sqlite3CreateForeignKey(pParse, FA, &T, TA, R);
|
||||
@@ -567,16 +549,16 @@ distinct(A) ::= . {A = 0;}
|
||||
%destructor sclp {sqlite3ExprListDelete(pParse->db, $$);}
|
||||
sclp(A) ::= selcollist(A) COMMA.
|
||||
sclp(A) ::= . {A = 0;}
|
||||
selcollist(A) ::= sclp(A) scanpt(B) expr(X) scanpt(Z) as(Y). {
|
||||
A = sqlite3ExprListAppend(pParse, A, X);
|
||||
selcollist(A) ::= sclp(A) expr(X) as(Y). {
|
||||
A = sqlite3ExprListAppend(pParse, A, X.pExpr);
|
||||
if( Y.n>0 ) sqlite3ExprListSetName(pParse, A, &Y, 1);
|
||||
sqlite3ExprListSetSpan(pParse,A,B,Z);
|
||||
sqlite3ExprListSetSpan(pParse,A,&X);
|
||||
}
|
||||
selcollist(A) ::= sclp(A) scanpt STAR. {
|
||||
selcollist(A) ::= sclp(A) STAR. {
|
||||
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
|
||||
A = sqlite3ExprListAppend(pParse, A, p);
|
||||
}
|
||||
selcollist(A) ::= sclp(A) scanpt nm(X) DOT STAR. {
|
||||
selcollist(A) ::= sclp(A) nm(X) DOT STAR. {
|
||||
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
|
||||
Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &X, 1);
|
||||
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
|
||||
@@ -674,7 +656,7 @@ joinop(X) ::= JOIN_KW(A) nm(B) nm(C) JOIN.
|
||||
|
||||
%type on_opt {Expr*}
|
||||
%destructor on_opt {sqlite3ExprDelete(pParse->db, $$);}
|
||||
on_opt(N) ::= ON expr(E). {N = E;}
|
||||
on_opt(N) ::= ON expr(E). {N = E.pExpr;}
|
||||
on_opt(N) ::= . {N = 0;}
|
||||
|
||||
// Note that this block abuses the Token type just a little. If there is
|
||||
@@ -711,11 +693,11 @@ using_opt(U) ::= . {U = 0;}
|
||||
orderby_opt(A) ::= . {A = 0;}
|
||||
orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;}
|
||||
sortlist(A) ::= sortlist(A) COMMA expr(Y) sortorder(Z). {
|
||||
A = sqlite3ExprListAppend(pParse,A,Y);
|
||||
A = sqlite3ExprListAppend(pParse,A,Y.pExpr);
|
||||
sqlite3ExprListSetSortOrder(A,Z);
|
||||
}
|
||||
sortlist(A) ::= expr(Y) sortorder(Z). {
|
||||
A = sqlite3ExprListAppend(pParse,0,Y); /*A-overwrites-Y*/
|
||||
A = sqlite3ExprListAppend(pParse,0,Y.pExpr); /*A-overwrites-Y*/
|
||||
sqlite3ExprListSetSortOrder(A,Z);
|
||||
}
|
||||
|
||||
@@ -733,7 +715,7 @@ groupby_opt(A) ::= GROUP BY nexprlist(X). {A = X;}
|
||||
%type having_opt {Expr*}
|
||||
%destructor having_opt {sqlite3ExprDelete(pParse->db, $$);}
|
||||
having_opt(A) ::= . {A = 0;}
|
||||
having_opt(A) ::= HAVING expr(X). {A = X;}
|
||||
having_opt(A) ::= HAVING expr(X). {A = X.pExpr;}
|
||||
|
||||
%type limit_opt {Expr*}
|
||||
|
||||
@@ -747,11 +729,11 @@ having_opt(A) ::= HAVING expr(X). {A = X;}
|
||||
//%destructor limit_opt {sqlite3ExprDelete(pParse->db, $$);}
|
||||
limit_opt(A) ::= . {A = 0;}
|
||||
limit_opt(A) ::= LIMIT expr(X).
|
||||
{A = sqlite3PExpr(pParse,TK_LIMIT,X,0);}
|
||||
{A = sqlite3PExpr(pParse,TK_LIMIT,X.pExpr,0);}
|
||||
limit_opt(A) ::= LIMIT expr(X) OFFSET expr(Y).
|
||||
{A = sqlite3PExpr(pParse,TK_LIMIT,X,Y);}
|
||||
{A = sqlite3PExpr(pParse,TK_LIMIT,X.pExpr,Y.pExpr);}
|
||||
limit_opt(A) ::= LIMIT expr(X) COMMA expr(Y).
|
||||
{A = sqlite3PExpr(pParse,TK_LIMIT,Y,X);}
|
||||
{A = sqlite3PExpr(pParse,TK_LIMIT,Y.pExpr,X.pExpr);}
|
||||
|
||||
/////////////////////////// The DELETE statement /////////////////////////////
|
||||
//
|
||||
@@ -775,7 +757,7 @@ cmd ::= with(C) DELETE FROM fullname(X) indexed_opt(I) where_opt(W). {
|
||||
%destructor where_opt {sqlite3ExprDelete(pParse->db, $$);}
|
||||
|
||||
where_opt(A) ::= . {A = 0;}
|
||||
where_opt(A) ::= WHERE expr(X). {A = X;}
|
||||
where_opt(A) ::= WHERE expr(X). {A = X.pExpr;}
|
||||
|
||||
////////////////////////// The UPDATE command ////////////////////////////////
|
||||
//
|
||||
@@ -802,18 +784,18 @@ cmd ::= with(C) UPDATE orconf(R) fullname(X) indexed_opt(I) SET setlist(Y)
|
||||
%destructor setlist {sqlite3ExprListDelete(pParse->db, $$);}
|
||||
|
||||
setlist(A) ::= setlist(A) COMMA nm(X) EQ expr(Y). {
|
||||
A = sqlite3ExprListAppend(pParse, A, Y);
|
||||
A = sqlite3ExprListAppend(pParse, A, Y.pExpr);
|
||||
sqlite3ExprListSetName(pParse, A, &X, 1);
|
||||
}
|
||||
setlist(A) ::= setlist(A) COMMA LP idlist(X) RP EQ expr(Y). {
|
||||
A = sqlite3ExprListAppendVector(pParse, A, X, Y);
|
||||
A = sqlite3ExprListAppendVector(pParse, A, X, Y.pExpr);
|
||||
}
|
||||
setlist(A) ::= nm(X) EQ expr(Y). {
|
||||
A = sqlite3ExprListAppend(pParse, 0, Y);
|
||||
A = sqlite3ExprListAppend(pParse, 0, Y.pExpr);
|
||||
sqlite3ExprListSetName(pParse, A, &X, 1);
|
||||
}
|
||||
setlist(A) ::= LP idlist(X) RP EQ expr(Y). {
|
||||
A = sqlite3ExprListAppendVector(pParse, 0, X, Y);
|
||||
A = sqlite3ExprListAppendVector(pParse, 0, X, Y.pExpr);
|
||||
}
|
||||
|
||||
////////////////////////// The INSERT command /////////////////////////////////
|
||||
@@ -847,18 +829,26 @@ idlist(A) ::= nm(Y).
|
||||
/////////////////////////// Expression Processing /////////////////////////////
|
||||
//
|
||||
|
||||
%type expr {Expr*}
|
||||
%destructor expr {sqlite3ExprDelete(pParse->db, $$);}
|
||||
%type term {Expr*}
|
||||
%destructor term {sqlite3ExprDelete(pParse->db, $$);}
|
||||
%type expr {ExprSpan}
|
||||
%destructor expr {sqlite3ExprDelete(pParse->db, $$.pExpr);}
|
||||
%type term {ExprSpan}
|
||||
%destructor term {sqlite3ExprDelete(pParse->db, $$.pExpr);}
|
||||
|
||||
%include {
|
||||
/* This is a utility routine used to set the ExprSpan.zStart and
|
||||
** ExprSpan.zEnd values of pOut so that the span covers the complete
|
||||
** range of text beginning with pStart and going to the end of pEnd.
|
||||
*/
|
||||
static void spanSet(ExprSpan *pOut, Token *pStart, Token *pEnd){
|
||||
pOut->zStart = pStart->z;
|
||||
pOut->zEnd = &pEnd->z[pEnd->n];
|
||||
}
|
||||
|
||||
/* Construct a new Expr object from a single identifier. Use the
|
||||
** new Expr to populate pOut. Set the span of pOut to be the identifier
|
||||
** that created the expression.
|
||||
*/
|
||||
static Expr *tokenExpr(Parse *pParse, int op, Token t){
|
||||
static void spanExpr(ExprSpan *pOut, Parse *pParse, int op, Token t){
|
||||
Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);
|
||||
if( p ){
|
||||
memset(p, 0, sizeof(Expr));
|
||||
@@ -876,98 +866,136 @@ idlist(A) ::= nm(Y).
|
||||
p->nHeight = 1;
|
||||
#endif
|
||||
}
|
||||
return p;
|
||||
pOut->pExpr = p;
|
||||
pOut->zStart = t.z;
|
||||
pOut->zEnd = &t.z[t.n];
|
||||
}
|
||||
}
|
||||
|
||||
expr(A) ::= term(A).
|
||||
expr(A) ::= LP expr(X) RP. {A = X;}
|
||||
expr(A) ::= id(X). {A=tokenExpr(pParse,TK_ID,X); /*A-overwrites-X*/}
|
||||
expr(A) ::= JOIN_KW(X). {A=tokenExpr(pParse,TK_ID,X); /*A-overwrites-X*/}
|
||||
expr(A) ::= LP(B) expr(X) RP(E).
|
||||
{spanSet(&A,&B,&E); /*A-overwrites-B*/ A.pExpr = X.pExpr;}
|
||||
expr(A) ::= id(X). {spanExpr(&A,pParse,TK_ID,X); /*A-overwrites-X*/}
|
||||
expr(A) ::= JOIN_KW(X). {spanExpr(&A,pParse,TK_ID,X); /*A-overwrites-X*/}
|
||||
expr(A) ::= nm(X) DOT nm(Y). {
|
||||
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &X, 1);
|
||||
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &Y, 1);
|
||||
A = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
|
||||
spanSet(&A,&X,&Y); /*A-overwrites-X*/
|
||||
A.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
|
||||
}
|
||||
expr(A) ::= nm(X) DOT nm(Y) DOT nm(Z). {
|
||||
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &X, 1);
|
||||
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &Y, 1);
|
||||
Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &Z, 1);
|
||||
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
|
||||
A = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
|
||||
spanSet(&A,&X,&Z); /*A-overwrites-X*/
|
||||
A.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
|
||||
}
|
||||
term(A) ::= NULL|FLOAT|BLOB(X). {A=tokenExpr(pParse,@X,X); /*A-overwrites-X*/}
|
||||
term(A) ::= STRING(X). {A=tokenExpr(pParse,@X,X); /*A-overwrites-X*/}
|
||||
term(A) ::= NULL|FLOAT|BLOB(X). {spanExpr(&A,pParse,@X,X); /*A-overwrites-X*/}
|
||||
term(A) ::= STRING(X). {spanExpr(&A,pParse,@X,X); /*A-overwrites-X*/}
|
||||
term(A) ::= INTEGER(X). {
|
||||
A = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &X, 1);
|
||||
A.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &X, 1);
|
||||
A.zStart = X.z;
|
||||
A.zEnd = X.z + X.n;
|
||||
}
|
||||
expr(A) ::= VARIABLE(X). {
|
||||
if( !(X.z[0]=='#' && sqlite3Isdigit(X.z[1])) ){
|
||||
u32 n = X.n;
|
||||
A = tokenExpr(pParse, TK_VARIABLE, X);
|
||||
sqlite3ExprAssignVarNumber(pParse, A, n);
|
||||
spanExpr(&A, pParse, TK_VARIABLE, X);
|
||||
sqlite3ExprAssignVarNumber(pParse, A.pExpr, n);
|
||||
}else{
|
||||
/* When doing a nested parse, one can include terms in an expression
|
||||
** that look like this: #1 #2 ... These terms refer to registers
|
||||
** in the virtual machine. #N is the N-th register. */
|
||||
Token t = X; /*A-overwrites-X*/
|
||||
assert( t.n>=2 );
|
||||
spanSet(&A, &t, &t);
|
||||
if( pParse->nested==0 ){
|
||||
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
|
||||
A = 0;
|
||||
A.pExpr = 0;
|
||||
}else{
|
||||
A = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
|
||||
if( A ) sqlite3GetInt32(&t.z[1], &A->iTable);
|
||||
A.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
|
||||
if( A.pExpr ) sqlite3GetInt32(&t.z[1], &A.pExpr->iTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
expr(A) ::= expr(A) COLLATE ids(C). {
|
||||
A = sqlite3ExprAddCollateToken(pParse, A, &C, 1);
|
||||
A.pExpr = sqlite3ExprAddCollateToken(pParse, A.pExpr, &C, 1);
|
||||
A.zEnd = &C.z[C.n];
|
||||
}
|
||||
%ifndef SQLITE_OMIT_CAST
|
||||
expr(A) ::= CAST LP expr(E) AS typetoken(T) RP. {
|
||||
A = sqlite3ExprAlloc(pParse->db, TK_CAST, &T, 1);
|
||||
sqlite3ExprAttachSubtrees(pParse->db, A, E, 0);
|
||||
expr(A) ::= CAST(X) LP expr(E) AS typetoken(T) RP(Y). {
|
||||
spanSet(&A,&X,&Y); /*A-overwrites-X*/
|
||||
A.pExpr = sqlite3ExprAlloc(pParse->db, TK_CAST, &T, 1);
|
||||
sqlite3ExprAttachSubtrees(pParse->db, A.pExpr, E.pExpr, 0);
|
||||
}
|
||||
%endif SQLITE_OMIT_CAST
|
||||
expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP. {
|
||||
expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP(E). {
|
||||
if( Y && Y->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
|
||||
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X);
|
||||
}
|
||||
A = sqlite3ExprFunction(pParse, Y, &X);
|
||||
if( D==SF_Distinct && A ){
|
||||
A->flags |= EP_Distinct;
|
||||
A.pExpr = sqlite3ExprFunction(pParse, Y, &X);
|
||||
spanSet(&A,&X,&E);
|
||||
if( D==SF_Distinct && A.pExpr ){
|
||||
A.pExpr->flags |= EP_Distinct;
|
||||
}
|
||||
}
|
||||
expr(A) ::= id(X) LP STAR RP. {
|
||||
A = sqlite3ExprFunction(pParse, 0, &X);
|
||||
expr(A) ::= id(X) LP STAR RP(E). {
|
||||
A.pExpr = sqlite3ExprFunction(pParse, 0, &X);
|
||||
spanSet(&A,&X,&E);
|
||||
}
|
||||
term(A) ::= CTIME_KW(OP). {
|
||||
A = sqlite3ExprFunction(pParse, 0, &OP);
|
||||
A.pExpr = sqlite3ExprFunction(pParse, 0, &OP);
|
||||
spanSet(&A, &OP, &OP);
|
||||
}
|
||||
|
||||
expr(A) ::= LP nexprlist(X) COMMA expr(Y) RP. {
|
||||
ExprList *pList = sqlite3ExprListAppend(pParse, X, Y);
|
||||
A = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
|
||||
if( A ){
|
||||
A->x.pList = pList;
|
||||
%include {
|
||||
/* This routine constructs a binary expression node out of two ExprSpan
|
||||
** objects and uses the result to populate a new ExprSpan object.
|
||||
*/
|
||||
static void spanBinaryExpr(
|
||||
Parse *pParse, /* The parsing context. Errors accumulate here */
|
||||
int op, /* The binary operation */
|
||||
ExprSpan *pLeft, /* The left operand, and output */
|
||||
ExprSpan *pRight /* The right operand */
|
||||
){
|
||||
pLeft->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr);
|
||||
pLeft->zEnd = pRight->zEnd;
|
||||
}
|
||||
|
||||
/* If doNot is true, then add a TK_NOT Expr-node wrapper around the
|
||||
** outside of *ppExpr.
|
||||
*/
|
||||
static void exprNot(Parse *pParse, int doNot, ExprSpan *pSpan){
|
||||
if( doNot ){
|
||||
pSpan->pExpr = sqlite3PExpr(pParse, TK_NOT, pSpan->pExpr, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expr(A) ::= LP(L) nexprlist(X) COMMA expr(Y) RP(R). {
|
||||
ExprList *pList = sqlite3ExprListAppend(pParse, X, Y.pExpr);
|
||||
A.pExpr = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
|
||||
if( A.pExpr ){
|
||||
A.pExpr->x.pList = pList;
|
||||
spanSet(&A, &L, &R);
|
||||
}else{
|
||||
sqlite3ExprListDelete(pParse->db, pList);
|
||||
}
|
||||
}
|
||||
|
||||
expr(A) ::= expr(A) AND(OP) expr(Y). {A=sqlite3PExpr(pParse,@OP,A,Y);}
|
||||
expr(A) ::= expr(A) OR(OP) expr(Y). {A=sqlite3PExpr(pParse,@OP,A,Y);}
|
||||
expr(A) ::= expr(A) AND(OP) expr(Y). {spanBinaryExpr(pParse,@OP,&A,&Y);}
|
||||
expr(A) ::= expr(A) OR(OP) expr(Y). {spanBinaryExpr(pParse,@OP,&A,&Y);}
|
||||
expr(A) ::= expr(A) LT|GT|GE|LE(OP) expr(Y).
|
||||
{A=sqlite3PExpr(pParse,@OP,A,Y);}
|
||||
expr(A) ::= expr(A) EQ|NE(OP) expr(Y). {A=sqlite3PExpr(pParse,@OP,A,Y);}
|
||||
{spanBinaryExpr(pParse,@OP,&A,&Y);}
|
||||
expr(A) ::= expr(A) EQ|NE(OP) expr(Y). {spanBinaryExpr(pParse,@OP,&A,&Y);}
|
||||
expr(A) ::= expr(A) BITAND|BITOR|LSHIFT|RSHIFT(OP) expr(Y).
|
||||
{A=sqlite3PExpr(pParse,@OP,A,Y);}
|
||||
{spanBinaryExpr(pParse,@OP,&A,&Y);}
|
||||
expr(A) ::= expr(A) PLUS|MINUS(OP) expr(Y).
|
||||
{A=sqlite3PExpr(pParse,@OP,A,Y);}
|
||||
{spanBinaryExpr(pParse,@OP,&A,&Y);}
|
||||
expr(A) ::= expr(A) STAR|SLASH|REM(OP) expr(Y).
|
||||
{A=sqlite3PExpr(pParse,@OP,A,Y);}
|
||||
expr(A) ::= expr(A) CONCAT(OP) expr(Y). {A=sqlite3PExpr(pParse,@OP,A,Y);}
|
||||
{spanBinaryExpr(pParse,@OP,&A,&Y);}
|
||||
expr(A) ::= expr(A) CONCAT(OP) expr(Y). {spanBinaryExpr(pParse,@OP,&A,&Y);}
|
||||
%type likeop {Token}
|
||||
likeop(A) ::= LIKE_KW|MATCH(A).
|
||||
likeop(A) ::= NOT LIKE_KW|MATCH(X). {A=X; A.n|=0x80000000; /*A-overwrite-X*/}
|
||||
@@ -975,26 +1003,42 @@ expr(A) ::= expr(A) likeop(OP) expr(Y). [LIKE_KW] {
|
||||
ExprList *pList;
|
||||
int bNot = OP.n & 0x80000000;
|
||||
OP.n &= 0x7fffffff;
|
||||
pList = sqlite3ExprListAppend(pParse,0, Y);
|
||||
pList = sqlite3ExprListAppend(pParse,pList, A);
|
||||
A = sqlite3ExprFunction(pParse, pList, &OP);
|
||||
if( bNot ) A = sqlite3PExpr(pParse, TK_NOT, A, 0);
|
||||
if( A ) A->flags |= EP_InfixFunc;
|
||||
pList = sqlite3ExprListAppend(pParse,0, Y.pExpr);
|
||||
pList = sqlite3ExprListAppend(pParse,pList, A.pExpr);
|
||||
A.pExpr = sqlite3ExprFunction(pParse, pList, &OP);
|
||||
exprNot(pParse, bNot, &A);
|
||||
A.zEnd = Y.zEnd;
|
||||
if( A.pExpr ) A.pExpr->flags |= EP_InfixFunc;
|
||||
}
|
||||
expr(A) ::= expr(A) likeop(OP) expr(Y) ESCAPE expr(E). [LIKE_KW] {
|
||||
ExprList *pList;
|
||||
int bNot = OP.n & 0x80000000;
|
||||
OP.n &= 0x7fffffff;
|
||||
pList = sqlite3ExprListAppend(pParse,0, Y);
|
||||
pList = sqlite3ExprListAppend(pParse,pList, A);
|
||||
pList = sqlite3ExprListAppend(pParse,pList, E);
|
||||
A = sqlite3ExprFunction(pParse, pList, &OP);
|
||||
if( bNot ) A = sqlite3PExpr(pParse, TK_NOT, A, 0);
|
||||
if( A ) A->flags |= EP_InfixFunc;
|
||||
pList = sqlite3ExprListAppend(pParse,0, Y.pExpr);
|
||||
pList = sqlite3ExprListAppend(pParse,pList, A.pExpr);
|
||||
pList = sqlite3ExprListAppend(pParse,pList, E.pExpr);
|
||||
A.pExpr = sqlite3ExprFunction(pParse, pList, &OP);
|
||||
exprNot(pParse, bNot, &A);
|
||||
A.zEnd = E.zEnd;
|
||||
if( A.pExpr ) A.pExpr->flags |= EP_InfixFunc;
|
||||
}
|
||||
|
||||
expr(A) ::= expr(A) ISNULL|NOTNULL(E). {A = sqlite3PExpr(pParse,@E,A,0);}
|
||||
expr(A) ::= expr(A) NOT NULL. {A = sqlite3PExpr(pParse,TK_NOTNULL,A,0);}
|
||||
%include {
|
||||
/* Construct an expression node for a unary postfix operator
|
||||
*/
|
||||
static void spanUnaryPostfix(
|
||||
Parse *pParse, /* Parsing context to record errors */
|
||||
int op, /* The operator */
|
||||
ExprSpan *pOperand, /* The operand, and output */
|
||||
Token *pPostOp /* The operand token for setting the span */
|
||||
){
|
||||
pOperand->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0);
|
||||
pOperand->zEnd = &pPostOp->z[pPostOp->n];
|
||||
}
|
||||
}
|
||||
|
||||
expr(A) ::= expr(A) ISNULL|NOTNULL(E). {spanUnaryPostfix(pParse,@E,&A,&E);}
|
||||
expr(A) ::= expr(A) NOT NULL(E). {spanUnaryPostfix(pParse,TK_NOTNULL,&A,&E);}
|
||||
|
||||
%include {
|
||||
/* A routine to convert a binary TK_IS or TK_ISNOT expression into a
|
||||
@@ -1016,42 +1060,61 @@ expr(A) ::= expr(A) NOT NULL. {A = sqlite3PExpr(pParse,TK_NOTNULL,A,0);}
|
||||
// is any other expression, code as TK_IS or TK_ISNOT.
|
||||
//
|
||||
expr(A) ::= expr(A) IS expr(Y). {
|
||||
A = sqlite3PExpr(pParse,TK_IS,A,Y);
|
||||
binaryToUnaryIfNull(pParse, Y, A, TK_ISNULL);
|
||||
spanBinaryExpr(pParse,TK_IS,&A,&Y);
|
||||
binaryToUnaryIfNull(pParse, Y.pExpr, A.pExpr, TK_ISNULL);
|
||||
}
|
||||
expr(A) ::= expr(A) IS NOT expr(Y). {
|
||||
A = sqlite3PExpr(pParse,TK_ISNOT,A,Y);
|
||||
binaryToUnaryIfNull(pParse, Y, A, TK_NOTNULL);
|
||||
spanBinaryExpr(pParse,TK_ISNOT,&A,&Y);
|
||||
binaryToUnaryIfNull(pParse, Y.pExpr, A.pExpr, TK_NOTNULL);
|
||||
}
|
||||
|
||||
%include {
|
||||
/* Construct an expression node for a unary prefix operator
|
||||
*/
|
||||
static void spanUnaryPrefix(
|
||||
ExprSpan *pOut, /* Write the new expression node here */
|
||||
Parse *pParse, /* Parsing context to record errors */
|
||||
int op, /* The operator */
|
||||
ExprSpan *pOperand, /* The operand */
|
||||
Token *pPreOp /* The operand token for setting the span */
|
||||
){
|
||||
pOut->zStart = pPreOp->z;
|
||||
pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0);
|
||||
pOut->zEnd = pOperand->zEnd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
expr(A) ::= NOT(B) expr(X).
|
||||
{A = sqlite3PExpr(pParse, @B, X, 0);/*A-overwrites-B*/}
|
||||
{spanUnaryPrefix(&A,pParse,@B,&X,&B);/*A-overwrites-B*/}
|
||||
expr(A) ::= BITNOT(B) expr(X).
|
||||
{A = sqlite3PExpr(pParse, @B, X, 0);/*A-overwrites-B*/}
|
||||
expr(A) ::= MINUS expr(X). [BITNOT]
|
||||
{A = sqlite3PExpr(pParse, TK_UMINUS, X, 0);}
|
||||
expr(A) ::= PLUS expr(X). [BITNOT]
|
||||
{A = sqlite3PExpr(pParse, TK_UPLUS, X, 0);}
|
||||
{spanUnaryPrefix(&A,pParse,@B,&X,&B);/*A-overwrites-B*/}
|
||||
expr(A) ::= MINUS(B) expr(X). [BITNOT]
|
||||
{spanUnaryPrefix(&A,pParse,TK_UMINUS,&X,&B);/*A-overwrites-B*/}
|
||||
expr(A) ::= PLUS(B) expr(X). [BITNOT]
|
||||
{spanUnaryPrefix(&A,pParse,TK_UPLUS,&X,&B);/*A-overwrites-B*/}
|
||||
|
||||
%type between_op {int}
|
||||
between_op(A) ::= BETWEEN. {A = 0;}
|
||||
between_op(A) ::= NOT BETWEEN. {A = 1;}
|
||||
expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] {
|
||||
ExprList *pList = sqlite3ExprListAppend(pParse,0, X);
|
||||
pList = sqlite3ExprListAppend(pParse,pList, Y);
|
||||
A = sqlite3PExpr(pParse, TK_BETWEEN, A, 0);
|
||||
if( A ){
|
||||
A->x.pList = pList;
|
||||
ExprList *pList = sqlite3ExprListAppend(pParse,0, X.pExpr);
|
||||
pList = sqlite3ExprListAppend(pParse,pList, Y.pExpr);
|
||||
A.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, A.pExpr, 0);
|
||||
if( A.pExpr ){
|
||||
A.pExpr->x.pList = pList;
|
||||
}else{
|
||||
sqlite3ExprListDelete(pParse->db, pList);
|
||||
}
|
||||
if( N ) A = sqlite3PExpr(pParse, TK_NOT, A, 0);
|
||||
exprNot(pParse, N, &A);
|
||||
A.zEnd = Y.zEnd;
|
||||
}
|
||||
%ifndef SQLITE_OMIT_SUBQUERY
|
||||
%type in_op {int}
|
||||
in_op(A) ::= IN. {A = 0;}
|
||||
in_op(A) ::= NOT IN. {A = 1;}
|
||||
expr(A) ::= expr(A) in_op(N) LP exprlist(Y) RP. [IN] {
|
||||
expr(A) ::= expr(A) in_op(N) LP exprlist(Y) RP(E). [IN] {
|
||||
if( Y==0 ){
|
||||
/* Expressions of the form
|
||||
**
|
||||
@@ -1061,8 +1124,8 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] {
|
||||
** simplify to constants 0 (false) and 1 (true), respectively,
|
||||
** regardless of the value of expr1.
|
||||
*/
|
||||
sqlite3ExprDelete(pParse->db, A);
|
||||
A = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[N],1);
|
||||
sqlite3ExprDelete(pParse->db, A.pExpr);
|
||||
A.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[N],1);
|
||||
}else if( Y->nExpr==1 ){
|
||||
/* Expressions of the form:
|
||||
**
|
||||
@@ -1089,48 +1152,54 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] {
|
||||
pRHS->flags &= ~EP_Collate;
|
||||
pRHS->flags |= EP_Generic;
|
||||
}
|
||||
A = sqlite3PExpr(pParse, N ? TK_NE : TK_EQ, A, pRHS);
|
||||
A.pExpr = sqlite3PExpr(pParse, N ? TK_NE : TK_EQ, A.pExpr, pRHS);
|
||||
}else{
|
||||
A = sqlite3PExpr(pParse, TK_IN, A, 0);
|
||||
if( A ){
|
||||
A->x.pList = Y;
|
||||
sqlite3ExprSetHeightAndFlags(pParse, A);
|
||||
A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0);
|
||||
if( A.pExpr ){
|
||||
A.pExpr->x.pList = Y;
|
||||
sqlite3ExprSetHeightAndFlags(pParse, A.pExpr);
|
||||
}else{
|
||||
sqlite3ExprListDelete(pParse->db, Y);
|
||||
}
|
||||
if( N ) A = sqlite3PExpr(pParse, TK_NOT, A, 0);
|
||||
exprNot(pParse, N, &A);
|
||||
}
|
||||
A.zEnd = &E.z[E.n];
|
||||
}
|
||||
expr(A) ::= LP select(X) RP. {
|
||||
A = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
|
||||
sqlite3PExprAddSelect(pParse, A, X);
|
||||
expr(A) ::= LP(B) select(X) RP(E). {
|
||||
spanSet(&A,&B,&E); /*A-overwrites-B*/
|
||||
A.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
|
||||
sqlite3PExprAddSelect(pParse, A.pExpr, X);
|
||||
}
|
||||
expr(A) ::= expr(A) in_op(N) LP select(Y) RP. [IN] {
|
||||
A = sqlite3PExpr(pParse, TK_IN, A, 0);
|
||||
sqlite3PExprAddSelect(pParse, A, Y);
|
||||
if( N ) A = sqlite3PExpr(pParse, TK_NOT, A, 0);
|
||||
expr(A) ::= expr(A) in_op(N) LP select(Y) RP(E). [IN] {
|
||||
A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0);
|
||||
sqlite3PExprAddSelect(pParse, A.pExpr, Y);
|
||||
exprNot(pParse, N, &A);
|
||||
A.zEnd = &E.z[E.n];
|
||||
}
|
||||
expr(A) ::= expr(A) in_op(N) nm(Y) dbnm(Z) paren_exprlist(E). [IN] {
|
||||
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&Y,&Z);
|
||||
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
|
||||
if( E ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, E);
|
||||
A = sqlite3PExpr(pParse, TK_IN, A, 0);
|
||||
sqlite3PExprAddSelect(pParse, A, pSelect);
|
||||
if( N ) A = sqlite3PExpr(pParse, TK_NOT, A, 0);
|
||||
A.pExpr = sqlite3PExpr(pParse, TK_IN, A.pExpr, 0);
|
||||
sqlite3PExprAddSelect(pParse, A.pExpr, pSelect);
|
||||
exprNot(pParse, N, &A);
|
||||
A.zEnd = Z.z ? &Z.z[Z.n] : &Y.z[Y.n];
|
||||
}
|
||||
expr(A) ::= EXISTS LP select(Y) RP. {
|
||||
expr(A) ::= EXISTS(B) LP select(Y) RP(E). {
|
||||
Expr *p;
|
||||
p = A = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
|
||||
spanSet(&A,&B,&E); /*A-overwrites-B*/
|
||||
p = A.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
|
||||
sqlite3PExprAddSelect(pParse, p, Y);
|
||||
}
|
||||
%endif SQLITE_OMIT_SUBQUERY
|
||||
|
||||
/* CASE expressions */
|
||||
expr(A) ::= CASE case_operand(X) case_exprlist(Y) case_else(Z) END. {
|
||||
A = sqlite3PExpr(pParse, TK_CASE, X, 0);
|
||||
if( A ){
|
||||
A->x.pList = Z ? sqlite3ExprListAppend(pParse,Y,Z) : Y;
|
||||
sqlite3ExprSetHeightAndFlags(pParse, A);
|
||||
expr(A) ::= CASE(C) case_operand(X) case_exprlist(Y) case_else(Z) END(E). {
|
||||
spanSet(&A,&C,&E); /*A-overwrites-C*/
|
||||
A.pExpr = sqlite3PExpr(pParse, TK_CASE, X, 0);
|
||||
if( A.pExpr ){
|
||||
A.pExpr->x.pList = Z ? sqlite3ExprListAppend(pParse,Y,Z) : Y;
|
||||
sqlite3ExprSetHeightAndFlags(pParse, A.pExpr);
|
||||
}else{
|
||||
sqlite3ExprListDelete(pParse->db, Y);
|
||||
sqlite3ExprDelete(pParse->db, Z);
|
||||
@@ -1139,20 +1208,20 @@ expr(A) ::= CASE case_operand(X) case_exprlist(Y) case_else(Z) END. {
|
||||
%type case_exprlist {ExprList*}
|
||||
%destructor case_exprlist {sqlite3ExprListDelete(pParse->db, $$);}
|
||||
case_exprlist(A) ::= case_exprlist(A) WHEN expr(Y) THEN expr(Z). {
|
||||
A = sqlite3ExprListAppend(pParse,A, Y);
|
||||
A = sqlite3ExprListAppend(pParse,A, Z);
|
||||
A = sqlite3ExprListAppend(pParse,A, Y.pExpr);
|
||||
A = sqlite3ExprListAppend(pParse,A, Z.pExpr);
|
||||
}
|
||||
case_exprlist(A) ::= WHEN expr(Y) THEN expr(Z). {
|
||||
A = sqlite3ExprListAppend(pParse,0, Y);
|
||||
A = sqlite3ExprListAppend(pParse,A, Z);
|
||||
A = sqlite3ExprListAppend(pParse,0, Y.pExpr);
|
||||
A = sqlite3ExprListAppend(pParse,A, Z.pExpr);
|
||||
}
|
||||
%type case_else {Expr*}
|
||||
%destructor case_else {sqlite3ExprDelete(pParse->db, $$);}
|
||||
case_else(A) ::= ELSE expr(X). {A = X;}
|
||||
case_else(A) ::= ELSE expr(X). {A = X.pExpr;}
|
||||
case_else(A) ::= . {A = 0;}
|
||||
%type case_operand {Expr*}
|
||||
%destructor case_operand {sqlite3ExprDelete(pParse->db, $$);}
|
||||
case_operand(A) ::= expr(X). {A = X; /*A-overwrites-X*/}
|
||||
case_operand(A) ::= expr(X). {A = X.pExpr; /*A-overwrites-X*/}
|
||||
case_operand(A) ::= . {A = 0;}
|
||||
|
||||
%type exprlist {ExprList*}
|
||||
@@ -1163,9 +1232,9 @@ case_operand(A) ::= . {A = 0;}
|
||||
exprlist(A) ::= nexprlist(A).
|
||||
exprlist(A) ::= . {A = 0;}
|
||||
nexprlist(A) ::= nexprlist(A) COMMA expr(Y).
|
||||
{A = sqlite3ExprListAppend(pParse,A,Y);}
|
||||
{A = sqlite3ExprListAppend(pParse,A,Y.pExpr);}
|
||||
nexprlist(A) ::= expr(Y).
|
||||
{A = sqlite3ExprListAppend(pParse,0,Y); /*A-overwrites-Y*/}
|
||||
{A = sqlite3ExprListAppend(pParse,0,Y.pExpr); /*A-overwrites-Y*/}
|
||||
|
||||
%ifndef SQLITE_OMIT_SUBQUERY
|
||||
/* A paren_exprlist is an optional expression list contained inside
|
||||
@@ -1319,7 +1388,7 @@ foreach_clause ::= FOR EACH ROW.
|
||||
%type when_clause {Expr*}
|
||||
%destructor when_clause {sqlite3ExprDelete(pParse->db, $$);}
|
||||
when_clause(A) ::= . { A = 0; }
|
||||
when_clause(A) ::= WHEN expr(X). { A = X; }
|
||||
when_clause(A) ::= WHEN expr(X). { A = X.pExpr; }
|
||||
|
||||
%type trigger_cmd_list {TriggerStep*}
|
||||
%destructor trigger_cmd_list {sqlite3DeleteTriggerStep(pParse->db, $$);}
|
||||
@@ -1368,33 +1437,34 @@ tridxby ::= NOT INDEXED. {
|
||||
%destructor trigger_cmd {sqlite3DeleteTriggerStep(pParse->db, $$);}
|
||||
// UPDATE
|
||||
trigger_cmd(A) ::=
|
||||
UPDATE(B) orconf(R) trnm(X) tridxby SET setlist(Y) where_opt(Z) scanpt(E).
|
||||
{A = sqlite3TriggerUpdateStep(pParse->db, &X, Y, Z, R, B.z, E);}
|
||||
UPDATE orconf(R) trnm(X) tridxby SET setlist(Y) where_opt(Z).
|
||||
{A = sqlite3TriggerUpdateStep(pParse->db, &X, Y, Z, R);}
|
||||
|
||||
// INSERT
|
||||
trigger_cmd(A) ::= scanpt(B) insert_cmd(R) INTO
|
||||
trnm(X) idlist_opt(F) select(S) scanpt(Z).
|
||||
{A = sqlite3TriggerInsertStep(pParse->db,&X,F,S,R,B,Z);/*A-overwrites-R*/}
|
||||
trigger_cmd(A) ::= insert_cmd(R) INTO trnm(X) idlist_opt(F) select(S).
|
||||
{A = sqlite3TriggerInsertStep(pParse->db, &X, F, S, R);/*A-overwrites-R*/}
|
||||
|
||||
// DELETE
|
||||
trigger_cmd(A) ::= DELETE(B) FROM trnm(X) tridxby where_opt(Y) scanpt(E).
|
||||
{A = sqlite3TriggerDeleteStep(pParse->db, &X, Y, B.z, E);}
|
||||
trigger_cmd(A) ::= DELETE FROM trnm(X) tridxby where_opt(Y).
|
||||
{A = sqlite3TriggerDeleteStep(pParse->db, &X, Y);}
|
||||
|
||||
// SELECT
|
||||
trigger_cmd(A) ::= scanpt(B) select(X) scanpt(E).
|
||||
{A = sqlite3TriggerSelectStep(pParse->db, X, B, E); /*A-overwrites-X*/}
|
||||
trigger_cmd(A) ::= select(X).
|
||||
{A = sqlite3TriggerSelectStep(pParse->db, X); /*A-overwrites-X*/}
|
||||
|
||||
// The special RAISE expression that may occur in trigger programs
|
||||
expr(A) ::= RAISE LP IGNORE RP. {
|
||||
A = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
|
||||
if( A ){
|
||||
A->affinity = OE_Ignore;
|
||||
expr(A) ::= RAISE(X) LP IGNORE RP(Y). {
|
||||
spanSet(&A,&X,&Y); /*A-overwrites-X*/
|
||||
A.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
|
||||
if( A.pExpr ){
|
||||
A.pExpr->affinity = OE_Ignore;
|
||||
}
|
||||
}
|
||||
expr(A) ::= RAISE LP raisetype(T) COMMA nm(Z) RP. {
|
||||
A = sqlite3ExprAlloc(pParse->db, TK_RAISE, &Z, 1);
|
||||
if( A ) {
|
||||
A->affinity = (char)T;
|
||||
expr(A) ::= RAISE(X) LP raisetype(T) COMMA nm(Z) RP(Y). {
|
||||
spanSet(&A,&X,&Y); /*A-overwrites-X*/
|
||||
A.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &Z, 1);
|
||||
if( A.pExpr ) {
|
||||
A.pExpr->affinity = (char)T;
|
||||
}
|
||||
}
|
||||
%endif !SQLITE_OMIT_TRIGGER
|
||||
@@ -1415,16 +1485,16 @@ cmd ::= DROP TRIGGER ifexists(NOERR) fullname(X). {
|
||||
//////////////////////// ATTACH DATABASE file AS name /////////////////////////
|
||||
%ifndef SQLITE_OMIT_ATTACH
|
||||
cmd ::= ATTACH database_kw_opt expr(F) AS expr(D) key_opt(K). {
|
||||
sqlite3Attach(pParse, F, D, K);
|
||||
sqlite3Attach(pParse, F.pExpr, D.pExpr, K);
|
||||
}
|
||||
cmd ::= DETACH database_kw_opt expr(D). {
|
||||
sqlite3Detach(pParse, D);
|
||||
sqlite3Detach(pParse, D.pExpr);
|
||||
}
|
||||
|
||||
%type key_opt {Expr*}
|
||||
%destructor key_opt {sqlite3ExprDelete(pParse->db, $$);}
|
||||
key_opt(A) ::= . { A = 0; }
|
||||
key_opt(A) ::= KEY expr(X). { A = X; }
|
||||
key_opt(A) ::= KEY expr(X). { A = X.pExpr; }
|
||||
|
||||
database_kw_opt ::= DATABASE.
|
||||
database_kw_opt ::= .
|
||||
|
||||
+19
-1
@@ -1080,7 +1080,6 @@ void sqlite3Pragma(
|
||||
** type: Column declaration type.
|
||||
** notnull: True if 'NOT NULL' is part of column declaration
|
||||
** dflt_value: The default value for the column, if any.
|
||||
** pk: Non-zero for PK fields.
|
||||
*/
|
||||
case PragTyp_TABLE_INFO: if( zRight ){
|
||||
Table *pTab;
|
||||
@@ -1118,6 +1117,25 @@ void sqlite3Pragma(
|
||||
}
|
||||
break;
|
||||
|
||||
/*
|
||||
** PRAGMA table_ipk(<table>)
|
||||
**
|
||||
** If <table> has an INTEGER PRIMARY KEY column that is an alias for
|
||||
** the ROWID, then return the name of that column. If <table> does not
|
||||
** have a ROWID alias, or if it does not have a ROWID, or if <table> is
|
||||
** a view or virtual table or if it does not exist, then return no rows.
|
||||
*/
|
||||
case PragTyp_TABLE_IPK: {
|
||||
if( zRight ){
|
||||
Table *pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);
|
||||
sqlite3CodeVerifySchema(pParse, iDb);
|
||||
if( pTab && HasRowid(pTab) && pTab->iPKey>=0 ){
|
||||
sqlite3VdbeMultiLoad(v, 1, "s", pTab->aCol[pTab->iPKey].zName);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
case PragTyp_STATS: {
|
||||
Index *pIdx;
|
||||
|
||||
+52
-46
@@ -40,18 +40,19 @@
|
||||
#define PragTyp_SOFT_HEAP_LIMIT 32
|
||||
#define PragTyp_SYNCHRONOUS 33
|
||||
#define PragTyp_TABLE_INFO 34
|
||||
#define PragTyp_TEMP_STORE 35
|
||||
#define PragTyp_TEMP_STORE_DIRECTORY 36
|
||||
#define PragTyp_THREADS 37
|
||||
#define PragTyp_WAL_AUTOCHECKPOINT 38
|
||||
#define PragTyp_WAL_CHECKPOINT 39
|
||||
#define PragTyp_ACTIVATE_EXTENSIONS 40
|
||||
#define PragTyp_HEXKEY 41
|
||||
#define PragTyp_KEY 42
|
||||
#define PragTyp_REKEY 43
|
||||
#define PragTyp_LOCK_STATUS 44
|
||||
#define PragTyp_PARSER_TRACE 45
|
||||
#define PragTyp_STATS 46
|
||||
#define PragTyp_TABLE_IPK 35
|
||||
#define PragTyp_TEMP_STORE 36
|
||||
#define PragTyp_TEMP_STORE_DIRECTORY 37
|
||||
#define PragTyp_THREADS 38
|
||||
#define PragTyp_WAL_AUTOCHECKPOINT 39
|
||||
#define PragTyp_WAL_CHECKPOINT 40
|
||||
#define PragTyp_ACTIVATE_EXTENSIONS 41
|
||||
#define PragTyp_HEXKEY 42
|
||||
#define PragTyp_KEY 43
|
||||
#define PragTyp_REKEY 44
|
||||
#define PragTyp_LOCK_STATUS 45
|
||||
#define PragTyp_PARSER_TRACE 46
|
||||
#define PragTyp_STATS 47
|
||||
|
||||
/* Property flags associated with various pragma. */
|
||||
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
|
||||
@@ -75,31 +76,31 @@ static const char *const pragCName[] = {
|
||||
/* 4 */ "notnull",
|
||||
/* 5 */ "dflt_value",
|
||||
/* 6 */ "pk",
|
||||
/* 7 */ "tbl", /* Used by: stats */
|
||||
/* 8 */ "idx",
|
||||
/* 9 */ "wdth",
|
||||
/* 10 */ "hght",
|
||||
/* 11 */ "flgs",
|
||||
/* 12 */ "seqno", /* Used by: index_info */
|
||||
/* 13 */ "cid",
|
||||
/* 14 */ "name",
|
||||
/* 15 */ "seqno", /* Used by: index_xinfo */
|
||||
/* 16 */ "cid",
|
||||
/* 17 */ "name",
|
||||
/* 18 */ "desc",
|
||||
/* 19 */ "coll",
|
||||
/* 20 */ "key",
|
||||
/* 21 */ "seq", /* Used by: index_list */
|
||||
/* 22 */ "name",
|
||||
/* 23 */ "unique",
|
||||
/* 24 */ "origin",
|
||||
/* 25 */ "partial",
|
||||
/* 26 */ "seq", /* Used by: database_list */
|
||||
/* 27 */ "name",
|
||||
/* 28 */ "file",
|
||||
/* 29 */ "name", /* Used by: function_list */
|
||||
/* 30 */ "builtin",
|
||||
/* 31 */ "name", /* Used by: module_list pragma_list */
|
||||
/* 7 */ "name", /* Used by: table_ipk module_list pragma_list */
|
||||
/* 8 */ "tbl", /* Used by: stats */
|
||||
/* 9 */ "idx",
|
||||
/* 10 */ "wdth",
|
||||
/* 11 */ "hght",
|
||||
/* 12 */ "flgs",
|
||||
/* 13 */ "seqno", /* Used by: index_info */
|
||||
/* 14 */ "cid",
|
||||
/* 15 */ "name",
|
||||
/* 16 */ "seqno", /* Used by: index_xinfo */
|
||||
/* 17 */ "cid",
|
||||
/* 18 */ "name",
|
||||
/* 19 */ "desc",
|
||||
/* 20 */ "coll",
|
||||
/* 21 */ "key",
|
||||
/* 22 */ "seq", /* Used by: index_list */
|
||||
/* 23 */ "name",
|
||||
/* 24 */ "unique",
|
||||
/* 25 */ "origin",
|
||||
/* 26 */ "partial",
|
||||
/* 27 */ "seq", /* Used by: database_list */
|
||||
/* 28 */ "name",
|
||||
/* 29 */ "file",
|
||||
/* 30 */ "name", /* Used by: function_list */
|
||||
/* 31 */ "builtin",
|
||||
/* 32 */ "seq", /* Used by: collation_list */
|
||||
/* 33 */ "name",
|
||||
/* 34 */ "id", /* Used by: foreign_key_list */
|
||||
@@ -237,7 +238,7 @@ static const PragmaName aPragmaName[] = {
|
||||
{/* zName: */ "database_list",
|
||||
/* ePragTyp: */ PragTyp_DATABASE_LIST,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
|
||||
/* ColNames: */ 26, 3,
|
||||
/* ColNames: */ 27, 3,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
|
||||
@@ -317,7 +318,7 @@ static const PragmaName aPragmaName[] = {
|
||||
{/* zName: */ "function_list",
|
||||
/* ePragTyp: */ PragTyp_FUNCTION_LIST,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 29, 2,
|
||||
/* ColNames: */ 30, 2,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
#endif
|
||||
@@ -353,17 +354,17 @@ static const PragmaName aPragmaName[] = {
|
||||
{/* zName: */ "index_info",
|
||||
/* ePragTyp: */ PragTyp_INDEX_INFO,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
|
||||
/* ColNames: */ 12, 3,
|
||||
/* ColNames: */ 13, 3,
|
||||
/* iArg: */ 0 },
|
||||
{/* zName: */ "index_list",
|
||||
/* ePragTyp: */ PragTyp_INDEX_LIST,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
|
||||
/* ColNames: */ 21, 5,
|
||||
/* ColNames: */ 22, 5,
|
||||
/* iArg: */ 0 },
|
||||
{/* zName: */ "index_xinfo",
|
||||
/* ePragTyp: */ PragTyp_INDEX_INFO,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
|
||||
/* ColNames: */ 15, 6,
|
||||
/* ColNames: */ 16, 6,
|
||||
/* iArg: */ 1 },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
|
||||
@@ -436,7 +437,7 @@ static const PragmaName aPragmaName[] = {
|
||||
{/* zName: */ "module_list",
|
||||
/* ePragTyp: */ PragTyp_MODULE_LIST,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 31, 1,
|
||||
/* ColNames: */ 7, 1,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
#endif
|
||||
@@ -469,7 +470,7 @@ static const PragmaName aPragmaName[] = {
|
||||
{/* zName: */ "pragma_list",
|
||||
/* ePragTyp: */ PragTyp_PRAGMA_LIST,
|
||||
/* ePragFlg: */ PragFlg_Result0,
|
||||
/* ColNames: */ 31, 1,
|
||||
/* ColNames: */ 7, 1,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
|
||||
@@ -556,7 +557,7 @@ static const PragmaName aPragmaName[] = {
|
||||
{/* zName: */ "stats",
|
||||
/* ePragTyp: */ PragTyp_STATS,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
|
||||
/* ColNames: */ 7, 5,
|
||||
/* ColNames: */ 8, 5,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
@@ -572,6 +573,11 @@ static const PragmaName aPragmaName[] = {
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
|
||||
/* ColNames: */ 1, 6,
|
||||
/* iArg: */ 0 },
|
||||
{/* zName: */ "table_ipk",
|
||||
/* ePragTyp: */ PragTyp_TABLE_IPK,
|
||||
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1,
|
||||
/* ColNames: */ 7, 1,
|
||||
/* iArg: */ 0 },
|
||||
#endif
|
||||
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
|
||||
{/* zName: */ "temp_store",
|
||||
@@ -646,4 +652,4 @@ static const PragmaName aPragmaName[] = {
|
||||
/* iArg: */ SQLITE_WriteSchema },
|
||||
#endif
|
||||
};
|
||||
/* Number of pragmas: 60 on by default, 77 total. */
|
||||
/* Number of pragmas: 61 on by default, 78 total. */
|
||||
|
||||
+8
-10
@@ -655,6 +655,8 @@ static int sqlite3Prepare(
|
||||
end_prepare:
|
||||
|
||||
sqlite3ParserReset(&sParse);
|
||||
rc = sqlite3ApiExit(db, rc);
|
||||
assert( (rc&db->errMask)==rc );
|
||||
return rc;
|
||||
}
|
||||
static int sqlite3LockAndPrepare(
|
||||
@@ -667,7 +669,6 @@ static int sqlite3LockAndPrepare(
|
||||
const char **pzTail /* OUT: End of parsed string */
|
||||
){
|
||||
int rc;
|
||||
int cnt = 0;
|
||||
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;
|
||||
@@ -678,18 +679,15 @@ static int sqlite3LockAndPrepare(
|
||||
}
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
sqlite3BtreeEnterAll(db);
|
||||
do{
|
||||
/* Make multiple attempts to compile the SQL, until it either succeeds
|
||||
** or encounters a permanent error. A schema problem after one schema
|
||||
** reset is considered a permanent error. */
|
||||
rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
|
||||
if( rc==SQLITE_SCHEMA ){
|
||||
sqlite3ResetOneSchema(db, -1);
|
||||
sqlite3_finalize(*ppStmt);
|
||||
rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail);
|
||||
assert( rc==SQLITE_OK || *ppStmt==0 );
|
||||
}while( rc==SQLITE_ERROR_RETRY
|
||||
|| (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) );
|
||||
}
|
||||
sqlite3BtreeLeaveAll(db);
|
||||
rc = sqlite3ApiExit(db, rc);
|
||||
assert( (rc&db->errMask)==rc );
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
assert( rc==SQLITE_OK || *ppStmt==0 );
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -1381,9 +1381,8 @@ static const char *columnTypeImpl(
|
||||
|
||||
assert( pExpr!=0 );
|
||||
assert( pNC->pSrcList!=0 );
|
||||
assert( pExpr->op!=TK_AGG_COLUMN ); /* This routine runes before aggregates
|
||||
** are processed */
|
||||
switch( pExpr->op ){
|
||||
case TK_AGG_COLUMN:
|
||||
case TK_COLUMN: {
|
||||
/* The expression is a column. Locate the table the column is being
|
||||
** extracted from in NameContext.pSrcList. This table may be real
|
||||
@@ -1392,6 +1391,8 @@ static const char *columnTypeImpl(
|
||||
Table *pTab = 0; /* Table structure column is extracted from */
|
||||
Select *pS = 0; /* Select the column is extracted from */
|
||||
int iCol = pExpr->iColumn; /* Index of column in pTab */
|
||||
testcase( pExpr->op==TK_AGG_COLUMN );
|
||||
testcase( pExpr->op==TK_COLUMN );
|
||||
while( pNC && !pTab ){
|
||||
SrcList *pTabList = pNC->pSrcList;
|
||||
for(j=0;j<pTabList->nSrc && pTabList->a[j].iCursor!=pExpr->iTable;j++);
|
||||
@@ -1595,7 +1596,6 @@ static void generateColumnNames(
|
||||
if( pParse->colNamesSet || db->mallocFailed ) return;
|
||||
/* Column names are determined by the left-most term of a compound select */
|
||||
while( pSelect->pPrior ) pSelect = pSelect->pPrior;
|
||||
SELECTTRACE(1,pParse,pSelect,("generating column names\n"));
|
||||
pTabList = pSelect->pSrc;
|
||||
pEList = pSelect->pEList;
|
||||
assert( v!=0 );
|
||||
@@ -1704,12 +1704,12 @@ int sqlite3ColumnsFromExprList(
|
||||
pColExpr = pColExpr->pRight;
|
||||
assert( pColExpr!=0 );
|
||||
}
|
||||
assert( pColExpr->op!=TK_AGG_COLUMN );
|
||||
if( pColExpr->op==TK_COLUMN ){
|
||||
if( (pColExpr->op==TK_COLUMN || pColExpr->op==TK_AGG_COLUMN)
|
||||
&& pColExpr->pTab!=0
|
||||
){
|
||||
/* For columns use the column name name */
|
||||
int iCol = pColExpr->iColumn;
|
||||
Table *pTab = pColExpr->pTab;
|
||||
assert( pTab!=0 );
|
||||
if( iCol<0 ) iCol = pTab->iPKey;
|
||||
zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid";
|
||||
}else if( pColExpr->op==TK_ID ){
|
||||
|
||||
+10
-191
@@ -796,8 +796,6 @@ static void shellAddSchemaName(
|
||||
INCLUDE ../ext/misc/shathree.c
|
||||
INCLUDE ../ext/misc/fileio.c
|
||||
INCLUDE ../ext/misc/completion.c
|
||||
INCLUDE ../ext/expert/sqlite3expert.h
|
||||
INCLUDE ../ext/expert/sqlite3expert.c
|
||||
|
||||
#if defined(SQLITE_ENABLE_SESSION)
|
||||
/*
|
||||
@@ -824,12 +822,6 @@ struct SavedModeInfo {
|
||||
int colWidth[100]; /* Column widths prior to ".explain on" */
|
||||
};
|
||||
|
||||
typedef struct ExpertInfo ExpertInfo;
|
||||
struct ExpertInfo {
|
||||
sqlite3expert *pExpert;
|
||||
int bVerbose;
|
||||
};
|
||||
|
||||
/*
|
||||
** State information about the database connection is contained in an
|
||||
** instance of the following structure.
|
||||
@@ -874,16 +866,8 @@ struct ShellState {
|
||||
int nSession; /* Number of active sessions */
|
||||
OpenSession aSession[4]; /* Array of sessions. [0] is in focus. */
|
||||
#endif
|
||||
ExpertInfo expert; /* Valid if previous command was ".expert OPT..." */
|
||||
};
|
||||
|
||||
/* Allowed values for ShellState.autoEQP
|
||||
*/
|
||||
#define AUTOEQP_off 0
|
||||
#define AUTOEQP_on 1
|
||||
#define AUTOEQP_trigger 2
|
||||
#define AUTOEQP_full 3
|
||||
|
||||
/*
|
||||
** These are the allowed shellFlgs values
|
||||
*/
|
||||
@@ -2265,79 +2249,6 @@ static void exec_prepared_stmt(
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is called to process SQL if the previous shell command
|
||||
** was ".expert". It passes the SQL in the second argument directly to
|
||||
** the sqlite3expert object.
|
||||
**
|
||||
** If successful, SQLITE_OK is returned. Otherwise, an SQLite error
|
||||
** code. In this case, (*pzErr) may be set to point to a buffer containing
|
||||
** an English language error message. It is the responsibility of the
|
||||
** caller to eventually free this buffer using sqlite3_free().
|
||||
*/
|
||||
static int expertHandleSQL(
|
||||
ShellState *pState,
|
||||
const char *zSql,
|
||||
char **pzErr
|
||||
){
|
||||
assert( pState->expert.pExpert );
|
||||
assert( pzErr==0 || *pzErr==0 );
|
||||
return sqlite3_expert_sql(pState->expert.pExpert, zSql, pzErr);
|
||||
}
|
||||
|
||||
/*
|
||||
** This function is called either to silently clean up the object
|
||||
** created by the ".expert" command (if bCancel==1), or to generate a
|
||||
** report from it and then clean it up (if bCancel==0).
|
||||
**
|
||||
** If successful, SQLITE_OK is returned. Otherwise, an SQLite error
|
||||
** code. In this case, (*pzErr) may be set to point to a buffer containing
|
||||
** an English language error message. It is the responsibility of the
|
||||
** caller to eventually free this buffer using sqlite3_free().
|
||||
*/
|
||||
static int expertFinish(
|
||||
ShellState *pState,
|
||||
int bCancel,
|
||||
char **pzErr
|
||||
){
|
||||
int rc = SQLITE_OK;
|
||||
sqlite3expert *p = pState->expert.pExpert;
|
||||
assert( p );
|
||||
assert( bCancel || pzErr==0 || *pzErr==0 );
|
||||
if( bCancel==0 ){
|
||||
FILE *out = pState->out;
|
||||
int bVerbose = pState->expert.bVerbose;
|
||||
|
||||
rc = sqlite3_expert_analyze(p, pzErr);
|
||||
if( rc==SQLITE_OK ){
|
||||
int nQuery = sqlite3_expert_count(p);
|
||||
int i;
|
||||
|
||||
if( bVerbose ){
|
||||
const char *zCand = sqlite3_expert_report(p,0,EXPERT_REPORT_CANDIDATES);
|
||||
raw_printf(out, "-- Candidates -----------------------------\n");
|
||||
raw_printf(out, "%s\n", zCand);
|
||||
}
|
||||
for(i=0; i<nQuery; i++){
|
||||
const char *zSql = sqlite3_expert_report(p, i, EXPERT_REPORT_SQL);
|
||||
const char *zIdx = sqlite3_expert_report(p, i, EXPERT_REPORT_INDEXES);
|
||||
const char *zEQP = sqlite3_expert_report(p, i, EXPERT_REPORT_PLAN);
|
||||
if( zIdx==0 ) zIdx = "(no new indexes)\n";
|
||||
if( bVerbose ){
|
||||
raw_printf(out, "-- Query %d --------------------------------\n",i+1);
|
||||
raw_printf(out, "%s\n\n", zSql);
|
||||
}
|
||||
raw_printf(out, "%s\n", zIdx);
|
||||
raw_printf(out, "%s\n", zEQP);
|
||||
}
|
||||
}
|
||||
}
|
||||
sqlite3_expert_destroy(p);
|
||||
pState->expert.pExpert = 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Execute a statement or set of statements. Print
|
||||
** any result rows/columns depending on the current mode
|
||||
@@ -2364,11 +2275,6 @@ static int shell_exec(
|
||||
*pzErrMsg = NULL;
|
||||
}
|
||||
|
||||
if( pArg->expert.pExpert ){
|
||||
rc = expertHandleSQL(pArg, zSql, pzErrMsg);
|
||||
return expertFinish(pArg, (rc!=SQLITE_OK), pzErrMsg);
|
||||
}
|
||||
|
||||
while( zSql[0] && (SQLITE_OK == rc) ){
|
||||
static const char *zStmtSql;
|
||||
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
|
||||
@@ -2402,12 +2308,7 @@ static int shell_exec(
|
||||
if( pArg && pArg->autoEQP && sqlite3_strlike("EXPLAIN%",zStmtSql,0)!=0 ){
|
||||
sqlite3_stmt *pExplain;
|
||||
char *zEQP;
|
||||
int triggerEQP = 0;
|
||||
disable_debug_trace_modes();
|
||||
sqlite3_db_config(db, SQLITE_DBCONFIG_TRIGGER_EQP, -1, &triggerEQP);
|
||||
if( pArg->autoEQP>=AUTOEQP_trigger ){
|
||||
sqlite3_db_config(db, SQLITE_DBCONFIG_TRIGGER_EQP, 1, 0);
|
||||
}
|
||||
zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s", zStmtSql);
|
||||
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
@@ -2420,7 +2321,7 @@ static int shell_exec(
|
||||
}
|
||||
sqlite3_finalize(pExplain);
|
||||
sqlite3_free(zEQP);
|
||||
if( pArg->autoEQP>=AUTOEQP_full ){
|
||||
if( pArg->autoEQP>=2 ){
|
||||
/* Also do an EXPLAIN for ".eqp full" mode */
|
||||
zEQP = sqlite3_mprintf("EXPLAIN %s", zStmtSql);
|
||||
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
|
||||
@@ -2433,7 +2334,6 @@ static int shell_exec(
|
||||
sqlite3_finalize(pExplain);
|
||||
sqlite3_free(zEQP);
|
||||
}
|
||||
sqlite3_db_config(db, SQLITE_DBCONFIG_TRIGGER_EQP, triggerEQP, 0);
|
||||
restore_debug_trace_modes();
|
||||
}
|
||||
|
||||
@@ -2792,7 +2692,6 @@ static char zHelp[] =
|
||||
".echo on|off Turn command echo on or off\n"
|
||||
".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN\n"
|
||||
".exit Exit this program\n"
|
||||
".expert EXPERIMENTAL. Suggest indexes for specified queries\n"
|
||||
/* Because explain mode comes on automatically now, the ".explain" mode
|
||||
** is removed from the help screen. It is still supported for legacy, however */
|
||||
/*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic\n"*/
|
||||
@@ -3996,10 +3895,10 @@ static int lintFkeyIndexes(
|
||||
**
|
||||
** 0. The text of an SQL statement similar to:
|
||||
**
|
||||
** "EXPLAIN QUERY PLAN SELECT 1 FROM child_table WHERE child_key=?"
|
||||
** "EXPLAIN QUERY PLAN SELECT rowid FROM child_table WHERE child_key=?"
|
||||
**
|
||||
** This SELECT is similar to the one that the foreign keys implementation
|
||||
** needs to run internally on child tables. If there is an index that can
|
||||
** This is the same SELECT that the foreign keys implementation needs
|
||||
** to run internally on child tables. If there is an index that can
|
||||
** be used to optimize this query, then it can also be used by the FK
|
||||
** implementation to optimize DELETE or UPDATE statements on the parent
|
||||
** table.
|
||||
@@ -4027,7 +3926,7 @@ static int lintFkeyIndexes(
|
||||
*/
|
||||
const char *zSql =
|
||||
"SELECT "
|
||||
" 'EXPLAIN QUERY PLAN SELECT 1 FROM ' || quote(s.name) || ' WHERE '"
|
||||
" 'EXPLAIN QUERY PLAN SELECT rowid FROM ' || quote(s.name) || ' WHERE '"
|
||||
" || group_concat(quote(s.name) || '.' || quote(f.[from]) || '=?' "
|
||||
" || fkey_collate_clause("
|
||||
" f.[table], COALESCE(f.[to], p.[name]), s.name, f.[from]),' AND ')"
|
||||
@@ -4169,64 +4068,6 @@ static int lintDotCommand(
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
** Implementation of ".expert" dot command.
|
||||
*/
|
||||
static int expertDotCommand(
|
||||
ShellState *pState, /* Current shell tool state */
|
||||
char **azArg, /* Array of arguments passed to dot command */
|
||||
int nArg /* Number of entries in azArg[] */
|
||||
){
|
||||
int rc = SQLITE_OK;
|
||||
char *zErr = 0;
|
||||
int i;
|
||||
int iSample = 0;
|
||||
|
||||
assert( pState->expert.pExpert==0 );
|
||||
memset(&pState->expert, 0, sizeof(ExpertInfo));
|
||||
|
||||
for(i=1; rc==SQLITE_OK && i<nArg; i++){
|
||||
char *z = azArg[i];
|
||||
int n;
|
||||
if( z[0]=='-' && z[1]=='-' ) z++;
|
||||
n = strlen(z);
|
||||
if( n>=2 && 0==strncmp(z, "-verbose", n) ){
|
||||
pState->expert.bVerbose = 1;
|
||||
}
|
||||
else if( n>=2 && 0==strncmp(z, "-sample", n) ){
|
||||
if( i==(nArg-1) ){
|
||||
raw_printf(stderr, "option requires an argument: %s\n", z);
|
||||
rc = SQLITE_ERROR;
|
||||
}else{
|
||||
iSample = (int)integerValue(azArg[++i]);
|
||||
if( iSample<0 || iSample>100 ){
|
||||
raw_printf(stderr, "value out of range: %s\n", azArg[i]);
|
||||
rc = SQLITE_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
raw_printf(stderr, "unknown option: %s\n", z);
|
||||
rc = SQLITE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
pState->expert.pExpert = sqlite3_expert_new(pState->db, &zErr);
|
||||
if( pState->expert.pExpert==0 ){
|
||||
raw_printf(stderr, "sqlite3_expert_new: %s\n", zErr);
|
||||
rc = SQLITE_ERROR;
|
||||
}else{
|
||||
sqlite3_expert_config(
|
||||
pState->expert.pExpert, EXPERT_CONFIG_SAMPLE, iSample
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
** If an input line begins with "." then invoke this routine to
|
||||
@@ -4241,10 +4082,6 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
int rc = 0;
|
||||
char *azArg[50];
|
||||
|
||||
if( p->expert.pExpert ){
|
||||
expertFinish(p, 1, 0);
|
||||
}
|
||||
|
||||
/* Parse the input line into tokens.
|
||||
*/
|
||||
while( zLine[h] && nArg<ArraySize(azArg) ){
|
||||
@@ -4560,14 +4397,12 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
if( c=='e' && strncmp(azArg[0], "eqp", n)==0 ){
|
||||
if( nArg==2 ){
|
||||
if( strcmp(azArg[1],"full")==0 ){
|
||||
p->autoEQP = AUTOEQP_full;
|
||||
}else if( strcmp(azArg[1],"trigger")==0 ){
|
||||
p->autoEQP = AUTOEQP_trigger;
|
||||
p->autoEQP = 2;
|
||||
}else{
|
||||
p->autoEQP = booleanValue(azArg[1]);
|
||||
}
|
||||
}else{
|
||||
raw_printf(stderr, "Usage: .eqp off|on|trigger|full\n");
|
||||
raw_printf(stderr, "Usage: .eqp on|off|full\n");
|
||||
rc = 1;
|
||||
}
|
||||
}else
|
||||
@@ -4601,11 +4436,6 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
}
|
||||
}else
|
||||
|
||||
if( c=='e' && strncmp(azArg[0], "expert", n)==0 ){
|
||||
open_db(p, 0);
|
||||
expertDotCommand(p, azArg, nArg);
|
||||
}else
|
||||
|
||||
if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
|
||||
ShellState data;
|
||||
char *zErrMsg = 0;
|
||||
@@ -5920,7 +5750,7 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
}else
|
||||
|
||||
if( c=='s' && strncmp(azArg[0], "show", n)==0 ){
|
||||
static const char *azBool[] = { "off", "on", "trigger", "full"};
|
||||
static const char *azBool[] = { "off", "on", "full", "unk" };
|
||||
int i;
|
||||
if( nArg!=1 ){
|
||||
raw_printf(stderr, "Usage: .show\n");
|
||||
@@ -6108,9 +5938,6 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
{ "localtime_fault", SQLITE_TESTCTRL_LOCALTIME_FAULT,"BOOLEAN" },
|
||||
{ "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT, "BOOLEAN" },
|
||||
{ "optimizations", SQLITE_TESTCTRL_OPTIMIZATIONS, "DISABLE-MASK" },
|
||||
#ifdef YYCOVERAGE
|
||||
{ "parser_coverage", SQLITE_TESTCTRL_PARSER_COVERAGE, "" },
|
||||
#endif
|
||||
{ "pending_byte", SQLITE_TESTCTRL_PENDING_BYTE, "OFFSET " },
|
||||
{ "prng_reset", SQLITE_TESTCTRL_PRNG_RESET, "" },
|
||||
{ "prng_restore", SQLITE_TESTCTRL_PRNG_RESTORE, "" },
|
||||
@@ -6236,14 +6063,6 @@ static int do_meta_command(char *zLine, ShellState *p){
|
||||
isOk = 3;
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef YYCOVERAGE
|
||||
case SQLITE_TESTCTRL_PARSER_COVERAGE:
|
||||
if( nArg==2 ){
|
||||
sqlite3_test_control(testctrl, p->out);
|
||||
isOk = 3;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if( isOk==0 && iCtrl>=0 ){
|
||||
@@ -7083,9 +6902,9 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
|
||||
}else if( strcmp(z,"-echo")==0 ){
|
||||
ShellSetFlag(&data, SHFLG_Echo);
|
||||
}else if( strcmp(z,"-eqp")==0 ){
|
||||
data.autoEQP = AUTOEQP_on;
|
||||
data.autoEQP = 1;
|
||||
}else if( strcmp(z,"-eqpfull")==0 ){
|
||||
data.autoEQP = AUTOEQP_full;
|
||||
data.autoEQP = 2;
|
||||
}else if( strcmp(z,"-stats")==0 ){
|
||||
data.statsOn = 1;
|
||||
}else if( strcmp(z,"-scanstats")==0 ){
|
||||
|
||||
+4
-32
@@ -470,8 +470,6 @@ int sqlite3_exec(
|
||||
** the most recent error can be obtained using
|
||||
** [sqlite3_extended_errcode()].
|
||||
*/
|
||||
#define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
|
||||
#define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
|
||||
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
|
||||
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
|
||||
#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
|
||||
@@ -517,7 +515,6 @@ int sqlite3_exec(
|
||||
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
|
||||
#define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8))
|
||||
#define SQLITE_READONLY_CANTINIT (SQLITE_READONLY | (5<<8))
|
||||
#define SQLITE_READONLY_DIRECTORY (SQLITE_READONLY | (6<<8))
|
||||
#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
|
||||
#define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8))
|
||||
#define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8))
|
||||
@@ -2060,6 +2057,7 @@ struct sqlite3_mem_methods {
|
||||
** into which is written 0 or 1 to indicate whether checkpoints-on-close
|
||||
** have been disabled - 0 if they are not disabled, 1 if they are.
|
||||
** </dd>
|
||||
**
|
||||
** <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
|
||||
** <dd>^(The SQLITE_DBCONFIG_ENABLE_QPSG option activates or deactivates
|
||||
** the [query planner stability guarantee] (QPSG). When the QPSG is active,
|
||||
@@ -2070,16 +2068,7 @@ struct sqlite3_mem_methods {
|
||||
** the QPSG active, SQLite will always use the same query plan in the field as
|
||||
** was used during testing in the lab.
|
||||
** </dd>
|
||||
** <dt>SQLITE_DBCONFIG_TRIGGER_EQP</dt>
|
||||
** <dd> By default, the output of EXPLAIN QUERY PLAN commands does not
|
||||
** include output for any operations performed by trigger programs. This
|
||||
** option is used to set or clear (the default) a flag that governs this
|
||||
** behavior. The first parameter passed to this operation is an integer -
|
||||
** non-zero to enable output for trigger programs, or zero to disable it.
|
||||
** The second parameter is a pointer to an integer into which is written
|
||||
** 0 or 1 to indicate whether output-for-triggers has been disabled - 0 if
|
||||
** it is not disabled, 1 if it is.
|
||||
** </dd>
|
||||
**
|
||||
** </dl>
|
||||
*/
|
||||
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
|
||||
@@ -2090,8 +2079,7 @@ struct sqlite3_mem_methods {
|
||||
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
|
||||
#define SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE 1006 /* int int* */
|
||||
#define SQLITE_DBCONFIG_ENABLE_QPSG 1007 /* int int* */
|
||||
#define SQLITE_DBCONFIG_TRIGGER_EQP 1008 /* int int* */
|
||||
#define SQLITE_DBCONFIG_MAX 1008 /* Largest DBCONFIG */
|
||||
|
||||
|
||||
/*
|
||||
** CAPI3REF: Enable Or Disable Extended Result Codes
|
||||
@@ -7042,8 +7030,7 @@ int sqlite3_test_control(int op, ...);
|
||||
#define SQLITE_TESTCTRL_ISINIT 23
|
||||
#define SQLITE_TESTCTRL_SORTER_MMAP 24
|
||||
#define SQLITE_TESTCTRL_IMPOSTER 25
|
||||
#define SQLITE_TESTCTRL_PARSER_COVERAGE 26
|
||||
#define SQLITE_TESTCTRL_LAST 26 /* Largest TESTCTRL */
|
||||
#define SQLITE_TESTCTRL_LAST 25
|
||||
|
||||
/*
|
||||
** CAPI3REF: SQLite Runtime Status
|
||||
@@ -8297,21 +8284,6 @@ int sqlite3_vtab_config(sqlite3*, int op, ...);
|
||||
*/
|
||||
int sqlite3_vtab_on_conflict(sqlite3 *);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Determine The Collation For a Virtual Table Constraint
|
||||
**
|
||||
** This function may only be called from within a call to the [xBestIndex]
|
||||
** method of a [virtual table implementation].
|
||||
**
|
||||
** The first argument must be the sqlite3_index_info object that is the
|
||||
** first parameter to the xBestIndex() method. The second argument must be
|
||||
** an index into the aConstraint[] array belonging to the sqlite3_index_info
|
||||
** structure passed to xBestIndex. This function returns a pointer to a buffer
|
||||
** containing the name of the collation sequence for the corresponding
|
||||
** constraint.
|
||||
*/
|
||||
SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Conflict resolution modes
|
||||
** KEYWORDS: {conflict resolution mode}
|
||||
|
||||
+21
-27
@@ -1063,6 +1063,7 @@ typedef struct Db Db;
|
||||
typedef struct Schema Schema;
|
||||
typedef struct Expr Expr;
|
||||
typedef struct ExprList ExprList;
|
||||
typedef struct ExprSpan ExprSpan;
|
||||
typedef struct FKey FKey;
|
||||
typedef struct FuncDestructor FuncDestructor;
|
||||
typedef struct FuncDef FuncDef;
|
||||
@@ -1419,7 +1420,7 @@ struct sqlite3 {
|
||||
Hash aModule; /* populated by sqlite3_create_module() */
|
||||
VtabCtx *pVtabCtx; /* Context for active vtab connect/create */
|
||||
VTable **aVTrans; /* Virtual tables with open transactions */
|
||||
VTable *pDisconnect; /* Disconnect these in next sqlite3_prepare() */
|
||||
VTable *pDisconnect; /* Disconnect these in next sqlite3_prepare() */
|
||||
#endif
|
||||
Hash aFunc; /* Hash table of connection functions */
|
||||
Hash aCollSeq; /* All collating sequences */
|
||||
@@ -1494,9 +1495,7 @@ struct sqlite3 {
|
||||
#define SQLITE_QueryOnly 0x00100000 /* Disable database changes */
|
||||
#define SQLITE_CellSizeCk 0x00200000 /* Check btree cell sizes on load */
|
||||
#define SQLITE_Fts3Tokenizer 0x00400000 /* Enable fts3_tokenizer(2) */
|
||||
#define SQLITE_EnableQPSG 0x00800000 /* Query Planner Stability Guarantee*/
|
||||
#define SQLITE_TriggerEQP 0x01000000 /* Show trigger EXPLAIN QUERY PLAN */
|
||||
|
||||
#define SQLITE_EnableQPSG 0x00800000 /* Query Planner Stability Guarantee */
|
||||
/* Flags used only if debugging */
|
||||
#ifdef SQLITE_DEBUG
|
||||
#define SQLITE_SqlTrace 0x08000000 /* Debug print SQL as it executes */
|
||||
@@ -1629,7 +1628,6 @@ struct FuncDestructor {
|
||||
#define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
|
||||
** single query - might change over time */
|
||||
#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
|
||||
#define SQLITE_FUNC_OFFSET 0x8000 /* Built-in sqlite_offset() function */
|
||||
|
||||
/*
|
||||
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
|
||||
@@ -2174,7 +2172,6 @@ struct Index {
|
||||
unsigned isCovering:1; /* True if this is a covering index */
|
||||
unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
|
||||
unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
|
||||
unsigned bNoQuery:1; /* Do not use this index to optimize queries */
|
||||
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
|
||||
int nSample; /* Number of elements in aSample[] */
|
||||
int nSampleCol; /* Size of IndexSample.anEq[] and so on */
|
||||
@@ -2504,6 +2501,17 @@ struct ExprList {
|
||||
} a[1]; /* One slot for each expression in the list */
|
||||
};
|
||||
|
||||
/*
|
||||
** An instance of this structure is used by the parser to record both
|
||||
** the parse tree for an expression and the span of input text for an
|
||||
** expression.
|
||||
*/
|
||||
struct ExprSpan {
|
||||
Expr *pExpr; /* The expression parse tree */
|
||||
const char *zStart; /* First character of input text */
|
||||
const char *zEnd; /* One character past the end of input text */
|
||||
};
|
||||
|
||||
/*
|
||||
** An instance of this structure can hold a simple list of identifiers,
|
||||
** such as the list "a,b,c" in the following statements:
|
||||
@@ -2976,7 +2984,7 @@ struct Parse {
|
||||
int nMem; /* Number of memory cells used so far */
|
||||
int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
|
||||
int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */
|
||||
int iSelfTab; /* Table associated with an index on expr, or negative
|
||||
int iSelfTab; /* Table for associated with an index on expr, or negative
|
||||
** of the base register during check-constraint eval */
|
||||
int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */
|
||||
int iCacheCnt; /* Counter used to generate aColCache[].lru values */
|
||||
@@ -3204,7 +3212,6 @@ struct TriggerStep {
|
||||
Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */
|
||||
ExprList *pExprList; /* SET clause for UPDATE. */
|
||||
IdList *pIdList; /* Column names for INSERT */
|
||||
char *zSpan; /* Original SQL text of this command */
|
||||
TriggerStep *pNext; /* Next in the link-list */
|
||||
TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */
|
||||
};
|
||||
@@ -3515,7 +3522,6 @@ void *sqlite3DbMallocRaw(sqlite3*, u64);
|
||||
void *sqlite3DbMallocRawNN(sqlite3*, u64);
|
||||
char *sqlite3DbStrDup(sqlite3*,const char*);
|
||||
char *sqlite3DbStrNDup(sqlite3*,const char*, u64);
|
||||
char *sqlite3DbSpanDup(sqlite3*,const char*,const char*);
|
||||
void *sqlite3Realloc(void*, u64);
|
||||
void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64);
|
||||
void *sqlite3DbRealloc(sqlite3 *, void *, u64);
|
||||
@@ -3584,12 +3590,6 @@ int sqlite3LookasideUsed(sqlite3*,int*);
|
||||
sqlite3_mutex *sqlite3Pcache1Mutex(void);
|
||||
sqlite3_mutex *sqlite3MallocMutex(void);
|
||||
|
||||
#if defined(SQLITE_ENABLE_MULTITHREADED_CHECKS) && !defined(SQLITE_MUTEX_OMIT)
|
||||
void sqlite3MutexWarnOnContention(sqlite3_mutex*);
|
||||
#else
|
||||
# define sqlite3MutexWarnOnContention(x)
|
||||
#endif
|
||||
|
||||
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||
int sqlite3IsNaN(double);
|
||||
#else
|
||||
@@ -3654,7 +3654,7 @@ ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
|
||||
ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
|
||||
void sqlite3ExprListSetSortOrder(ExprList*,int);
|
||||
void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
|
||||
void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
|
||||
void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);
|
||||
void sqlite3ExprListDelete(sqlite3*, ExprList*);
|
||||
u32 sqlite3ExprListFlags(const ExprList*);
|
||||
int sqlite3Init(sqlite3*, char**);
|
||||
@@ -3684,7 +3684,7 @@ void sqlite3AddColumn(Parse*,Token*,Token*);
|
||||
void sqlite3AddNotNull(Parse*, int);
|
||||
void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
|
||||
void sqlite3AddCheckConstraint(Parse*, Expr*);
|
||||
void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);
|
||||
void sqlite3AddDefaultValue(Parse*,ExprSpan*);
|
||||
void sqlite3AddCollateType(Parse*, Token*);
|
||||
void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
|
||||
int sqlite3ParseUri(const char*,const char*,unsigned int*,
|
||||
@@ -3905,14 +3905,11 @@ void sqlite3MaterializeView(Parse*, Table*, Expr*, ExprList*,Expr*,int);
|
||||
void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int);
|
||||
void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*);
|
||||
void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*);
|
||||
TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*,
|
||||
const char*,const char*);
|
||||
TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);
|
||||
TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*,
|
||||
Select*,u8,const char*,const char*);
|
||||
TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8,
|
||||
const char*,const char*);
|
||||
TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*,
|
||||
const char*,const char*);
|
||||
Select*,u8);
|
||||
TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8);
|
||||
TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*);
|
||||
void sqlite3DeleteTrigger(sqlite3*, Trigger*);
|
||||
void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*);
|
||||
u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int);
|
||||
@@ -4342,9 +4339,6 @@ void sqlite3Put4byte(u8*, u32);
|
||||
#ifdef SQLITE_DEBUG
|
||||
void sqlite3ParserTrace(FILE*, char *);
|
||||
#endif
|
||||
#if defined(YYCOVERAGE)
|
||||
int sqlite3ParserCoverage(FILE*);
|
||||
#endif
|
||||
|
||||
/*
|
||||
** If the SQLITE_ENABLE IOTRACE exists then the global variable
|
||||
|
||||
@@ -160,12 +160,6 @@ static void set_options(Tcl_Interp *interp){
|
||||
Tcl_SetVar2(interp, "sqlite_options", "mem5", "0", TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
|
||||
Tcl_SetVar2(interp, "sqlite_options", "offset_sql_func","1",TCL_GLOBAL_ONLY);
|
||||
#else
|
||||
Tcl_SetVar2(interp, "sqlite_options", "offset_sql_func","0",TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
|
||||
Tcl_SetVar2(interp, "sqlite_options", "preupdate", "1", TCL_GLOBAL_ONLY);
|
||||
#else
|
||||
@@ -435,12 +429,6 @@ static void set_options(Tcl_Interp *interp){
|
||||
Tcl_SetVar2(interp, "sqlite_options", "icu", "0", TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_ENABLE_ICU_COLLATIONS
|
||||
Tcl_SetVar2(interp, "sqlite_options", "icu_collations", "1", TCL_GLOBAL_ONLY);
|
||||
#else
|
||||
Tcl_SetVar2(interp, "sqlite_options", "icu_collations", "0", TCL_GLOBAL_ONLY);
|
||||
#endif
|
||||
|
||||
#ifdef SQLITE_OMIT_INCRBLOB
|
||||
Tcl_SetVar2(interp, "sqlite_options", "incrblob", "0", TCL_GLOBAL_ONLY);
|
||||
#else
|
||||
|
||||
@@ -104,8 +104,6 @@ const char *sqlite3TestInit(Tcl_Interp *interp){
|
||||
#ifdef SQLITE_ENABLE_ZIPVFS
|
||||
extern int Zipvfs_Init(Tcl_Interp*);
|
||||
#endif
|
||||
extern int TestExpert_Init(Tcl_Interp*);
|
||||
|
||||
Tcl_CmdInfo cmdInfo;
|
||||
|
||||
/* Since the primary use case for this binary is testing of SQLite,
|
||||
@@ -168,7 +166,6 @@ const char *sqlite3TestInit(Tcl_Interp *interp){
|
||||
#if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4)
|
||||
Sqlitetestfts3_Init(interp);
|
||||
#endif
|
||||
TestExpert_Init(interp);
|
||||
|
||||
Tcl_CreateObjCommand(
|
||||
interp, "load_testfixture_extensions", load_testfixture_extensions,0,0
|
||||
|
||||
+2
-10
@@ -507,20 +507,12 @@ void sqlite3TreeViewBareExprList(
|
||||
sqlite3TreeViewLine(pView, "%s", zLabel);
|
||||
for(i=0; i<pList->nExpr; i++){
|
||||
int j = pList->a[i].u.x.iOrderByCol;
|
||||
char *zName = pList->a[i].zName;
|
||||
if( j || zName ){
|
||||
sqlite3TreeViewPush(pView, 0);
|
||||
}
|
||||
if( zName ){
|
||||
sqlite3TreeViewLine(pView, "AS %s", zName);
|
||||
}
|
||||
if( j ){
|
||||
sqlite3TreeViewPush(pView, 0);
|
||||
sqlite3TreeViewLine(pView, "iOrderByCol=%d", j);
|
||||
}
|
||||
sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1);
|
||||
if( j || zName ){
|
||||
sqlite3TreeViewPop(pView);
|
||||
}
|
||||
if( j ) sqlite3TreeViewPop(pView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-49
@@ -25,7 +25,6 @@ void sqlite3DeleteTriggerStep(sqlite3 *db, TriggerStep *pTriggerStep){
|
||||
sqlite3ExprListDelete(db, pTmp->pExprList);
|
||||
sqlite3SelectDelete(db, pTmp->pSelect);
|
||||
sqlite3IdListDelete(db, pTmp->pIdList);
|
||||
sqlite3DbFree(db, pTmp->zSpan);
|
||||
|
||||
sqlite3DbFree(db, pTmp);
|
||||
}
|
||||
@@ -340,17 +339,6 @@ triggerfinish_cleanup:
|
||||
sqlite3DeleteTriggerStep(db, pStepList);
|
||||
}
|
||||
|
||||
/*
|
||||
** Duplicate a range of text from an SQL statement, then convert all
|
||||
** whitespace characters into ordinary space characters.
|
||||
*/
|
||||
static char *triggerSpanDup(sqlite3 *db, const char *zStart, const char *zEnd){
|
||||
char *z = sqlite3DbSpanDup(db, zStart, zEnd);
|
||||
int i;
|
||||
if( z ) for(i=0; z[i]; i++) if( sqlite3Isspace(z[i]) ) z[i] = ' ';
|
||||
return z;
|
||||
}
|
||||
|
||||
/*
|
||||
** Turn a SELECT statement (that the pSelect parameter points to) into
|
||||
** a trigger step. Return a pointer to a TriggerStep structure.
|
||||
@@ -358,12 +346,7 @@ static char *triggerSpanDup(sqlite3 *db, const char *zStart, const char *zEnd){
|
||||
** The parser calls this routine when it finds a SELECT statement in
|
||||
** body of a TRIGGER.
|
||||
*/
|
||||
TriggerStep *sqlite3TriggerSelectStep(
|
||||
sqlite3 *db, /* Database connection */
|
||||
Select *pSelect, /* The SELECT statement */
|
||||
const char *zStart, /* Start of SQL text */
|
||||
const char *zEnd /* End of SQL text */
|
||||
){
|
||||
TriggerStep *sqlite3TriggerSelectStep(sqlite3 *db, Select *pSelect){
|
||||
TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep));
|
||||
if( pTriggerStep==0 ) {
|
||||
sqlite3SelectDelete(db, pSelect);
|
||||
@@ -372,7 +355,6 @@ TriggerStep *sqlite3TriggerSelectStep(
|
||||
pTriggerStep->op = TK_SELECT;
|
||||
pTriggerStep->pSelect = pSelect;
|
||||
pTriggerStep->orconf = OE_Default;
|
||||
pTriggerStep->zSpan = triggerSpanDup(db, zStart, zEnd);
|
||||
return pTriggerStep;
|
||||
}
|
||||
|
||||
@@ -385,9 +367,7 @@ TriggerStep *sqlite3TriggerSelectStep(
|
||||
static TriggerStep *triggerStepAllocate(
|
||||
sqlite3 *db, /* Database connection */
|
||||
u8 op, /* Trigger opcode */
|
||||
Token *pName, /* The target name */
|
||||
const char *zStart, /* Start of SQL text */
|
||||
const char *zEnd /* End of SQL text */
|
||||
Token *pName /* The target name */
|
||||
){
|
||||
TriggerStep *pTriggerStep;
|
||||
|
||||
@@ -398,7 +378,6 @@ static TriggerStep *triggerStepAllocate(
|
||||
sqlite3Dequote(z);
|
||||
pTriggerStep->zTarget = z;
|
||||
pTriggerStep->op = op;
|
||||
pTriggerStep->zSpan = triggerSpanDup(db, zStart, zEnd);
|
||||
}
|
||||
return pTriggerStep;
|
||||
}
|
||||
@@ -415,15 +394,13 @@ TriggerStep *sqlite3TriggerInsertStep(
|
||||
Token *pTableName, /* Name of the table into which we insert */
|
||||
IdList *pColumn, /* List of columns in pTableName to insert into */
|
||||
Select *pSelect, /* A SELECT statement that supplies values */
|
||||
u8 orconf, /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
|
||||
const char *zStart, /* Start of SQL text */
|
||||
const char *zEnd /* End of SQL text */
|
||||
u8 orconf /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */
|
||||
){
|
||||
TriggerStep *pTriggerStep;
|
||||
|
||||
assert(pSelect != 0 || db->mallocFailed);
|
||||
|
||||
pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName, zStart, zEnd);
|
||||
pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName);
|
||||
if( pTriggerStep ){
|
||||
pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
|
||||
pTriggerStep->pIdList = pColumn;
|
||||
@@ -446,13 +423,11 @@ TriggerStep *sqlite3TriggerUpdateStep(
|
||||
Token *pTableName, /* Name of the table to be updated */
|
||||
ExprList *pEList, /* The SET clause: list of column and new values */
|
||||
Expr *pWhere, /* The WHERE clause */
|
||||
u8 orconf, /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */
|
||||
const char *zStart, /* Start of SQL text */
|
||||
const char *zEnd /* End of SQL text */
|
||||
u8 orconf /* The conflict algorithm. (OE_Abort, OE_Ignore, etc) */
|
||||
){
|
||||
TriggerStep *pTriggerStep;
|
||||
|
||||
pTriggerStep = triggerStepAllocate(db, TK_UPDATE, pTableName, zStart, zEnd);
|
||||
pTriggerStep = triggerStepAllocate(db, TK_UPDATE, pTableName);
|
||||
if( pTriggerStep ){
|
||||
pTriggerStep->pExprList = sqlite3ExprListDup(db, pEList, EXPRDUP_REDUCE);
|
||||
pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
|
||||
@@ -471,13 +446,11 @@ TriggerStep *sqlite3TriggerUpdateStep(
|
||||
TriggerStep *sqlite3TriggerDeleteStep(
|
||||
sqlite3 *db, /* Database connection */
|
||||
Token *pTableName, /* The table from which rows are deleted */
|
||||
Expr *pWhere, /* The WHERE clause */
|
||||
const char *zStart, /* Start of SQL text */
|
||||
const char *zEnd /* End of SQL text */
|
||||
Expr *pWhere /* The WHERE clause */
|
||||
){
|
||||
TriggerStep *pTriggerStep;
|
||||
|
||||
pTriggerStep = triggerStepAllocate(db, TK_DELETE, pTableName, zStart, zEnd);
|
||||
pTriggerStep = triggerStepAllocate(db, TK_DELETE, pTableName);
|
||||
if( pTriggerStep ){
|
||||
pTriggerStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
|
||||
pTriggerStep->orconf = OE_Default;
|
||||
@@ -732,14 +705,6 @@ static int codeTriggerProgram(
|
||||
pParse->eOrconf = (orconf==OE_Default)?pStep->orconf:(u8)orconf;
|
||||
assert( pParse->okConstFactor==0 );
|
||||
|
||||
#ifndef SQLITE_OMIT_TRACE
|
||||
if( pStep->zSpan ){
|
||||
sqlite3VdbeAddOp4(v, OP_Trace, 0x7fffffff, 1, 0,
|
||||
sqlite3MPrintf(db, "-- %s", pStep->zSpan),
|
||||
P4_DYNAMIC);
|
||||
}
|
||||
#endif
|
||||
|
||||
switch( pStep->op ){
|
||||
case TK_UPDATE: {
|
||||
sqlite3Update(pParse,
|
||||
@@ -880,11 +845,9 @@ static TriggerPrg *codeRowTrigger(
|
||||
pTab->zName
|
||||
));
|
||||
#ifndef SQLITE_OMIT_TRACE
|
||||
if( pTrigger->zName ){
|
||||
sqlite3VdbeChangeP4(v, -1,
|
||||
sqlite3MPrintf(db, "-- TRIGGER %s", pTrigger->zName), P4_DYNAMIC
|
||||
);
|
||||
}
|
||||
sqlite3VdbeChangeP4(v, -1,
|
||||
sqlite3MPrintf(db, "-- TRIGGER %s", pTrigger->zName), P4_DYNAMIC
|
||||
);
|
||||
#endif
|
||||
|
||||
/* If one was specified, code the WHEN clause. If it evaluates to false
|
||||
@@ -912,7 +875,7 @@ static TriggerPrg *codeRowTrigger(
|
||||
VdbeComment((v, "End: %s.%s", pTrigger->zName, onErrorText(orconf)));
|
||||
|
||||
transferParseError(pParse, pSubParse);
|
||||
if( db->mallocFailed==0 && pParse->nErr==0 ){
|
||||
if( db->mallocFailed==0 ){
|
||||
pProgram->aOp = sqlite3VdbeTakeOpArray(v, &pProgram->nOp, &pTop->nMaxArg);
|
||||
}
|
||||
pProgram->nMem = pSubParse->nMem;
|
||||
|
||||
+6
-20
@@ -320,24 +320,6 @@ int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
|
||||
return N<0 ? 0 : UpperToLower[*a] - UpperToLower[*b];
|
||||
}
|
||||
|
||||
/*
|
||||
** Compute 10 to the E-th power. Examples: E==1 results in 10.
|
||||
** E==2 results in 100. E==50 results in 1.0e50.
|
||||
**
|
||||
** This routine only works for values of E between 1 and 341.
|
||||
*/
|
||||
static LONGDOUBLE_TYPE sqlite3Pow10(int E){
|
||||
LONGDOUBLE_TYPE x = 10.0;
|
||||
LONGDOUBLE_TYPE r = 1.0;
|
||||
while(1){
|
||||
if( E & 1 ) r *= x;
|
||||
E >>= 1;
|
||||
if( E==0 ) break;
|
||||
x *= x;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
** The string z[] is an text representation of a real number.
|
||||
** Convert this string to a double and write it into *pResult.
|
||||
@@ -493,10 +475,11 @@ do_atof_calc:
|
||||
if( e==0 ){ /*OPTIMIZATION-IF-TRUE*/
|
||||
result = (double)s;
|
||||
}else{
|
||||
LONGDOUBLE_TYPE scale = 1.0;
|
||||
/* attempt to handle extremely small/large numbers better */
|
||||
if( e>307 ){ /*OPTIMIZATION-IF-TRUE*/
|
||||
if( e<342 ){ /*OPTIMIZATION-IF-TRUE*/
|
||||
LONGDOUBLE_TYPE scale = sqlite3Pow10(e-308);
|
||||
while( e%308 ) { scale *= 1.0e+1; e -= 1; }
|
||||
if( esign<0 ){
|
||||
result = s / scale;
|
||||
result /= 1.0e+308;
|
||||
@@ -516,7 +499,10 @@ do_atof_calc:
|
||||
}
|
||||
}
|
||||
}else{
|
||||
LONGDOUBLE_TYPE scale = sqlite3Pow10(e);
|
||||
/* 1.0e+22 is the largest power of 10 than can be
|
||||
** represented exactly. */
|
||||
while( e%22 ) { scale *= 1.0e+1; e -= 1; }
|
||||
while( e>0 ) { scale *= 1.0e+22; e -= 22; }
|
||||
if( esign<0 ){
|
||||
result = s / scale;
|
||||
}else{
|
||||
|
||||
+2
-42
@@ -2349,36 +2349,6 @@ case OP_IfNullRow: { /* jump */
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
|
||||
/* Opcode: Offset P1 P2 P3 * *
|
||||
** Synopsis: r[P3] = sqlite_offset(P1)
|
||||
**
|
||||
** Store in register r[P3] the byte offset into the database file that is the
|
||||
** start of the payload for the record at which that cursor P1 is currently
|
||||
** pointing.
|
||||
**
|
||||
** P2 is the column number for the argument to the sqlite_offset() function.
|
||||
** This opcode does not use P2 itself, but the P2 value is used by the
|
||||
** code generator. The P1, P2, and P3 operands to this opcode are the
|
||||
** as as for OP_Column.
|
||||
**
|
||||
** This opcode is only available if SQLite is compiled with the
|
||||
** -DSQLITE_ENABLE_OFFSET_SQL_FUNC option.
|
||||
*/
|
||||
case OP_Offset: { /* out3 */
|
||||
VdbeCursor *pC; /* The VDBE cursor */
|
||||
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
|
||||
pC = p->apCsr[pOp->p1];
|
||||
pOut = &p->aMem[pOp->p3];
|
||||
if( pC==0 || pC->eCurType!=CURTYPE_BTREE ){
|
||||
sqlite3VdbeMemSetNull(pOut);
|
||||
}else{
|
||||
sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* SQLITE_ENABLE_OFFSET_SQL_FUNC */
|
||||
|
||||
/* Opcode: Column P1 P2 P3 P4 P5
|
||||
** Synopsis: r[P3]=PX
|
||||
**
|
||||
@@ -7046,13 +7016,7 @@ case OP_Function: {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: Trace P1 P2 * P4 *
|
||||
**
|
||||
** Write P4 on the statement trace output if statement tracing is
|
||||
** enabled.
|
||||
**
|
||||
** Operand P1 must be 0x7fffffff and P2 must positive.
|
||||
*/
|
||||
|
||||
/* Opcode: Init P1 P2 P3 P4 *
|
||||
** Synopsis: Start at P2
|
||||
**
|
||||
@@ -7071,7 +7035,6 @@ case OP_Function: {
|
||||
** If P3 is not zero, then it is an address to jump to if an SQLITE_CORRUPT
|
||||
** error is encountered.
|
||||
*/
|
||||
case OP_Trace:
|
||||
case OP_Init: { /* jump */
|
||||
char *zTrace;
|
||||
int i;
|
||||
@@ -7086,9 +7049,7 @@ case OP_Init: { /* jump */
|
||||
** sqlite3_expanded_sql(P) otherwise.
|
||||
*/
|
||||
assert( pOp->p4.z==0 || strncmp(pOp->p4.z, "-" "- ", 3)==0 );
|
||||
|
||||
/* OP_Init is always instruction 0 */
|
||||
assert( pOp==p->aOp || pOp->opcode==OP_Trace );
|
||||
assert( pOp==p->aOp ); /* Always instruction 0 */
|
||||
|
||||
#ifndef SQLITE_OMIT_TRACE
|
||||
if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0
|
||||
@@ -7131,7 +7092,6 @@ case OP_Init: { /* jump */
|
||||
#endif /* SQLITE_OMIT_TRACE */
|
||||
assert( pOp->p2>0 );
|
||||
if( pOp->p1>=sqlite3GlobalConfig.iOnceResetThreshold ){
|
||||
if( pOp->opcode==OP_Trace ) break;
|
||||
for(i=1; i<p->nOp; i++){
|
||||
if( p->aOp[i].opcode==OP_Once ) p->aOp[i].p1 = 0;
|
||||
}
|
||||
|
||||
+86
-98
@@ -1639,8 +1639,6 @@ int sqlite3VdbeList(
|
||||
int i; /* Loop counter */
|
||||
int rc = SQLITE_OK; /* Return code */
|
||||
Mem *pMem = &p->aMem[1]; /* First Mem of result set */
|
||||
int bListSubprogs = (p->explain==1 || (db->flags & SQLITE_TriggerEQP)!=0);
|
||||
Op *pOp = 0;
|
||||
|
||||
assert( p->explain );
|
||||
assert( p->magic==VDBE_MAGIC_RUN );
|
||||
@@ -1653,7 +1651,7 @@ int sqlite3VdbeList(
|
||||
releaseMemArray(pMem, 8);
|
||||
p->pResultSet = 0;
|
||||
|
||||
if( p->rc==SQLITE_NOMEM ){
|
||||
if( p->rc==SQLITE_NOMEM_BKPT ){
|
||||
/* This happens if a malloc() inside a call to sqlite3_column_text() or
|
||||
** sqlite3_column_text16() failed. */
|
||||
sqlite3OomFault(db);
|
||||
@@ -1668,7 +1666,7 @@ int sqlite3VdbeList(
|
||||
** encountered, but p->pc will eventually catch up to nRow.
|
||||
*/
|
||||
nRow = p->nOp;
|
||||
if( bListSubprogs ){
|
||||
if( p->explain==1 ){
|
||||
/* The first 8 memory cells are used for the result set. So we will
|
||||
** commandeer the 9th cell to use as storage for an array of pointers
|
||||
** to trigger subprograms. The VDBE is guaranteed to have at least 9
|
||||
@@ -1688,11 +1686,17 @@ int sqlite3VdbeList(
|
||||
|
||||
do{
|
||||
i = p->pc++;
|
||||
if( i>=nRow ){
|
||||
p->rc = SQLITE_OK;
|
||||
rc = SQLITE_DONE;
|
||||
break;
|
||||
}
|
||||
}while( i<nRow && p->explain==2 && p->aOp[i].opcode!=OP_Explain );
|
||||
if( i>=nRow ){
|
||||
p->rc = SQLITE_OK;
|
||||
rc = SQLITE_DONE;
|
||||
}else if( db->u1.isInterrupted ){
|
||||
p->rc = SQLITE_INTERRUPT;
|
||||
rc = SQLITE_ERROR;
|
||||
sqlite3VdbeError(p, sqlite3ErrStr(p->rc));
|
||||
}else{
|
||||
char *zP4;
|
||||
Op *pOp;
|
||||
if( i<p->nOp ){
|
||||
/* The output line number is small enough that we are still in the
|
||||
** main program. */
|
||||
@@ -1707,110 +1711,94 @@ int sqlite3VdbeList(
|
||||
}
|
||||
pOp = &apSub[j]->aOp[i];
|
||||
}
|
||||
if( p->explain==1 ){
|
||||
pMem->flags = MEM_Int;
|
||||
pMem->u.i = i; /* Program counter */
|
||||
pMem++;
|
||||
|
||||
pMem->flags = MEM_Static|MEM_Str|MEM_Term;
|
||||
pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */
|
||||
assert( pMem->z!=0 );
|
||||
pMem->n = sqlite3Strlen30(pMem->z);
|
||||
pMem->enc = SQLITE_UTF8;
|
||||
pMem++;
|
||||
|
||||
/* When an OP_Program opcode is encounter (the only opcode that has
|
||||
** a P4_SUBPROGRAM argument), expand the size of the array of subprograms
|
||||
** kept in p->aMem[9].z to hold the new program - assuming this subprogram
|
||||
** has not already been seen.
|
||||
*/
|
||||
if( bListSubprogs && pOp->p4type==P4_SUBPROGRAM ){
|
||||
int nByte = (nSub+1)*sizeof(SubProgram*);
|
||||
int j;
|
||||
for(j=0; j<nSub; j++){
|
||||
if( apSub[j]==pOp->p4.pProgram ) break;
|
||||
}
|
||||
if( j==nSub ){
|
||||
p->rc = sqlite3VdbeMemGrow(pSub, nByte, nSub!=0);
|
||||
if( p->rc!=SQLITE_OK ){
|
||||
rc = SQLITE_ERROR;
|
||||
break;
|
||||
/* When an OP_Program opcode is encounter (the only opcode that has
|
||||
** a P4_SUBPROGRAM argument), expand the size of the array of subprograms
|
||||
** kept in p->aMem[9].z to hold the new program - assuming this subprogram
|
||||
** has not already been seen.
|
||||
*/
|
||||
if( pOp->p4type==P4_SUBPROGRAM ){
|
||||
int nByte = (nSub+1)*sizeof(SubProgram*);
|
||||
int j;
|
||||
for(j=0; j<nSub; j++){
|
||||
if( apSub[j]==pOp->p4.pProgram ) break;
|
||||
}
|
||||
if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, nSub!=0) ){
|
||||
apSub = (SubProgram **)pSub->z;
|
||||
apSub[nSub++] = pOp->p4.pProgram;
|
||||
pSub->flags |= MEM_Blob;
|
||||
pSub->n = nSub*sizeof(SubProgram*);
|
||||
}
|
||||
apSub = (SubProgram **)pSub->z;
|
||||
apSub[nSub++] = pOp->p4.pProgram;
|
||||
pSub->flags |= MEM_Blob;
|
||||
pSub->n = nSub*sizeof(SubProgram*);
|
||||
nRow += pOp->p4.pProgram->nOp;
|
||||
}
|
||||
}
|
||||
}while( p->explain==2 && pOp->opcode!=OP_Explain );
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
if( db->u1.isInterrupted ){
|
||||
p->rc = SQLITE_INTERRUPT;
|
||||
rc = SQLITE_ERROR;
|
||||
sqlite3VdbeError(p, sqlite3ErrStr(p->rc));
|
||||
pMem->flags = MEM_Int;
|
||||
pMem->u.i = pOp->p1; /* P1 */
|
||||
pMem++;
|
||||
|
||||
pMem->flags = MEM_Int;
|
||||
pMem->u.i = pOp->p2; /* P2 */
|
||||
pMem++;
|
||||
|
||||
pMem->flags = MEM_Int;
|
||||
pMem->u.i = pOp->p3; /* P3 */
|
||||
pMem++;
|
||||
|
||||
if( sqlite3VdbeMemClearAndResize(pMem, 100) ){ /* P4 */
|
||||
assert( p->db->mallocFailed );
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
pMem->flags = MEM_Str|MEM_Term;
|
||||
zP4 = displayP4(pOp, pMem->z, pMem->szMalloc);
|
||||
if( zP4!=pMem->z ){
|
||||
pMem->n = 0;
|
||||
sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0);
|
||||
}else{
|
||||
char *zP4;
|
||||
if( p->explain==1 ){
|
||||
pMem->flags = MEM_Int;
|
||||
pMem->u.i = i; /* Program counter */
|
||||
pMem++;
|
||||
|
||||
pMem->flags = MEM_Static|MEM_Str|MEM_Term;
|
||||
pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */
|
||||
assert( pMem->z!=0 );
|
||||
pMem->n = sqlite3Strlen30(pMem->z);
|
||||
pMem->enc = SQLITE_UTF8;
|
||||
pMem++;
|
||||
}
|
||||
assert( pMem->z!=0 );
|
||||
pMem->n = sqlite3Strlen30(pMem->z);
|
||||
pMem->enc = SQLITE_UTF8;
|
||||
}
|
||||
pMem++;
|
||||
|
||||
pMem->flags = MEM_Int;
|
||||
pMem->u.i = pOp->p1; /* P1 */
|
||||
pMem++;
|
||||
|
||||
pMem->flags = MEM_Int;
|
||||
pMem->u.i = pOp->p2; /* P2 */
|
||||
pMem++;
|
||||
|
||||
pMem->flags = MEM_Int;
|
||||
pMem->u.i = pOp->p3; /* P3 */
|
||||
pMem++;
|
||||
|
||||
if( sqlite3VdbeMemClearAndResize(pMem, 100) ){ /* P4 */
|
||||
if( p->explain==1 ){
|
||||
if( sqlite3VdbeMemClearAndResize(pMem, 4) ){
|
||||
assert( p->db->mallocFailed );
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
pMem->flags = MEM_Str|MEM_Term;
|
||||
zP4 = displayP4(pOp, pMem->z, pMem->szMalloc);
|
||||
if( zP4!=pMem->z ){
|
||||
pMem->n = 0;
|
||||
sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0);
|
||||
}else{
|
||||
assert( pMem->z!=0 );
|
||||
pMem->n = sqlite3Strlen30(pMem->z);
|
||||
pMem->enc = SQLITE_UTF8;
|
||||
}
|
||||
pMem->n = 2;
|
||||
sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */
|
||||
pMem->enc = SQLITE_UTF8;
|
||||
pMem++;
|
||||
|
||||
if( p->explain==1 ){
|
||||
if( sqlite3VdbeMemClearAndResize(pMem, 4) ){
|
||||
assert( p->db->mallocFailed );
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
pMem->flags = MEM_Str|MEM_Term;
|
||||
pMem->n = 2;
|
||||
sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */
|
||||
pMem->enc = SQLITE_UTF8;
|
||||
pMem++;
|
||||
|
||||
|
||||
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
|
||||
if( sqlite3VdbeMemClearAndResize(pMem, 500) ){
|
||||
assert( p->db->mallocFailed );
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
pMem->flags = MEM_Str|MEM_Term;
|
||||
pMem->n = displayComment(pOp, zP4, pMem->z, 500);
|
||||
pMem->enc = SQLITE_UTF8;
|
||||
#else
|
||||
pMem->flags = MEM_Null; /* Comment */
|
||||
#endif
|
||||
if( sqlite3VdbeMemClearAndResize(pMem, 500) ){
|
||||
assert( p->db->mallocFailed );
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
|
||||
p->nResColumn = 8 - 4*(p->explain-1);
|
||||
p->pResultSet = &p->aMem[1];
|
||||
p->rc = SQLITE_OK;
|
||||
rc = SQLITE_ROW;
|
||||
pMem->flags = MEM_Str|MEM_Term;
|
||||
pMem->n = displayComment(pOp, zP4, pMem->z, 500);
|
||||
pMem->enc = SQLITE_UTF8;
|
||||
#else
|
||||
pMem->flags = MEM_Null; /* Comment */
|
||||
#endif
|
||||
}
|
||||
|
||||
p->nResColumn = 8 - 4*(p->explain-1);
|
||||
p->pResultSet = &p->aMem[1];
|
||||
p->rc = SQLITE_OK;
|
||||
rc = SQLITE_ROW;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
+1
-8
@@ -1321,11 +1321,7 @@ static int valueFromExpr(
|
||||
|
||||
assert( pExpr!=0 );
|
||||
while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft;
|
||||
#if defined(SQLITE_ENABLE_STAT3_OR_STAT4)
|
||||
if( op==TK_REGISTER ) op = pExpr->op2;
|
||||
#else
|
||||
if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
|
||||
#endif
|
||||
|
||||
/* Compressed expressions only appear when parsing the DEFAULT clause
|
||||
** on a table column definition, and hence only when pCtx==0. This
|
||||
@@ -1420,10 +1416,7 @@ static int valueFromExpr(
|
||||
return rc;
|
||||
|
||||
no_mem:
|
||||
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
|
||||
if( pCtx==0 || pCtx->pParse->nErr==0 )
|
||||
#endif
|
||||
sqlite3OomFault(db);
|
||||
sqlite3OomFault(db);
|
||||
sqlite3DbFree(db, zVal);
|
||||
assert( *ppVal==0 );
|
||||
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
|
||||
|
||||
@@ -2494,7 +2494,8 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
|
||||
pInfo = walCkptInfo(pWal);
|
||||
if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame
|
||||
#ifdef SQLITE_ENABLE_SNAPSHOT
|
||||
&& (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0)
|
||||
&& (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0
|
||||
|| 0==memcmp(&pWal->hdr, pWal->pSnapshot, sizeof(WalIndexHdr)))
|
||||
#endif
|
||||
){
|
||||
/* The WAL has been completely backfilled (or it is empty).
|
||||
|
||||
+7
-52
@@ -19,21 +19,6 @@
|
||||
#include "sqliteInt.h"
|
||||
#include "whereInt.h"
|
||||
|
||||
/*
|
||||
** Extra information appended to the end of sqlite3_index_info but not
|
||||
** visible to the xBestIndex function, at least not directly. The
|
||||
** sqlite3_vtab_collation() interface knows how to reach it, however.
|
||||
**
|
||||
** This object is not an API and can be changed from one release to the
|
||||
** next. As long as allocateIndexInfo() and sqlite3_vtab_collation()
|
||||
** agree on the structure, all will be well.
|
||||
*/
|
||||
typedef struct HiddenIndexInfo HiddenIndexInfo;
|
||||
struct HiddenIndexInfo {
|
||||
WhereClause *pWC; /* The Where clause being analyzed */
|
||||
Parse *pParse; /* The parsing context */
|
||||
};
|
||||
|
||||
/* Forward declaration of methods */
|
||||
static int whereLoopResize(sqlite3*, WhereLoop*, int);
|
||||
|
||||
@@ -856,11 +841,11 @@ end_auto_index_create:
|
||||
** by passing the pointer returned by this function to sqlite3_free().
|
||||
*/
|
||||
static sqlite3_index_info *allocateIndexInfo(
|
||||
Parse *pParse, /* The parsing context */
|
||||
WhereClause *pWC, /* The WHERE clause being analyzed */
|
||||
Parse *pParse,
|
||||
WhereClause *pWC,
|
||||
Bitmask mUnusable, /* Ignore terms with these prereqs */
|
||||
struct SrcList_item *pSrc, /* The FROM clause term that is the vtab */
|
||||
ExprList *pOrderBy, /* The ORDER BY clause */
|
||||
struct SrcList_item *pSrc,
|
||||
ExprList *pOrderBy,
|
||||
u16 *pmNoOmit /* Mask of terms not to omit */
|
||||
){
|
||||
int i, j;
|
||||
@@ -868,7 +853,6 @@ static sqlite3_index_info *allocateIndexInfo(
|
||||
struct sqlite3_index_constraint *pIdxCons;
|
||||
struct sqlite3_index_orderby *pIdxOrderBy;
|
||||
struct sqlite3_index_constraint_usage *pUsage;
|
||||
struct HiddenIndexInfo *pHidden;
|
||||
WhereTerm *pTerm;
|
||||
int nOrderBy;
|
||||
sqlite3_index_info *pIdxInfo;
|
||||
@@ -910,7 +894,7 @@ static sqlite3_index_info *allocateIndexInfo(
|
||||
*/
|
||||
pIdxInfo = sqlite3DbMallocZero(pParse->db, sizeof(*pIdxInfo)
|
||||
+ (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm
|
||||
+ sizeof(*pIdxOrderBy)*nOrderBy + sizeof(*pHidden) );
|
||||
+ sizeof(*pIdxOrderBy)*nOrderBy );
|
||||
if( pIdxInfo==0 ){
|
||||
sqlite3ErrorMsg(pParse, "out of memory");
|
||||
return 0;
|
||||
@@ -921,8 +905,7 @@ static sqlite3_index_info *allocateIndexInfo(
|
||||
** changing them. We have to do some funky casting in order to
|
||||
** initialize those fields.
|
||||
*/
|
||||
pHidden = (struct HiddenIndexInfo*)&pIdxInfo[1];
|
||||
pIdxCons = (struct sqlite3_index_constraint*)&pHidden[1];
|
||||
pIdxCons = (struct sqlite3_index_constraint*)&pIdxInfo[1];
|
||||
pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];
|
||||
pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];
|
||||
*(int*)&pIdxInfo->nConstraint = nTerm;
|
||||
@@ -932,8 +915,6 @@ static sqlite3_index_info *allocateIndexInfo(
|
||||
*(struct sqlite3_index_constraint_usage**)&pIdxInfo->aConstraintUsage =
|
||||
pUsage;
|
||||
|
||||
pHidden->pWC = pWC;
|
||||
pHidden->pParse = pParse;
|
||||
for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
|
||||
u16 op;
|
||||
if( pTerm->leftCursor != pSrc->iCursor ) continue;
|
||||
@@ -2898,7 +2879,6 @@ static int whereLoopAddBtree(
|
||||
testcase( pNew->iTab!=pSrc->iCursor ); /* See ticket [98d973b8f5] */
|
||||
continue; /* Partial index inappropriate for this query */
|
||||
}
|
||||
if( pProbe->bNoQuery ) continue;
|
||||
rSize = pProbe->aiRowLogEst[0];
|
||||
pNew->u.btree.nEq = 0;
|
||||
pNew->u.btree.nBtm = 0;
|
||||
@@ -3157,27 +3137,6 @@ static int whereLoopAddVirtualOne(
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** If this function is invoked from within an xBestIndex() callback, it
|
||||
** returns a pointer to a buffer containing the name of the collation
|
||||
** sequence associated with element iCons of the sqlite3_index_info.aConstraint
|
||||
** array. Or, if iCons is out of range or there is no active xBestIndex
|
||||
** call, return NULL.
|
||||
*/
|
||||
const char *sqlite3_vtab_collation(sqlite3_index_info *pIdxInfo, int iCons){
|
||||
HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
|
||||
const char *zRet = 0;
|
||||
if( iCons>=0 && iCons<pIdxInfo->nConstraint ){
|
||||
CollSeq *pC = 0;
|
||||
int iTerm = pIdxInfo->aConstraint[iCons].iTermOffset;
|
||||
Expr *pX = pHidden->pWC->a[iTerm].pExpr;
|
||||
if( pX->pLeft ){
|
||||
pC = sqlite3BinaryCompareCollSeq(pHidden->pParse, pX->pLeft, pX->pRight);
|
||||
}
|
||||
zRet = (pC ? pC->zName : "BINARY");
|
||||
}
|
||||
return zRet;
|
||||
}
|
||||
|
||||
/*
|
||||
** Add all WhereLoop objects for a table of the join identified by
|
||||
@@ -5146,11 +5105,7 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
|
||||
pOp = sqlite3VdbeGetOp(v, k);
|
||||
for(; k<last; k++, pOp++){
|
||||
if( pOp->p1!=pLevel->iTabCur ) continue;
|
||||
if( pOp->opcode==OP_Column
|
||||
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
|
||||
|| pOp->opcode==OP_Offset
|
||||
#endif
|
||||
){
|
||||
if( pOp->opcode==OP_Column ){
|
||||
int x = pOp->p2;
|
||||
assert( pIdx->pTable==pTab );
|
||||
if( !HasRowid(pTab) ){
|
||||
|
||||
+1
-2
@@ -128,7 +128,7 @@ int sqlite3WhereExplainOneScan(
|
||||
){
|
||||
int ret = 0;
|
||||
#if !defined(SQLITE_DEBUG) && !defined(SQLITE_ENABLE_STMT_SCANSTATUS)
|
||||
if( sqlite3ParseToplevel(pParse)->explain==2 )
|
||||
if( pParse->explain==2 )
|
||||
#endif
|
||||
{
|
||||
struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom];
|
||||
@@ -1690,7 +1690,6 @@ Bitmask sqlite3WhereCodeOneLoopStart(
|
||||
}
|
||||
}else if( bStopAtNull ){
|
||||
sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
|
||||
sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
|
||||
endEq = 0;
|
||||
nConstraint++;
|
||||
}
|
||||
|
||||
+1
-1
@@ -184,7 +184,7 @@ do_test capi2-3.5 {
|
||||
} {1 {(1) no such column: bogus} {;;x;}}
|
||||
do_test capi2-3.6 {
|
||||
set rc [catch {
|
||||
sqlite3_prepare $DB {select 5/0;} -1 TAIL
|
||||
sqlite3_prepare $DB {select 5/0} -1 TAIL
|
||||
} VM]
|
||||
lappend rc $TAIL
|
||||
} {0 {}}
|
||||
|
||||
@@ -378,46 +378,6 @@ do_test colname-9.210 {
|
||||
execsql2 {SELECT t1.a, v3.a AS n FROM t1 JOIN v3}
|
||||
} {a 1 n 3}
|
||||
|
||||
# 2017-12-23: Ticket https://www.sqlite.org/src/info/3b4450072511e621
|
||||
# Inconsistent column names in CREATE TABLE AS
|
||||
#
|
||||
# Verify that the names of columns in the created table of a CREATE TABLE AS
|
||||
# are the same as the names of result columns in the SELECT statement.
|
||||
#
|
||||
do_execsql_test colname-9.300 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP TABLE IF EXISTS t2;
|
||||
CREATE TABLE t1(aaa INT);
|
||||
INSERT INTO t1(aaa) VALUES(123);
|
||||
}
|
||||
do_test colname-9.310 {
|
||||
execsql2 {SELECT BBb FROM (SELECT aaa AS Bbb FROM t1)}
|
||||
} {Bbb 123}
|
||||
do_execsql_test colname-9.320 {
|
||||
CREATE TABLE t2 AS SELECT BBb FROM (SELECT aaa AS Bbb FROM t1);
|
||||
SELECT name FROM pragma_table_info('t2');
|
||||
} {Bbb}
|
||||
|
||||
# Issue detected by OSSFuzz on 2017-12-24 (Christmas Eve)
|
||||
# caused by check-in https://sqlite.org/src/info/6b2ff26c25
|
||||
#
|
||||
# Prior to being fixed, the following CREATE TABLE was dereferencing
|
||||
# a NULL pointer and segfaulting.
|
||||
#
|
||||
do_catchsql_test colname-9.400 {
|
||||
CREATE TABLE t4 AS SELECT #0;
|
||||
} {1 {near "#0": syntax error}}
|
||||
|
||||
# Issue detected by OSSFuzz on 2017-12-25 (Christmas Day)
|
||||
# also caused by check-in https://sqlite.org/src/info/6b2ff26c25
|
||||
#
|
||||
# Prior to being fixed, the following CREATE TABLE caused an
|
||||
# assertion fault.
|
||||
#
|
||||
do_catchsql_test colname-9.410 {
|
||||
CREATE TABLE t5 AS SELECT RAISE(abort,a);
|
||||
} {1 {RAISE() may only be used within a trigger-program}}
|
||||
|
||||
# Make sure the quotation marks get removed from the column names
|
||||
# when constructing a new table from an aggregate SELECT.
|
||||
# Email from Juergen Palm on 2017-07-11.
|
||||
|
||||
@@ -171,20 +171,6 @@ do_catchsql_test fkey1-5.2 {
|
||||
INSERT OR REPLACE INTO t11 VALUES (2, 3);
|
||||
} {1 {FOREIGN KEY constraint failed}}
|
||||
|
||||
# Make sure sqlite3_trace() output works with triggers used to implement
|
||||
# FK constraints
|
||||
#
|
||||
proc sqltrace {txt} {
|
||||
global traceoutput
|
||||
lappend traceoutput $txt
|
||||
}
|
||||
do_test fkey1-5.2.1 {
|
||||
unset -nocomplain traceoutput
|
||||
db trace sqltrace
|
||||
catch {db eval {INSERT OR REPLACE INTO t11 VALUES(2,3);}}
|
||||
set traceoutput
|
||||
} {{INSERT OR REPLACE INTO t11 VALUES(2,3);} {INSERT OR REPLACE INTO t11 VALUES(2,3);} {INSERT OR REPLACE INTO t11 VALUES(2,3);}}
|
||||
|
||||
# A similar test to the above.
|
||||
do_execsql_test fkey1-5.3 {
|
||||
CREATE TABLE Foo (
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
# 2017-12-16
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
#*************************************************************************
|
||||
#
|
||||
# Test cases for the sqlite_unsupported_offset() function.
|
||||
#
|
||||
# Some of the tests in this file depend on the exact placement of content
|
||||
# within b-tree pages. Such placement is at the implementations discretion,
|
||||
# and so it is possible for results to change from one release to the next.
|
||||
#
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
ifcapable !offset_sql_func {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
do_execsql_test func6-100 {
|
||||
PRAGMA page_size=4096;
|
||||
PRAGMA auto_vacuum=NONE;
|
||||
CREATE TABLE t1(a,b,c,d);
|
||||
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
|
||||
INSERT INTO t1(a,b,c,d) SELECT printf('abc%03x',x), x, 1000-x, NULL FROM c;
|
||||
CREATE INDEX t1a ON t1(a);
|
||||
CREATE INDEX t1bc ON t1(b,c);
|
||||
CREATE TABLE t2(x TEXT PRIMARY KEY, y) WITHOUT ROWID;
|
||||
INSERT INTO t2(x,y) SELECT a, b FROM t1;
|
||||
}
|
||||
do_execsql_test func6-110 {
|
||||
SELECT a, sqlite_unsupported_offset(d)/4096 + 1,
|
||||
sqlite_unsupported_offset(d)%4096 FROM t1
|
||||
ORDER BY rowid LIMIT 2;
|
||||
} {abc001 2 4084 abc002 2 4069}
|
||||
do_execsql_test func6-120 {
|
||||
SELECT a, typeof(sqlite_unsupported_offset(+a)) FROM t1
|
||||
ORDER BY rowid LIMIT 2;
|
||||
} {abc001 null abc002 null}
|
||||
do_execsql_test func6-130 {
|
||||
SELECT a, sqlite_unsupported_offset(a)/4096+1,
|
||||
sqlite_unsupported_offset(a)%4096
|
||||
FROM t1
|
||||
ORDER BY a LIMIT 2;
|
||||
} {abc001 3 4087 abc002 3 4076}
|
||||
do_execsql_test func6-140 {
|
||||
SELECT a, sqlite_unsupported_offset(d)/4096+1,
|
||||
sqlite_unsupported_offset(d)%4096
|
||||
FROM t1
|
||||
ORDER BY a LIMIT 2;
|
||||
} {abc001 2 4084 abc002 2 4069}
|
||||
do_execsql_test func6-150 {
|
||||
SELECT a,
|
||||
sqlite_unsupported_offset(a)/4096+1,
|
||||
sqlite_unsupported_offset(a)%4096,
|
||||
sqlite_unsupported_offset(d)/4096+1,
|
||||
sqlite_unsupported_offset(d)%4096
|
||||
FROM t1
|
||||
ORDER BY a LIMIT 2;
|
||||
} {abc001 3 4087 2 4084 abc002 3 4076 2 4069}
|
||||
do_execsql_test func6-160 {
|
||||
SELECT b,
|
||||
sqlite_unsupported_offset(b)/4096+1,
|
||||
sqlite_unsupported_offset(b)%4096,
|
||||
sqlite_unsupported_offset(c)/4096+1,
|
||||
sqlite_unsupported_offset(c)%4096,
|
||||
sqlite_unsupported_offset(d)/4096+1,
|
||||
sqlite_unsupported_offset(d)%4096
|
||||
FROM t1
|
||||
ORDER BY b LIMIT 2;
|
||||
} {1 4 4090 4 4090 2 4084 2 4 4081 4 4081 2 4069}
|
||||
|
||||
|
||||
do_execsql_test func6-200 {
|
||||
SELECT y, sqlite_unsupported_offset(y)/4096+1,
|
||||
sqlite_unsupported_offset(y)%4096
|
||||
FROM t2
|
||||
ORDER BY x LIMIT 2;
|
||||
} {1 5 4087 2 5 4076}
|
||||
|
||||
finish_test
|
||||
+58
-62
@@ -15,7 +15,7 @@
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
ifcapable !icu&&!icu_collations {
|
||||
ifcapable !icu {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
@@ -35,57 +35,54 @@ proc test_expr {name settings expr result} {
|
||||
} $settings $expr] $result
|
||||
}
|
||||
|
||||
ifcapable icu {
|
||||
# Tests of the REGEXP operator.
|
||||
#
|
||||
test_expr icu-1.1 {i1='hello'} {i1 REGEXP 'hello'} 1
|
||||
test_expr icu-1.2 {i1='hello'} {i1 REGEXP '.ello'} 1
|
||||
test_expr icu-1.3 {i1='hello'} {i1 REGEXP '.ell'} 0
|
||||
test_expr icu-1.4 {i1='hello'} {i1 REGEXP '.ell.*'} 1
|
||||
test_expr icu-1.5 {i1=NULL} {i1 REGEXP '.ell.*'} {}
|
||||
|
||||
# Tests of the REGEXP operator.
|
||||
#
|
||||
test_expr icu-1.1 {i1='hello'} {i1 REGEXP 'hello'} 1
|
||||
test_expr icu-1.2 {i1='hello'} {i1 REGEXP '.ello'} 1
|
||||
test_expr icu-1.3 {i1='hello'} {i1 REGEXP '.ell'} 0
|
||||
test_expr icu-1.4 {i1='hello'} {i1 REGEXP '.ell.*'} 1
|
||||
test_expr icu-1.5 {i1=NULL} {i1 REGEXP '.ell.*'} {}
|
||||
# Some non-ascii characters with defined case mappings
|
||||
#
|
||||
set ::EGRAVE "\xC8"
|
||||
set ::egrave "\xE8"
|
||||
|
||||
# Some non-ascii characters with defined case mappings
|
||||
#
|
||||
set ::EGRAVE "\xC8"
|
||||
set ::egrave "\xE8"
|
||||
set ::OGRAVE "\xD2"
|
||||
set ::ograve "\xF2"
|
||||
|
||||
set ::OGRAVE "\xD2"
|
||||
set ::ograve "\xF2"
|
||||
# That German letter that looks a bit like a B. The
|
||||
# upper-case version of which is "SS" (two characters).
|
||||
#
|
||||
set ::szlig "\xDF"
|
||||
|
||||
# That German letter that looks a bit like a B. The
|
||||
# upper-case version of which is "SS" (two characters).
|
||||
#
|
||||
set ::szlig "\xDF"
|
||||
# Tests of the upper()/lower() functions.
|
||||
#
|
||||
test_expr icu-2.1 {i1='HellO WorlD'} {upper(i1)} {HELLO WORLD}
|
||||
test_expr icu-2.2 {i1='HellO WorlD'} {lower(i1)} {hello world}
|
||||
test_expr icu-2.3 {i1=$::egrave} {lower(i1)} $::egrave
|
||||
test_expr icu-2.4 {i1=$::egrave} {upper(i1)} $::EGRAVE
|
||||
test_expr icu-2.5 {i1=$::ograve} {lower(i1)} $::ograve
|
||||
test_expr icu-2.6 {i1=$::ograve} {upper(i1)} $::OGRAVE
|
||||
test_expr icu-2.3 {i1=$::EGRAVE} {lower(i1)} $::egrave
|
||||
test_expr icu-2.4 {i1=$::EGRAVE} {upper(i1)} $::EGRAVE
|
||||
test_expr icu-2.5 {i1=$::OGRAVE} {lower(i1)} $::ograve
|
||||
test_expr icu-2.6 {i1=$::OGRAVE} {upper(i1)} $::OGRAVE
|
||||
|
||||
# Tests of the upper()/lower() functions.
|
||||
#
|
||||
test_expr icu-2.1 {i1='HellO WorlD'} {upper(i1)} {HELLO WORLD}
|
||||
test_expr icu-2.2 {i1='HellO WorlD'} {lower(i1)} {hello world}
|
||||
test_expr icu-2.3 {i1=$::egrave} {lower(i1)} $::egrave
|
||||
test_expr icu-2.4 {i1=$::egrave} {upper(i1)} $::EGRAVE
|
||||
test_expr icu-2.5 {i1=$::ograve} {lower(i1)} $::ograve
|
||||
test_expr icu-2.6 {i1=$::ograve} {upper(i1)} $::OGRAVE
|
||||
test_expr icu-2.3 {i1=$::EGRAVE} {lower(i1)} $::egrave
|
||||
test_expr icu-2.4 {i1=$::EGRAVE} {upper(i1)} $::EGRAVE
|
||||
test_expr icu-2.5 {i1=$::OGRAVE} {lower(i1)} $::ograve
|
||||
test_expr icu-2.6 {i1=$::OGRAVE} {upper(i1)} $::OGRAVE
|
||||
test_expr icu-2.7 {i1=$::szlig} {upper(i1)} "SS"
|
||||
test_expr icu-2.8 {i1='SS'} {lower(i1)} "ss"
|
||||
|
||||
test_expr icu-2.7 {i1=$::szlig} {upper(i1)} "SS"
|
||||
test_expr icu-2.8 {i1='SS'} {lower(i1)} "ss"
|
||||
do_execsql_test icu-2.9 {
|
||||
SELECT upper(char(0xfb04,0xfb04,0xfb04,0xfb04));
|
||||
} {FFLFFLFFLFFL}
|
||||
|
||||
do_execsql_test icu-2.9 {
|
||||
SELECT upper(char(0xfb04,0xfb04,0xfb04,0xfb04));
|
||||
} {FFLFFLFFLFFL}
|
||||
|
||||
# In turkish (locale="tr_TR"), the lower case version of I
|
||||
# is "small dotless i" (code point 0x131 (decimal 305)).
|
||||
#
|
||||
set ::small_dotless_i "\u0131"
|
||||
test_expr icu-3.1 {i1='I'} {lower(i1)} "i"
|
||||
test_expr icu-3.2 {i1='I'} {lower(i1, 'tr_tr')} $::small_dotless_i
|
||||
test_expr icu-3.3 {i1='I'} {lower(i1, 'en_AU')} "i"
|
||||
}
|
||||
# In turkish (locale="tr_TR"), the lower case version of I
|
||||
# is "small dotless i" (code point 0x131 (decimal 305)).
|
||||
#
|
||||
set ::small_dotless_i "\u0131"
|
||||
test_expr icu-3.1 {i1='I'} {lower(i1)} "i"
|
||||
test_expr icu-3.2 {i1='I'} {lower(i1, 'tr_tr')} $::small_dotless_i
|
||||
test_expr icu-3.3 {i1='I'} {lower(i1, 'en_AU')} "i"
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Test the collation sequence function.
|
||||
@@ -127,23 +124,22 @@ do_test icu-4.3 {
|
||||
#
|
||||
# http://src.chromium.org/viewvc/chrome/trunk/src/third_party/sqlite/icu-regexp.patch?revision=34807&view=markup
|
||||
#
|
||||
ifcapable icu {
|
||||
do_catchsql_test icu-5.1 { SELECT regexp('a[abc]c.*', 'abc') } {0 1}
|
||||
do_catchsql_test icu-5.2 {
|
||||
SELECT regexp('a[abc]c.*')
|
||||
} {1 {wrong number of arguments to function regexp()}}
|
||||
do_catchsql_test icu-5.3 {
|
||||
SELECT regexp('a[abc]c.*', 'abc', 'c')
|
||||
} {1 {wrong number of arguments to function regexp()}}
|
||||
do_catchsql_test icu-5.4 {
|
||||
SELECT 'abc' REGEXP 'a[abc]c.*'
|
||||
} {0 1}
|
||||
do_catchsql_test icu-5.4 {SELECT 'abc' REGEXP } {1 {near " ": syntax error}}
|
||||
do_catchsql_test icu-5.5 {SELECT 'abc' REGEXP, 1} {1 {near ",": syntax error}}
|
||||
|
||||
do_malloc_test icu-6.10 -sqlbody {
|
||||
SELECT upper(char(0xfb04,0xdf,0xfb04,0xe8,0xfb04));
|
||||
}
|
||||
do_catchsql_test icu-5.1 { SELECT regexp('a[abc]c.*', 'abc') } {0 1}
|
||||
do_catchsql_test icu-5.2 {
|
||||
SELECT regexp('a[abc]c.*')
|
||||
} {1 {wrong number of arguments to function regexp()}}
|
||||
do_catchsql_test icu-5.3 {
|
||||
SELECT regexp('a[abc]c.*', 'abc', 'c')
|
||||
} {1 {wrong number of arguments to function regexp()}}
|
||||
do_catchsql_test icu-5.4 {
|
||||
SELECT 'abc' REGEXP 'a[abc]c.*'
|
||||
} {0 1}
|
||||
do_catchsql_test icu-5.4 { SELECT 'abc' REGEXP } {1 {near " ": syntax error}}
|
||||
do_catchsql_test icu-5.5 { SELECT 'abc' REGEXP, 1 } {1 {near ",": syntax error}}
|
||||
|
||||
|
||||
do_malloc_test icu-6.10 -sqlbody {
|
||||
SELECT upper(char(0xfb04,0xdf,0xfb04,0xe8,0xfb04));
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
+83
-2
@@ -1,4 +1,4 @@
|
||||
# 2001 September 15
|
||||
# 2001-09-15
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
@@ -13,7 +13,6 @@
|
||||
# This file implements tests for the special processing associated
|
||||
# with INTEGER PRIMARY KEY columns.
|
||||
#
|
||||
# $Id: intpkey.test,v 1.24 2007/11/29 17:43:28 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -642,4 +641,86 @@ do_execsql_test intpkey-17.2 {
|
||||
SELECT * FROM t17 ORDER BY +x;
|
||||
} {123 elephant 248 ostrich}
|
||||
|
||||
# 2017-11-28: The table_ipk pragma.
|
||||
#
|
||||
do_execsql_test intpkey-18.0 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER PRIMARY KEY, abc, pqr);
|
||||
PRAGMA table_ipk(t1);
|
||||
} {xyz}
|
||||
do_execsql_test intpkey-18.1 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER PRIMARY KEY ASC, abc, pqr);
|
||||
PRAGMA table_ipk(t1);
|
||||
} {xyz}
|
||||
do_execsql_test intpkey-18.2 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER PRIMARY KEY DESC, abc, pqr);
|
||||
PRAGMA table_ipk(t1);
|
||||
} {}
|
||||
do_execsql_test intpkey-18.3 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER, abc, pqr, PRIMARY KEY(xyz));
|
||||
PRAGMA table_ipk(t1);
|
||||
} {xyz}
|
||||
do_execsql_test intpkey-18.4 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER, abc, pqr, PRIMARY KEY(xyz ASC));
|
||||
PRAGMA table_ipk(t1);
|
||||
} {xyz}
|
||||
do_execsql_test intpkey-18.5 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER, abc, pqr, PRIMARY KEY(xyz DESC));
|
||||
PRAGMA table_ipk(t1);
|
||||
} {xyz}
|
||||
do_execsql_test intpkey-18.10 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER PRIMARY KEY, abc, pqr) WITHOUT ROWID;
|
||||
PRAGMA table_ipk(t1);
|
||||
} {}
|
||||
do_execsql_test intpkey-18.11 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER PRIMARY KEY ASC, abc, pqr) WITHOUT ROWID;
|
||||
PRAGMA table_ipk(t1);
|
||||
} {}
|
||||
do_execsql_test intpkey-18.12 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER PRIMARY KEY DESC, abc, pqr) WITHOUT ROWID;
|
||||
PRAGMA table_ipk(t1);
|
||||
} {}
|
||||
do_execsql_test intpkey-18.13 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER, abc, pqr, PRIMARY KEY(xyz)) WITHOUT ROWID;
|
||||
PRAGMA table_ipk(t1);
|
||||
} {}
|
||||
do_execsql_test intpkey-18.14 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER, abc, pqr, PRIMARY KEY(xyz ASC)) WITHOUT ROWID;
|
||||
PRAGMA table_ipk(t1);
|
||||
} {}
|
||||
do_execsql_test intpkey-18.15 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(xyz INTEGER, abc, pqr, PRIMARY KEY(xyz DESC)) WITHOUT ROWID;
|
||||
PRAGMA table_ipk(t1);
|
||||
} {}
|
||||
do_execsql_test intpkey-18.20 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
PRAGMA table_ipk(t1);
|
||||
} {}
|
||||
do_execsql_test intpkey-18.21 {
|
||||
CREATE TABLE t1(a,b,xyz INTEGER PRIMARY KEY NOT NULL);
|
||||
SELECT * FROM pragma_table_ipk('t1');
|
||||
} {xyz}
|
||||
do_execsql_test intpkey-18.22 {
|
||||
PRAGMA table_ipk(pragma_table_ipk);
|
||||
} {}
|
||||
do_execsql_test intpkey-18.23 {
|
||||
PRAGMA table_info(pragma_table_ipk);
|
||||
} {0 name {} 0 {} 0}
|
||||
do_execsql_test intpkey-18.24 {
|
||||
CREATE VIEW v1 AS SELECT * FROM t1 WHERE rowid>5;
|
||||
PRAGMA table_ipk(v1);
|
||||
} {}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -150,21 +150,4 @@ do_execsql_test 502 {
|
||||
SELECT j FROM t502 WHERE i IN (1,2,3,4,5) ORDER BY j LIMIT 3;
|
||||
} {1 3 4}
|
||||
|
||||
# Ticket https://www.sqlite.org/src/info/123c9ba32130a6c9 2017-12-13
|
||||
# Incorrect result when an idnex is used for an ordered join.
|
||||
#
|
||||
# This test case is in the limit2.test module because the problem was first
|
||||
# exposed by check-in https://www.sqlite.org/src/info/559733b09e which
|
||||
# implemented the ORDER BY LIMIT optimization that limit2.test strives to
|
||||
# test.
|
||||
#
|
||||
do_execsql_test 600 {
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1,2);
|
||||
DROP TABLE IF EXISTS t2;
|
||||
CREATE TABLE t2(x, y); INSERT INTO t2 VALUES(1,3);
|
||||
CREATE INDEX t1ab ON t1(a,b);
|
||||
SELECT y FROM t1, t2 WHERE a=x AND b<=y ORDER BY b DESC;
|
||||
} {3}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -722,24 +722,4 @@ do_execsql_test misc1-26.0 {
|
||||
SELECT randomblob(min(max(coalesce(EXISTS (SELECT 1 FROM ( SELECT (SELECT 2147483647) NOT IN (SELECT 2147483649 UNION ALL SELECT DISTINCT -1) IN (SELECT 2147483649), 'fault', (SELECT ALL -1 INTERSECT SELECT 'experiments') IN (SELECT ALL 56.1 ORDER BY 'experiments' DESC) FROM (SELECT DISTINCT 2147483648, 'hardware' UNION ALL SELECT -2147483648, 'experiments' ORDER BY 2147483648 LIMIT 1 OFFSET 123456789.1234567899) GROUP BY (SELECT ALL 0 INTERSECT SELECT 'in') IN (SELECT DISTINCT 'experiments' ORDER BY zeroblob(1000) LIMIT 56.1 OFFSET -456) HAVING EXISTS (SELECT 'fault' EXCEPT SELECT DISTINCT 56.1) UNION SELECT 'The', 'The', 2147483649 UNION ALL SELECT DISTINCT 'hardware', 'first', 'experiments' ORDER BY 'hardware' LIMIT 123456789.1234567899 OFFSET -2147483647)) NOT IN (SELECT (SELECT DISTINCT (SELECT 'The') FROM abc ORDER BY EXISTS (SELECT -1 INTERSECT SELECT ALL NULL) ASC) IN (SELECT DISTINCT EXISTS (SELECT ALL 123456789.1234567899 ORDER BY 1 ASC, NULL DESC) FROM sqlite_master INTERSECT SELECT 456)), (SELECT ALL 'injection' UNION ALL SELECT ALL (SELECT DISTINCT 'first' UNION SELECT DISTINCT 'The') FROM (SELECT 456, 'in', 2147483649))),1), 500)), 'first', EXISTS (SELECT DISTINCT 456 FROM abc ORDER BY 'experiments' DESC) FROM abc;
|
||||
} {}
|
||||
|
||||
# 2017-12-29
|
||||
#
|
||||
# The following behaviors (duplicate column names on an INSERT or UPDATE)
|
||||
# are undocumented. These tests are added to ensure that historical behavior
|
||||
# does not change accidentally.
|
||||
#
|
||||
# For duplication columns on an INSERT, the first value is used.
|
||||
# For duplication columns on an UPDATE, the last value is used.
|
||||
#
|
||||
do_execsql_test misc1-27.0 {
|
||||
CREATE TABLE dup1(a,b,c);
|
||||
INSERT INTO dup1(a,b,c,a,b,c) VALUES(1,2,3,4,5,6);
|
||||
SELECT a,b,c FROM dup1;
|
||||
} {1 2 3}
|
||||
do_execsql_test misc1-27.1 {
|
||||
UPDATE dup1 SET a=7, b=8, c=9, a=10, b=11, c=12;
|
||||
SELECT a,b,c FROM dup1;
|
||||
} {10 11 12}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -15,11 +15,6 @@ set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix mjournal
|
||||
|
||||
if {[permutation]=="inmemory_journal"} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
# Test that nothing bad happens if a journal file contains a pointer to
|
||||
# a master journal file that does not have a "-" in the name. At one point
|
||||
# this was causing a segfault on unix.
|
||||
|
||||
@@ -86,10 +86,9 @@ proc test_set {args} {
|
||||
#
|
||||
set alltests [list]
|
||||
foreach f [glob $testdir/*.test] { lappend alltests [file tail $f] }
|
||||
foreach f [glob -nocomplain \
|
||||
$testdir/../ext/rtree/*.test \
|
||||
foreach f [glob -nocomplain \
|
||||
$testdir/../ext/rtree/*.test \
|
||||
$testdir/../ext/fts5/test/*.test \
|
||||
$testdir/../ext/expert/*.test \
|
||||
$testdir/../ext/lsm1/test/*.test \
|
||||
] {
|
||||
lappend alltests $f
|
||||
|
||||
@@ -93,14 +93,6 @@ foreach {tn schema output} {
|
||||
} {
|
||||
}
|
||||
|
||||
10 {
|
||||
CREATE TABLE parent (id INTEGER PRIMARY KEY);
|
||||
CREATE TABLE child2 (id INT PRIMARY KEY, parentID INT REFERENCES parent)
|
||||
WITHOUT ROWID;
|
||||
} {
|
||||
CREATE INDEX 'child2_parentID' ON 'child2'('parentID'); --> parent(id)
|
||||
}
|
||||
|
||||
} {
|
||||
forcedelete test.db
|
||||
sqlite3 db test.db
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
# 2016 September 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. The focus
|
||||
# of this file is the sqlite3_snapshot_xxx() APIs.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
ifcapable !snapshot {finish_test; return}
|
||||
set testprefix snapshot3
|
||||
|
||||
# This test does not work with the inmemory_journal permutation. The reason
|
||||
# is that each connection opened as part of this permutation executes
|
||||
# "PRAGMA journal_mode=memory", which fails if the database is in wal mode
|
||||
# and there are one or more existing connections.
|
||||
if {[permutation]=="inmemory_journal"} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# This block of tests verifies that it is not possible to wrap the wal
|
||||
# file - using a writer or a "PRAGMA wal_checkpoint = TRUNCATE" - while
|
||||
# there is an open snapshot transaction (transaction opened using
|
||||
# sqlite3_snapshot_open()).
|
||||
#
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TABLE t1(y);
|
||||
PRAGMA journal_mode = wal;
|
||||
INSERT INTO t1 VALUES(1);
|
||||
INSERT INTO t1 VALUES(2);
|
||||
INSERT INTO t1 VALUES(3);
|
||||
INSERT INTO t1 VALUES(4);
|
||||
} {wal}
|
||||
|
||||
do_test 1.1 {
|
||||
sqlite3 db2 test.db
|
||||
sqlite3 db3 test.db
|
||||
|
||||
execsql {SELECT * FROM sqlite_master} db2
|
||||
execsql {SELECT * FROM sqlite_master} db3
|
||||
|
||||
db2 trans { set snap [sqlite3_snapshot_get_blob db2 main] }
|
||||
db2 eval { SELECT * FROM t1 }
|
||||
} {1 2 3 4}
|
||||
|
||||
do_test 1.2 {
|
||||
execsql BEGIN db2
|
||||
sqlite3_snapshot_open_blob db2 main $snap
|
||||
db2 eval { SELECT * FROM t1 }
|
||||
} {1 2 3 4}
|
||||
|
||||
do_test 1.2 {
|
||||
execsql END db2
|
||||
execsql { PRAGMA wal_checkpoint }
|
||||
|
||||
execsql BEGIN db2
|
||||
sqlite3_snapshot_open_blob db2 main $snap
|
||||
db2 eval { SELECT * FROM t1 }
|
||||
} {1 2 3 4}
|
||||
|
||||
set sz [file size test.db-wal]
|
||||
do_test 1.3 {
|
||||
execsql { PRAGMA wal_checkpoint = truncate }
|
||||
file size test.db-wal
|
||||
} $sz
|
||||
|
||||
do_test 1.4 {
|
||||
execsql BEGIN db3
|
||||
list [catch { sqlite3_snapshot_open_blob db3 main $snap } msg] $msg
|
||||
} {0 {}}
|
||||
|
||||
do_test 1.5 {
|
||||
db3 eval { SELECT * FROM t1; END }
|
||||
} {1 2 3 4}
|
||||
|
||||
do_test 1.6 {
|
||||
db2 eval { SELECT * FROM t1; END }
|
||||
} {1 2 3 4}
|
||||
|
||||
do_test 1.7 {
|
||||
execsql { PRAGMA wal_checkpoint = truncate }
|
||||
file size test.db-wal
|
||||
} 0
|
||||
|
||||
do_test 1.8 {
|
||||
execsql BEGIN db3
|
||||
list [catch { sqlite3_snapshot_open_blob db3 main $snap } msg] $msg
|
||||
} {1 SQLITE_BUSY_SNAPSHOT}
|
||||
|
||||
finish_test
|
||||
|
||||
+2
-74
@@ -32,7 +32,7 @@ static const char zHelp[] =
|
||||
" --size N Relative test size. Default=100\n"
|
||||
" --stats Show statistics at the end\n"
|
||||
" --temp N N from 0 to 9. 0: no temp table. 9: all temp tables\n"
|
||||
" --testset T Run test-set T (main, cte, rtree, orm, fp, debug)\n"
|
||||
" --testset T Run test-set T (main, cte, rtree, orm, debug)\n"
|
||||
" --trace Turn on SQL tracing\n"
|
||||
" --threads N Use up to N threads for sorting\n"
|
||||
" --utf16be Set text encoding to UTF-16BE\n"
|
||||
@@ -1120,77 +1120,7 @@ void testset_cte(void){
|
||||
);
|
||||
speedtest1_run();
|
||||
speedtest1_end_test();
|
||||
}
|
||||
|
||||
/*
|
||||
** Compute a pseudo-random floating point ascii number.
|
||||
*/
|
||||
void speedtest1_random_ascii_fp(char *zFP){
|
||||
int x = speedtest1_random();
|
||||
int y = speedtest1_random();
|
||||
int z;
|
||||
z = y%10;
|
||||
if( z<0 ) z = -z;
|
||||
y /= 10;
|
||||
sqlite3_snprintf(100,zFP,"%d.%de%d",y,z,x%200);
|
||||
}
|
||||
|
||||
/*
|
||||
** A testset for floating-point numbers.
|
||||
*/
|
||||
void testset_fp(void){
|
||||
int n;
|
||||
int i;
|
||||
char zFP1[100];
|
||||
char zFP2[100];
|
||||
|
||||
n = g.szTest*5000;
|
||||
speedtest1_begin_test(100, "Fill a table with %d FP values", n*2);
|
||||
speedtest1_exec("BEGIN");
|
||||
speedtest1_exec("CREATE%s TABLE t1(a REAL %s, b REAL %s);",
|
||||
isTemp(1), g.zNN, g.zNN);
|
||||
speedtest1_prepare("INSERT INTO t1 VALUES(?1,?2); -- %d times", n);
|
||||
for(i=1; i<=n; i++){
|
||||
speedtest1_random_ascii_fp(zFP1);
|
||||
speedtest1_random_ascii_fp(zFP2);
|
||||
sqlite3_bind_text(g.pStmt, 1, zFP1, -1, SQLITE_STATIC);
|
||||
sqlite3_bind_text(g.pStmt, 2, zFP2, -1, SQLITE_STATIC);
|
||||
speedtest1_run();
|
||||
}
|
||||
speedtest1_exec("COMMIT");
|
||||
speedtest1_end_test();
|
||||
|
||||
n = g.szTest/25 + 2;
|
||||
speedtest1_begin_test(110, "%d range queries", n);
|
||||
speedtest1_prepare("SELECT sum(b) FROM t1 WHERE a BETWEEN ?1 AND ?2");
|
||||
for(i=1; i<=n; i++){
|
||||
speedtest1_random_ascii_fp(zFP1);
|
||||
speedtest1_random_ascii_fp(zFP2);
|
||||
sqlite3_bind_text(g.pStmt, 1, zFP1, -1, SQLITE_STATIC);
|
||||
sqlite3_bind_text(g.pStmt, 2, zFP2, -1, SQLITE_STATIC);
|
||||
speedtest1_run();
|
||||
}
|
||||
speedtest1_end_test();
|
||||
|
||||
speedtest1_begin_test(120, "CREATE INDEX three times");
|
||||
speedtest1_exec("BEGIN;");
|
||||
speedtest1_exec("CREATE INDEX t1a ON t1(a);");
|
||||
speedtest1_exec("CREATE INDEX t1b ON t1(b);");
|
||||
speedtest1_exec("CREATE INDEX t1ab ON t1(a,b);");
|
||||
speedtest1_exec("COMMIT;");
|
||||
speedtest1_end_test();
|
||||
|
||||
n = g.szTest/3 + 2;
|
||||
speedtest1_begin_test(130, "%d indexed range queries", n);
|
||||
speedtest1_prepare("SELECT sum(b) FROM t1 WHERE a BETWEEN ?1 AND ?2");
|
||||
for(i=1; i<=n; i++){
|
||||
speedtest1_random_ascii_fp(zFP1);
|
||||
speedtest1_random_ascii_fp(zFP2);
|
||||
sqlite3_bind_text(g.pStmt, 1, zFP1, -1, SQLITE_STATIC);
|
||||
sqlite3_bind_text(g.pStmt, 2, zFP2, -1, SQLITE_STATIC);
|
||||
speedtest1_run();
|
||||
}
|
||||
speedtest1_end_test();
|
||||
}
|
||||
|
||||
#ifdef SQLITE_ENABLE_RTREE
|
||||
@@ -1943,8 +1873,6 @@ int main(int argc, char **argv){
|
||||
testset_orm();
|
||||
}else if( strcmp(zTSet,"cte")==0 ){
|
||||
testset_cte();
|
||||
}else if( strcmp(zTSet,"fp")==0 ){
|
||||
testset_fp();
|
||||
}else if( strcmp(zTSet,"rtree")==0 ){
|
||||
#ifdef SQLITE_ENABLE_RTREE
|
||||
testset_rtree(6, 147);
|
||||
@@ -1953,7 +1881,7 @@ int main(int argc, char **argv){
|
||||
"the R-Tree tests\n");
|
||||
#endif
|
||||
}else{
|
||||
fatal_error("unknown testset: \"%s\"\nChoices: main debug1 cte rtree fp\n",
|
||||
fatal_error("unknown testset: \"%s\"\nChoices: main debug1 cte rtree\n",
|
||||
zTSet);
|
||||
}
|
||||
speedtest1_final();
|
||||
|
||||
+1
-1
@@ -213,7 +213,7 @@ do_catchsql_test 3.1 {
|
||||
("test.db2", "t1", 11, 20)
|
||||
', 'fetch_db_no_such_function'
|
||||
);
|
||||
} {1 {sql error: no such function: fetch_db_no_such_function}}
|
||||
} {1 {no such function: fetch_db_no_such_function}}
|
||||
|
||||
do_catchsql_test 3.2 {
|
||||
CREATE VIRTUAL TABLE temp.xyz USING swarmvtab(
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix swarmvtab2
|
||||
set testprefix swarmvtab
|
||||
do_not_use_codec
|
||||
|
||||
ifcapable !vtab {
|
||||
|
||||
@@ -1,233 +0,0 @@
|
||||
# 2017-07-15
|
||||
#
|
||||
# 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 file is the "swarmvtab" extension
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix swarmvtab3
|
||||
do_not_use_codec
|
||||
|
||||
ifcapable !vtab {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
load_static_extension db unionvtab
|
||||
|
||||
set nFile $sqlite_open_file_count
|
||||
|
||||
do_execsql_test 1.0 {
|
||||
CREATE TEMP TABLE swarm(id, tbl, minval, maxval);
|
||||
}
|
||||
|
||||
# Set up 100 databases with filenames "remote_test.dbN", where N is between
|
||||
# 0 and 99.
|
||||
do_test 1.1 {
|
||||
for {set i 0} {$i < 100} {incr i} {
|
||||
set file remote_test.db$i
|
||||
forcedelete $file
|
||||
forcedelete test.db$i
|
||||
sqlite3 rrr $file
|
||||
rrr eval {
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
|
||||
INSERT INTO t1 VALUES($i, $i);
|
||||
}
|
||||
rrr close
|
||||
db eval {
|
||||
INSERT INTO swarm VALUES($i, 't1', $i, $i);
|
||||
}
|
||||
set ::dbcache(test.db$i) 0
|
||||
}
|
||||
} {}
|
||||
|
||||
proc missing_db {filename} {
|
||||
set remote "remote_$filename"
|
||||
forcedelete $filename
|
||||
file copy $remote $filename
|
||||
}
|
||||
db func missing_db missing_db
|
||||
|
||||
proc openclose_db {filename bClose} {
|
||||
if {$bClose} {
|
||||
incr ::dbcache($filename) -1
|
||||
} else {
|
||||
incr ::dbcache($filename) 1
|
||||
}
|
||||
if {$::dbcache($filename)==0} {
|
||||
forcedelete $filename
|
||||
}
|
||||
}
|
||||
db func openclose_db openclose_db
|
||||
|
||||
proc check_dbcache {} {
|
||||
set n 0
|
||||
for {set i 0} {$i<100} {incr i} {
|
||||
set exists [file exists test.db$i]
|
||||
if {$exists!=($::dbcache(test.db$i)!=0)} {
|
||||
error "inconsistent ::dbcache and disk"
|
||||
}
|
||||
incr n $exists
|
||||
}
|
||||
return $n
|
||||
}
|
||||
|
||||
foreach {tn nMaxOpen cvt} {
|
||||
1 5 {
|
||||
CREATE VIRTUAL TABLE temp.s USING swarmvtab(
|
||||
'SELECT :prefix || id, tbl, minval, minval FROM swarm',
|
||||
:prefix='test.db',
|
||||
missing=missing_db,
|
||||
openclose=openclose_db,
|
||||
maxopen=5
|
||||
)
|
||||
}
|
||||
|
||||
2 3 {
|
||||
CREATE VIRTUAL TABLE temp.s USING swarmvtab(
|
||||
'SELECT :prefix || id, tbl, minval, minval FROM swarm',
|
||||
:prefix='test.db',
|
||||
missing = 'missing_db',
|
||||
openclose=[openclose_db],
|
||||
maxopen = 3
|
||||
)
|
||||
}
|
||||
|
||||
3 1 {
|
||||
CREATE VIRTUAL TABLE temp.s USING swarmvtab(
|
||||
'SELECT :prefix||''.''||:suffix||id, tbl, minval, minval FROM swarm',
|
||||
:prefix=test, :suffix=db,
|
||||
missing = 'missing_db',
|
||||
openclose=[openclose_db],
|
||||
maxopen = 1
|
||||
)
|
||||
}
|
||||
|
||||
} {
|
||||
execsql { DROP TABLE IF EXISTS s }
|
||||
|
||||
do_execsql_test 1.$tn.1 $cvt
|
||||
|
||||
do_execsql_test 1.$tn.2 {
|
||||
SELECT b FROM s WHERE a<10;
|
||||
} {0 1 2 3 4 5 6 7 8 9}
|
||||
|
||||
do_test 1.$tn.3 { check_dbcache } $nMaxOpen
|
||||
|
||||
do_execsql_test 1.$tn.4 {
|
||||
SELECT b FROM s WHERE (b%10)=0;
|
||||
} {0 10 20 30 40 50 60 70 80 90}
|
||||
|
||||
do_test 1.$tn.5 { check_dbcache } $nMaxOpen
|
||||
}
|
||||
|
||||
execsql { DROP TABLE IF EXISTS s }
|
||||
for {set i 0} {$i < 100} {incr i} {
|
||||
forcedelete remote_test.db$i
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
do_execsql_test 2.0 {
|
||||
DROP TABLE IF EXISTS swarm;
|
||||
CREATE TEMP TABLE swarm(file, tbl, minval, maxval, ctx);
|
||||
}
|
||||
|
||||
catch { array unset ::dbcache }
|
||||
|
||||
# Set up 100 databases with filenames "remote_test.dbN", where N is a
|
||||
# random integer between 0 and 1,000,000
|
||||
# 0 and 99.
|
||||
do_test 2.1 {
|
||||
for {set i 0} {$i < 100} {incr i} {
|
||||
while 1 {
|
||||
set ctx [expr abs(int(rand() *1000000))]
|
||||
if {[info exists ::dbcache($ctx)]==0} break
|
||||
}
|
||||
|
||||
set file test_remote.db$ctx
|
||||
forcedelete $file
|
||||
forcedelete test.db$i
|
||||
sqlite3 rrr $file
|
||||
rrr eval {
|
||||
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
|
||||
INSERT INTO t1 VALUES($i, $i);
|
||||
}
|
||||
rrr close
|
||||
db eval {
|
||||
INSERT INTO swarm VALUES('test.db' || $i, 't1', $i, $i, $file)
|
||||
}
|
||||
set ::dbcache(test.db$i) 0
|
||||
}
|
||||
} {}
|
||||
|
||||
proc missing_db {filename ctx} {
|
||||
file copy $ctx $filename
|
||||
}
|
||||
db func missing_db missing_db
|
||||
|
||||
proc openclose_db {filename ctx bClose} {
|
||||
if {$bClose} {
|
||||
incr ::dbcache($filename) -1
|
||||
} else {
|
||||
incr ::dbcache($filename) 1
|
||||
}
|
||||
if {$::dbcache($filename)==0} {
|
||||
forcedelete $filename
|
||||
}
|
||||
}
|
||||
db func openclose_db openclose_db
|
||||
|
||||
proc check_dbcache {} {
|
||||
set n 0
|
||||
foreach k [array names ::dbcache] {
|
||||
set exists [file exists $k]
|
||||
if {$exists!=($::dbcache($k)!=0)} {
|
||||
error "inconsistent ::dbcache and disk ($k)"
|
||||
}
|
||||
incr n $exists
|
||||
}
|
||||
return $n
|
||||
}
|
||||
|
||||
foreach {tn nMaxOpen cvt} {
|
||||
2 5 {
|
||||
CREATE VIRTUAL TABLE temp.s USING swarmvtab(
|
||||
'SELECT file, tbl, minval, minval, ctx FROM swarm',
|
||||
missing=missing_db,
|
||||
openclose=openclose_db,
|
||||
maxopen=5
|
||||
)
|
||||
}
|
||||
} {
|
||||
execsql { DROP TABLE IF EXISTS s }
|
||||
|
||||
do_execsql_test 1.$tn.1 $cvt
|
||||
|
||||
do_execsql_test 1.$tn.2 {
|
||||
SELECT b FROM s WHERE a<10;
|
||||
} {0 1 2 3 4 5 6 7 8 9}
|
||||
|
||||
do_test 1.$tn.3 { check_dbcache } $nMaxOpen
|
||||
|
||||
do_execsql_test 1.$tn.4 {
|
||||
SELECT b FROM s WHERE (b%10)=0;
|
||||
} {0 10 20 30 40 50 60 70 80 90}
|
||||
|
||||
do_test 1.$tn.5 { check_dbcache } $nMaxOpen
|
||||
}
|
||||
|
||||
db close
|
||||
forcedelete {*}[glob test_remote.db*]
|
||||
|
||||
finish_test
|
||||
|
||||
+2
-6
@@ -2271,17 +2271,13 @@ proc test_restore_config_pagecache {} {
|
||||
sqlite3 db test.db
|
||||
}
|
||||
|
||||
proc test_binary_name {nm} {
|
||||
proc test_find_binary {nm} {
|
||||
if {$::tcl_platform(platform)=="windows"} {
|
||||
set ret "$nm.exe"
|
||||
} else {
|
||||
set ret $nm
|
||||
}
|
||||
file normalize [file join $::cmdlinearg(TESTFIXTURE_HOME) $ret]
|
||||
}
|
||||
|
||||
proc test_find_binary {nm} {
|
||||
set ret [test_binary_name $nm]
|
||||
set ret [file normalize [file join $::cmdlinearg(TESTFIXTURE_HOME) $ret]]
|
||||
if {![file executable $ret]} {
|
||||
finish_test
|
||||
return ""
|
||||
|
||||
+1
-1
@@ -197,7 +197,7 @@ ifcapable trigger {
|
||||
UPDATE t1 SET a=a+1;
|
||||
}
|
||||
set TRACE_OUT
|
||||
} {{UPDATE t1 SET a=a+1;} {-- TRIGGER r1t1} {-- UPDATE t2 SET a=new.a WHERE rowid=new.rowid} {-- TRIGGER r1t2} {-- SELECT 'hello'} {-- TRIGGER r1t1} {-- UPDATE t2 SET a=new.a WHERE rowid=new.rowid} {-- TRIGGER r1t2} {-- SELECT 'hello'} {-- TRIGGER r1t1} {-- UPDATE t2 SET a=new.a WHERE rowid=new.rowid} {-- TRIGGER r1t2} {-- SELECT 'hello'}}
|
||||
} {{UPDATE t1 SET a=a+1;} {-- TRIGGER r1t1} {-- TRIGGER r1t2} {-- TRIGGER r1t1} {-- TRIGGER r1t2} {-- TRIGGER r1t1} {-- TRIGGER r1t2}}
|
||||
}
|
||||
|
||||
# With 3.6.21, we add the ability to expand host parameters in the trace
|
||||
|
||||
@@ -62,17 +62,4 @@ do_execsql_test 200 {
|
||||
SELECT b FROM t2 ORDER BY b;
|
||||
} {20202 20203 20302 20303 30202 30203 30302 30303 40202 40203 40302 40303 50202 50203 50302 50303}
|
||||
|
||||
# At one point the following was causing an assert() to fail.
|
||||
#
|
||||
do_execsql_test 300 {
|
||||
CREATE TABLE t4(x);
|
||||
CREATE TRIGGER tr4 AFTER INSERT ON t4 BEGIN
|
||||
SELECT 0x2147483648e0e0099 AS y WHERE y;
|
||||
END;
|
||||
}
|
||||
|
||||
do_catchsql_test 310 {
|
||||
INSERT INTO t4 VALUES(1);
|
||||
} {1 {hex literal too big: 0x2147483648e0e0099}}
|
||||
|
||||
finish_test
|
||||
|
||||
+9
-23
@@ -52,21 +52,21 @@ do_test 1.1 {
|
||||
set ::locks [list]
|
||||
sqlite3 db test.db -vfs T
|
||||
execsql { SELECT * FROM x }
|
||||
lrange $::locks 0 5
|
||||
} [list {0 1 lock exclusive} {1 2 lock exclusive} {4 4 lock exclusive} \
|
||||
{1 2 unlock exclusive} {4 4 unlock exclusive} {0 1 unlock exclusive} \
|
||||
lrange $::locks 0 3
|
||||
} [list {0 1 lock exclusive} {1 7 lock exclusive} \
|
||||
{1 7 unlock exclusive} {0 1 unlock exclusive} \
|
||||
]
|
||||
do_test 1.2 {
|
||||
db close
|
||||
set ::locks [list]
|
||||
sqlite3 db test.db -vfs T
|
||||
execsql { SELECT * FROM x }
|
||||
lrange $::locks 0 5
|
||||
} [list {0 1 lock exclusive} {1 2 lock exclusive} {4 4 lock exclusive} \
|
||||
{1 2 unlock exclusive} {4 4 unlock exclusive} {0 1 unlock exclusive} \
|
||||
lrange $::locks 0 3
|
||||
} [list {0 1 lock exclusive} {1 7 lock exclusive} \
|
||||
{1 7 unlock exclusive} {0 1 unlock exclusive} \
|
||||
]
|
||||
proc lock_callback {method filename handle lock} {
|
||||
if {$lock == "1 2 lock exclusive"} { return SQLITE_BUSY }
|
||||
if {$lock == "1 7 lock exclusive"} { return SQLITE_BUSY }
|
||||
return SQLITE_OK
|
||||
}
|
||||
puts "# Warning: This next test case causes SQLite to call xSleep(1) 100 times."
|
||||
@@ -90,18 +90,6 @@ do_test 1.4 {
|
||||
sqlite3 db test.db -vfs T
|
||||
catchsql { SELECT * FROM x }
|
||||
} {1 {locking protocol}}
|
||||
|
||||
puts "# Warning: Third time!"
|
||||
proc lock_callback {method filename handle lock} {
|
||||
if {$lock == "4 4 lock exclusive"} { return SQLITE_BUSY }
|
||||
return SQLITE_OK
|
||||
}
|
||||
do_test 1.5 {
|
||||
db close
|
||||
set ::locks [list]
|
||||
sqlite3 db test.db -vfs T
|
||||
catchsql { SELECT * FROM x }
|
||||
} {1 {locking protocol}}
|
||||
db close
|
||||
T delete
|
||||
|
||||
@@ -147,14 +135,13 @@ T filter xShmLock
|
||||
T script lock_callback
|
||||
|
||||
proc lock_callback {method file handle spec} {
|
||||
if {$spec == "1 2 unlock exclusive"} {
|
||||
if {$spec == "1 7 unlock exclusive"} {
|
||||
T filter {}
|
||||
set ::r [catchsql { SELECT * FROM b } db2]
|
||||
}
|
||||
}
|
||||
sqlite3 db test.db
|
||||
sqlite3 db2 test.db
|
||||
puts "# Warning: Another slow test!"
|
||||
do_test 2.5 {
|
||||
execsql { SELECT * FROM b }
|
||||
} {Tehran Qom Markazi Qazvin Gilan Ardabil}
|
||||
@@ -170,13 +157,12 @@ sqlite3 db2 test.db
|
||||
T filter xShmLock
|
||||
T script lock_callback
|
||||
proc lock_callback {method file handle spec} {
|
||||
if {$spec == "1 2 unlock exclusive"} {
|
||||
if {$spec == "1 7 unlock exclusive"} {
|
||||
T filter {}
|
||||
set ::r [catchsql { SELECT * FROM b } db2]
|
||||
}
|
||||
}
|
||||
unset ::r
|
||||
puts "# Warning: Last one!"
|
||||
do_test 2.7 {
|
||||
execsql { SELECT * FROM b }
|
||||
} {Tehran Qom Markazi Qazvin Gilan Ardabil}
|
||||
|
||||
+2
-3
@@ -262,9 +262,8 @@ do_multiclient_test tn {
|
||||
}
|
||||
} {500}
|
||||
do_test $TN.4.2.2 {
|
||||
set sz [file size test.db-wal]
|
||||
expr {$sz>400000 && $sz<500000}
|
||||
} {1}
|
||||
file size test.db-wal
|
||||
} {461152}
|
||||
do_test $TN.4.2.4 {
|
||||
file_control_persist_wal db 1; db close
|
||||
|
||||
|
||||
+52
-114
@@ -384,12 +384,6 @@ struct lemon {
|
||||
int nrule; /* Number of rules */
|
||||
int nsymbol; /* Number of terminal and nonterminal symbols */
|
||||
int nterminal; /* Number of terminal symbols */
|
||||
int minShiftReduce; /* Minimum shift-reduce action value */
|
||||
int errAction; /* Error action value */
|
||||
int accAction; /* Accept action value */
|
||||
int noAction; /* No-op action value */
|
||||
int minReduce; /* Minimum reduce action */
|
||||
int maxAction; /* Maximum action value of any kind */
|
||||
struct symbol **symbols; /* Sorted array of pointers to symbols */
|
||||
int errorcnt; /* Number of errors */
|
||||
struct symbol *errsym; /* The error symbol */
|
||||
@@ -413,7 +407,6 @@ struct lemon {
|
||||
char *tokenprefix; /* A prefix added to token names in the .h file */
|
||||
int nconflict; /* Number of parsing conflicts */
|
||||
int nactiontab; /* Number of entries in the yy_action[] table */
|
||||
int nlookaheadtab; /* Number of entries in yy_lookahead[] */
|
||||
int tablesize; /* Total table size of all tables in bytes */
|
||||
int basisflag; /* Print only basis configurations */
|
||||
int has_fallback; /* True if any %fallback is seen in the grammar */
|
||||
@@ -590,12 +583,10 @@ struct acttab {
|
||||
int mxLookahead; /* Maximum aLookahead[].lookahead */
|
||||
int nLookahead; /* Used slots in aLookahead[] */
|
||||
int nLookaheadAlloc; /* Slots allocated in aLookahead[] */
|
||||
int nterminal; /* Number of terminal symbols */
|
||||
int nsymbol; /* total number of symbols */
|
||||
};
|
||||
|
||||
/* Return the number of entries in the yy_action table */
|
||||
#define acttab_lookahead_size(X) ((X)->nAction)
|
||||
#define acttab_size(X) ((X)->nAction)
|
||||
|
||||
/* The value for the N-th entry in yy_action */
|
||||
#define acttab_yyaction(X,N) ((X)->aAction[N].action)
|
||||
@@ -611,15 +602,13 @@ void acttab_free(acttab *p){
|
||||
}
|
||||
|
||||
/* Allocate a new acttab structure */
|
||||
acttab *acttab_alloc(int nsymbol, int nterminal){
|
||||
acttab *acttab_alloc(void){
|
||||
acttab *p = (acttab *) calloc( 1, sizeof(*p) );
|
||||
if( p==0 ){
|
||||
fprintf(stderr,"Unable to allocate memory for a new acttab.");
|
||||
exit(1);
|
||||
}
|
||||
memset(p, 0, sizeof(*p));
|
||||
p->nsymbol = nsymbol;
|
||||
p->nterminal = nterminal;
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -660,24 +649,16 @@ void acttab_action(acttab *p, int lookahead, int action){
|
||||
** to an empty set in preparation for a new round of acttab_action() calls.
|
||||
**
|
||||
** Return the offset into the action table of the new transaction.
|
||||
**
|
||||
** If the makeItSafe parameter is true, then the offset is chosen so that
|
||||
** it is impossible to overread the yy_lookaside[] table regardless of
|
||||
** the lookaside token. This is done for the terminal symbols, as they
|
||||
** come from external inputs and can contain syntax errors. When makeItSafe
|
||||
** is false, there is more flexibility in selecting offsets, resulting in
|
||||
** a smaller table. For non-terminal symbols, which are never syntax errors,
|
||||
** makeItSafe can be false.
|
||||
*/
|
||||
int acttab_insert(acttab *p, int makeItSafe){
|
||||
int i, j, k, n, end;
|
||||
int acttab_insert(acttab *p){
|
||||
int i, j, k, n;
|
||||
assert( p->nLookahead>0 );
|
||||
|
||||
/* Make sure we have enough space to hold the expanded action table
|
||||
** in the worst case. The worst case occurs if the transaction set
|
||||
** must be appended to the current action table
|
||||
*/
|
||||
n = p->nsymbol + 1;
|
||||
n = p->mxLookahead + 1;
|
||||
if( p->nAction + n >= p->nActionAlloc ){
|
||||
int oldAlloc = p->nActionAlloc;
|
||||
p->nActionAlloc = p->nAction + n + p->nActionAlloc + 20;
|
||||
@@ -699,8 +680,7 @@ int acttab_insert(acttab *p, int makeItSafe){
|
||||
**
|
||||
** i is the index in p->aAction[] where p->mnLookahead is inserted.
|
||||
*/
|
||||
end = makeItSafe ? p->mnLookahead : 0;
|
||||
for(i=p->nAction-1; i>=end; i--){
|
||||
for(i=p->nAction-1; i>=0; i--){
|
||||
if( p->aAction[i].lookahead==p->mnLookahead ){
|
||||
/* All lookaheads and actions in the aLookahead[] transaction
|
||||
** must match against the candidate aAction[i] entry. */
|
||||
@@ -730,13 +710,12 @@ int acttab_insert(acttab *p, int makeItSafe){
|
||||
** an empty offset in the aAction[] table in which we can add the
|
||||
** aLookahead[] transaction.
|
||||
*/
|
||||
if( i<end ){
|
||||
if( i<0 ){
|
||||
/* Look for holes in the aAction[] table that fit the current
|
||||
** aLookahead[] transaction. Leave i set to the offset of the hole.
|
||||
** If no holes are found, i is left at p->nAction, which means the
|
||||
** transaction will be appended. */
|
||||
i = makeItSafe ? p->mnLookahead : 0;
|
||||
for(; i<p->nActionAlloc - p->mxLookahead; i++){
|
||||
for(i=0; i<p->nActionAlloc - p->mxLookahead; i++){
|
||||
if( p->aAction[i].lookahead<0 ){
|
||||
for(j=0; j<p->nLookahead; j++){
|
||||
k = p->aLookahead[j].lookahead - p->mnLookahead + i;
|
||||
@@ -754,19 +733,11 @@ int acttab_insert(acttab *p, int makeItSafe){
|
||||
}
|
||||
}
|
||||
/* Insert transaction set at index i. */
|
||||
#if 0
|
||||
printf("Acttab:");
|
||||
for(j=0; j<p->nLookahead; j++){
|
||||
printf(" %d", p->aLookahead[j].lookahead);
|
||||
}
|
||||
printf(" inserted at %d\n", i);
|
||||
#endif
|
||||
for(j=0; j<p->nLookahead; j++){
|
||||
k = p->aLookahead[j].lookahead - p->mnLookahead + i;
|
||||
p->aAction[k] = p->aLookahead[j];
|
||||
if( k>=p->nAction ) p->nAction = k+1;
|
||||
}
|
||||
if( makeItSafe && i+p->nterminal>=p->nAction ) p->nAction = i+p->nterminal+1;
|
||||
p->nLookahead = 0;
|
||||
|
||||
/* Return the offset that is added to the lookahead in order to get the
|
||||
@@ -774,16 +745,6 @@ int acttab_insert(acttab *p, int makeItSafe){
|
||||
return i - p->mnLookahead;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the size of the action table without the trailing syntax error
|
||||
** entries.
|
||||
*/
|
||||
int acttab_action_size(acttab *p){
|
||||
int n = p->nAction;
|
||||
while( n>0 && p->aAction[n-1].lookahead<0 ){ n--; }
|
||||
return n;
|
||||
}
|
||||
|
||||
/********************** From the file "build.c" *****************************/
|
||||
/*
|
||||
** Routines to construction the finite state machine for the LEMON
|
||||
@@ -1757,7 +1718,6 @@ int main(int argc, char **argv)
|
||||
stats_line("states", lem.nxstate);
|
||||
stats_line("conflicts", lem.nconflict);
|
||||
stats_line("action table entries", lem.nactiontab);
|
||||
stats_line("lookahead table entries", lem.nlookaheadtab);
|
||||
stats_line("total table size (bytes)", lem.tablesize);
|
||||
}
|
||||
if( lem.nconflict > 0 ){
|
||||
@@ -3060,27 +3020,6 @@ PRIVATE FILE *file_open(
|
||||
return fp;
|
||||
}
|
||||
|
||||
/* Print the text of a rule
|
||||
*/
|
||||
void rule_print(FILE *out, struct rule *rp){
|
||||
int i, j;
|
||||
fprintf(out, "%s",rp->lhs->name);
|
||||
/* if( rp->lhsalias ) fprintf(out,"(%s)",rp->lhsalias); */
|
||||
fprintf(out," ::=");
|
||||
for(i=0; i<rp->nrhs; i++){
|
||||
struct symbol *sp = rp->rhs[i];
|
||||
if( sp->type==MULTITERMINAL ){
|
||||
fprintf(out," %s", sp->subsym[0]->name);
|
||||
for(j=1; j<sp->nsubsym; j++){
|
||||
fprintf(out,"|%s", sp->subsym[j]->name);
|
||||
}
|
||||
}else{
|
||||
fprintf(out," %s", sp->name);
|
||||
}
|
||||
/* if( rp->rhsalias[i] ) fprintf(out,"(%s)",rp->rhsalias[i]); */
|
||||
}
|
||||
}
|
||||
|
||||
/* Duplicate the input file without comments and without actions
|
||||
** on rules */
|
||||
void Reprint(struct lemon *lemp)
|
||||
@@ -3108,7 +3047,21 @@ void Reprint(struct lemon *lemp)
|
||||
printf("\n");
|
||||
}
|
||||
for(rp=lemp->rule; rp; rp=rp->next){
|
||||
rule_print(stdout, rp);
|
||||
printf("%s",rp->lhs->name);
|
||||
/* if( rp->lhsalias ) printf("(%s)",rp->lhsalias); */
|
||||
printf(" ::=");
|
||||
for(i=0; i<rp->nrhs; i++){
|
||||
sp = rp->rhs[i];
|
||||
if( sp->type==MULTITERMINAL ){
|
||||
printf(" %s", sp->subsym[0]->name);
|
||||
for(j=1; j<sp->nsubsym; j++){
|
||||
printf("|%s", sp->subsym[j]->name);
|
||||
}
|
||||
}else{
|
||||
printf(" %s", sp->name);
|
||||
}
|
||||
/* if( rp->rhsalias[i] ) printf("(%s)",rp->rhsalias[i]); */
|
||||
}
|
||||
printf(".");
|
||||
if( rp->precsym ) printf(" [%s]",rp->precsym->name);
|
||||
/* if( rp->code ) printf("\n %s",rp->code); */
|
||||
@@ -3368,19 +3321,16 @@ PRIVATE int compute_action(struct lemon *lemp, struct action *ap)
|
||||
switch( ap->type ){
|
||||
case SHIFT: act = ap->x.stp->statenum; break;
|
||||
case SHIFTREDUCE: {
|
||||
act = ap->x.rp->iRule + lemp->nstate;
|
||||
/* Since a SHIFT is inherient after a prior REDUCE, convert any
|
||||
** SHIFTREDUCE action with a nonterminal on the LHS into a simple
|
||||
** REDUCE action: */
|
||||
if( ap->sp->index>=lemp->nterminal ){
|
||||
act = lemp->minReduce + ap->x.rp->iRule;
|
||||
}else{
|
||||
act = lemp->minShiftReduce + ap->x.rp->iRule;
|
||||
}
|
||||
if( ap->sp->index>=lemp->nterminal ) act += lemp->nrule;
|
||||
break;
|
||||
}
|
||||
case REDUCE: act = lemp->minReduce + ap->x.rp->iRule; break;
|
||||
case ERROR: act = lemp->errAction; break;
|
||||
case ACCEPT: act = lemp->accAction; break;
|
||||
case REDUCE: act = ap->x.rp->iRule + lemp->nstate+lemp->nrule; break;
|
||||
case ERROR: act = lemp->nstate + lemp->nrule*2; break;
|
||||
case ACCEPT: act = lemp->nstate + lemp->nrule*2 + 1; break;
|
||||
default: act = -1; break;
|
||||
}
|
||||
return act;
|
||||
@@ -4088,13 +4038,6 @@ void ReportTable(
|
||||
int mnNtOfst, mxNtOfst;
|
||||
struct axset *ax;
|
||||
|
||||
lemp->minShiftReduce = lemp->nstate;
|
||||
lemp->errAction = lemp->minShiftReduce + lemp->nrule;
|
||||
lemp->accAction = lemp->errAction + 1;
|
||||
lemp->noAction = lemp->accAction + 1;
|
||||
lemp->minReduce = lemp->noAction + 1;
|
||||
lemp->maxAction = lemp->minReduce + lemp->nrule;
|
||||
|
||||
in = tplt_open(lemp);
|
||||
if( in==0 ) return;
|
||||
out = file_open(lemp,".c","wb");
|
||||
@@ -4133,7 +4076,7 @@ void ReportTable(
|
||||
minimum_size_type(0, lemp->nsymbol+1, &szCodeType)); lineno++;
|
||||
fprintf(out,"#define YYNOCODE %d\n",lemp->nsymbol+1); lineno++;
|
||||
fprintf(out,"#define YYACTIONTYPE %s\n",
|
||||
minimum_size_type(0,lemp->maxAction,&szActionType)); lineno++;
|
||||
minimum_size_type(0,lemp->nstate+lemp->nrule*2+5,&szActionType)); lineno++;
|
||||
if( lemp->wildcard ){
|
||||
fprintf(out,"#define YYWILDCARD %d\n",
|
||||
lemp->wildcard->index); lineno++;
|
||||
@@ -4201,7 +4144,7 @@ void ReportTable(
|
||||
** of placing the largest action sets first */
|
||||
for(i=0; i<lemp->nxstate*2; i++) ax[i].iOrder = i;
|
||||
qsort(ax, lemp->nxstate*2, sizeof(ax[0]), axset_compare);
|
||||
pActtab = acttab_alloc(lemp->nsymbol, lemp->nterminal);
|
||||
pActtab = acttab_alloc();
|
||||
for(i=0; i<lemp->nxstate*2 && ax[i].nAction>0; i++){
|
||||
stp = ax[i].stp;
|
||||
if( ax[i].isTkn ){
|
||||
@@ -4212,7 +4155,7 @@ void ReportTable(
|
||||
if( action<0 ) continue;
|
||||
acttab_action(pActtab, ap->sp->index, action);
|
||||
}
|
||||
stp->iTknOfst = acttab_insert(pActtab, 1);
|
||||
stp->iTknOfst = acttab_insert(pActtab);
|
||||
if( stp->iTknOfst<mnTknOfst ) mnTknOfst = stp->iTknOfst;
|
||||
if( stp->iTknOfst>mxTknOfst ) mxTknOfst = stp->iTknOfst;
|
||||
}else{
|
||||
@@ -4224,7 +4167,7 @@ void ReportTable(
|
||||
if( action<0 ) continue;
|
||||
acttab_action(pActtab, ap->sp->index, action);
|
||||
}
|
||||
stp->iNtOfst = acttab_insert(pActtab, 0);
|
||||
stp->iNtOfst = acttab_insert(pActtab);
|
||||
if( stp->iNtOfst<mnNtOfst ) mnNtOfst = stp->iNtOfst;
|
||||
if( stp->iNtOfst>mxNtOfst ) mxNtOfst = stp->iNtOfst;
|
||||
}
|
||||
@@ -4257,18 +4200,16 @@ void ReportTable(
|
||||
** been computed */
|
||||
fprintf(out,"#define YYNSTATE %d\n",lemp->nxstate); lineno++;
|
||||
fprintf(out,"#define YYNRULE %d\n",lemp->nrule); lineno++;
|
||||
fprintf(out,"#define YYNTOKEN %d\n",lemp->nterminal); lineno++;
|
||||
fprintf(out,"#define YY_MAX_SHIFT %d\n",lemp->nxstate-1); lineno++;
|
||||
i = lemp->minShiftReduce;
|
||||
fprintf(out,"#define YY_MIN_SHIFTREDUCE %d\n",i); lineno++;
|
||||
i += lemp->nrule;
|
||||
fprintf(out,"#define YY_MIN_SHIFTREDUCE %d\n",lemp->nstate); lineno++;
|
||||
i = lemp->nstate + lemp->nrule;
|
||||
fprintf(out,"#define YY_MAX_SHIFTREDUCE %d\n", i-1); lineno++;
|
||||
fprintf(out,"#define YY_ERROR_ACTION %d\n", lemp->errAction); lineno++;
|
||||
fprintf(out,"#define YY_ACCEPT_ACTION %d\n", lemp->accAction); lineno++;
|
||||
fprintf(out,"#define YY_NO_ACTION %d\n", lemp->noAction); lineno++;
|
||||
fprintf(out,"#define YY_MIN_REDUCE %d\n", lemp->minReduce); lineno++;
|
||||
i = lemp->minReduce + lemp->nrule;
|
||||
fprintf(out,"#define YY_MIN_REDUCE %d\n", i); lineno++;
|
||||
i = lemp->nstate + lemp->nrule*2;
|
||||
fprintf(out,"#define YY_MAX_REDUCE %d\n", i-1); lineno++;
|
||||
fprintf(out,"#define YY_ERROR_ACTION %d\n", i); lineno++;
|
||||
fprintf(out,"#define YY_ACCEPT_ACTION %d\n", i+1); lineno++;
|
||||
fprintf(out,"#define YY_NO_ACTION %d\n", i+2); lineno++;
|
||||
tplt_xfer(lemp->name,in,out,&lineno);
|
||||
|
||||
/* Now output the action table and its associates:
|
||||
@@ -4284,13 +4225,13 @@ void ReportTable(
|
||||
*/
|
||||
|
||||
/* Output the yy_action table */
|
||||
lemp->nactiontab = n = acttab_action_size(pActtab);
|
||||
lemp->nactiontab = n = acttab_size(pActtab);
|
||||
lemp->tablesize += n*szActionType;
|
||||
fprintf(out,"#define YY_ACTTAB_COUNT (%d)\n", n); lineno++;
|
||||
fprintf(out,"static const YYACTIONTYPE yy_action[] = {\n"); lineno++;
|
||||
for(i=j=0; i<n; i++){
|
||||
int action = acttab_yyaction(pActtab, i);
|
||||
if( action<0 ) action = lemp->noAction;
|
||||
if( action<0 ) action = lemp->nstate + lemp->nrule + 2;
|
||||
if( j==0 ) fprintf(out," /* %5d */ ", i);
|
||||
fprintf(out, " %4d,", action);
|
||||
if( j==9 || i==n-1 ){
|
||||
@@ -4303,7 +4244,6 @@ void ReportTable(
|
||||
fprintf(out, "};\n"); lineno++;
|
||||
|
||||
/* Output the yy_lookahead table */
|
||||
lemp->nlookaheadtab = n = acttab_lookahead_size(pActtab);
|
||||
lemp->tablesize += n*szCodeType;
|
||||
fprintf(out,"static const YYCODETYPE yy_lookahead[] = {\n"); lineno++;
|
||||
for(i=j=0; i<n; i++){
|
||||
@@ -4323,6 +4263,7 @@ void ReportTable(
|
||||
/* Output the yy_shift_ofst[] table */
|
||||
n = lemp->nxstate;
|
||||
while( n>0 && lemp->sorted[n-1]->iTknOfst==NO_OFFSET ) n--;
|
||||
fprintf(out, "#define YY_SHIFT_USE_DFLT (%d)\n", lemp->nactiontab); lineno++;
|
||||
fprintf(out, "#define YY_SHIFT_COUNT (%d)\n", n-1); lineno++;
|
||||
fprintf(out, "#define YY_SHIFT_MIN (%d)\n", mnTknOfst); lineno++;
|
||||
fprintf(out, "#define YY_SHIFT_MAX (%d)\n", mxTknOfst); lineno++;
|
||||
@@ -4347,6 +4288,7 @@ void ReportTable(
|
||||
fprintf(out, "};\n"); lineno++;
|
||||
|
||||
/* Output the yy_reduce_ofst[] table */
|
||||
fprintf(out, "#define YY_REDUCE_USE_DFLT (%d)\n", mnNtOfst-1); lineno++;
|
||||
n = lemp->nxstate;
|
||||
while( n>0 && lemp->sorted[n-1]->iNtOfst==NO_OFFSET ) n--;
|
||||
fprintf(out, "#define YY_REDUCE_COUNT (%d)\n", n-1); lineno++;
|
||||
@@ -4378,11 +4320,7 @@ void ReportTable(
|
||||
for(i=j=0; i<n; i++){
|
||||
stp = lemp->sorted[i];
|
||||
if( j==0 ) fprintf(out," /* %5d */ ", i);
|
||||
if( stp->iDfltReduce<0 ){
|
||||
fprintf(out, " %4d,", lemp->errAction);
|
||||
}else{
|
||||
fprintf(out, " %4d,", stp->iDfltReduce + lemp->minReduce);
|
||||
}
|
||||
fprintf(out, " %4d,", stp->iDfltReduce+lemp->nstate+lemp->nrule);
|
||||
if( j==9 || i==n-1 ){
|
||||
fprintf(out, "\n"); lineno++;
|
||||
j = 0;
|
||||
@@ -4416,8 +4354,10 @@ void ReportTable(
|
||||
*/
|
||||
for(i=0; i<lemp->nsymbol; i++){
|
||||
lemon_sprintf(line,"\"%s\",",lemp->symbols[i]->name);
|
||||
fprintf(out," /* %4d */ \"%s\",\n",i, lemp->symbols[i]->name); lineno++;
|
||||
fprintf(out," %-15s",line);
|
||||
if( (i&3)==3 ){ fprintf(out,"\n"); lineno++; }
|
||||
}
|
||||
if( (i&3)!=0 ){ fprintf(out,"\n"); lineno++; }
|
||||
tplt_xfer(lemp->name,in,out,&lineno);
|
||||
|
||||
/* Generate a table containing a text string that describes every
|
||||
@@ -4461,7 +4401,7 @@ void ReportTable(
|
||||
if( sp==0 || sp->type==TERMINAL ||
|
||||
sp->index<=0 || sp->destructor!=0 ) continue;
|
||||
if( once ){
|
||||
fprintf(out, " /* Default NON-TERMINAL Destructor */\n");lineno++;
|
||||
fprintf(out, " /* Default NON-TERMINAL Destructor */\n"); lineno++;
|
||||
once = 0;
|
||||
}
|
||||
fprintf(out," case %d: /* %s */\n", sp->index, sp->name); lineno++;
|
||||
@@ -4504,10 +4444,8 @@ void ReportTable(
|
||||
** Note: This code depends on the fact that rules are number
|
||||
** sequentually beginning with 0.
|
||||
*/
|
||||
for(i=0, rp=lemp->rule; rp; rp=rp->next, i++){
|
||||
fprintf(out," { %4d, %4d }, /* (%d) ",rp->lhs->index,-rp->nrhs,i);
|
||||
rule_print(out, rp);
|
||||
fprintf(out," */\n"); lineno++;
|
||||
for(rp=lemp->rule; rp; rp=rp->next){
|
||||
fprintf(out," { %d, %d },\n",rp->lhs->index,-rp->nrhs); lineno++;
|
||||
}
|
||||
tplt_xfer(lemp->name,in,out,&lineno);
|
||||
|
||||
@@ -4773,7 +4711,7 @@ void ResortStates(struct lemon *lemp)
|
||||
for(i=0; i<lemp->nstate; i++){
|
||||
stp = lemp->sorted[i];
|
||||
stp->nTknAct = stp->nNtAct = 0;
|
||||
stp->iDfltReduce = -1; /* Init dflt action to "syntax error" */
|
||||
stp->iDfltReduce = lemp->nrule; /* Init dflt action to "syntax error" */
|
||||
stp->iTknOfst = NO_OFFSET;
|
||||
stp->iNtOfst = NO_OFFSET;
|
||||
for(ap=stp->ap; ap; ap=ap->next){
|
||||
@@ -4785,7 +4723,7 @@ void ResortStates(struct lemon *lemp)
|
||||
stp->nNtAct++;
|
||||
}else{
|
||||
assert( stp->autoReduce==0 || stp->pDfltReduce==ap->x.rp );
|
||||
stp->iDfltReduce = iAction;
|
||||
stp->iDfltReduce = iAction - lemp->nstate - lemp->nrule;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+43
-100
@@ -72,15 +72,14 @@
|
||||
** defined, then do no error processing.
|
||||
** YYNSTATE the combined number of states.
|
||||
** YYNRULE the number of rules in the grammar
|
||||
** YYNTOKEN Number of terminal symbols
|
||||
** YY_MAX_SHIFT Maximum value for shift actions
|
||||
** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions
|
||||
** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions
|
||||
** YY_MIN_REDUCE Minimum value for reduce actions
|
||||
** YY_MAX_REDUCE Maximum value for reduce actions
|
||||
** YY_ERROR_ACTION The yy_action[] code for syntax error
|
||||
** YY_ACCEPT_ACTION The yy_action[] code for accept
|
||||
** YY_NO_ACTION The yy_action[] code for no-op
|
||||
** YY_MIN_REDUCE Minimum value for reduce actions
|
||||
** YY_MAX_REDUCE Maximum value for reduce actions
|
||||
*/
|
||||
#ifndef INTERFACE
|
||||
# define INTERFACE 1
|
||||
@@ -116,6 +115,9 @@
|
||||
** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then
|
||||
** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE.
|
||||
**
|
||||
** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
|
||||
** and YY_MAX_REDUCE
|
||||
**
|
||||
** N == YY_ERROR_ACTION A syntax error has occurred.
|
||||
**
|
||||
** N == YY_ACCEPT_ACTION The parser accepts its input.
|
||||
@@ -123,22 +125,25 @@
|
||||
** N == YY_NO_ACTION No such action. Denotes unused
|
||||
** slots in the yy_action[] table.
|
||||
**
|
||||
** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE
|
||||
** and YY_MAX_REDUCE
|
||||
**
|
||||
** The action table is constructed as a single large table named yy_action[].
|
||||
** Given state S and lookahead X, the action is computed as either:
|
||||
**
|
||||
** (A) N = yy_action[ yy_shift_ofst[S] + X ]
|
||||
** (B) N = yy_default[S]
|
||||
**
|
||||
** The (A) formula is preferred. The B formula is used instead if
|
||||
** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X.
|
||||
** The (A) formula is preferred. The B formula is used instead if:
|
||||
** (1) The yy_shift_ofst[S]+X value is out of range, or
|
||||
** (2) yy_lookahead[yy_shift_ofst[S]+X] is not equal to X, or
|
||||
** (3) yy_shift_ofst[S] equal YY_SHIFT_USE_DFLT.
|
||||
** (Implementation note: YY_SHIFT_USE_DFLT is chosen so that
|
||||
** YY_SHIFT_USE_DFLT+X will be out of range for all possible lookaheads X.
|
||||
** Hence only tests (1) and (2) need to be evaluated.)
|
||||
**
|
||||
** The formulas above are for computing the action when the lookahead is
|
||||
** a terminal symbol. If the lookahead is a non-terminal (as occurs after
|
||||
** a reduce action) then the yy_reduce_ofst[] array is used in place of
|
||||
** the yy_shift_ofst[] array.
|
||||
** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of
|
||||
** YY_SHIFT_USE_DFLT.
|
||||
**
|
||||
** The following are the tables generated in this section:
|
||||
**
|
||||
@@ -254,13 +259,13 @@ void ParseTrace(FILE *TraceFILE, char *zTracePrompt){
|
||||
}
|
||||
#endif /* NDEBUG */
|
||||
|
||||
#if defined(YYCOVERAGE) || !defined(NDEBUG)
|
||||
#ifndef NDEBUG
|
||||
/* For tracing shifts, the names of all terminals and nonterminals
|
||||
** are required. The following table supplies these names */
|
||||
static const char *const yyTokenName[] = {
|
||||
%%
|
||||
};
|
||||
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
|
||||
#endif /* NDEBUG */
|
||||
|
||||
#ifndef NDEBUG
|
||||
/* For tracing reduce actions, the names of all rules are required.
|
||||
@@ -456,43 +461,6 @@ int ParseStackPeak(void *p){
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This array of booleans keeps track of the parser statement
|
||||
** coverage. The element yycoverage[X][Y] is set when the parser
|
||||
** is in state X and has a lookahead token Y. In a well-tested
|
||||
** systems, every element of this matrix should end up being set.
|
||||
*/
|
||||
#if defined(YYCOVERAGE)
|
||||
static unsigned char yycoverage[YYNSTATE][YYNTOKEN];
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Write into out a description of every state/lookahead combination that
|
||||
**
|
||||
** (1) has not been used by the parser, and
|
||||
** (2) is not a syntax error.
|
||||
**
|
||||
** Return the number of missed state/lookahead combinations.
|
||||
*/
|
||||
#if defined(YYCOVERAGE)
|
||||
int ParseCoverage(FILE *out){
|
||||
int stateno, iLookAhead, i;
|
||||
int nMissed = 0;
|
||||
for(stateno=0; stateno<YYNSTATE; stateno++){
|
||||
i = yy_shift_ofst[stateno];
|
||||
for(iLookAhead=0; iLookAhead<YYNTOKEN; iLookAhead++){
|
||||
if( yy_lookahead[i+iLookAhead]!=iLookAhead ) continue;
|
||||
if( yycoverage[stateno][iLookAhead]==0 ) nMissed++;
|
||||
if( out ){
|
||||
fprintf(out,"State %d lookahead %s %s\n", stateno,
|
||||
yyTokenName[iLookAhead],
|
||||
yycoverage[stateno][iLookAhead] ? "ok" : "missed");
|
||||
}
|
||||
}
|
||||
}
|
||||
return nMissed;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Find the appropriate action for a parser given the terminal
|
||||
** look-ahead token iLookAhead.
|
||||
@@ -504,18 +472,13 @@ static unsigned int yy_find_shift_action(
|
||||
int i;
|
||||
int stateno = pParser->yytos->stateno;
|
||||
|
||||
if( stateno>YY_MAX_SHIFT ) return stateno;
|
||||
if( stateno>=YY_MIN_REDUCE ) return stateno;
|
||||
assert( stateno <= YY_SHIFT_COUNT );
|
||||
#if defined(YYCOVERAGE)
|
||||
yycoverage[stateno][iLookAhead] = 1;
|
||||
#endif
|
||||
do{
|
||||
i = yy_shift_ofst[stateno];
|
||||
assert( i>=0 && i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) );
|
||||
assert( iLookAhead!=YYNOCODE );
|
||||
assert( iLookAhead < YYNTOKEN );
|
||||
i += iLookAhead;
|
||||
if( yy_lookahead[i]!=iLookAhead ){
|
||||
if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){
|
||||
#ifdef YYFALLBACK
|
||||
YYCODETYPE iFallback; /* Fallback token */
|
||||
if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0])
|
||||
@@ -578,6 +541,7 @@ static int yy_find_reduce_action(
|
||||
assert( stateno<=YY_REDUCE_COUNT );
|
||||
#endif
|
||||
i = yy_reduce_ofst[stateno];
|
||||
assert( i!=YY_REDUCE_USE_DFLT );
|
||||
assert( iLookAhead!=YYNOCODE );
|
||||
i += iLookAhead;
|
||||
#ifdef YYERRORSYMBOL
|
||||
@@ -614,21 +578,20 @@ static void yyStackOverflow(yyParser *yypParser){
|
||||
** Print tracing information for a SHIFT action
|
||||
*/
|
||||
#ifndef NDEBUG
|
||||
static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){
|
||||
static void yyTraceShift(yyParser *yypParser, int yyNewState){
|
||||
if( yyTraceFILE ){
|
||||
if( yyNewState<YYNSTATE ){
|
||||
fprintf(yyTraceFILE,"%s%s '%s', go to state %d\n",
|
||||
yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
|
||||
fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n",
|
||||
yyTracePrompt,yyTokenName[yypParser->yytos->major],
|
||||
yyNewState);
|
||||
}else{
|
||||
fprintf(yyTraceFILE,"%s%s '%s', pending reduce %d\n",
|
||||
yyTracePrompt, zTag, yyTokenName[yypParser->yytos->major],
|
||||
yyNewState - YY_MIN_REDUCE);
|
||||
fprintf(yyTraceFILE,"%sShift '%s'\n",
|
||||
yyTracePrompt,yyTokenName[yypParser->yytos->major]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define yyTraceShift(X,Y,Z)
|
||||
# define yyTraceShift(X,Y)
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -670,7 +633,7 @@ static void yy_shift(
|
||||
yytos->stateno = (YYACTIONTYPE)yyNewState;
|
||||
yytos->major = (YYCODETYPE)yyMajor;
|
||||
yytos->minor.yy0 = yyMinor;
|
||||
yyTraceShift(yypParser, yyNewState, "Shift");
|
||||
yyTraceShift(yypParser, yyNewState);
|
||||
}
|
||||
|
||||
/* The following table contains information about every rule that
|
||||
@@ -688,18 +651,10 @@ static void yy_accept(yyParser*); /* Forward Declaration */
|
||||
/*
|
||||
** Perform a reduce action and the shift that must immediately
|
||||
** follow the reduce.
|
||||
**
|
||||
** The yyLookahead and yyLookaheadToken parameters provide reduce actions
|
||||
** access to the lookahead token (if any). The yyLookahead will be YYNOCODE
|
||||
** if the lookahead token has already been consumed. As this procedure is
|
||||
** only called from one place, optimizing compilers will in-line it, which
|
||||
** means that the extra parameters have no performance impact.
|
||||
*/
|
||||
static void yy_reduce(
|
||||
yyParser *yypParser, /* The parser */
|
||||
unsigned int yyruleno, /* Number of the rule by which to reduce */
|
||||
int yyLookahead, /* Lookahead token, or YYNOCODE if none */
|
||||
ParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */
|
||||
unsigned int yyruleno /* Number of the rule by which to reduce */
|
||||
){
|
||||
int yygoto; /* The next state */
|
||||
int yyact; /* The next action */
|
||||
@@ -710,14 +665,8 @@ static void yy_reduce(
|
||||
#ifndef NDEBUG
|
||||
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
|
||||
yysize = yyRuleInfo[yyruleno].nrhs;
|
||||
if( yysize ){
|
||||
fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n",
|
||||
yyTracePrompt,
|
||||
yyruleno, yyRuleName[yyruleno], yymsp[yysize].stateno);
|
||||
}else{
|
||||
fprintf(yyTraceFILE, "%sReduce %d [%s].\n",
|
||||
yyTracePrompt, yyruleno, yyRuleName[yyruleno]);
|
||||
}
|
||||
fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
|
||||
yyRuleName[yyruleno], yymsp[yysize].stateno);
|
||||
}
|
||||
#endif /* NDEBUG */
|
||||
|
||||
@@ -772,11 +721,16 @@ static void yy_reduce(
|
||||
/* It is not possible for a REDUCE to be followed by an error */
|
||||
assert( yyact!=YY_ERROR_ACTION );
|
||||
|
||||
yymsp += yysize+1;
|
||||
yypParser->yytos = yymsp;
|
||||
yymsp->stateno = (YYACTIONTYPE)yyact;
|
||||
yymsp->major = (YYCODETYPE)yygoto;
|
||||
yyTraceShift(yypParser, yyact, "... then shift");
|
||||
if( yyact==YY_ACCEPT_ACTION ){
|
||||
yypParser->yytos += yysize;
|
||||
yy_accept(yypParser);
|
||||
}else{
|
||||
yymsp += yysize+1;
|
||||
yypParser->yytos = yymsp;
|
||||
yymsp->stateno = (YYACTIONTYPE)yyact;
|
||||
yymsp->major = (YYCODETYPE)yygoto;
|
||||
yyTraceShift(yypParser, yyact);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -886,31 +840,20 @@ void Parse(
|
||||
|
||||
#ifndef NDEBUG
|
||||
if( yyTraceFILE ){
|
||||
int stateno = yypParser->yytos->stateno;
|
||||
if( stateno < YY_MIN_REDUCE ){
|
||||
fprintf(yyTraceFILE,"%sInput '%s' in state %d\n",
|
||||
yyTracePrompt,yyTokenName[yymajor],stateno);
|
||||
}else{
|
||||
fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n",
|
||||
yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE);
|
||||
}
|
||||
fprintf(yyTraceFILE,"%sInput '%s'\n",yyTracePrompt,yyTokenName[yymajor]);
|
||||
}
|
||||
#endif
|
||||
|
||||
do{
|
||||
yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
|
||||
if( yyact >= YY_MIN_REDUCE ){
|
||||
yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor);
|
||||
}else if( yyact <= YY_MAX_SHIFTREDUCE ){
|
||||
if( yyact <= YY_MAX_SHIFTREDUCE ){
|
||||
yy_shift(yypParser,yyact,yymajor,yyminor);
|
||||
#ifndef YYNOERRORRECOVERY
|
||||
yypParser->yyerrcnt--;
|
||||
#endif
|
||||
yymajor = YYNOCODE;
|
||||
}else if( yyact==YY_ACCEPT_ACTION ){
|
||||
yypParser->yytos--;
|
||||
yy_accept(yypParser);
|
||||
return;
|
||||
}else if( yyact <= YY_MAX_REDUCE ){
|
||||
yy_reduce(yypParser,yyact-YY_MIN_REDUCE);
|
||||
}else{
|
||||
assert( yyact == YY_ERROR_ACTION );
|
||||
yyminorunion.yy0 = yyminor;
|
||||
|
||||
@@ -223,6 +223,11 @@ set pragma_def {
|
||||
COLS: cid name type notnull dflt_value pk
|
||||
IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
|
||||
|
||||
NAME: table_ipk
|
||||
FLAG: NeedSchema Result1
|
||||
COLS: name
|
||||
IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
|
||||
|
||||
NAME: stats
|
||||
FLAG: NeedSchema Result0 SchemaReq
|
||||
COLS: tbl idx wdth hght flgs
|
||||
|
||||
@@ -117,12 +117,6 @@ while test "$1" != ""; do
|
||||
--orm)
|
||||
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset orm"
|
||||
;;
|
||||
--cte)
|
||||
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset cte"
|
||||
;;
|
||||
--fp)
|
||||
SPEEDTEST_OPTS="$SPEEDTEST_OPTS --testset fp"
|
||||
;;
|
||||
-*)
|
||||
CC_OPTS="$CC_OPTS $1"
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user