/ Check-in [fd584d1c]
Login

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

Overview
Comment:Host parameter names conform to SQL-2003. (CVS 1902)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fd584d1ccf6643b723c2ff0a7a16c2aea3f1142c
User & Date: drh 2004-08-25 04:07:02
Context
2004-08-26
00:56
Protect Tcl_Obj pointers from change using Tcl_IncrRefCount() while executing SQL statements in the TCL bindings. (CVS 1903) check-in: 6199f2f2 user: drh tags: trunk
2004-08-25
04:07
Host parameter names conform to SQL-2003. (CVS 1902) check-in: fd584d1c user: drh tags: trunk
2004-08-24
15:23
Fix a bug in the parsing of wildcards that begin with '$'. (CVS 1901) check-in: 054dd890 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/parse.y.

    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains SQLite's grammar for SQL.  Process this file
    13     13   ** using the lemon parser generator to generate C code that runs
    14     14   ** the parser.  Lemon will also generate a header file containing
    15     15   ** numeric codes for all of the tokens.
    16     16   **
    17         -** @(#) $Id: parse.y,v 1.134 2004/08/20 16:02:39 drh Exp $
           17  +** @(#) $Id: parse.y,v 1.135 2004/08/25 04:07:02 drh Exp $
    18     18   */
    19     19   %token_prefix TK_
    20     20   %token_type {Token}
    21     21   %default_type {Token}
    22     22   %extra_argument {Parse *pParse}
    23     23   %syntax_error {
    24     24     if( pParse->zErrMsg==0 ){
................................................................................
   557    557   expr(A) ::= FLOAT(X).        {A = sqlite3Expr(@X, 0, 0, &X);}
   558    558   expr(A) ::= STRING(X).       {A = sqlite3Expr(@X, 0, 0, &X);}
   559    559   expr(A) ::= BLOB(X).         {A = sqlite3Expr(@X, 0, 0, &X);}
   560    560   expr(A) ::= VARIABLE(X).     {
   561    561     Token *pToken = &X;
   562    562     Expr *pExpr = A = sqlite3Expr(TK_VARIABLE, 0, 0, pToken);
   563    563     if( pExpr ){
   564         -    if( pToken->z[0]==':' ){
   565         -      int n = pExpr->iTable = atoi(&pToken->z[1]);
   566         -      if( pParse->nVar<n ) pParse->nVar = n;
   567         -    }else{
   568         -      pExpr->iTable = ++pParse->nVar;
   569         -    }
          564  +    pExpr->iTable = ++pParse->nVar;
   570    565     }
   571    566   }
   572    567   expr(A) ::= ID(X) LP exprlist(Y) RP(E). {
   573    568     A = sqlite3ExprFunction(Y, &X);
   574    569     sqlite3ExprSpan(A,&X,&E);
   575    570   }
   576    571   expr(A) ::= ID(X) LP STAR RP(E). {

Changes to src/tclsqlite.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** A TCL Interface to SQLite
    13     13   **
    14         -** $Id: tclsqlite.c,v 1.101 2004/08/24 15:23:34 drh Exp $
           14  +** $Id: tclsqlite.c,v 1.102 2004/08/25 04:07:02 drh Exp $
    15     15   */
    16     16   #ifndef NO_TCL     /* Omit this whole file if TCL is unavailable */
    17     17   
    18     18   #include "sqliteInt.h"
    19     19   #include "hash.h"
    20     20   #include "tcl.h"
    21     21   #include <stdlib.h>
................................................................................
   741    741           }
   742    742         }
   743    743   
   744    744         /* Bind values to wildcards that begin with $ */  
   745    745         nVar = sqlite3_bind_parameter_count(pStmt);
   746    746         for(i=1; i<=nVar; i++){
   747    747           const char *zVar = sqlite3_bind_parameter_name(pStmt, i);
   748         -        if( zVar[0]=='$' ){
          748  +        if( zVar[0]=='$' || zVar[0]==':' ){
   749    749             Tcl_Obj *pVar = Tcl_GetVar2Ex(interp, &zVar[1], 0, 0);
   750    750             if( pVar ){
   751    751               int n;
   752    752               u8 *data;
   753    753               char *zType = pVar->typePtr ? pVar->typePtr->name : "";
   754    754               char c = zType[0];
   755    755               if( c=='b' && strcmp(zType,"bytearray")==0 ){

Changes to src/tokenize.c.

    11     11   *************************************************************************
    12     12   ** An tokenizer for SQL
    13     13   **
    14     14   ** This file contains C code that splits an SQL input string up into
    15     15   ** individual tokens and sends those tokens one-by-one over to the
    16     16   ** parser for analysis.
    17     17   **
    18         -** $Id: tokenize.c,v 1.83 2004/08/24 15:23:34 drh Exp $
           18  +** $Id: tokenize.c,v 1.84 2004/08/25 04:07:02 drh Exp $
    19     19   */
    20     20   #include "sqliteInt.h"
    21     21   #include "os.h"
    22     22   #include <ctype.h>
    23     23   #include <stdlib.h>
    24     24   
    25     25   /*
................................................................................
   370    370         return i;
   371    371       }
   372    372       case '?': {
   373    373         *tokenType = TK_VARIABLE;
   374    374         return 1;
   375    375       }
   376    376       case ':': {
   377         -      for(i=1; isdigit(z[i]); i++){}
   378         -      if( i>1 && z[i]==':' ){
   379         -        *tokenType = TK_VARIABLE;
   380         -        return i+1;
   381         -      }else{
   382         -        *tokenType = TK_ILLEGAL;
   383         -        return i;
   384         -      }
          377  +      for(i=1; (z[i]&0x80)!=0 || isIdChar[z[i]]; i++){}
          378  +      *tokenType = i>1 ? TK_VARIABLE : TK_ILLEGAL;
          379  +      return i;
   385    380       }
   386    381       case '$': {
   387    382         int c;
   388    383         *tokenType = TK_VARIABLE;
   389    384         if( z[1]=='{' ){
   390    385           int nBrace = 1;
   391    386           for(i=2; (c=z[i])!=0 && nBrace; i++){

Changes to test/bind.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script testing the sqlite_bind API.
    13     13   #
    14         -# $Id: bind.test,v 1.17 2004/08/20 18:34:20 drh Exp $
           14  +# $Id: bind.test,v 1.18 2004/08/25 04:07:03 drh Exp $
    15     15   #
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   proc sqlite_step {stmt N VALS COLS} {
    21     21     upvar VALS vals
................................................................................
    33     33   
    34     34     return $rc
    35     35   }
    36     36   
    37     37   do_test bind-1.1 {
    38     38     db close
    39     39     set DB [sqlite3 db test.db]
    40         -  execsql {CREATE TABLE t1(a,b,c)}
    41         -  set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:1:,?,:3:)} -1 TAIL]
           40  +  execsql {CREATE TABLE t1(a,b,c);}
           41  +  set VM [sqlite3_prepare $DB {INSERT INTO t1 VALUES(:1,?,:abc)} -1 TAIL]
    42     42     set TAIL
    43     43   } {}
    44     44   do_test bind-1.1.1 {
    45     45     sqlite3_bind_parameter_count $VM
    46     46   } 3
    47     47   do_test bind-1.1.2 {
    48     48     sqlite3_bind_parameter_name $VM 1
    49         -} {:1:}
           49  +} {:1}
    50     50   do_test bind-1.1.3 {
    51     51     sqlite3_bind_parameter_name $VM 2
    52     52   } {}
    53     53   do_test bind-1.1.4 {
    54     54     sqlite3_bind_parameter_name $VM 3
    55         -} {:3:}
           55  +} {:abc}
    56     56   do_test bind-1.2 {
    57     57     sqlite_step $VM N VALUES COLNAMES
    58     58   } {SQLITE_DONE}
    59     59   do_test bind-1.3 {
    60     60     execsql {SELECT rowid, * FROM t1}
    61     61   } {1 {} {} {}}
    62     62   do_test bind-1.4 {

Changes to www/capi3ref.tcl.

     1         -set rcsid {$Id: capi3ref.tcl,v 1.8 2004/08/20 16:02:40 drh Exp $}
            1  +set rcsid {$Id: capi3ref.tcl,v 1.9 2004/08/25 04:07:03 drh Exp $}
     2      2   source common.tcl
     3      3   header {C/C++ Interface For SQLite Version 3}
     4      4   puts {
     5      5   <h2>C/C++ Interface For SQLite Version 3</h2>
     6      6   }
     7      7   
     8      8   proc api {name prototype desc {notused x}} {
................................................................................
    76     76     int sqlite3_bind_null(sqlite3_stmt*, int);
    77     77     int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
    78     78     int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
    79     79     #define SQLITE_STATIC      ((void(*)(void *))0)
    80     80     #define SQLITE_TRANSIENT   ((void(*)(void *))-1)
    81     81   } {
    82     82    In the SQL strings input to sqlite3_prepare() and sqlite3_prepare16(),
    83         - one or more literals can be replace by a wildcard "?" or ":N:" where
    84         - N is an integer.  The value of these wildcard literals can be set
    85         - using these routines.
           83  + one or more literals can be replace by a wildcard "?" or ":AAA" where
           84  + AAA is an alphanumeric identifier.
           85  + The value of these wildcard literals (also called "host parameter names")
           86  + can be set using these routines.
    86     87   
    87     88    The first parameter is a pointer to the sqlite3_stmt
    88     89    structure returned from sqlite3_prepare().  The second parameter is the
    89         - index of the wildcard.  The first "?" has an index of 1.  ":N:" wildcards
    90         - use the index N.
           90  + index of the wildcard.  The first wildcard has an index of 1. 
    91     91   
    92     92    The fifth parameter to sqlite3_bind_blob(), sqlite3_bind_text(), and
    93     93    sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
    94     94    text after SQLite has finished with it.  If the fifth argument is the
    95     95    special value SQLITE_STATIC, then the library assumes that the information
    96     96    is in static, unmanaged space and does not need to be freed.  If the
    97     97    fifth argument has the value SQLITE_TRANSIENT, then SQLite makes its
................................................................................
   110    110     the argument.
   111    111   }
   112    112   
   113    113   api {} {
   114    114     const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int n);
   115    115   } {
   116    116     Return the name of the n-th wildcard in the precompiled statement.
   117         -  Wildcards of the form ":N:" have a name which is the string ":N:".
          117  +  Wildcards of the form ":AAA" have a name which is the string ":AAA".
   118    118     Wildcards of the form "?" have no name.
   119    119   
   120    120     If the value n is out of range or if the n-th wildcard is nameless,
   121    121     then NULL is returned.  The returned string is always in the
   122    122     UTF-8 encoding.
   123    123   }
   124    124