Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Allow the keyword INDEXED to be used as the name of a table or index or column - for backwards compatibility. (CVS 6370) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
53149c9f5d5cfaba3374703cd3af92a9 |
User & Date: | drh 2009-03-22 20:36:19.000 |
Context
2009-03-23
| ||
02:34 | Fix compiler warning in MSVC. (CVS 6371) (check-in: 83a4d5b3d7 user: shane tags: trunk) | |
2009-03-22
| ||
20:36 | Allow the keyword INDEXED to be used as the name of a table or index or column - for backwards compatibility. (CVS 6370) (check-in: 53149c9f5d user: drh tags: trunk) | |
2009-03-21
| ||
16:19 | Update comments in build.c to conform to the latest implementation. (CVS 6369) (check-in: a915e8e0a4 user: drh tags: trunk) | |
Changes
Changes to src/parse.y.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** 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. ** | | | 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.271 2009/03/22 20:36:19 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. |
︙ | ︙ | |||
170 171 172 173 174 175 176 177 178 179 180 181 182 183 | // An IDENTIFIER can be a generic identifier, or one of several // keywords. Any non-standard keyword can also be an identifier. // %type id {Token} 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 | > | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | // An IDENTIFIER can be a generic identifier, or one of several // keywords. Any non-standard keyword can also be an identifier. // %type id {Token} id(A) ::= ID(X). {A = X;} id(A) ::= INDEXED(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 |
︙ | ︙ | |||
220 221 222 223 224 225 226 | // %type ids {Token} ids(A) ::= ID|STRING(X). {A = X;} // The name of a column or table can be any of the following: // %type nm {Token} | | | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | // %type ids {Token} ids(A) ::= ID|STRING(X). {A = X;} // The name of a column or table can be any of the following: // %type nm {Token} nm(A) ::= id(X). {A = X;} nm(A) ::= STRING(X). {A = X;} nm(A) ::= JOIN_KW(X). {A = X;} // A typetoken is really one or more tokens that form a type name such // as can be found after the column name in a CREATE TABLE statement. // Multiple tokens are concatenated to form the value of the typetoken. // |
︙ | ︙ | |||
693 694 695 696 697 698 699 | %destructor expr {sqlite3ExprDelete(pParse->db, $$);} %type term {Expr*} %destructor term {sqlite3ExprDelete(pParse->db, $$);} expr(A) ::= term(X). {A = X;} expr(A) ::= LP(B) expr(X) RP(E). {A = X; sqlite3ExprSpan(A,&B,&E); } term(A) ::= NULL(X). {A = sqlite3PExpr(pParse, @X, 0, 0, &X);} | | | 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 | %destructor expr {sqlite3ExprDelete(pParse->db, $$);} %type term {Expr*} %destructor term {sqlite3ExprDelete(pParse->db, $$);} expr(A) ::= term(X). {A = X;} expr(A) ::= LP(B) expr(X) RP(E). {A = X; sqlite3ExprSpan(A,&B,&E); } term(A) ::= NULL(X). {A = sqlite3PExpr(pParse, @X, 0, 0, &X);} expr(A) ::= id(X). {A = sqlite3PExpr(pParse, TK_ID, 0, 0, &X);} expr(A) ::= JOIN_KW(X). {A = sqlite3PExpr(pParse, TK_ID, 0, 0, &X);} expr(A) ::= nm(X) DOT nm(Y). { Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &X); Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &Y); A = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); } expr(A) ::= nm(X) DOT nm(Y) DOT nm(Z). { |
︙ | ︙ |
Changes to src/where.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is responsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. This module is responsible for ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** ** $Id: where.c,v 1.376 2009/03/22 20:36:19 drh Exp $ */ #include "sqliteInt.h" /* ** Trace output macros */ #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) |
︙ | ︙ | |||
1713 1714 1715 1716 1717 1718 1719 | ** * Whether or not sorting must occur. ** ** * Whether or not there must be separate lookups in the ** index and in the main table. ** ** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in ** the SQL statement, then this function only considers plans using the | | | | 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 | ** * Whether or not sorting must occur. ** ** * Whether or not there must be separate lookups in the ** index and in the main table. ** ** If there was an INDEXED BY clause (pSrc->pIndex) attached to the table in ** the SQL statement, then this function only considers plans using the ** named index. If no such plan is found, then the returned cost is ** SQLITE_BIG_DBL. If a plan is found that uses the named index, ** then the cost is calculated in the usual way. ** ** If a NOT INDEXED clause (pSrc->notIndexed!=0) was attached to the table ** in the SELECT statement, then no indexes are considered. However, the ** selected plan may still take advantage of the tables built-in rowid ** index. */ |
︙ | ︙ |
Changes to test/indexedby.test.
1 2 3 4 5 6 7 8 9 10 11 | # 2008 October 4 # # 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. # #*********************************************************************** # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # 2008 October 4 # # 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. # #*********************************************************************** # # $Id: indexedby.test,v 1.5 2009/03/22 20:36:19 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Create a schema with some indexes. # do_test indexedby-1.1 { |
︙ | ︙ | |||
221 222 223 224 225 226 227 | on ( m.id = j.id_int) } } {1 {cannot use index: joinme_id_text_idx}} do_test indexedby-9.3 { catchsql { select * from maintable, joinme INDEXED by joinme_id_text_idx } } {1 {cannot use index: joinme_id_text_idx}} | > > > | > > > > | > > > > > > > > > > > > > > > > > > | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | on ( m.id = j.id_int) } } {1 {cannot use index: joinme_id_text_idx}} do_test indexedby-9.3 { catchsql { select * from maintable, joinme INDEXED by joinme_id_text_idx } } {1 {cannot use index: joinme_id_text_idx}} # Make sure we can still create tables, indices, and columns whose name # is "indexed". # do_test indexedby-10.1 { execsql { CREATE TABLE indexed(x,y); INSERT INTO indexed VALUES(1,2); SELECT * FROM indexed; } } {1 2} do_test indexedby-10.2 { execsql { CREATE INDEX i10 ON indexed(x); SELECT * FROM indexed indexed by i10 where x>0; } } {1 2} do_test indexedby-10.3 { execsql { DROP TABLE indexed; CREATE TABLE t10(indexed INTEGER); INSERT INTO t10 VALUES(1); CREATE INDEX indexed ON t10(indexed); SELECT * FROM t10 indexed by indexed WHERE indexed>0 } } {1} finish_test |