From: drh Date: Sun, 22 Mar 2009 20:36:18 +0000 (+0000) Subject: Allow the keyword INDEXED to be used as the name of a table or index or X-Git-Tag: version-3.6.15~380 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=296a483c2e95ba2289e9872d436c7e459185e9af;p=thirdparty%2Fsqlite.git Allow the keyword INDEXED to be used as the name of a table or index or column - for backwards compatibility. (CVS 6370) FossilOrigin-Name: 53149c9f5d5cfaba3374703cd3af92a9d4cf8718 --- diff --git a/manifest b/manifest index 73afc84c53..42f0becce0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\scomments\sin\sbuild.c\sto\sconform\sto\sthe\slatest\simplementation.\s(CVS\s6369) -D 2009-03-21T16:19:26 +C Allow\sthe\skeyword\sINDEXED\sto\sbe\sused\sas\sthe\sname\sof\sa\stable\sor\sindex\sor\ncolumn\s-\sfor\sbackwards\scompatibility.\s(CVS\s6370) +D 2009-03-22T20:36:19 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 583e87706abc3026960ed759aff6371faf84c211 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -145,7 +145,7 @@ F src/os_unix.c a20fe61c025117452c003ae4cafd05c3e610b616 F src/os_win.c 40636702058ed4dcd35d68151bfab56d4997cdc1 F src/pager.c 01e3facb2f7c5f307e36a0f4ed9343cf3761711a F src/pager.h 0c9f3520c00d8a3b8e792ca56c9a11b6b02b4b0f -F src/parse.y c315b6f9bf6c7e7ec985481f81b6a45dba6c26d0 +F src/parse.y 30ae25cd9ce8002527fca3011052a7fba0aff349 F src/pcache.c fcf7738c83c4d3e9d45836b2334c8a368cc41274 F src/pcache.h 9b927ccc5a538e31b4c3bc7eec4f976db42a1324 F src/pcache1.c f12518540ba776df3051215c4244e9cdc06b09cd @@ -209,7 +209,7 @@ F src/vdbeblob.c 3408f5e1ab62627300b9c9c3168cff1de65e1658 F src/vdbemem.c 543a79d722734d2f8b7ad70f08218c30bcc5bbf5 F src/vtab.c 18d671f0a45d0159088070bc6b219a3105034c87 F src/walker.c 42bd3f00ca2ef5ae842304ec0d59903ef051412d -F src/where.c 42d3756dbed6ed390bafcd849cc2075230e0eda6 +F src/where.c 55b13048fd0f82b330511e37766208b96fd764df F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45 @@ -400,7 +400,7 @@ F test/incrvacuum_ioerr.test 57d2f5777ab13fa03b87b262a4ea1bad5cfc0291 F test/index.test cbf301cdb2da43e4eac636c3400c2439af1834ad F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 F test/index3.test 727d55dceb9a4ec36675057bb5becfc265e28ca6 -F test/indexedby.test bcf239ccdc5ac6112110136f8481b40dcd070164 +F test/indexedby.test 946ca2628a521f4ced0520421a0788345abaf3dc F test/insert.test aef273dd1cee84cc92407469e6bd1b3cdcb76908 F test/insert2.test 4f3a04d168c728ed5ec2c88842e772606c7ce435 F test/insert3.test 7188f1da1126eb15f1b27cf34f4c2753c7d5fd27 @@ -709,7 +709,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P a331562727be465874a66c2c1d15ee070f96f7e0 -R 4402ba006efc4583ed7d0cf413c713f4 +P a915e8e0a429ab6a10536c45264a790c2d076461 +R 1162241df47288b20352f997466915d0 U drh -Z 38186ef5f341ca0ce183f01a326c1493 +Z 145cbd00e8dda3a6879518186372f565 diff --git a/manifest.uuid b/manifest.uuid index 9911b68572..6af0659470 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a915e8e0a429ab6a10536c45264a790c2d076461 \ No newline at end of file +53149c9f5d5cfaba3374703cd3af92a9d4cf8718 \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index df3dd307c5..63c68ac689 100644 --- a/src/parse.y +++ b/src/parse.y @@ -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.270 2009/03/05 03:48:07 shane Exp $ +** @(#) $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_" @@ -174,6 +174,7 @@ columnid(A) ::= nm(X). { // %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. @@ -224,7 +225,7 @@ 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) ::= id(X). {A = X;} nm(A) ::= STRING(X). {A = X;} nm(A) ::= JOIN_KW(X). {A = X;} @@ -697,7 +698,7 @@ inscollist(A) ::= nm(Y). 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) ::= 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); diff --git a/src/where.c b/src/where.c index 96e4652451..6545494563 100644 --- a/src/where.c +++ b/src/where.c @@ -16,7 +16,7 @@ ** 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.375 2009/03/20 14:18:52 danielk1977 Exp $ +** $Id: where.c,v 1.376 2009/03/22 20:36:19 drh Exp $ */ #include "sqliteInt.h" @@ -1717,8 +1717,8 @@ static double bestVirtualIndex( ** ** 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 one cannot be found, then the returned cost is -** SQLITE_BIG_DBL. If a plan can be found that uses the named index, +** 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 diff --git a/test/indexedby.test b/test/indexedby.test index 38750e74f7..62a2a5fd43 100644 --- a/test/indexedby.test +++ b/test/indexedby.test @@ -9,7 +9,7 @@ # #*********************************************************************** # -# $Id: indexedby.test,v 1.4 2008/12/30 09:45:46 danielk1977 Exp $ +# $Id: indexedby.test,v 1.5 2009/03/22 20:36:19 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -225,5 +225,30 @@ do_test indexedby-9.3 { catchsql { select * from maintable, joinme INDEXED by joinme_id_text_idx } } {1 {cannot use index: joinme_id_text_idx}} -finish_test +# 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