181eba73eSdrh# 2013-10-19 281eba73eSdrh# 381eba73eSdrh# The author disclaims copyright to this source code. In place of 481eba73eSdrh# a legal notice, here is a blessing: 581eba73eSdrh# 681eba73eSdrh# May you do good and not evil. 781eba73eSdrh# May you find forgiveness for yourself and forgive others. 881eba73eSdrh# May you share freely, never taking more than you give. 981eba73eSdrh# 1081eba73eSdrh#*********************************************************************** 1181eba73eSdrh# 1281eba73eSdrh# Test the operation of table-options in the WITH clause of the 1381eba73eSdrh# CREATE TABLE statement. 1481eba73eSdrh# 1581eba73eSdrh 1681eba73eSdrh 1781eba73eSdrhset testdir [file dirname $argv0] 1881eba73eSdrhsource $testdir/tester.tcl 1981eba73eSdrh 2081eba73eSdrhdo_test tableopt-1.1 { 2181eba73eSdrh catchsql { 225969da4aSdrh CREATE TABLE t1(a,b) WITHOUT rowid; 2381eba73eSdrh } 24*d2fe3358Sdrh} {1 {PRIMARY KEY missing on table t1}} 25*d2fe3358Sdrhdo_test tableopt-1.1b { 26*d2fe3358Sdrh catchsql { 27*d2fe3358Sdrh CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT,b) WITHOUT rowid; 28*d2fe3358Sdrh } 29*d2fe3358Sdrh} {1 {AUTOINCREMENT not allowed on WITHOUT ROWID tables}} 3081eba73eSdrhdo_test tableopt-1.2 { 3181eba73eSdrh catchsql { 325969da4aSdrh CREATE TABLE t1(a,b) WITHOUT unknown2; 3381eba73eSdrh } 3481eba73eSdrh} {1 {unknown table option: unknown2}} 3581eba73eSdrh 3681eba73eSdrhdo_execsql_test tableopt-2.1 { 375969da4aSdrh CREATE TABLE t1(a, b, c, PRIMARY KEY(a,b)) WITHOUT rowid; 3881eba73eSdrh INSERT INTO t1 VALUES(1,2,3),(2,3,4); 3981eba73eSdrh SELECT c FROM t1 WHERE a IN (1,2) ORDER BY b; 4081eba73eSdrh} {3 4} 4111f9b033Sdrhdo_test tableopt-2.1.1 { 4211f9b033Sdrh catchsql { 4311f9b033Sdrh SELECT rowid, * FROM t1; 4411f9b033Sdrh } 4511f9b033Sdrh} {1 {no such column: rowid}} 4611f9b033Sdrhdo_test tableopt-2.1.2 { 4711f9b033Sdrh catchsql { 4811f9b033Sdrh SELECT _rowid_, * FROM t1; 4911f9b033Sdrh } 5011f9b033Sdrh} {1 {no such column: _rowid_}} 5111f9b033Sdrhdo_test tableopt-2.1.3 { 5211f9b033Sdrh catchsql { 5311f9b033Sdrh SELECT oid, * FROM t1; 5411f9b033Sdrh } 5511f9b033Sdrh} {1 {no such column: oid}} 5681eba73eSdrhdo_execsql_test tableopt-2.2 { 5781eba73eSdrh VACUUM; 5881eba73eSdrh SELECT c FROM t1 WHERE a IN (1,2) ORDER BY b; 5981eba73eSdrh} {3 4} 6081eba73eSdrhdo_test tableopt-2.3 { 6181eba73eSdrh sqlite3 db2 test.db 6281eba73eSdrh db2 eval {SELECT c FROM t1 WHERE a IN (1,2) ORDER BY b;} 6381eba73eSdrh} {3 4} 6481eba73eSdrhdb2 close 6581eba73eSdrh 665969da4aSdrh# Make sure the "without" keyword is still usable as a table or 675969da4aSdrh# column name. 685969da4aSdrh# 695969da4aSdrhdo_execsql_test tableopt-3.1 { 705969da4aSdrh CREATE TABLE without(x INTEGER PRIMARY KEY, without TEXT); 715969da4aSdrh INSERT INTO without VALUES(1, 'xyzzy'), (2, 'fizzle'); 725969da4aSdrh SELECT * FROM without WHERE without='xyzzy'; 735969da4aSdrh} {1 xyzzy} 745969da4aSdrh 755969da4aSdrh 7681eba73eSdrhfinish_test 77