From 569c6676a6ddb0ff73821d7693b5e18ddef809b9 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 16 Oct 2014 22:51:35 -0400 Subject: Imported Upstream version 3.2.0 --- test/join.test | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'test/join.test') diff --git a/test/join.test b/test/join.test index 88ac04f..4c83fa6 100644 --- a/test/join.test +++ b/test/join.test @@ -36,6 +36,17 @@ do_test join-1.2 { } } {1 2 3 2 3 4 3 4 5} +# A FROM clause of the form: ",
ON " is not +# allowed by the SQLite syntax diagram, nor by any other SQL database +# engine that we are aware of. Nevertheless, historic versions of +# SQLite have allowed it. We need to continue to support it moving +# forward to prevent breakage of legacy applications. Though, we will +# not advertise it as being supported. +# +do_execsql_test join-1.2.1 { + SELECT t1.rowid, t2.rowid, '|' FROM t1, t2 ON t1.a=t2.b; +} {1 1 | 2 2 | 3 3 |} + do_test join-1.3 { execsql2 { SELECT * FROM t1 NATURAL JOIN t2; @@ -641,4 +652,39 @@ do_test join-11.10 { execsql { SELECT * FROM t2 NATURAL JOIN t1 } } {1 one 2 two} +#------------------------------------------------------------------------- +# Test that at most 64 tables are allowed in a join. +# +do_execsql_test join-12.1 { + CREATE TABLE t14(x); + INSERT INTO t14 VALUES('abcdefghij'); +} + +proc jointest {tn nTbl res} { + set sql "SELECT 1 FROM [string repeat t14, [expr $nTbl-1]] t14;" + uplevel [list do_catchsql_test $tn $sql $res] +} + +jointest join-12.2 30 {0 1} +jointest join-12.3 63 {0 1} +jointest join-12.4 64 {0 1} +jointest join-12.5 65 {1 {at most 64 tables in a join}} +jointest join-12.6 66 {1 {at most 64 tables in a join}} +jointest join-12.7 127 {1 {at most 64 tables in a join}} +jointest join-12.8 128 {1 {at most 64 tables in a join}} +jointest join-12.9 1000 {1 {at most 64 tables in a join}} + +# If SQLite is built with SQLITE_MEMDEBUG, then the huge number of realloc() +# calls made by the following test cases are too time consuming to run. +# Without SQLITE_MEMDEBUG, realloc() is fast enough that these are not +# a problem. +ifcapable pragma&&compileoption_diags { + if {[lsearch [db eval {PRAGMA compile_options}] MEMDEBUG]<0} { + jointest join-12.10 65534 {1 {at most 64 tables in a join}} + jointest join-12.11 65535 {1 {too many references to "t14": max 65535}} + jointest join-12.12 65536 {1 {too many references to "t14": max 65535}} + jointest join-12.13 65537 {1 {too many references to "t14": max 65535}} + } +} + finish_test -- cgit v1.2.3