/ Check-in [d12a8924]
Login

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

Overview
Comment:Additional parsing bugs fixed. (CVS 3981)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d12a8924c6083cdff14990b4fd036ca386c2e34a
User & Date: drh 2007-05-11 01:44:51
Context
2007-05-11
07:08
Fix a problem with inserting zeroblob() into an indexed column. (CVS 3982) check-in: ccef5d2d user: danielk1977 tags: trunk
01:44
Additional parsing bugs fixed. (CVS 3981) check-in: d12a8924 user: drh tags: trunk
00:20
Make sure that the REGISTER token generates a valid Expr. REGISTER will cause the tokenizer to abort, but the parser might do several reduce actions prior to that abort and those reduce actions sometimes need a valid Expr. (CVS 3980) check-in: d146f01a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

     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   ** This file contains routines used for analyzing expressions and
    13     13   ** for generating VDBE code that evaluates expressions in SQLite.
    14     14   **
    15         -** $Id: expr.c,v 1.290 2007/05/11 00:20:08 drh Exp $
           15  +** $Id: expr.c,v 1.291 2007/05/11 01:44:51 drh Exp $
    16     16   */
    17     17   #include "sqliteInt.h"
    18     18   #include <ctype.h>
    19     19   
    20     20   /*
    21     21   ** Return the 'affinity' of the expression pExpr if any.
    22     22   **
................................................................................
   276    276   ** The returns an expression that will code to extract the value from
   277    277   ** that memory location as needed.
   278    278   */
   279    279   Expr *sqlite3RegisterExpr(Parse *pParse, Token *pToken){
   280    280     Vdbe *v = pParse->pVdbe;
   281    281     Expr *p;
   282    282     int depth;
   283         -  static const Token zeroToken = { (u8*)"0", 0, 1 };
   284    283     if( pParse->nested==0 ){
   285    284       sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", pToken);
   286         -    return sqlite3Expr(TK_INTEGER, 0, 0, &zeroToken);
          285  +    return sqlite3Expr(TK_NULL, 0, 0, 0);
   287    286     }
   288    287     if( v==0 ) return 0;
   289    288     p = sqlite3Expr(TK_REGISTER, 0, 0, pToken);
   290    289     if( p==0 ){
   291    290       return 0;  /* Malloc failed */
   292    291     }
   293    292     depth = atoi((char*)&pToken->z[1]);

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.225 2007/05/10 10:46:57 danielk1977 Exp $
           17  +** @(#) $Id: parse.y,v 1.226 2007/05/11 01:44:52 drh Exp $
    18     18   */
    19     19   
    20     20   // All token codes are small integers with #defines that begin with "TK_"
    21     21   %token_prefix TK_
    22     22   
    23     23   // The type of the data attached to each token is Token.  This is also the
    24     24   // default type for non-terminals.
................................................................................
   657    657     A = sqlite3Expr(TK_CAST, E, 0, &T);
   658    658     sqlite3ExprSpan(A,&X,&Y);
   659    659   }
   660    660   %endif  SQLITE_OMIT_CAST
   661    661   expr(A) ::= ID(X) LP distinct(D) exprlist(Y) RP(E). {
   662    662     if( Y->nExpr>SQLITE_MAX_FUNCTION_ARG ){
   663    663       sqlite3ErrorMsg(pParse, "too many arguments on function %T", &X);
   664         -    sqlite3ExprListDelete(Y);
   665         -    A = 0;
   666         -  }else{
   667         -    A = sqlite3ExprFunction(Y, &X);
   668         -    sqlite3ExprSpan(A,&X,&E);
   669         -    if( D && A ){
   670         -      A->flags |= EP_Distinct;
   671         -    }
          664  +  }
          665  +  A = sqlite3ExprFunction(Y, &X);
          666  +  sqlite3ExprSpan(A,&X,&E);
          667  +  if( D && A ){
          668  +    A->flags |= EP_Distinct;
   672    669     }
   673    670   }
   674    671   expr(A) ::= ID(X) LP STAR RP(E). {
   675    672     A = sqlite3ExprFunction(0, &X);
   676    673     sqlite3ExprSpan(A,&X,&E);
   677    674   }
   678    675   term(A) ::= CTIME_KW(OP). {

Changes to test/func.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 file is testing built-in functions.
    13     13   #
    14         -# $Id: func.test,v 1.65 2007/05/08 14:39:04 danielk1977 Exp $
           14  +# $Id: func.test,v 1.66 2007/05/11 01:44:52 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # Create a table to work with.
    20     20   #
    21     21   do_test func-0.0 {
................................................................................
   830    830   } {{  hi  zzzy}}
   831    831   do_test func-22.12 {
   832    832     execsql {SELECT rtrim('xyxzy  hi  zzzy','xyz');}
   833    833   } {{xyxzy  hi  }}
   834    834   do_test func-22.13 {
   835    835     execsql {SELECT trim('  hi  ','');}
   836    836   } {{  hi  }}
   837         -do_test func-22.14 {
   838         -  execsql {SELECT hex(trim(x'c280e1bfbff48fbfbf6869',x'6162e1bfbfc280'))}
   839         -} {F48FBFBF6869}
   840         -do_test func-22.15 {
   841         -  execsql {SELECT hex(trim(x'6869c280e1bfbff48fbfbf61',
   842         -                           x'6162e1bfbfc280f48fbfbf'))}
   843         -} {6869}
   844         -do_test func-22.16 {
   845         -  execsql {SELECT hex(trim(x'ceb1ceb2ceb3',x'ceb1'));}
   846         -} {CEB2CEB3}
          837  +if {[db one {PRAGMA encoding}]=="UTF-8"} {
          838  +  do_test func-22.14 {
          839  +    execsql {SELECT hex(trim(x'c280e1bfbff48fbfbf6869',x'6162e1bfbfc280'))}
          840  +  } {F48FBFBF6869}
          841  +  do_test func-22.15 {
          842  +    execsql {SELECT hex(trim(x'6869c280e1bfbff48fbfbf61',
          843  +                             x'6162e1bfbfc280f48fbfbf'))}
          844  +  } {6869}
          845  +  do_test func-22.16 {
          846  +    execsql {SELECT hex(trim(x'ceb1ceb2ceb3',x'ceb1'));}
          847  +  } {CEB2CEB3}
          848  +}
   847    849   do_test func-22.20 {
   848    850     execsql {SELECT typeof(trim(NULL));}
   849    851   } {null}
   850    852   do_test func-22.21 {
   851    853     execsql {SELECT typeof(trim(NULL,'xyz'));}
   852    854   } {null}
   853    855   do_test func-22.22 {
   854    856     execsql {SELECT typeof(trim('hello',NULL));}
   855    857   } {null}
   856    858   
   857    859   finish_test