From 2c6674cf7edd7b8ee18c26176c24a14180401163 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 25 Aug 2004 04:07:01 +0000 Subject: [PATCH] Host parameter names conform to SQL-2003. (CVS 1902) FossilOrigin-Name: fd584d1ccf6643b723c2ff0a7a16c2aea3f1142c --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/parse.y | 9 ++------- src/tclsqlite.c | 4 ++-- src/tokenize.c | 13 ++++--------- test/bind.test | 10 +++++----- www/capi3ref.tcl | 14 +++++++------- 7 files changed, 31 insertions(+), 41 deletions(-) diff --git a/manifest b/manifest index 32769dd224..e3dd1cdd59 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\sthe\sparsing\sof\swildcards\sthat\sbegin\swith\s'$'.\s(CVS\s1901) -D 2004-08-24T15:23:34 +C Host\sparameter\snames\sconform\sto\sSQL-2003.\s(CVS\s1902) +D 2004-08-25T04:07:02 F Makefile.in 4a5e570a9e2d35b09c31b3cf01b78cea764ade4b F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -53,7 +53,7 @@ F src/os_win.c 54181eb73cb4783c4241feca9eaa490768b39008 F src/os_win.h babd4e912967c6b09088cfe38a45e8005a07ba44 F src/pager.c 6ecf24602f56ac98914685d449f6653903f36fec F src/pager.h 67739fe649f33be55dba522ca8a9cc4e42d14f71 -F src/parse.y 8b4cab1901900927f717d10885b7a1bd3375345b +F src/parse.y 581a2ce014b843506805b2470c02b7865ad034d5 F src/pragma.c a7cea75286fcff6666a5412b04478fcf0ecef5c4 F src/printf.c 17b28a1eedfe8129b05de981719306c18c3f1327 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3 @@ -62,13 +62,13 @@ F src/shell.c 42f65424a948f197f389e13bc7aaa3cf24dafd0c F src/sqlite.h.in de2be4043f0bfa16958d33392a3e7a5e7d4bd50b F src/sqliteInt.h c7ed161ecc40f9fd0f080fbcc00e34bd7d6735ee F src/table.c 4521c278892f60e4d630788c0ea5cf4db1e75c49 -F src/tclsqlite.c 90de7fd34c4eb66e5c3223849b0042b4b55ce624 +F src/tclsqlite.c dbbcc553c78fbf928461fb951c7a59f05f46a212 F src/test1.c b87fae63b2994c150a579c4101f302be48ad77bc F src/test2.c f4c2f3928f1998fd8cb75a81e33a60e025ea85d4 F src/test3.c 94d0a2a90bccd85802488cb42c69ec8afd2e4646 F src/test4.c c38766914e924091516030b6a8b677d849c08bf0 F src/test5.c b001fa7f1b9e2dc5c2331de62fc641b5ab2bd7a1 -F src/tokenize.c d8ea315961f30d5a62232a98ec81d7ec1a72b087 +F src/tokenize.c 32171c3d576c7ec6acd6cf15e55c00ac0b314769 F src/trigger.c 8b147c6b8ae0bab3a13463a4ca9ab6ad61f1361d F src/update.c 151f1869ce532ed883f1ce26306f0b0fa7b2589a F src/utf.c 3d8f7bffcbefcced69a436c9e0a1c7eb9e0bb4fa @@ -88,7 +88,7 @@ F test/attach3.test 6d060986ff004ebb89e1876a331d96c6bb62269e F test/auth.test e74b015545f608c06d5b84d17acdf7146eb818af F test/bigfile.test 62722ac4b420dfbcdceb137b8634e2cf2865fe27 F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747 -F test/bind.test 8fd93bd2c828decc8208b71b6fa6cf4d15636d9e +F test/bind.test 7968edd61eb83b6e09165e4ba38e327dace6fb35 F test/blob.test 8727a7b46b2073a369cfc9bcb6f54dd366b9d884 F test/btree.test 97b563e1ab999bf8764b129e8c4b4be0a116a52a F test/btree2.test aa4a6d05b1ea90b1acaf83ba89039dd302a88635 @@ -212,7 +212,7 @@ F www/arch2b.fig d22a2c9642d584b89d4088b1e51e2bb0f7c04bed F www/audit.tcl 90e09d580f79c7efec0c7d6f447b7ec5c2dce5c0 F www/c_interface.tcl 2176519fc2bd2d2cf6fe74fd806fc2d8362de2c8 F www/capi3.tcl 5c1cb163f4d2a54e2d0e22dcc399dd71245c8b89 -F www/capi3ref.tcl 460ae1d1dd88560f878234a5d000336788434238 +F www/capi3ref.tcl 740d222be4d66e8947b60a0627dd760a2e019e9f F www/changes.tcl 8c36aab96163bbb64f5f07a12606a242c0a820f2 F www/common.tcl f786e6be86fb2627ceb30e770e9efa83b9c67a3a F www/conflict.tcl fb8a2ba83746c7fdfd9e52fa7f6aaf5c422b8246 @@ -243,7 +243,7 @@ F www/tclsqlite.tcl 06a86cba4d7fc88e2bcd633b57702d3d16abebb5 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P b6eb4bf8c7763ef73723fc3d3697af435c19bae4 -R 8c0203ae9b9fb401a60a066d64e9f953 +P 054dd8901dbfe64a8f61e7b99e23512057bad99a +R d23910c2c69266eac96be9e2b599d41f U drh -Z d6e1c40c23af021b5f4969f3b7403dcc +Z 5aba1f7ee7cf5f46b8a50edb359ed966 diff --git a/manifest.uuid b/manifest.uuid index 8b02ff8601..24a4dde35d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -054dd8901dbfe64a8f61e7b99e23512057bad99a \ No newline at end of file +fd584d1ccf6643b723c2ff0a7a16c2aea3f1142c \ No newline at end of file diff --git a/src/parse.y b/src/parse.y index 528711e4c4..a22f9e5d14 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.134 2004/08/20 16:02:39 drh Exp $ +** @(#) $Id: parse.y,v 1.135 2004/08/25 04:07:02 drh Exp $ */ %token_prefix TK_ %token_type {Token} @@ -561,12 +561,7 @@ expr(A) ::= VARIABLE(X). { Token *pToken = &X; Expr *pExpr = A = sqlite3Expr(TK_VARIABLE, 0, 0, pToken); if( pExpr ){ - if( pToken->z[0]==':' ){ - int n = pExpr->iTable = atoi(&pToken->z[1]); - if( pParse->nVarnVar = n; - }else{ - pExpr->iTable = ++pParse->nVar; - } + pExpr->iTable = ++pParse->nVar; } } expr(A) ::= ID(X) LP exprlist(Y) RP(E). { diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 8d52ac3194..8388495c39 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -11,7 +11,7 @@ ************************************************************************* ** A TCL Interface to SQLite ** -** $Id: tclsqlite.c,v 1.101 2004/08/24 15:23:34 drh Exp $ +** $Id: tclsqlite.c,v 1.102 2004/08/25 04:07:02 drh Exp $ */ #ifndef NO_TCL /* Omit this whole file if TCL is unavailable */ @@ -745,7 +745,7 @@ static int DbObjCmd(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ nVar = sqlite3_bind_parameter_count(pStmt); for(i=1; i<=nVar; i++){ const char *zVar = sqlite3_bind_parameter_name(pStmt, i); - if( zVar[0]=='$' ){ + if( zVar[0]=='$' || zVar[0]==':' ){ Tcl_Obj *pVar = Tcl_GetVar2Ex(interp, &zVar[1], 0, 0); if( pVar ){ int n; diff --git a/src/tokenize.c b/src/tokenize.c index ff9c32bee1..891a6352ed 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -15,7 +15,7 @@ ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** -** $Id: tokenize.c,v 1.83 2004/08/24 15:23:34 drh Exp $ +** $Id: tokenize.c,v 1.84 2004/08/25 04:07:02 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -374,14 +374,9 @@ static int sqliteGetToken(const unsigned char *z, int *tokenType){ return 1; } case ':': { - for(i=1; isdigit(z[i]); i++){} - if( i>1 && z[i]==':' ){ - *tokenType = TK_VARIABLE; - return i+1; - }else{ - *tokenType = TK_ILLEGAL; - return i; - } + for(i=1; (z[i]&0x80)!=0 || isIdChar[z[i]]; i++){} + *tokenType = i>1 ? TK_VARIABLE : TK_ILLEGAL; + return i; } case '$': { int c; diff --git a/test/bind.test b/test/bind.test index 96f57d781c..d5ea33f67c 100644 --- a/test/bind.test +++ b/test/bind.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script testing the sqlite_bind API. # -# $Id: bind.test,v 1.17 2004/08/20 18:34:20 drh Exp $ +# $Id: bind.test,v 1.18 2004/08/25 04:07:03 drh Exp $ # set testdir [file dirname $argv0] @@ -37,8 +37,8 @@ proc sqlite_step {stmt N VALS COLS} { do_test bind-1.1 { db close set DB [sqlite3 db test.db] - execsql {CREATE TABLE t1(a,b,c)} - set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:1:,?,:3:)} -1 TAIL] + execsql {CREATE TABLE t1(a,b,c);} + set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:1,?,:abc)} -1 TAIL] set TAIL } {} do_test bind-1.1.1 { @@ -46,13 +46,13 @@ do_test bind-1.1.1 { } 3 do_test bind-1.1.2 { sqlite3_bind_parameter_name $VM 1 -} {:1:} +} {:1} do_test bind-1.1.3 { sqlite3_bind_parameter_name $VM 2 } {} do_test bind-1.1.4 { sqlite3_bind_parameter_name $VM 3 -} {:3:} +} {:abc} do_test bind-1.2 { sqlite_step $VM N VALUES COLNAMES } {SQLITE_DONE} diff --git a/www/capi3ref.tcl b/www/capi3ref.tcl index 22d00045fe..ed32f07fcd 100644 --- a/www/capi3ref.tcl +++ b/www/capi3ref.tcl @@ -1,4 +1,4 @@ -set rcsid {$Id: capi3ref.tcl,v 1.8 2004/08/20 16:02:40 drh Exp $} +set rcsid {$Id: capi3ref.tcl,v 1.9 2004/08/25 04:07:03 drh Exp $} source common.tcl header {C/C++ Interface For SQLite Version 3} puts { @@ -80,14 +80,14 @@ api {} { #define SQLITE_TRANSIENT ((void(*)(void *))-1) } { In the SQL strings input to sqlite3_prepare() and sqlite3_prepare16(), - one or more literals can be replace by a wildcard "?" or ":N:" where - N is an integer. The value of these wildcard literals can be set - using these routines. + one or more literals can be replace by a wildcard "?" or ":AAA" where + AAA is an alphanumeric identifier. + The value of these wildcard literals (also called "host parameter names") + can be set using these routines. The first parameter is a pointer to the sqlite3_stmt structure returned from sqlite3_prepare(). The second parameter is the - index of the wildcard. The first "?" has an index of 1. ":N:" wildcards - use the index N. + index of the wildcard. The first wildcard has an index of 1. The fifth parameter to sqlite3_bind_blob(), sqlite3_bind_text(), and sqlite3_bind_text16() is a destructor used to dispose of the BLOB or @@ -114,7 +114,7 @@ api {} { const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int n); } { Return the name of the n-th wildcard in the precompiled statement. - Wildcards of the form ":N:" have a name which is the string ":N:". + Wildcards of the form ":AAA" have a name which is the string ":AAA". Wildcards of the form "?" have no name. If the value n is out of range or if the n-th wildcard is nameless,