SQLite

Check-in [6041ca87a1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6041ca87a16858f047727bc01f10b0bbc83609ed
User & Date: drh 2009-01-29 19:27:47.000
Context
2009-01-30
05:40
Minor changes to remove a few MSVC compiler warnings at /W3. Ticket #3610. (CVS 6215) (check-in: c74c78e4eb user: shane tags: trunk)
2009-01-29
19:27
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) (check-in: 6041ca87a1 user: drh tags: trunk)
02:54
add a cvsignore file (CVS 6213) (check-in: 68c8cdd73b user: vapier tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/parse.y.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** This file contains SQLite's grammar for SQL.  Process this file
** using the lemon parser generator to generate C code that runs
** 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 $
*/

// All token codes are small integers with #defines that begin with "TK_"
%token_prefix TK_

// The type of the data attached to each token is Token.  This is also the
// default type for non-terminals.







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** This file contains SQLite's grammar for SQL.  Process this file
** using the lemon parser generator to generate C code that runs
** the parser.  Lemon will also generate a header file containing
** numeric codes for all of the tokens.
**
** @(#) $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_"
%token_prefix TK_

// The type of the data attached to each token is Token.  This is also the
// default type for non-terminals.
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
id(A) ::= ID(X).         {A = X;}

// The following directive causes tokens ABORT, AFTER, ASC, etc. to
// fallback to ID if they will not parse as their original value.
// This obviates the need for the "id" nonterminal.
//
%fallback ID
  ABORT AFTER ANALYZE ASC ATTACH BEFORE BEGIN CASCADE CAST 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
  SAVEPOINT TEMP TRIGGER VACUUM VIEW VIRTUAL
%ifdef SQLITE_OMIT_COMPOUND_SELECT
  EXCEPT INTERSECT UNION
%endif SQLITE_OMIT_COMPOUND_SELECT
  REINDEX RENAME CTIME_KW IF
  .
%wildcard ANY.







|


|







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
id(A) ::= ID(X).         {A = X;}

// The following directive causes tokens ABORT, AFTER, ASC, etc. to
// fallback to ID if they will not parse as their original value.
// This obviates the need for the "id" nonterminal.
//
%fallback ID
  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 ROLLBACK
  SAVEPOINT TEMP TRIGGER VACUUM VIEW VIRTUAL
%ifdef SQLITE_OMIT_COMPOUND_SELECT
  EXCEPT INTERSECT UNION
%endif SQLITE_OMIT_COMPOUND_SELECT
  REINDEX RENAME CTIME_KW IF
  .
%wildcard ANY.
Added test/keyword1.test.












































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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