Incorporate recent trunk changes.

FossilOrigin-Name: 62b8269ba2ff71e2daaa86688698896badd6f6e34ab42fbf92dda7fcda73a230
This commit is contained in:
drh
2017-06-28 15:56:58 +00:00
49 changed files with 1550 additions and 317 deletions
+45
View File
@@ -0,0 +1,45 @@
# 2014 June 17
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is testing the FTS5 module.
#
source [file join [file dirname [info script]] fts5_common.tcl]
set testprefix fts5leftjoin
# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
ifcapable !fts5 {
finish_test
return
}
do_execsql_test 1.0 {
CREATE VIRTUAL TABLE vt USING fts5(x);
INSERT INTO vt VALUES('abc');
INSERT INTO vt VALUES('xyz');
CREATE TABLE t1(a INTEGER PRIMARY KEY);
INSERT INTO t1 VALUES(1), (2);
}
do_execsql_test 1.1 {
SELECT * FROM t1 LEFT JOIN (
SELECT rowid AS rrr, * FROM vt WHERE vt MATCH 'abc'
) ON t1.a = rrr
} {1 1 abc 2 {} {}}
do_execsql_test 1.2 {
SELECT * FROM t1 LEFT JOIN vt ON (vt MATCH 'abc')
} {1 abc 2 abc}
finish_test
+18
View File
@@ -77,6 +77,7 @@ struct CsvReader {
int n; /* Number of bytes in z */
int nAlloc; /* Space allocated for z[] */
int nLine; /* Current line number */
int bNotFirst; /* True if prior text has been seen */
char cTerm; /* Character that terminated the most recent field */
size_t iIn; /* Next unread character in the input buffer */
size_t nIn; /* Number of characters in the input buffer */
@@ -91,6 +92,7 @@ static void csv_reader_init(CsvReader *p){
p->n = 0;
p->nAlloc = 0;
p->nLine = 0;
p->bNotFirst = 0;
p->nIn = 0;
p->zIn = 0;
p->zErr[0] = 0;
@@ -251,6 +253,21 @@ static char *csv_read_one_field(CsvReader *p){
pc = c;
}
}else{
/* If this is the first field being parsed and it begins with the
** UTF-8 BOM (0xEF BB BF) then skip the BOM */
if( (c&0xff)==0xef && p->bNotFirst==0 ){
csv_append(p, (char)c);
c = csv_getc(p);
if( (c&0xff)==0xbb ){
csv_append(p, (char)c);
c = csv_getc(p);
if( (c&0xff)==0xbf ){
p->bNotFirst = 1;
p->n = 0;
return csv_read_one_field(p);
}
}
}
while( c>',' || (c!=EOF && c!=',' && c!='\n') ){
if( csv_append(p, (char)c) ) return 0;
c = csv_getc(p);
@@ -262,6 +279,7 @@ static char *csv_read_one_field(CsvReader *p){
p->cTerm = (char)c;
}
if( p->z ) p->z[p->n] = 0;
p->bNotFirst = 1;
return p->z;
}
+8
View File
@@ -298,6 +298,14 @@ do_test 2.1.2 {
list [catch { rbu close } msg] $msg
} {1 {SQLITE_ERROR - cannot vacuum wal mode database}}
do_test 2.1.3 {
sqlite3rbu_vacuum rbu test.db state.db
rbu step
} {SQLITE_ERROR}
do_test 2.1.4 {
list [catch { rbu close_no_error } msg] $msg
} {1 SQLITE_ERROR}
reset_db
do_execsql_test 2.2.0 {
CREATE TABLE tx(a PRIMARY KEY, b BLOB);
+5 -1
View File
@@ -3787,7 +3787,11 @@ int sqlite3rbu_close(sqlite3rbu *p, char **pzErrmsg){
rbuEditErrmsg(p);
rc = p->rc;
*pzErrmsg = p->zErrmsg;
if( pzErrmsg ){
*pzErrmsg = p->zErrmsg;
}else{
sqlite3_free(p->zErrmsg);
}
sqlite3_free(p->zState);
sqlite3_free(p);
}else{
+4 -4
View File
@@ -420,10 +420,10 @@ int sqlite3rbu_savestate(sqlite3rbu *pRbu);
**
** If an error has already occurred as part of an sqlite3rbu_step()
** or sqlite3rbu_open() call, or if one occurs within this function, an
** SQLite error code is returned. Additionally, *pzErrmsg may be set to
** point to a buffer containing a utf-8 formatted English language error
** message. It is the responsibility of the caller to eventually free any
** such buffer using sqlite3_free().
** SQLite error code is returned. Additionally, if pzErrmsg is not NULL,
** *pzErrmsg may be set to point to a buffer containing a utf-8 formatted
** English language error message. It is the responsibility of the caller to
** eventually free any such buffer using sqlite3_free().
**
** Otherwise, if no error occurs, this function returns SQLITE_OK if the
** update has been partially applied, or SQLITE_DONE if it has been
+7 -1
View File
@@ -78,6 +78,7 @@ static int SQLITE_TCLAPI test_sqlite3rbu_cmd(
{"db", 3, "RBU"}, /* 6 */
{"state", 2, ""}, /* 7 */
{"progress", 2, ""}, /* 8 */
{"close_no_error", 2, ""}, /* 9 */
{0,0,0}
};
int iCmd;
@@ -102,11 +103,16 @@ static int SQLITE_TCLAPI test_sqlite3rbu_cmd(
break;
}
case 9: /* close_no_error */
case 1: /* close */ {
char *zErrmsg = 0;
int rc;
Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));
rc = sqlite3rbu_close(pRbu, &zErrmsg);
if( iCmd==1 ){
rc = sqlite3rbu_close(pRbu, &zErrmsg);
}else{
rc = sqlite3rbu_close(pRbu, 0);
}
if( rc==SQLITE_OK || rc==SQLITE_DONE ){
Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
assert( zErrmsg==0 );
+29
View File
@@ -209,6 +209,35 @@ eval [string map [list %WR% $trailing] {
list [catch { sqlite3changeset_concat $c1 $c2} msg] $msg
} {1 SQLITE_SCHEMA}
#-----------------------------------------------------------------------
db2 close
sqlite3 db2 test.db
do_execsql_test $tn.6.0 {
CREATE TABLE t7(a INTEGER PRIMARY KEY, b) %WR%;
INSERT INTO t7 VALUES(1, 1);
INSERT INTO t7 VALUES(2, 2);
INSERT INTO t7 VALUES(3, 3);
}
do_test $tn.6.1 {
set c1 [sql_exec_changeset db {
INSERT INTO t7 VALUES(4, 4);
DELETE FROM t7 WHERE a=1;
UPDATE t7 SET b=222 WHERE a=2;
}]
set cinv [sqlite3changeset_invert $c1]
execsql { SELECT * FROM t7 }
} {2 222 3 3 4 4}
do_execsql_test -db db2 $tn.6.2 {
ALTER TABLE t7 ADD COLUMN c DEFAULT 'ccc'
}
proc xConfict {args} { return "OMIT" }
do_test $tn.6.3 {
sqlite3changeset_apply db $cinv xConflict
execsql { SELECT * FROM t7 }
} {1 1 ccc 2 2 ccc 3 3 ccc}
}]
}
+1 -1
View File
@@ -16,6 +16,7 @@ if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source $testdir/tester.tcl
ifcapable !session {finish_test; return}
set testprefix sessiondiff
set PROG [test_find_sqldiff]
@@ -111,4 +112,3 @@ do_changeset_test 1.2 {
}
finish_test