Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Side by Side Diff: third_party/sqlite/src/test/e_expr.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/e_dropview.test ('k') | third_party/sqlite/src/test/e_fkey.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2010 July 16 1 # 2010 July 16
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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 # only evaluated once. 840 # only evaluated once.
841 # 841 #
842 db func x x 842 db func x x
843 proc x {} { incr ::xcount ; return [expr $::x] } 843 proc x {} { incr ::xcount ; return [expr $::x] }
844 foreach {tn x expr res nEval} { 844 foreach {tn x expr res nEval} {
845 1 10 "x() >= 5 AND x() <= 15" 1 2 845 1 10 "x() >= 5 AND x() <= 15" 1 2
846 2 10 "x() BETWEEN 5 AND 15" 1 1 846 2 10 "x() BETWEEN 5 AND 15" 1 1
847 847
848 3 5 "x() >= 5 AND x() <= 5" 1 2 848 3 5 "x() >= 5 AND x() <= 5" 1 2
849 4 5 "x() BETWEEN 5 AND 5" 1 1 849 4 5 "x() BETWEEN 5 AND 5" 1 1
850
851 5 9 "(x(),8) >= (9,7) AND (x(),8)<=(9,10)" 1 2
852 6 9 "(x(),8) BETWEEN (9,7) AND (9,10)" 1 1
850 } { 853 } {
851 do_test e_expr-13.1.$tn { 854 do_test e_expr-13.1.$tn {
852 set ::xcount 0 855 set ::xcount 0
853 set a [execsql "SELECT $expr"] 856 set a [execsql "SELECT $expr"]
854 list $::xcount $a 857 list $::xcount $a
855 } [list $nEval $res] 858 } [list $nEval $res]
856 } 859 }
857 860
858 # EVIDENCE-OF: R-05155-34454 The precedence of the BETWEEN operator is 861 # EVIDENCE-OF: R-05155-34454 The precedence of the BETWEEN operator is
859 # the same as the precedence as operators == and != and LIKE and groups 862 # the same as the precedence as operators == and != and LIKE and groups
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 } {text UVU real 1.23 integer 4} 1430 } {text UVU real 1.23 integer 4}
1428 1431
1429 # EVIDENCE-OF: R-32434-09092 If the value of expr is NULL, then the 1432 # EVIDENCE-OF: R-32434-09092 If the value of expr is NULL, then the
1430 # result of the CAST expression is also NULL. 1433 # result of the CAST expression is also NULL.
1431 # 1434 #
1432 do_expr_test e_expr-27.2.1 { CAST(NULL AS integer) } null {} 1435 do_expr_test e_expr-27.2.1 { CAST(NULL AS integer) } null {}
1433 do_expr_test e_expr-27.2.2 { CAST(NULL AS text) } null {} 1436 do_expr_test e_expr-27.2.2 { CAST(NULL AS text) } null {}
1434 do_expr_test e_expr-27.2.3 { CAST(NULL AS blob) } null {} 1437 do_expr_test e_expr-27.2.3 { CAST(NULL AS blob) } null {}
1435 do_expr_test e_expr-27.2.4 { CAST(NULL AS number) } null {} 1438 do_expr_test e_expr-27.2.4 { CAST(NULL AS number) } null {}
1436 1439
1440 # EVIDENCE-OF: R-29283-15561 Otherwise, the storage class of the result
1441 # is determined by applying the rules for determining column affinity to
1442 # the type-name.
1443 #
1444 # The R-29283-15561 requirement above is demonstrated by all of the
1445 # subsequent e_expr-26 tests.
1446 #
1437 # EVIDENCE-OF: R-43522-35548 Casting a value to a type-name with no 1447 # EVIDENCE-OF: R-43522-35548 Casting a value to a type-name with no
1438 # affinity causes the value to be converted into a BLOB. 1448 # affinity causes the value to be converted into a BLOB.
1439 # 1449 #
1440 do_expr_test e_expr-27.3.1 { CAST('abc' AS blob) } blob abc 1450 do_expr_test e_expr-27.3.1 { CAST('abc' AS blob) } blob abc
1441 do_expr_test e_expr-27.3.2 { CAST('def' AS shobblob_x) } blob def 1451 do_expr_test e_expr-27.3.2 { CAST('def' AS shobblob_x) } blob def
1442 do_expr_test e_expr-27.3.3 { CAST('ghi' AS abbLOb10) } blob ghi 1452 do_expr_test e_expr-27.3.3 { CAST('ghi' AS abbLOb10) } blob ghi
1443 1453
1444 # EVIDENCE-OF: R-22956-37754 Casting to a BLOB consists of first casting 1454 # EVIDENCE-OF: R-22956-37754 Casting to a BLOB consists of first casting
1445 # the value to TEXT in the encoding of the database connection, then 1455 # the value to TEXT in the encoding of the database connection, then
1446 # interpreting the resulting byte sequence as a BLOB instead of as TEXT. 1456 # interpreting the resulting byte sequence as a BLOB instead of as TEXT.
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 sqlite3 db test.db 1786 sqlite3 db test.db
1777 do_test e_expr-35.0 { 1787 do_test e_expr-35.0 {
1778 execsql { 1788 execsql {
1779 CREATE TABLE t2(a, b); 1789 CREATE TABLE t2(a, b);
1780 INSERT INTO t2 VALUES('one', 'two'); 1790 INSERT INTO t2 VALUES('one', 'two');
1781 INSERT INTO t2 VALUES('three', NULL); 1791 INSERT INTO t2 VALUES('three', NULL);
1782 INSERT INTO t2 VALUES(4, 5.0); 1792 INSERT INTO t2 VALUES(4, 5.0);
1783 } 1793 }
1784 } {} 1794 } {}
1785 1795
1786 # EVIDENCE-OF: R-00980-39256 A SELECT statement enclosed in parentheses 1796 # EVIDENCE-OF: R-43573-23448 A SELECT statement enclosed in parentheses
1787 # may appear as a scalar quantity. 1797 # is a subquery.
1788 # 1798 #
1789 # EVIDENCE-OF: R-56294-03966 All types of SELECT statement, including 1799 # EVIDENCE-OF: R-56294-03966 All types of SELECT statement, including
1790 # aggregate and compound SELECT queries (queries with keywords like 1800 # aggregate and compound SELECT queries (queries with keywords like
1791 # UNION or EXCEPT) are allowed as scalar subqueries. 1801 # UNION or EXCEPT) are allowed as scalar subqueries.
1792 # 1802 #
1793 do_expr_test e_expr-35.1.1 { (SELECT 35) } integer 35 1803 do_expr_test e_expr-35.1.1 { (SELECT 35) } integer 35
1794 do_expr_test e_expr-35.1.2 { (SELECT NULL) } null {} 1804 do_expr_test e_expr-35.1.2 { (SELECT NULL) } null {}
1795 1805
1796 do_expr_test e_expr-35.1.3 { (SELECT count(*) FROM t2) } integer 3 1806 do_expr_test e_expr-35.1.3 { (SELECT count(*) FROM t2) } integer 3
1797 do_expr_test e_expr-35.1.4 { (SELECT 4 FROM t2) } integer 4 1807 do_expr_test e_expr-35.1.4 { (SELECT 4 FROM t2) } integer 4
1798 1808
1799 do_expr_test e_expr-35.1.5 { 1809 do_expr_test e_expr-35.1.5 {
1800 (SELECT b FROM t2 UNION SELECT a+1 FROM t2) 1810 (SELECT b FROM t2 UNION SELECT a+1 FROM t2)
1801 } null {} 1811 } null {}
1802 do_expr_test e_expr-35.1.6 { 1812 do_expr_test e_expr-35.1.6 {
1803 (SELECT a FROM t2 UNION SELECT COALESCE(b, 55) FROM t2 ORDER BY 1) 1813 (SELECT a FROM t2 UNION SELECT COALESCE(b, 55) FROM t2 ORDER BY 1)
1804 } integer 4 1814 } integer 4
1805 1815
1806 # EVIDENCE-OF: R-46899-53765 A SELECT used as a scalar quantity must 1816 # EVIDENCE-OF: R-22239-33740 A subquery that returns two or more columns
1807 # return a result set with a single column. 1817 # is a row value subquery and can only be used as the operand of a
1818 # comparison operator.
1808 # 1819 #
1809 # The following block tests that errors are returned in a bunch of cases 1820 # The following block tests that errors are returned in a bunch of cases
1810 # where a subquery returns more than one column. 1821 # where a subquery returns more than one column.
1811 # 1822 #
1812 set M {only a single result allowed for a SELECT that is part of an expression} 1823 set M {/1 {sub-select returns [23] columns - expected 1}/}
1813 foreach {tn sql} { 1824 foreach {tn sql} {
1814 1 { SELECT (SELECT * FROM t2 UNION SELECT a+1, b+1 FROM t2) } 1825 1 { SELECT (SELECT * FROM t2 UNION SELECT a+1, b+1 FROM t2) }
1815 2 { SELECT (SELECT * FROM t2 UNION SELECT a+1, b+1 FROM t2 ORDER BY 1) } 1826 2 { SELECT (SELECT * FROM t2 UNION SELECT a+1, b+1 FROM t2 ORDER BY 1) }
1816 3 { SELECT (SELECT 1, 2) } 1827 3 { SELECT (SELECT 1, 2) }
1817 4 { SELECT (SELECT NULL, NULL, NULL) } 1828 4 { SELECT (SELECT NULL, NULL, NULL) }
1818 5 { SELECT (SELECT * FROM t2) } 1829 5 { SELECT (SELECT * FROM t2) }
1819 6 { SELECT (SELECT * FROM (SELECT 1, 2, 3)) } 1830 6 { SELECT (SELECT * FROM (SELECT 1, 2, 3)) }
1820 } { 1831 } {
1821 do_catchsql_test e_expr-35.2.$tn $sql [list 1 $M] 1832 do_catchsql_test e_expr-35.2.$tn $sql $M
1822 } 1833 }
1823 1834
1824 # EVIDENCE-OF: R-35764-28041 The result of the expression is the value 1835 # EVIDENCE-OF: R-18318-14995 The value of a subquery expression is the
1825 # of the only column in the first row returned by the SELECT statement. 1836 # first row of the result from the enclosed SELECT statement.
1826 # 1837 #
1827 # EVIDENCE-OF: R-41898-06686 If the SELECT yields more than one result 1838 # EVIDENCE-OF: R-15900-52156 In other words, an implied "LIMIT 1" is
1828 # row, all rows after the first are ignored. 1839 # added to the subquery, overriding an explicitly coded LIMIT.
1829 # 1840 #
1830 do_execsql_test e_expr-36.3.1 { 1841 do_execsql_test e_expr-36.3.1 {
1831 CREATE TABLE t4(x, y); 1842 CREATE TABLE t4(x, y);
1832 INSERT INTO t4 VALUES(1, 'one'); 1843 INSERT INTO t4 VALUES(1, 'one');
1833 INSERT INTO t4 VALUES(2, 'two'); 1844 INSERT INTO t4 VALUES(2, 'two');
1834 INSERT INTO t4 VALUES(3, 'three'); 1845 INSERT INTO t4 VALUES(3, 'three');
1835 } {} 1846 } {}
1836 1847
1837 foreach {tn expr restype resval} { 1848 foreach {tn expr restype resval} {
1838 2 { ( SELECT x FROM t4 ORDER BY x ) } integer 1 1849 2 { ( SELECT x FROM t4 ORDER BY x ) } integer 1
1839 3 { ( SELECT x FROM t4 ORDER BY y ) } integer 1 1850 3 { ( SELECT x FROM t4 ORDER BY y ) } integer 1
1840 4 { ( SELECT x FROM t4 ORDER BY x DESC ) } integer 3 1851 4 { ( SELECT x FROM t4 ORDER BY x DESC ) } integer 3
1841 5 { ( SELECT x FROM t4 ORDER BY y DESC ) } integer 2 1852 5 { ( SELECT x FROM t4 ORDER BY y DESC ) } integer 2
1842 6 { ( SELECT y FROM t4 ORDER BY y DESC ) } text two 1853 6 { ( SELECT y FROM t4 ORDER BY y DESC ) } text two
1843 1854
1844 7 { ( SELECT sum(x) FROM t4 ) } integer 6 1855 7 { ( SELECT sum(x) FROM t4 ) } integer 6
1845 8 { ( SELECT group_concat(y,'') FROM t4 ) } text onetwothree 1856 8 { ( SELECT group_concat(y,'') FROM t4 ) } text onetwothree
1846 9 { ( SELECT max(x) FROM t4 WHERE y LIKE '___') } integer 2 1857 9 { ( SELECT max(x) FROM t4 WHERE y LIKE '___') } integer 2
1847 1858
1848 } { 1859 } {
1849 do_expr_test e_expr-36.3.$tn $expr $restype $resval 1860 do_expr_test e_expr-36.3.$tn $expr $restype $resval
1850 } 1861 }
1851 1862
1852 # EVIDENCE-OF: R-25492-41572 If the SELECT yields no rows, then the 1863 # EVIDENCE-OF: R-52325-25449 The value of a subquery expression is NULL
1853 # value of the expression is NULL. 1864 # if the enclosed SELECT statement returns no rows.
1854 # 1865 #
1855 foreach {tn expr} { 1866 foreach {tn expr} {
1856 1 { ( SELECT x FROM t4 WHERE x>3 ORDER BY x ) } 1867 1 { ( SELECT x FROM t4 WHERE x>3 ORDER BY x ) }
1857 2 { ( SELECT x FROM t4 WHERE y<'one' ORDER BY y ) } 1868 2 { ( SELECT x FROM t4 WHERE y<'one' ORDER BY y ) }
1858 } { 1869 } {
1859 do_expr_test e_expr-36.4.$tn $expr null {} 1870 do_expr_test e_expr-36.4.$tn $expr null {}
1860 } 1871 }
1861 1872
1862 # EVIDENCE-OF: R-62477-06476 For example, the values NULL, 0.0, 0, 1873 # EVIDENCE-OF: R-62477-06476 For example, the values NULL, 0.0, 0,
1863 # 'english' and '0' are all considered to be false. 1874 # 'english' and '0' are all considered to be false.
(...skipping 28 matching lines...) Expand all
1892 } {true} 1903 } {true}
1893 do_execsql_test e_expr-37.9 { 1904 do_execsql_test e_expr-37.9 {
1894 SELECT CASE WHEN -0.1 THEN 'true' ELSE 'false' END; 1905 SELECT CASE WHEN -0.1 THEN 'true' ELSE 'false' END;
1895 } {true} 1906 } {true}
1896 do_execsql_test e_expr-37.10 { 1907 do_execsql_test e_expr-37.10 {
1897 SELECT CASE WHEN '1english' THEN 'true' ELSE 'false' END; 1908 SELECT CASE WHEN '1english' THEN 'true' ELSE 'false' END;
1898 } {true} 1909 } {true}
1899 1910
1900 1911
1901 finish_test 1912 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/e_dropview.test ('k') | third_party/sqlite/src/test/e_fkey.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698