OLD | NEW |
1 # 2002 May 24 | 1 # 2002 May 24 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 18 matching lines...) Expand all Loading... |
29 do_test join-1.2 { | 29 do_test join-1.2 { |
30 execsql { | 30 execsql { |
31 CREATE TABLE t2(b,c,d); | 31 CREATE TABLE t2(b,c,d); |
32 INSERT INTO t2 VALUES(1,2,3); | 32 INSERT INTO t2 VALUES(1,2,3); |
33 INSERT INTO t2 VALUES(2,3,4); | 33 INSERT INTO t2 VALUES(2,3,4); |
34 INSERT INTO t2 VALUES(3,4,5); | 34 INSERT INTO t2 VALUES(3,4,5); |
35 SELECT * FROM t2; | 35 SELECT * FROM t2; |
36 } | 36 } |
37 } {1 2 3 2 3 4 3 4 5} | 37 } {1 2 3 2 3 4 3 4 5} |
38 | 38 |
| 39 # A FROM clause of the form: "<table>, <table> ON <expr>" is not |
| 40 # allowed by the SQLite syntax diagram, nor by any other SQL database |
| 41 # engine that we are aware of. Nevertheless, historic versions of |
| 42 # SQLite have allowed it. We need to continue to support it moving |
| 43 # forward to prevent breakage of legacy applications. Though, we will |
| 44 # not advertise it as being supported. |
| 45 # |
| 46 do_execsql_test join-1.2.1 { |
| 47 SELECT t1.rowid, t2.rowid, '|' FROM t1, t2 ON t1.a=t2.b; |
| 48 } {1 1 | 2 2 | 3 3 |} |
| 49 |
39 do_test join-1.3 { | 50 do_test join-1.3 { |
40 execsql2 { | 51 execsql2 { |
41 SELECT * FROM t1 NATURAL JOIN t2; | 52 SELECT * FROM t1 NATURAL JOIN t2; |
42 } | 53 } |
43 } {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5} | 54 } {a 1 b 2 c 3 d 4 a 2 b 3 c 4 d 5} |
44 do_test join-1.3.1 { | 55 do_test join-1.3.1 { |
45 execsql2 { | 56 execsql2 { |
46 SELECT * FROM t2 NATURAL JOIN t1; | 57 SELECT * FROM t2 NATURAL JOIN t1; |
47 } | 58 } |
48 } {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2} | 59 } {b 2 c 3 d 4 a 1 b 3 c 4 d 5 a 2} |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 INSERT INTO t2 VALUES(2, 'two'); | 645 INSERT INTO t2 VALUES(2, 'two'); |
635 } | 646 } |
636 } {} | 647 } {} |
637 do_test join-11.9 { | 648 do_test join-11.9 { |
638 execsql { SELECT * FROM t1 NATURAL JOIN t2 } | 649 execsql { SELECT * FROM t1 NATURAL JOIN t2 } |
639 } {one 1.0 two 2} | 650 } {one 1.0 two 2} |
640 do_test join-11.10 { | 651 do_test join-11.10 { |
641 execsql { SELECT * FROM t2 NATURAL JOIN t1 } | 652 execsql { SELECT * FROM t2 NATURAL JOIN t1 } |
642 } {1 one 2 two} | 653 } {1 one 2 two} |
643 | 654 |
| 655 #------------------------------------------------------------------------- |
| 656 # Test that at most 64 tables are allowed in a join. |
| 657 # |
| 658 do_execsql_test join-12.1 { |
| 659 CREATE TABLE t14(x); |
| 660 INSERT INTO t14 VALUES('abcdefghij'); |
| 661 } |
| 662 |
| 663 proc jointest {tn nTbl res} { |
| 664 set sql "SELECT 1 FROM [string repeat t14, [expr $nTbl-1]] t14;" |
| 665 uplevel [list do_catchsql_test $tn $sql $res] |
| 666 } |
| 667 |
| 668 jointest join-12.2 30 {0 1} |
| 669 jointest join-12.3 63 {0 1} |
| 670 jointest join-12.4 64 {0 1} |
| 671 jointest join-12.5 65 {1 {at most 64 tables in a join}} |
| 672 jointest join-12.6 66 {1 {at most 64 tables in a join}} |
| 673 jointest join-12.7 127 {1 {at most 64 tables in a join}} |
| 674 jointest join-12.8 128 {1 {at most 64 tables in a join}} |
| 675 jointest join-12.9 1000 {1 {at most 64 tables in a join}} |
| 676 |
| 677 # If SQLite is built with SQLITE_MEMDEBUG, then the huge number of realloc() |
| 678 # calls made by the following test cases are too time consuming to run. |
| 679 # Without SQLITE_MEMDEBUG, realloc() is fast enough that these are not |
| 680 # a problem. |
| 681 ifcapable pragma&&compileoption_diags { |
| 682 if {[lsearch [db eval {PRAGMA compile_options}] MEMDEBUG]<0} { |
| 683 jointest join-12.10 65534 {1 {at most 64 tables in a join}} |
| 684 jointest join-12.11 65535 {1 {too many references to "t14": max 65535}} |
| 685 jointest join-12.12 65536 {1 {too many references to "t14": max 65535}} |
| 686 jointest join-12.13 65537 {1 {too many references to "t14": max 65535}} |
| 687 } |
| 688 } |
| 689 |
644 finish_test | 690 finish_test |
OLD | NEW |