Remove unused code. Test coverage enhancements. Modify the algorithm used

to select column names for VIEWs of joins so that the constructed column
names omits the underlying table names. (CVS 5386)

FossilOrigin-Name: 636cd723296a8b1709011fdd99b236ffddf3f1b0
This commit is contained in:
drh
2008-07-10 00:32:42 +00:00
parent af005fbc13
commit 93a960a0a8
20 changed files with 167 additions and 395 deletions
+16 -2
View File
@@ -13,7 +13,7 @@
# focus of this script is making sure that the names of collation
# sequences may be quoted using double quotes in SQL statements.
#
# $Id: collate9.test,v 1.1 2007/11/12 09:50:26 danielk1977 Exp $
# $Id: collate9.test,v 1.2 2008/07/10 00:32:42 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -105,6 +105,11 @@ do_test collate9-2.5 {
SELECT y FROM xy ORDER BY y COLLATE "reverse sort"
}
} {two three one}
do_test collate9-2.6 {
execsql {
SELECT y COLLATE "reverse sort" AS aaa FROM xy ORDER BY aaa
}
} {two three one}
do_test collate9-3.1 {
execsql {
@@ -121,6 +126,16 @@ do_test collate9-3.3 {
SELECT y FROM xy ORDER BY y COLLATE "reverse sort"
}
} {two three one nosort}
do_test collate9-3.4 {
cksort {
SELECT y AS aaa FROM xy ORDER BY aaa
}
} {one three two sort}
do_test collate9-3.5 {
cksort {
SELECT y COLLATE "reverse sort" AS aaa FROM xy ORDER BY aaa
}
} {two three one nosort}
ifcapable reindex {
do_test collate9-4.1 {
@@ -161,4 +176,3 @@ ifcapable reindex {
}
finish_test
+26 -1
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the SELECT statement.
#
# $Id: select1.test,v 1.62 2008/07/09 01:39:44 drh Exp $
# $Id: select1.test,v 1.63 2008/07/10 00:32:42 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -533,6 +533,26 @@ do_test select1-6.9.5 {
SELECT 123.45;
}
} {123.45 123.45}
do_test select1-6.9.6 {
execsql2 {
SELECT * FROM test1 a, test1 b LIMIT 1
}
} {a.f1 11 a.f2 22 b.f1 11 b.f2 22}
do_test select1-6.9.7 {
set x [execsql2 {
SELECT * FROM test1 a, (select 5, 6) LIMIT 1
}]
regsub -all {subquery_[0-9a-fA-F]+_} $x {subquery} x
set x
} {a.f1 11 a.f2 22 sqlite_subquery.5 5 sqlite_subquery.6 6}
do_test select1-6.9.8 {
set x [execsql2 {
SELECT * FROM test1 a, (select 5 AS x, 6 AS y) AS b LIMIT 1
}]
regsub -all {subquery_[0-9a-fA-F]+_} $x {subquery} x
set x
} {a.f1 11 a.f2 22 b.x 5 b.y 6}
db eval {
PRAGMA short_column_names=ON;
PRAGMA full_column_names=OFF;
@@ -754,6 +774,11 @@ do_test select1-10.6 {
SELECT f1-22 AS x, f2-22 as y FROM test1 WHERE x>0 AND y<50
}
} {11 22}
do_test select1-10.7 {
execsql {
SELECT f1 COLLATE nocase AS x FROM test1 ORDER BY x
}
} {11 33}
# Check the ability to specify "TABLE.*" in the result set of a SELECT
#
+21 -1
View File
@@ -12,7 +12,7 @@
# This file contains tests to verify that the limits defined in
# sqlite source file limits.h are enforced.
#
# $Id: sqllimits1.test,v 1.29 2008/07/08 15:26:50 drh Exp $
# $Id: sqllimits1.test,v 1.30 2008/07/10 00:32:42 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -625,6 +625,26 @@ do_test sqllimits1-8.9 {
catchsql "CREATE TABLE t2([join $cols ,])"
catchsql "CREATE VIEW v1 AS SELECT *, c1 AS o FROM t2;"
} {1 {too many columns in result set}}
do_test sqllimits1-8.10 {
# ORDER BY columns
set cols [list]
for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {
lappend cols c
}
set sql "SELECT c FROM t1 ORDER BY [join $cols ,]"
catchsql $sql
} {1 {too many terms in ORDER BY clause}}
do_test sqllimits1-8.11 {
# ORDER BY columns
set cols [list]
for {set i 0} {$i <= $SQLITE_LIMIT_COLUMN} {incr i} {
lappend cols [expr {$i%3 + 1}]
}
set sql "SELECT c, c+1, c+2 FROM t1 UNION SELECT c-1, c-2, c-3 FROM t1"
append sql " ORDER BY [join $cols ,]"
catchsql $sql
} {1 {too many terms in ORDER BY clause}}
#--------------------------------------------------------------------
# These tests - sqllimits1-9.* - test that the SQLITE_LIMIT_EXPR_DEPTH
+3 -3
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this script is testing correlated subqueries
#
# $Id: subquery.test,v 1.15 2007/09/18 16:53:53 drh Exp $
# $Id: subquery.test,v 1.16 2008/07/10 00:32:42 drh Exp $
#
set testdir [file dirname $argv0]
@@ -127,7 +127,7 @@ do_test subquery-1.10.4 {
INSERT INTO t5 VALUES(25, '2003-3');
INSERT INTO t5 VALUES(5, '2003-4');
SELECT "a.period", vsum
SELECT period, vsum
FROM (SELECT
a.period,
(select sum(val) from t5 where period between a.period and '2002-4') vsum
@@ -137,7 +137,7 @@ do_test subquery-1.10.4 {
} {2002-2 30 2002-3 25 2002-4 15}
do_test subquery-1.10.5 {
execsql {
SELECT "a.period", vsum from
SELECT period, vsum from
(select a.period,
(select sum(val) from t5 where period between a.period and '2002-4') vsum
FROM t5 a where a.period between '2002-1' and '2002-4')
+8 -2
View File
@@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing VIEW statements.
#
# $Id: view.test,v 1.36 2008/06/30 18:12:28 danielk1977 Exp $
# $Id: view.test,v 1.37 2008/07/10 00:32:42 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@@ -139,13 +139,19 @@ do_test view-3.2 {
SELECT * FROM v2 LIMIT 1
}
} {x 7 a 8 b 9 c 10}
do_test view-3.3 {
do_test view-3.3.1 {
execsql2 {
DROP VIEW v1;
CREATE VIEW v1 AS SELECT a AS 'xyz', b+c AS 'pqr', c-b FROM t1;
SELECT * FROM v1 LIMIT 1
}
} {xyz 2 pqr 7 c-b 1}
do_test view-3.3.2 {
execsql2 {
CREATE VIEW v1b AS SELECT t1.a, b+c, t1.c FROM t1;
SELECT * FROM v1b LIMIT 1
}
} {a 2 b+c 7 c 4}
ifcapable compound {
do_test view-3.4 {