1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-19 21:43:15 +03:00

Merge the trunk changes for 3.8.6 beta3 into the sessions branch.

FossilOrigin-Name: d49455d9a972fc2224d9beb97165a998ca56e838
This commit is contained in:
drh
2014-08-13 14:43:32 +00:00
28 changed files with 422 additions and 210 deletions

View File

@@ -1175,9 +1175,9 @@ do_createtable_tests 4.2 -repair {
# EVIDENCE-OF: R-59124-61339 Each row in a table with a primary key must
# have a unique combination of values in its primary key columns.
#
# EVIDENCE-OF: R-39102-06737 If an INSERT or UPDATE statement attempts
# to modify the table content so that two or more rows feature identical
# primary key values, it is a constraint violation.
# EVIDENCE-OF: R-06471-16287 If an INSERT or UPDATE statement attempts
# to modify the table content so that two or more rows have identical
# primary key values, that is a constraint violation.
#
drop_all_tables
do_execsql_test 4.3.0 {

View File

@@ -450,7 +450,7 @@ do_execsql_test e_expr-10.3.4 { SELECT typeof('isn''t') } {text}
# containing hexadecimal data and preceded by a single "x" or "X"
# character.
#
# EVIDENCE-OF: R-39344-59787 For example: X'53514C697465'
# EVIDENCE-OF: R-19836-11244 Example: X'53514C697465'
#
do_execsql_test e_expr-10.4.1 { SELECT typeof(X'0123456789ABCDEF') } blob
do_execsql_test e_expr-10.4.2 { SELECT typeof(x'0123456789ABCDEF') } blob
@@ -1596,6 +1596,13 @@ do_expr_test e_expr-30.4.1 { CAST('' AS INTEGER) } integer 0
do_expr_test e_expr-30.4.2 { CAST('not a number' AS INTEGER) } integer 0
do_expr_test e_expr-30.4.3 { CAST('XXI' AS INTEGER) } integer 0
# EVIDENCE-OF: R-08980-53124 The CAST operator understands decimal
# integers only — conversion of hexadecimal integers stops at
# the "x" in the "0x" prefix of the hexadecimal integer string and thus
# result of the CAST is always zero.
do_expr_test e_expr-30.5.1 { CAST('0x1234' AS INTEGER) } integer 0
do_expr_test e_expr-30.5.2 { CAST('0X1234' AS INTEGER) } integer 0
# EVIDENCE-OF: R-02752-50091 A cast of a REAL value into an INTEGER
# results in the integer between the REAL value and zero that is closest
# to the REAL value.

View File

@@ -153,28 +153,38 @@ do_test func3-5.39 {
db eval {EXPLAIN SELECT unlikely(min(1.0+'2.0',4*11))}
} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
do_execsql_test func3-5.40 {
# EVIDENCE-OF: R-23735-03107 The likely(X) function returns the argument
# X unchanged.
#
do_execsql_test func3-5.50 {
SELECT likely(9223372036854775807);
} {9223372036854775807}
do_execsql_test func3-5.41 {
do_execsql_test func3-5.51 {
SELECT likely(-9223372036854775808);
} {-9223372036854775808}
do_execsql_test func3-5.42 {
do_execsql_test func3-5.52 {
SELECT likely(14.125);
} {14.125}
do_execsql_test func3-5.43 {
do_execsql_test func3-5.53 {
SELECT likely(NULL);
} {{}}
do_execsql_test func3-5.44 {
do_execsql_test func3-5.54 {
SELECT likely('test-string');
} {test-string}
do_execsql_test func3-5.45 {
do_execsql_test func3-5.55 {
SELECT quote(likely(x'010203000405'));
} {X'010203000405'}
do_test func3-5.49 {
# EVIDENCE-OF: R-43464-09689 The likely(X) function is a no-op that the
# code generator optimizes away so that it consumes no CPU cycles at
# run-time (that is, during calls to sqlite3_step()).
#
do_test func3-5.59 {
db eval {EXPLAIN SELECT likely(min(1.0+'2.0',4*11))}
} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
finish_test

View File

@@ -14,6 +14,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix incrblob_err
ifcapable {!incrblob || !memdebug || !tclvar} {
finish_test

View File

@@ -20,6 +20,7 @@
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set ::testprefix malloc
# Only run these tests if memory debugging is turned on.

43
test/mallocL.test Normal file
View File

@@ -0,0 +1,43 @@
# 2014 August 12
#
# 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 test script is designed to show that the assert() fix at
# [f1cb48f412] really is required.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/malloc_common.tcl
set testprefix mallocL
do_test 1.0 {
for {set i 0} {$i < 40} {incr i} {
lappend cols "c$i"
lappend vals $i
}
execsql "CREATE TABLE t1([join $cols ,])"
execsql "CREATE INDEX i1 ON t1([join $cols ,])"
execsql "INSERT INTO t1 VALUES([join $vals ,])"
} {}
for {set j 1} {$j < 40} {incr j} {
set ::sql "SELECT DISTINCT [join [lrange $cols 0 $j] ,] FROM t1"
do_faultsim_test 1.$j -faults oom* -body {
execsql $::sql
} -test {
faultsim_test_result [list 0 [lrange $::vals 0 $::j]]
}
}
finish_test

View File

@@ -409,6 +409,7 @@ proc do_malloc_test {tn args} {
if {[string is integer $tn]} {
set tn malloc-$tn
catch { set tn $::testprefix-$tn }
}
if {[info exists ::mallocopts(-start)]} {
set start $::mallocopts(-start)

View File

@@ -176,6 +176,12 @@ array set ::Configs {
-DSQLITE_DISABLE_FTS4_DEFERRED
-DSQLITE_ENABLE_RTREE
}
"No-lookaside" {
-DSQLITE_TEST_REALLOC_STRESS=1
-DSQLITE_OMIT_LOOKASIDE=1
-DHAVE_USLEEP=1
}
}
array set ::Platforms {
@@ -188,6 +194,7 @@ array set ::Platforms {
"Extra-Robustness" test
"Device-Two" test
"Ftrapv" test
"No-lookaside" test
"Default" "threadtest test"
"Device-One" fulltest
}

View File

@@ -781,7 +781,12 @@ do_test where9-6.8.2 {
OR (b NOT NULL AND c NOT NULL AND d IS NULL)
}
} {1 {no query solution}}
set solution_possible 0
ifcapable stat4||stat3 {
if {[permutation] != "no_optimization"} { set solution_possible 1 }
}
if $solution_possible {
# When STAT3 is enabled, the "b NOT NULL" terms get translated
# into b>NULL, which can be satified by the index t1b. It is a very
# expensive way to do the query, but it works, and so a solution is possible.

View File

@@ -9,7 +9,7 @@
#
#***********************************************************************
#
# This file implements a single regression test for a complex
# This file implements regression tests for a complex
# query planning case.
#
@@ -328,4 +328,48 @@ do_execsql_test whereJ-1.4 {
GROUP BY aid;
} {/B-TREE/}
############################################################################
# Ensure that the sorting cost does not swamp the loop costs and cause
# distinctions between individual loop costs to get lost, and hence for
# sub-optimal loops to be chosen.
#
do_execsql_test whereJ-2.1 {
CREATE TABLE tab(
id INTEGER PRIMARY KEY,
minChild INTEGER REFERENCES t1,
maxChild INTEGER REFERENCES t1,
x INTEGER
);
EXPLAIN QUERY PLAN
SELECT t4.x
FROM tab AS t0, tab AS t1, tab AS t2, tab AS t3, tab AS t4
WHERE t0.id=0
AND t1.id BETWEEN t0.minChild AND t0.maxChild
AND t2.id BETWEEN t1.minChild AND t1.maxChild
AND t3.id BETWEEN t2.minChild AND t2.maxChild
AND t4.id BETWEEN t3.minChild AND t3.maxChild
ORDER BY t4.x;
} {~/SCAN/}
do_execsql_test whereJ-2.2 {
EXPLAIN QUERY PLAN
SELECT t4.x
FROM tab AS t0a, tab AS t0b,
tab AS t1a, tab AS t1b,
tab AS t2a, tab AS t2b,
tab AS t3a, tab AS t3b,
tab AS t4
WHERE 1
AND t0a.id=1
AND t1a.id BETWEEN t0a.minChild AND t0a.maxChild
AND t2a.id BETWEEN t1a.minChild AND t1a.maxChild
AND t3a.id BETWEEN t2a.minChild AND t2a.maxChild
AND t0b.id=2
AND t1b.id BETWEEN t0b.minChild AND t0b.maxChild
AND t2b.id BETWEEN t1b.minChild AND t1b.maxChild
AND t3b.id BETWEEN t2b.minChild AND t2b.maxChild
AND t4.id BETWEEN t3a.minChild AND t3b.maxChild
ORDER BY t4.x;
} {~/SCAN/}
finish_test