mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-15 11:41:13 +03:00
Merge all the latest trunk enhancements into the sessions branch.
FossilOrigin-Name: c91065f8edb1e54076791716fc20d3fcfe3070dc
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix corrupt2
|
||||
|
||||
# Do not use a codec for tests in this file, as the database file is
|
||||
# manipulated directly using tcl scripts (using the [hexio_write] command).
|
||||
@@ -558,4 +559,51 @@ ifcapable autovacuum {
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that PRAGMA integrity_check detects cases where the freelist-count
|
||||
# header field is smaller than the actual number of pages on the freelist.
|
||||
#
|
||||
|
||||
reset_db
|
||||
do_execsql_test 14.0 {
|
||||
PRAGMA auto_vacuum = 0;
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1 VALUES(randomblob(3500));
|
||||
DELETE FROM t1;
|
||||
}
|
||||
|
||||
do_execsql_test 14.1 {
|
||||
PRAGMA integrity_check;
|
||||
PRAGMA freelist_count;
|
||||
} {ok 3}
|
||||
|
||||
# There are now 3 free pages. Modify the header-field so that it
|
||||
# (incorrectly) says that just 2 are free.
|
||||
do_test 14.2 {
|
||||
db close
|
||||
hexio_write test.db 36 [hexio_render_int32 2]
|
||||
sqlite3 db test.db
|
||||
execsql { PRAGMA freelist_count }
|
||||
} {2}
|
||||
|
||||
do_execsql_test 14.3 {
|
||||
PRAGMA integrity_check;
|
||||
} {{*** in database main ***
|
||||
Main freelist: free-page count in header is too small}}
|
||||
|
||||
# Use 2 of the free pages on the free-list.
|
||||
#
|
||||
do_execsql_test 14.4 {
|
||||
INSERT INTO t1 VALUES(randomblob(2500));
|
||||
PRAGMA freelist_count;
|
||||
} {0}
|
||||
|
||||
do_execsql_test 14.5 {
|
||||
PRAGMA integrity_check;
|
||||
} {{*** in database main ***
|
||||
Page 3 is never used}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -189,7 +189,11 @@ do_test corruptC-2.7 {
|
||||
catchsql {BEGIN; UPDATE t2 SET y='abcdef-uvwxyz'; ROLLBACK;}
|
||||
} {1 {database disk image is malformed}}
|
||||
|
||||
|
||||
# corruption (seed 179069)
|
||||
# Obsolete. With single-pass DELETE the corruption in the
|
||||
# main database is not detected.
|
||||
if 0 {
|
||||
do_test corruptC-2.8 {
|
||||
db close
|
||||
forcecopy test.bu test.db
|
||||
@@ -204,6 +208,7 @@ do_test corruptC-2.8 {
|
||||
sqlite3 db test.db
|
||||
catchsql {BEGIN; DELETE FROM t1 WHERE x>13; ROLLBACK;}
|
||||
} {1 {database disk image is malformed}}
|
||||
}
|
||||
|
||||
# corruption (seed 170434)
|
||||
#
|
||||
|
||||
@@ -296,6 +296,38 @@ static void readfileFunc(
|
||||
fclose(in);
|
||||
}
|
||||
|
||||
/*
|
||||
** Implementation of the "writefile(X,Y)" SQL function. The argument Y
|
||||
** is written into file X. The number of bytes written is returned. Or
|
||||
** NULL is returned if something goes wrong, such as being unable to open
|
||||
** file X for writing.
|
||||
*/
|
||||
static void writefileFunc(
|
||||
sqlite3_context *context,
|
||||
int argc,
|
||||
sqlite3_value **argv
|
||||
){
|
||||
FILE *out;
|
||||
const char *z;
|
||||
sqlite3_int64 rc;
|
||||
const char *zFile;
|
||||
|
||||
(void)argc;
|
||||
zFile = (const char*)sqlite3_value_text(argv[0]);
|
||||
if( zFile==0 ) return;
|
||||
out = fopen(zFile, "wb");
|
||||
if( out==0 ) return;
|
||||
z = (const char*)sqlite3_value_blob(argv[1]);
|
||||
if( z==0 ){
|
||||
rc = 0;
|
||||
}else{
|
||||
rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);
|
||||
}
|
||||
fclose(out);
|
||||
sqlite3_result_int64(context, rc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Load a list of Blob objects from the database
|
||||
*/
|
||||
@@ -751,6 +783,8 @@ static void showHelp(void){
|
||||
"Options:\n"
|
||||
" --cell-size-check Set the PRAGMA cell_size_check=ON\n"
|
||||
" --dbid N Use only the database where dbid=N\n"
|
||||
" --export-db DIR Write databases to files(s) in DIR. Works with --dbid\n"
|
||||
" --export-sql DIR Write SQL to file(s) in DIR. Also works with --sqlid\n"
|
||||
" --help Show this help text\n"
|
||||
" -q Reduced output\n"
|
||||
" --quiet Reduced output\n"
|
||||
@@ -763,7 +797,7 @@ static void showHelp(void){
|
||||
" --rebuild Rebuild and vacuum the database file\n"
|
||||
" --result-trace Show the results of each SQL command\n"
|
||||
" --sqlid N Use only SQL where sqlid=N\n"
|
||||
" --timeline N Abort if any single test case needs more than N seconds\n"
|
||||
" --timeout N Abort if any single test case needs more than N seconds\n"
|
||||
" -v Increased output\n"
|
||||
" --verbose Increased output\n"
|
||||
);
|
||||
@@ -799,6 +833,8 @@ int main(int argc, char **argv){
|
||||
int sqlFuzz = 0; /* True for SQL fuzz testing. False for DB fuzz */
|
||||
int iTimeout = 120; /* Default 120-second timeout */
|
||||
int nMem = 0; /* Memory limit */
|
||||
char *zExpDb = 0; /* Write Databases to files in this directory */
|
||||
char *zExpSql = 0; /* Write SQL to files in this directory */
|
||||
|
||||
iBegin = timeOfDay();
|
||||
#ifdef __unix__
|
||||
@@ -818,6 +854,14 @@ int main(int argc, char **argv){
|
||||
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||
onlyDbid = integerValue(argv[++i]);
|
||||
}else
|
||||
if( strcmp(z,"export-db")==0 ){
|
||||
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||
zExpDb = argv[++i];
|
||||
}else
|
||||
if( strcmp(z,"export-sql")==0 ){
|
||||
if( i>=argc-1 ) fatalError("missing arguments on %s", argv[i]);
|
||||
zExpSql = argv[++i];
|
||||
}else
|
||||
if( strcmp(z,"help")==0 ){
|
||||
showHelp();
|
||||
return 0;
|
||||
@@ -943,6 +987,50 @@ int main(int argc, char **argv){
|
||||
sqlite3_close(db);
|
||||
return 0;
|
||||
}
|
||||
if( zExpDb!=0 || zExpSql!=0 ){
|
||||
sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
|
||||
writefileFunc, 0, 0);
|
||||
if( zExpDb!=0 ){
|
||||
const char *zExDb =
|
||||
"SELECT writefile(printf('%s/db%06d.db',?1,dbid),dbcontent),"
|
||||
" dbid, printf('%s/db%06d.db',?1,dbid), length(dbcontent)"
|
||||
" FROM db WHERE ?2<0 OR dbid=?2;";
|
||||
rc = sqlite3_prepare_v2(db, zExDb, -1, &pStmt, 0);
|
||||
if( rc ) fatalError("cannot prepare statement [%s]: %s",
|
||||
zExDb, sqlite3_errmsg(db));
|
||||
sqlite3_bind_text64(pStmt, 1, zExpDb, strlen(zExpDb),
|
||||
SQLITE_STATIC, SQLITE_UTF8);
|
||||
sqlite3_bind_int(pStmt, 2, onlyDbid);
|
||||
while( sqlite3_step(pStmt)==SQLITE_ROW ){
|
||||
printf("write db-%d (%d bytes) into %s\n",
|
||||
sqlite3_column_int(pStmt,1),
|
||||
sqlite3_column_int(pStmt,3),
|
||||
sqlite3_column_text(pStmt,2));
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
}
|
||||
if( zExpSql!=0 ){
|
||||
const char *zExSql =
|
||||
"SELECT writefile(printf('%s/sql%06d.txt',?1,sqlid),sqltext),"
|
||||
" sqlid, printf('%s/sql%06d.txt',?1,sqlid), length(sqltext)"
|
||||
" FROM xsql WHERE ?2<0 OR sqlid=?2;";
|
||||
rc = sqlite3_prepare_v2(db, zExSql, -1, &pStmt, 0);
|
||||
if( rc ) fatalError("cannot prepare statement [%s]: %s",
|
||||
zExSql, sqlite3_errmsg(db));
|
||||
sqlite3_bind_text64(pStmt, 1, zExpSql, strlen(zExpSql),
|
||||
SQLITE_STATIC, SQLITE_UTF8);
|
||||
sqlite3_bind_int(pStmt, 2, onlySqlid);
|
||||
while( sqlite3_step(pStmt)==SQLITE_ROW ){
|
||||
printf("write sql-%d (%d bytes) into %s\n",
|
||||
sqlite3_column_int(pStmt,1),
|
||||
sqlite3_column_int(pStmt,3),
|
||||
sqlite3_column_text(pStmt,2));
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
}
|
||||
sqlite3_close(db);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Load all SQL script content and all initial database images from the
|
||||
** source db
|
||||
@@ -1039,6 +1127,12 @@ int main(int argc, char **argv){
|
||||
}
|
||||
rc = sqlite3_open_v2("main.db", &db, openFlags, zVfs);
|
||||
if( rc ) fatalError("cannot open inmem database");
|
||||
#ifdef SQLITE_ENABLE_JSON1
|
||||
{
|
||||
extern int sqlite3_json_init(sqlite3*);
|
||||
sqlite3_json_init(db);
|
||||
}
|
||||
#endif
|
||||
if( cellSzCkFlag ) runSql(db, "PRAGMA cell_size_check=ON", runFlags);
|
||||
setAlarm(iTimeout);
|
||||
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
|
||||
|
||||
BIN
test/fuzzdata4.db
Normal file
BIN
test/fuzzdata4.db
Normal file
Binary file not shown.
@@ -218,5 +218,41 @@ do_execsql_test indexexpr1-510eqp {
|
||||
SELECT substr(a,4,3) AS k FROM cnt, t5 WHERE k=printf('%03d',x);
|
||||
} {/USING INDEX t5ax/}
|
||||
|
||||
# Skip-scan on an indexed expression
|
||||
#
|
||||
do_execsql_test indexexpr1-600 {
|
||||
DROP TABLE IF EXISTS t4;
|
||||
CREATE TABLE t4(a,b,c,d,e,f,g,h,i);
|
||||
CREATE INDEX t4all ON t4(a,b,c<d,e,f,i,h);
|
||||
INSERT INTO t4 VALUES(1,2,3,4,5,6,7,8,9);
|
||||
ANALYZE;
|
||||
DELETE FROM sqlite_stat1;
|
||||
INSERT INTO sqlite_stat1
|
||||
VALUES('t4','t4all','600000 160000 40000 10000 2000 600 100 40 10');
|
||||
ANALYZE sqlite_master;
|
||||
SELECT i FROM t4 WHERE e=5;
|
||||
} {9}
|
||||
|
||||
# Indexed expressions on both sides of an == in a WHERE clause.
|
||||
#
|
||||
do_execsql_test indexexpr1-700 {
|
||||
DROP TABLE IF EXISTS t7;
|
||||
CREATE TABLE t7(a,b,c);
|
||||
INSERT INTO t7(a,b,c) VALUES(1,2,2),('abc','def','def'),(4,5,6);
|
||||
CREATE INDEX t7b ON t7(+b);
|
||||
CREATE INDEX t7c ON t7(+c);
|
||||
SELECT *, '|' FROM t7 WHERE +b=+c ORDER BY +a;
|
||||
} {1 2 2 | abc def def |}
|
||||
do_execsql_test indexexpr1-710 {
|
||||
CREATE TABLE t71(a,b,c);
|
||||
CREATE INDEX t71bc ON t71(b+c);
|
||||
CREATE TABLE t72(x,y,z);
|
||||
CREATE INDEX t72yz ON t72(y+z);
|
||||
INSERT INTO t71(a,b,c) VALUES(1,11,2),(2,7,15),(3,5,4);
|
||||
INSERT INTO t72(x,y,z) VALUES(1,10,3),(2,8,14),(3,9,9);
|
||||
SELECT a, x, '|' FROM t71, t72
|
||||
WHERE b+c=y+z
|
||||
ORDER BY +a, +x;
|
||||
} {1 1 | 2 2 |}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -16,28 +16,28 @@ set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
load_static_extension db json
|
||||
do_execsql_test json1-1.1.00 {
|
||||
do_execsql_test json101-1.1.00 {
|
||||
SELECT json_array(1,2.5,null,'hello');
|
||||
} {[1,2.5,null,"hello"]}
|
||||
do_execsql_test json1-1.1.01 {
|
||||
do_execsql_test json101-1.1.01 {
|
||||
SELECT json_array(1,'{"abc":2.5,"def":null,"ghi":hello}',99);
|
||||
-- the second term goes in as a string:
|
||||
} {[1,"{\\"abc\\":2.5,\\"def\\":null,\\"ghi\\":hello}",99]}
|
||||
do_execsql_test json1-1.1.02 {
|
||||
do_execsql_test json101-1.1.02 {
|
||||
SELECT json_array(1,json('{"abc":2.5,"def":null,"ghi":"hello"}'),99);
|
||||
-- the second term goes in as JSON
|
||||
} {[1,{"abc":2.5,"def":null,"ghi":"hello"},99]}
|
||||
do_execsql_test json1-1.1.03 {
|
||||
do_execsql_test json101-1.1.03 {
|
||||
SELECT json_array(1,json_object('abc',2.5,'def',null,'ghi','hello'),99);
|
||||
-- the second term goes in as JSON
|
||||
} {[1,{"abc":2.5,"def":null,"ghi":"hello"},99]}
|
||||
do_execsql_test json1-1.2 {
|
||||
do_execsql_test json101-1.2 {
|
||||
SELECT hex(json_array('String "\ Test'));
|
||||
} {5B22537472696E67205C225C5C2054657374225D}
|
||||
do_catchsql_test json1-1.3 {
|
||||
SELECT json_array(1,2,x'abcd',3);
|
||||
do_catchsql_test json101-1.3 {
|
||||
SELECT json_array(1,printf('%.1000c','x'),x'abcd',3);
|
||||
} {1 {JSON cannot hold BLOB values}}
|
||||
do_execsql_test json1-1.4 {
|
||||
do_execsql_test json101-1.4 {
|
||||
SELECT json_array(-9223372036854775808,9223372036854775807,0,1,-1,
|
||||
0.0, 1.0, -1.0, -1e99, +2e100,
|
||||
'one','two','three',
|
||||
@@ -49,36 +49,41 @@ do_execsql_test json1-1.4 {
|
||||
99);
|
||||
} {[-9223372036854775808,9223372036854775807,0,1,-1,0.0,1.0,-1.0,-1.0e+99,2.0e+100,"one","two","three",4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,null,21,22,23,24,25,26,27,28,29,30,31,"abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwyxzABCDEFGHIJKLMNOPQRSTUVWXYZ",99]}
|
||||
|
||||
do_execsql_test json1-2.1 {
|
||||
do_execsql_test json101-2.1 {
|
||||
SELECT json_object('a',1,'b',2.5,'c',null,'d','String Test');
|
||||
} {{{"a":1,"b":2.5,"c":null,"d":"String Test"}}}
|
||||
do_catchsql_test json1-2.2 {
|
||||
SELECT json_object('a',1,2,2.5);
|
||||
do_catchsql_test json101-2.2 {
|
||||
SELECT json_object('a',printf('%.1000c','x'),2,2.5);
|
||||
} {1 {json_object() labels must be TEXT}}
|
||||
do_catchsql_test json1-2.3 {
|
||||
do_catchsql_test json101-2.3 {
|
||||
SELECT json_object('a',1,'b');
|
||||
} {1 {json_object() requires an even number of arguments}}
|
||||
do_catchsql_test json1-2.4 {
|
||||
SELECT json_object('a',1,'b',x'abcd');
|
||||
do_catchsql_test json101-2.4 {
|
||||
SELECT json_object('a',printf('%.1000c','x'),'b',x'abcd');
|
||||
} {1 {JSON cannot hold BLOB values}}
|
||||
|
||||
do_execsql_test json1-3.1 {
|
||||
do_execsql_test json101-3.1 {
|
||||
SELECT json_replace('{"a":1,"b":2}','$.a','[3,4,5]');
|
||||
} {{{"a":"[3,4,5]","b":2}}}
|
||||
do_execsql_test json1-3.2 {
|
||||
do_execsql_test json101-3.2 {
|
||||
SELECT json_replace('{"a":1,"b":2}','$.a',json('[3,4,5]'));
|
||||
} {{{"a":[3,4,5],"b":2}}}
|
||||
do_execsql_test json1-3.3 {
|
||||
do_execsql_test json101-3.3 {
|
||||
SELECT json_type(json_set('{"a":1,"b":2}','$.b','{"x":3,"y":4}'),'$.b');
|
||||
} {text}
|
||||
do_execsql_test json1-3.4 {
|
||||
do_execsql_test json101-3.4 {
|
||||
SELECT json_type(json_set('{"a":1,"b":2}','$.b',json('{"x":3,"y":4}')),'$.b');
|
||||
} {object}
|
||||
ifcapable vtab {
|
||||
do_execsql_test json101-3.5 {
|
||||
SELECT fullkey, atom, '|' FROM json_tree(json_set('{}','$.x',123,'$.x',456));
|
||||
} {{$} {} | {$.x} 456 |}
|
||||
}
|
||||
|
||||
# Per rfc7159, any JSON value is allowed at the top level, and whitespace
|
||||
# is permitting before and/or after that value.
|
||||
#
|
||||
do_execsql_test json1-4.1 {
|
||||
do_execsql_test json101-4.1 {
|
||||
CREATE TABLE j1(x);
|
||||
INSERT INTO j1(x)
|
||||
VALUES('true'),('false'),('null'),('123'),('-234'),('34.5e+6'),
|
||||
@@ -87,32 +92,32 @@ do_execsql_test json1-4.1 {
|
||||
('{"a":true,"b":{"c":false}}');
|
||||
SELECT * FROM j1 WHERE NOT json_valid(x);
|
||||
} {}
|
||||
do_execsql_test json1-4.2 {
|
||||
do_execsql_test json101-4.2 {
|
||||
SELECT * FROM j1 WHERE NOT json_valid(char(0x20,0x09,0x0a,0x0d)||x);
|
||||
} {}
|
||||
do_execsql_test json1-4.3 {
|
||||
do_execsql_test json101-4.3 {
|
||||
SELECT * FROM j1 WHERE NOT json_valid(x||char(0x20,0x09,0x0a,0x0d));
|
||||
} {}
|
||||
|
||||
# But an empty string, or a string of pure whitespace is not valid JSON.
|
||||
#
|
||||
do_execsql_test json1-4.4 {
|
||||
do_execsql_test json101-4.4 {
|
||||
SELECT json_valid(''), json_valid(char(0x20,0x09,0x0a,0x0d));
|
||||
} {0 0}
|
||||
|
||||
# json_remove() and similar functions with no edit operations return their
|
||||
# input unchanged.
|
||||
#
|
||||
do_execsql_test json1-4.5 {
|
||||
do_execsql_test json101-4.5 {
|
||||
SELECT x FROM j1 WHERE json_remove(x)<>x;
|
||||
} {}
|
||||
do_execsql_test json1-4.6 {
|
||||
do_execsql_test json101-4.6 {
|
||||
SELECT x FROM j1 WHERE json_replace(x)<>x;
|
||||
} {}
|
||||
do_execsql_test json1-4.7 {
|
||||
do_execsql_test json101-4.7 {
|
||||
SELECT x FROM j1 WHERE json_set(x)<>x;
|
||||
} {}
|
||||
do_execsql_test json1-4.8 {
|
||||
do_execsql_test json101-4.8 {
|
||||
SELECT x FROM j1 WHERE json_insert(x)<>x;
|
||||
} {}
|
||||
|
||||
@@ -302,6 +307,18 @@ do_execsql_test json-5.8 {
|
||||
WHERE jx.value<>jx.atom AND type NOT IN ('array','object');
|
||||
} {}
|
||||
|
||||
do_execsql_test json-6.1 {
|
||||
SELECT json_valid('{"a":55,"b":72,}');
|
||||
} {0}
|
||||
do_execsql_test json-6.2 {
|
||||
SELECT json_valid('{"a":55,"b":72}');
|
||||
} {1}
|
||||
do_execsql_test json-6.3 {
|
||||
SELECT json_valid('["a",55,"b",72,]');
|
||||
} {0}
|
||||
do_execsql_test json-6.4 {
|
||||
SELECT json_valid('["a",55,"b",72]');
|
||||
} {1}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -278,4 +278,20 @@ do_execsql_test json102-1132 {
|
||||
} {123}
|
||||
} ;# end ifcapable vtab
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Test that json_valid() correctly identifies non-ascii range
|
||||
# characters as non-whitespace.
|
||||
#
|
||||
do_execsql_test json102-1201 { SELECT json_valid(char(32) || '"xyz"') } 1
|
||||
do_execsql_test json102-1202 { SELECT json_valid(char(200) || '"xyz"') } 0
|
||||
|
||||
# Off-by-one error in jsonAppendString()
|
||||
#
|
||||
for {set i 0} {$i<100} {incr i} {
|
||||
set str abcdef[string repeat \" [expr {$i+50}]]uvwxyz
|
||||
do_test json102-[format %d [expr {$i+1300}]] {
|
||||
db eval {SELECT json_extract(json_array($::str),'$[0]')==$::str}
|
||||
} {1}
|
||||
}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -27,6 +27,16 @@ do_execsql_test setup {
|
||||
c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<100)
|
||||
INSERT INTO t1 SELECT x FROM c;
|
||||
}
|
||||
|
||||
# Some versions of TCL are unable to [lsort -int] for
|
||||
# 64-bit integers. So we write our own comparison
|
||||
# routine.
|
||||
proc bigintcompare {a b} {
|
||||
set x [expr {$a-$b}]
|
||||
if {$x<0} {return -1}
|
||||
if {$x>0} {return +1}
|
||||
return 0
|
||||
}
|
||||
do_test 1.0 {
|
||||
set l1 {}
|
||||
# If random() is only evaluated once and then reused for each row, then
|
||||
@@ -34,19 +44,19 @@ do_test 1.0 {
|
||||
# separately for the result set and the ORDER BY clause, then the output
|
||||
# order will be random.
|
||||
db eval {SELECT random() AS y FROM t1 ORDER BY 1;} {lappend l1 $y}
|
||||
expr {$l1==[lsort -int $l1]}
|
||||
expr {$l1==[lsort -command bigintcompare $l1]}
|
||||
} {1}
|
||||
|
||||
do_test 1.1 {
|
||||
set l1 {}
|
||||
db eval {SELECT random() AS y FROM t1 ORDER BY random();} {lappend l1 $y}
|
||||
expr {$l1==[lsort -int $l1]}
|
||||
expr {$l1==[lsort -command bigintcompare $l1]}
|
||||
} {1}
|
||||
|
||||
do_test 1.2 {
|
||||
set l1 {}
|
||||
db eval {SELECT random() AS y FROM t1 ORDER BY +random();} {lappend l1 $y}
|
||||
expr {$l1==[lsort -int $l1]}
|
||||
expr {$l1==[lsort -command bigintcompare $l1]}
|
||||
} {0}
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -297,6 +297,7 @@ proc PUTS {args} {
|
||||
puts [lindex $args 0]
|
||||
puts $::LOG [lindex $args 0]
|
||||
}
|
||||
flush $::LOG
|
||||
}
|
||||
puts $LOG "$argv0 $argv"
|
||||
set tm0 [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S} -gmt 1]
|
||||
|
||||
@@ -29,32 +29,35 @@ do_execsql_test 1.0 {
|
||||
|
||||
do_execsql_test 1.1 {
|
||||
SELECT word, distance, matchlen FROM demo
|
||||
WHERE word MATCH 'amstedam*' AND top=3;
|
||||
WHERE word MATCH 'amstedam*' AND top=3
|
||||
ORDER BY +word;
|
||||
} {
|
||||
amsterdam 100 9
|
||||
amsterdammetje 100 9
|
||||
amsterdamania 100 9
|
||||
amsterdammetje 100 9
|
||||
}
|
||||
|
||||
do_execsql_test 1.2 {
|
||||
SELECT word, distance, matchlen FROM demo WHERE
|
||||
word MATCH 'amstedam*' AND top=3 AND distance <= 100;
|
||||
word MATCH 'amstedam*' AND top=3 AND distance <= 100
|
||||
ORDER BY +word;
|
||||
} {
|
||||
amsterdam 100 9
|
||||
amsterdammetje 100 9
|
||||
amsterdamania 100 9
|
||||
amsterdammetje 100 9
|
||||
}
|
||||
|
||||
do_execsql_test 1.3 {
|
||||
SELECT word, distance, matchlen FROM demo WHERE
|
||||
word MATCH 'amstedam*' AND distance <= 100;
|
||||
word MATCH 'amstedam*' AND distance <= 100
|
||||
ORDER BY +word;
|
||||
} {
|
||||
amsterdam 100 9
|
||||
amsterdammetje 100 9
|
||||
amsterdamania 100 9
|
||||
amsterdamweg 100 9
|
||||
amsterdamsestraat 100 9
|
||||
amsterdamlaan 100 9
|
||||
amsterdammetje 100 9
|
||||
amsterdamsestraat 100 9
|
||||
amsterdamweg 100 9
|
||||
}
|
||||
|
||||
do_test 1.4 {
|
||||
@@ -111,4 +114,3 @@ do_execsql_test 1.7 {
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
|
||||
@@ -643,7 +643,8 @@ do_test sqllimits1-8.8 {
|
||||
for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {
|
||||
lappend cols "c$i"
|
||||
}
|
||||
catchsql "CREATE VIEW v1 AS SELECT [join $cols ,] FROM t1;"
|
||||
execsql "CREATE VIEW v1 AS SELECT [join $cols ,] FROM t1;"
|
||||
catchsql {SELECT * FROM v1}
|
||||
} {1 {too many columns in result set}}
|
||||
|
||||
do_test sqllimits1-8.9 {
|
||||
@@ -652,9 +653,12 @@ do_test sqllimits1-8.9 {
|
||||
for {set i 0} {$i < $SQLITE_LIMIT_COLUMN} {incr i} {
|
||||
lappend cols "c$i"
|
||||
}
|
||||
execsql {DROP VIEW IF EXISTS v1}
|
||||
catchsql "CREATE TABLE t2([join $cols ,])"
|
||||
catchsql "CREATE VIEW v1 AS SELECT *, c1 AS o FROM t2;"
|
||||
catchsql "SELECT * FROM v1"
|
||||
} {1 {too many columns in result set}}
|
||||
|
||||
do_test sqllimits1-8.10 {
|
||||
# ORDER BY columns
|
||||
set cols [list]
|
||||
|
||||
@@ -55,6 +55,21 @@ do_execsql_test tabfunc01-1.10 {
|
||||
SELECT rowid, * FROM generate_series(0,32,5) ORDER BY +value DESC;
|
||||
} {7 30 6 25 5 20 4 15 3 10 2 5 1 0}
|
||||
|
||||
do_execsql_test tabfunc01-1.20 {
|
||||
CREATE VIEW v1(a,b) AS VALUES(1,2),(3,4);
|
||||
SELECT * FROM v1;
|
||||
} {1 2 3 4}
|
||||
do_catchsql_test tabfunc01-1.21 {
|
||||
SELECT * FROM v1(55);
|
||||
} {1 {'v1' is not a function}}
|
||||
do_execsql_test tabfunc01-1.22 {
|
||||
CREATE VIEW v2(x) AS SELECT value FROM generate_series(1,5);
|
||||
SELECT * FROM v2;
|
||||
} {1 2 3 4 5}
|
||||
do_catchsql_test tabfunc01-1.23 {
|
||||
SELECT * FROM v2(55);
|
||||
} {1 {'v2' is not a function}}
|
||||
|
||||
do_execsql_test tabfunc01-2.1 {
|
||||
CREATE TABLE t1(x);
|
||||
INSERT INTO t1(x) VALUES(2),(3);
|
||||
|
||||
@@ -75,4 +75,12 @@ foreach {id sql} {
|
||||
} {1 {UNIQUE constraint failed: t1.y, t1.z}}
|
||||
}
|
||||
|
||||
do_catchsql_test 13.1 {
|
||||
CREATE TABLE err1(a,b,c,UNIQUE(rowid));
|
||||
} {1 {no such column: rowid}}
|
||||
do_catchsql_test 13.2 {
|
||||
CREATE TABLE err1(a,b,c,PRIMARY KEY(rowid));
|
||||
} {1 {no such column: rowid}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
@@ -34,10 +34,6 @@ db func a_string a_string
|
||||
# of test cases tests that nothing appears to go wrong when this is
|
||||
# done.
|
||||
#
|
||||
set ans 4056
|
||||
if {[info exists G(perm:name)] && $G(perm:name)=="memsubsys1"} {
|
||||
set ans 4251
|
||||
}
|
||||
do_test wal3-1.0 {
|
||||
execsql {
|
||||
PRAGMA cache_size = 2000;
|
||||
@@ -64,8 +60,12 @@ do_test wal3-1.0 {
|
||||
COMMIT;
|
||||
PRAGMA cache_size = 10;
|
||||
}
|
||||
wal_frame_count test.db-wal 1024
|
||||
} $ans
|
||||
set x [wal_frame_count test.db-wal 1024]
|
||||
if {$::G(perm:name)=="memsubsys1"} {
|
||||
if {$x==4251 || $x==4290} {set x 4056}
|
||||
}
|
||||
set x
|
||||
} 4056
|
||||
|
||||
for {set i 1} {$i < 50} {incr i} {
|
||||
|
||||
|
||||
@@ -113,5 +113,9 @@ do_execsql_test without_rowid6-520 {
|
||||
PRAGMA index_list(t1);
|
||||
} {/sqlite_autoindex_t1_1 1 pk/}
|
||||
|
||||
do_catchsql_test without_rowid6-600 {
|
||||
CREATE TABLE t6(a,b,c,PRIMARY KEY(a,rowid,b))WITHOUT ROWID;
|
||||
} {1 {no such column: rowid}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user