SQLite

Check-in [ffe7573636]
Login

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

Overview
Comment:Avoid a NULL pointer deference when processing the IS operator if the right-hand side is an illegal "#ID" style variable. Fix for ticket [8c32a33a53092c85a15b]
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ffe7573636c8057614b02f0a85559e1857fd04e4
User & Date: drh 2014-10-02 21:52:35.759
Context
2014-10-03
14:54
Update to requirements marks related to changes in the memory allocation interface and enhancement of the documentation regarding DEFAULT clauses in CREATE TABLE. (check-in: 440705b98a user: drh tags: trunk)
2014-10-02
21:52
Avoid a NULL pointer deference when processing the IS operator if the right-hand side is an illegal "#ID" style variable. Fix for ticket [8c32a33a53092c85a15b] (check-in: ffe7573636 user: drh tags: trunk)
2014-10-01
13:17
Show the TK_DOT operator in the TreeView debugging output. No changes to production code. (check-in: 07c89940c4 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/parse.y.
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
expr(A) ::= expr(X) NOT NULL(E). {spanUnaryPostfix(&A,pParse,TK_NOTNULL,&X,&E);}

%include {
  /* A routine to convert a binary TK_IS or TK_ISNOT expression into a
  ** unary TK_ISNULL or TK_NOTNULL expression. */
  static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){
    sqlite3 *db = pParse->db;
    if( db->mallocFailed==0 && pY->op==TK_NULL ){
      pA->op = (u8)op;
      sqlite3ExprDelete(db, pA->pRight);
      pA->pRight = 0;
    }
  }
}








|







957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
expr(A) ::= expr(X) NOT NULL(E). {spanUnaryPostfix(&A,pParse,TK_NOTNULL,&X,&E);}

%include {
  /* A routine to convert a binary TK_IS or TK_ISNOT expression into a
  ** unary TK_ISNULL or TK_NOTNULL expression. */
  static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){
    sqlite3 *db = pParse->db;
    if( pY && pA && pY->op==TK_NULL ){
      pA->op = (u8)op;
      sqlite3ExprDelete(db, pA->pRight);
      pA->pRight = 0;
    }
  }
}

Changes to test/expr.test.
201
202
203
204
205
206
207




208
209
210
211
212
213
214
test_expr expr-1.124 {i1=NULL, i2=NULL} \
  {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} no
test_expr expr-1.125 {i1=6, i2=NULL} \
  {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} yes
test_expr expr-1.126 {i1=8, i2=8} \
  {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} no





ifcapable floatingpoint {if {[working_64bit_int]} {
  test_expr expr-1.200\
      {i1=9223372036854775806, i2=1} {i1+i2}      9223372036854775807
  test_realnum_expr expr-1.201\
      {i1=9223372036854775806, i2=2} {i1+i2}      9.22337203685478e+18
  test_realnum_expr expr-1.202\
      {i1=9223372036854775806, i2=100000} {i1+i2} 9.22337203685488e+18







>
>
>
>







201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
test_expr expr-1.124 {i1=NULL, i2=NULL} \
  {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} no
test_expr expr-1.125 {i1=6, i2=NULL} \
  {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} yes
test_expr expr-1.126 {i1=8, i2=8} \
  {CASE WHEN i1 IS NOT i2 THEN 'yes' ELSE 'no' END} no

do_catchsql_test expr-1.127 {
  SELECT 1 IS #1;
} {1 {near "#1": syntax error}}

ifcapable floatingpoint {if {[working_64bit_int]} {
  test_expr expr-1.200\
      {i1=9223372036854775806, i2=1} {i1+i2}      9223372036854775807
  test_realnum_expr expr-1.201\
      {i1=9223372036854775806, i2=2} {i1+i2}      9.22337203685478e+18
  test_realnum_expr expr-1.202\
      {i1=9223372036854775806, i2=100000} {i1+i2} 9.22337203685488e+18