Add test cases to make sure that keywords that we say can be used as

identifiers really can be used as identifiers.  These tests were
inspired by ticket #3612, but they do not directly address ticket #3612. (CVS 6214)

FossilOrigin-Name: 6041ca87a16858f047727bc01f10b0bbc83609ed
This commit is contained in:
drh 2009-01-29 19:27:46 +00:00
parent 832a36dbf5
commit db15bcd550
4 changed files with 130 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C add\sa\scvsignore\sfile\s(CVS\s6213)
D 2009-01-29T02:54:57
C Add\stest\scases\sto\smake\ssure\sthat\skeywords\sthat\swe\ssay\scan\sbe\sused\sas\nidentifiers\sreally\scan\sbe\sused\sas\sidentifiers.\s\sThese\stests\swere\ninspired\sby\sticket\s#3612,\sbut\sthey\sdo\snot\sdirectly\saddress\sticket\s#3612.\s(CVS\s6214)
D 2009-01-29T19:27:47
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 3871d308188cefcb7c5ab20da4c7b6aad023bc52
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -144,7 +144,7 @@ F src/os_unix.c c74255cc1fcddc38fc3cc1dcf70c2325d3c2948e
F src/os_win.c 496e3ceb499aedc63622a89ef76f7af2dd902709
F src/pager.c ce459ad59b388d2beafd263c4365bb05c9bdfcc9
F src/pager.h 59e3b500a0f6a8d17ec61976535007b0de39b9a4
F src/parse.y b214295a91e985c42adb6bfd3ad1c56c47828e8d
F src/parse.y 4f4d16aee0d11f69fec2adb77dac88878043ed8d
F src/pcache.c fcf7738c83c4d3e9d45836b2334c8a368cc41274
F src/pcache.h 9b927ccc5a538e31b4c3bc7eec4f976db42a1324
F src/pcache1.c dabb8ab14827e090321f17150ce96fda172974e8
@ -413,6 +413,7 @@ F test/join4.test 1a352e4e267114444c29266ce79e941af5885916
F test/join5.test 86675fc2919269aa923c84dd00ee4249b97990fe
F test/journal1.test 36f2d1bb9bf03f790f43fbdb439e44c0657fab19
F test/jrnlmode.test 32e79fa272e78ff3b734aac08db886f98f84165a
F test/keyword1.test a2400977a2e4fde43bf33754c2929fda34dbca05
F test/lastinsert.test 474d519c68cb79d07ecae56a763aa7f322c72f51
F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200
F test/like.test 22f7857f9d7da7ff5061ded8806c43a6271109fc
@ -692,7 +693,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 68957cf0c4bae0c6cf450b4de1d6bc1bc64b232c
R 1d921b41466ddcb216497f4cc6d6fe23
U vapier
Z 0bc88850dd2b3af5293ba63c76284b74
P 68c8cdd73b2b9f03264f9fdd27cddb65e1bdc7ae
R 326a823ae7f359b7ba50517c53432cb2
U drh
Z 7d5305661f64863cd9b8b57a439851af

View File

@ -1 +1 @@
68c8cdd73b2b9f03264f9fdd27cddb65e1bdc7ae
6041ca87a16858f047727bc01f10b0bbc83609ed

View File

@ -14,7 +14,7 @@
** the parser. Lemon will also generate a header file containing
** numeric codes for all of the tokens.
**
** @(#) $Id: parse.y,v 1.267 2009/01/16 11:04:58 danielk1977 Exp $
** @(#) $Id: parse.y,v 1.268 2009/01/29 19:27:47 drh Exp $
*/
// All token codes are small integers with #defines that begin with "TK_"
@ -180,10 +180,10 @@ id(A) ::= ID(X). {A = X;}
// This obviates the need for the "id" nonterminal.
//
%fallback ID
ABORT AFTER ANALYZE ASC ATTACH BEFORE BEGIN CASCADE CAST CONFLICT
ABORT AFTER ANALYZE ASC ATTACH BEFORE BEGIN BY CASCADE CAST COLUMNKW CONFLICT
DATABASE DEFERRED DESC DETACH EACH END EXCLUSIVE EXPLAIN FAIL FOR
IGNORE IMMEDIATE INITIALLY INSTEAD LIKE_KW MATCH PLAN
QUERY KEY OF OFFSET PRAGMA RAISE RELEASE REPLACE RESTRICT ROW
QUERY KEY OF OFFSET PRAGMA RAISE RELEASE REPLACE RESTRICT ROW ROLLBACK
SAVEPOINT TEMP TRIGGER VACUUM VIEW VIRTUAL
%ifdef SQLITE_OMIT_COMPOUND_SELECT
EXCEPT INTERSECT UNION

118
test/keyword1.test Normal file
View File

@ -0,0 +1,118 @@
# 2009 January 29
#
# 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.
#
#***********************************************************************
#
# Verify that certain keywords can be used as identifiers.
#
# $Id: keyword1.test,v 1.1 2009/01/29 19:27:47 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
db eval {
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(1, 'one');
INSERT INTO t1 VALUES(2, 'two');
INSERT INTO t1 VALUES(3, 'three');
}
set kwlist {
abort
after
analyze
asc
attach
before
begin
by
cascade
cast
column
conflict
current_date
current_time
current_timestamp
database
deferred
desc
detach
end
each
exclusive
explain
fail
for
glob
if
ignore
immediate
initially
instead
key
like
match
of
offset
plan
pragma
query
raise
regexp
reindex
release
rename
replace
restrict
rollback
row
savepoint
temp
temporary
trigger
vacuum
view
virtual
};
set exprkw {
cast
current_date
current_time
current_timestamp
raise
}
foreach kw $kwlist {
do_test keyword1-$kw.1 {
if {$kw=="if"} {
db eval "CREATE TABLE \"$kw\"($kw $kw)"
} else {
db eval "CREATE TABLE ${kw}($kw $kw)"
}
db eval "INSERT INTO $kw VALUES(99)"
db eval "INSERT INTO $kw SELECT a FROM t1"
if {[lsearch $exprkw $kw]<0} {
db eval "SELECT * FROM $kw ORDER BY $kw ASC"
} else {
db eval "SELECT * FROM $kw ORDER BY \"$kw\" ASC"
}
} {1 2 3 99}
do_test keyword1-$kw.2 {
if {$kw=="if"} {
db eval "DROP TABLE \"$kw\""
db eval "CREATE INDEX \"$kw\" ON t1(a)"
} else {
db eval "DROP TABLE $kw"
db eval "CREATE INDEX $kw ON t1(a)"
}
db eval "SELECT b FROM t1 INDEXED BY $kw WHERE a=2"
} {two}
}
finish_test