summaryrefslogtreecommitdiffstats
path: root/third_party/sqlite/test/select7.test
diff options
context:
space:
mode:
authormpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 22:39:41 +0000
committermpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 22:39:41 +0000
commit586381f8db3497c24c11f96234f1879b34e74bc7 (patch)
tree99f7d18350289b135ef6dd5c161baba8bce668a3 /third_party/sqlite/test/select7.test
parent6e3b12ff2cbbe8c481f986c8f0dd230bb50add2a (diff)
downloadchromium_src-586381f8db3497c24c11f96234f1879b34e74bc7.zip
chromium_src-586381f8db3497c24c11f96234f1879b34e74bc7.tar.gz
chromium_src-586381f8db3497c24c11f96234f1879b34e74bc7.tar.bz2
Upgrade our sqlite to 3.6.1, with the local changes made by Gears. I'm
checking in the full sqlite tree to make upstream merges easier. This means we'll have generated sources split out from the originals. One important change this makes is that "BEGIN" now defaults to "BEGIN IMMEDIATE" rather than "BEGIN DEFERRED". This doesn't affect us because we don't use unqualified BEGIN statements. The full CL is too big for Rietveld. I'm splitting it into 2. This one is reviewable. The other CL is just a fresh drop of: //depot/googleclient/gears/opensource/third_party/sqlite_google Review URL: http://codereview.chromium.org/15067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7623 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/sqlite/test/select7.test')
-rwxr-xr-xthird_party/sqlite/test/select7.test159
1 files changed, 159 insertions, 0 deletions
diff --git a/third_party/sqlite/test/select7.test b/third_party/sqlite/test/select7.test
new file mode 100755
index 0000000..3837c88
--- /dev/null
+++ b/third_party/sqlite/test/select7.test
@@ -0,0 +1,159 @@
+# 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 file implements regression tests for SQLite library. The
+# focus of this file is testing compute SELECT statements and nested
+# views.
+#
+# $Id: select7.test,v 1.11 2007/09/12 17:01:45 danielk1977 Exp $
+
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+ifcapable compound {
+
+# A 3-way INTERSECT. Ticket #875
+ifcapable tempdb {
+ do_test select7-1.1 {
+ execsql {
+ create temp table t1(x);
+ insert into t1 values('amx');
+ insert into t1 values('anx');
+ insert into t1 values('amy');
+ insert into t1 values('bmy');
+ select * from t1 where x like 'a__'
+ intersect select * from t1 where x like '_m_'
+ intersect select * from t1 where x like '__x';
+ }
+ } {amx}
+}
+
+
+# Nested views do not handle * properly. Ticket #826.
+#
+ifcapable view {
+do_test select7-2.1 {
+ execsql {
+ CREATE TABLE x(id integer primary key, a TEXT NULL);
+ INSERT INTO x (a) VALUES ('first');
+ CREATE TABLE tempx(id integer primary key, a TEXT NULL);
+ INSERT INTO tempx (a) VALUES ('t-first');
+ CREATE VIEW tv1 AS SELECT x.id, tx.id FROM x JOIN tempx tx ON tx.id=x.id;
+ CREATE VIEW tv1b AS SELECT x.id, tx.id FROM x JOIN tempx tx on tx.id=x.id;
+ CREATE VIEW tv2 AS SELECT * FROM tv1 UNION SELECT * FROM tv1b;
+ SELECT * FROM tv2;
+ }
+} {1 1}
+} ;# ifcapable view
+
+} ;# ifcapable compound
+
+# Do not allow GROUP BY without an aggregate. Ticket #1039.
+#
+# Change: force any query with a GROUP BY clause to be processed as
+# an aggregate query, whether it contains aggregates or not.
+#
+ifcapable subquery {
+ # do_test select7-3.1 {
+ # catchsql {
+ # SELECT * FROM (SELECT * FROM sqlite_master) GROUP BY name
+ # }
+ # } {1 {GROUP BY may only be used on aggregate queries}}
+ do_test select7-3.1 {
+ catchsql {
+ SELECT * FROM (SELECT * FROM sqlite_master) GROUP BY name
+ }
+ } [list 0 [execsql {SELECT * FROM sqlite_master ORDER BY name}]]
+}
+
+# Ticket #2018 - Make sure names are resolved correctly on all
+# SELECT statements of a compound subquery.
+#
+ifcapable {subquery && compound} {
+ do_test select7-4.1 {
+ execsql {
+ CREATE TABLE IF NOT EXISTS photo(pk integer primary key, x);
+ CREATE TABLE IF NOT EXISTS tag(pk integer primary key, fk int, name);
+
+ SELECT P.pk from PHOTO P WHERE NOT EXISTS (
+ SELECT T2.pk from TAG T2 WHERE T2.fk = P.pk
+ EXCEPT
+ SELECT T3.pk from TAG T3 WHERE T3.fk = P.pk AND T3.name LIKE '%foo%'
+ );
+ }
+ } {}
+ do_test select7-4.2 {
+ execsql {
+ INSERT INTO photo VALUES(1,1);
+ INSERT INTO photo VALUES(2,2);
+ INSERT INTO photo VALUES(3,3);
+ INSERT INTO tag VALUES(11,1,'one');
+ INSERT INTO tag VALUES(12,1,'two');
+ INSERT INTO tag VALUES(21,1,'one-b');
+ SELECT P.pk from PHOTO P WHERE NOT EXISTS (
+ SELECT T2.pk from TAG T2 WHERE T2.fk = P.pk
+ EXCEPT
+ SELECT T3.pk from TAG T3 WHERE T3.fk = P.pk AND T3.name LIKE '%foo%'
+ );
+ }
+ } {2 3}
+}
+
+# ticket #2347
+#
+ifcapable {subquery && compound} {
+ do_test select7-5.1 {
+ catchsql {
+ CREATE TABLE t2(a,b);
+ SELECT 5 IN (SELECT a,b FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
+ do_test select7-5.2 {
+ catchsql {
+ SELECT 5 IN (SELECT * FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
+ do_test select7-5.3 {
+ catchsql {
+ SELECT 5 IN (SELECT a,b FROM t2 UNION SELECT b,a FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
+ do_test select7-5.4 {
+ catchsql {
+ SELECT 5 IN (SELECT * FROM t2 UNION SELECT * FROM t2);
+ }
+ } [list 1 \
+ {only a single result allowed for a SELECT that is part of an expression}]
+}
+
+# Verify that an error occurs if you have too many terms on a
+# compound select statement.
+#
+ifcapable compound {
+ if {$SQLITE_MAX_COMPOUND_SELECT>0} {
+ set sql {SELECT 0}
+ set result 0
+ for {set i 1} {$i<$SQLITE_MAX_COMPOUND_SELECT} {incr i} {
+ append sql " UNION ALL SELECT $i"
+ lappend result $i
+ }
+ do_test select7-6.1 {
+ catchsql $sql
+ } [list 0 $result]
+ append sql { UNION ALL SELECT 99999999}
+ do_test select7-6.2 {
+ catchsql $sql
+ } {1 {too many terms in compound SELECT}}
+ }
+}
+
+finish_test