1 # 2009 January 29 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 # 12 # Verify that certain keywords can be used as identifiers. 13 # 14 # $Id: keyword1.test,v 1.1 2009/01/29 19:27:47 drh Exp $ 15 16 17 set testdir [file dirname $argv0] 18 source $testdir/tester.tcl 19 20 db eval { 21 CREATE TABLE t1(a, b); 22 INSERT INTO t1 VALUES(1, 'one'); 23 INSERT INTO t1 VALUES(2, 'two'); 24 INSERT INTO t1 VALUES(3, 'three'); 25 } 26 27 set kwlist { 28 abort 29 after 30 analyze 31 asc 32 attach 33 before 34 begin 35 by 36 cascade 37 cast 38 column 39 conflict 40 current_date 41 current_time 42 current_timestamp 43 database 44 deferred 45 desc 46 detach 47 end 48 each 49 exclusive 50 explain 51 fail 52 for 53 glob 54 if 55 ignore 56 immediate 57 initially 58 instead 59 key 60 like 61 match 62 of 63 offset 64 plan 65 pragma 66 query 67 raise 68 regexp 69 reindex 70 release 71 rename 72 replace 73 restrict 74 rollback 75 row 76 savepoint 77 temp 78 temporary 79 trigger 80 vacuum 81 view 82 virtual 83 }; 84 set exprkw { 85 cast 86 current_date 87 current_time 88 current_timestamp 89 raise 90 } 91 foreach kw $kwlist { 92 do_test keyword1-$kw.1 { 93 if {$kw=="if"} { 94 db eval "CREATE TABLE \"$kw\"($kw $kw)" 95 } else { 96 db eval "CREATE TABLE ${kw}($kw $kw)" 97 } 98 db eval "INSERT INTO $kw VALUES(99)" 99 db eval "INSERT INTO $kw SELECT a FROM t1" 100 if {[lsearch $exprkw $kw]<0} { 101 db eval "SELECT * FROM $kw ORDER BY $kw ASC" 102 } else { 103 db eval "SELECT * FROM $kw ORDER BY \"$kw\" ASC" 104 } 105 } {1 2 3 99} 106 do_test keyword1-$kw.2 { 107 if {$kw=="if"} { 108 db eval "DROP TABLE \"$kw\"" 109 db eval "CREATE INDEX \"$kw\" ON t1(a)" 110 } else { 111 db eval "DROP TABLE $kw" 112 db eval "CREATE INDEX $kw ON t1(a)" 113 } 114 db eval "SELECT b FROM t1 INDEXED BY $kw WHERE a=2" 115 } {two} 116 } 117 118 finish_test 119