1# 2014-08-24 2# 3# The author disclaims copyright to this source code. In place of 4# a legal notice, here is a blessing: 5# 6# May you do good and not evil. 7# May you find forgiveness for yourself and forgive others. 8# May you share freely, never taking more than you give. 9# 10#*********************************************************************** 11# This file implements regression tests for SQLite library. 12# The focus of this script is testing details of the SQL language parser. 13# 14 15set testdir [file dirname $argv0] 16source $testdir/tester.tcl 17 18do_catchsql_test parser1-1.1 { 19 CREATE TABLE t1( 20 a TEXT PRIMARY KEY, 21 b TEXT, 22 FOREIGN KEY(b COLLATE nocase DESC) REFERENCES t1(a COLLATE binary ASC) 23 ); 24} {1 {syntax error after column name "a"}} 25do_execsql_test parser1-1.2 { 26 CREATE TABLE t1( 27 a TEXT PRIMARY KEY, 28 b TEXT, 29 FOREIGN KEY(b) REFERENCES t1(a) 30 ); 31 INSERT INTO t1 VALUES('abc',NULL),('xyz','abc'); 32 PRAGMA writable_schema=on; 33 UPDATE sqlite_master SET sql='CREATE TABLE t1( 34 a TEXT PRIMARY KEY, 35 b TEXT, 36 FOREIGN KEY(b COLLATE nocase) REFERENCES t1(a) 37 )' WHERE name='t1'; 38 SELECT name FROM sqlite_master WHERE sql LIKE '%collate%'; 39} {t1} 40sqlite3 db2 test.db 41do_test parser1-1.3 { 42 sqlite3 db2 test.db 43 db2 eval {SELECT * FROM t1 ORDER BY 1} 44} {abc {} xyz abc} 45 46 47do_catchsql_test parser1-2.1 { 48 WITH RECURSIVE 49 c(x COLLATE binary) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<5) 50 SELECT x FROM c; 51} {1 {syntax error after column name "x"}} 52do_catchsql_test parser1-2.2 { 53 WITH RECURSIVE 54 c(x ASC) AS (VALUES(1) UNION SELECT x+1 FROM c WHERE x<5) 55 SELECT x FROM c; 56} {1 {syntax error after column name "x"}} 57 58finish_test 59