/ Check-in [191a7f48]
Login

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

Overview
Comment::-) (CVS 13)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 191a7f484e0a10839e7e1c8eb6658536643e4756
User & Date: drh 2000-05-30 03:28:36
Context
2000-05-30
13:44
:-) (CVS 14) check-in: 1bb8ee8d user: drh tags: trunk
03:28
:-) (CVS 13) check-in: 191a7f48 user: drh tags: trunk
03:12
:-) (CVS 12) check-in: 20f2811f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

    21     21   **   http://www.hwaci.com/drh/
    22     22   **
    23     23   *************************************************************************
    24     24   ** This module contains C code that generates VDBE code used to process
    25     25   ** the WHERE clause of SQL statements.  Also found here are subroutines
    26     26   ** to generate VDBE code to evaluate expressions.
    27     27   **
    28         -** $Id: where.c,v 1.1 2000/05/29 14:26:02 drh Exp $
           28  +** $Id: where.c,v 1.2 2000/05/30 03:28:36 drh Exp $
    29     29   */
    30     30   #include "sqliteInt.h"
    31     31   
    32     32   /*
    33     33   ** The query generator uses an array of instances of this structure to
    34     34   ** help it analyze the subexpressions of the WHERE clause.  Each WHERE
    35     35   ** clause subexpression is separated from the others by an AND operator.
................................................................................
   363    363     switch( pExpr->op ){
   364    364       case TK_PLUS:     op = OP_Add;      break;
   365    365       case TK_MINUS:    op = OP_Subtract; break;
   366    366       case TK_STAR:     op = OP_Multiply; break;
   367    367       case TK_SLASH:    op = OP_Divide;   break;
   368    368       case TK_AND:      op = OP_And;      break;
   369    369       case TK_OR:       op = OP_Or;       break;
   370         -    case TK_LT:       op = OP_Lt;       break;
   371         -    case TK_LE:       op = OP_Le;       break;
   372         -    case TK_GT:       op = OP_Gt;       break;
   373         -    case TK_GE:       op = OP_Ge;       break;
   374         -    case TK_NE:       op = OP_Ne;       break;
   375         -    case TK_EQ:       op = OP_Eq;       break;
          370  +    case TK_LT:       op = OP_Ge;       break;
          371  +    case TK_LE:       op = OP_Gt;       break;
          372  +    case TK_GT:       op = OP_Le;       break;
          373  +    case TK_GE:       op = OP_Lt;       break;
          374  +    case TK_NE:       op = OP_Eq;       break;
          375  +    case TK_EQ:       op = OP_Ne;       break;
   376    376       case TK_ISNULL:   op = OP_IsNull;   break;
   377    377       case TK_NOTNULL:  op = OP_NotNull;  break;
   378    378       case TK_NOT:      op = OP_Not;      break;
   379    379       case TK_UMINUS:   op = OP_Negative; break;
   380    380       default: break;
   381    381     }
   382    382     switch( pExpr->op ){

Added test/expr.test.

            1  +# Copyright (c) 1999, 2000 D. Richard Hipp
            2  +#
            3  +# This program is free software; you can redistribute it and/or
            4  +# modify it under the terms of the GNU General Public
            5  +# License as published by the Free Software Foundation; either
            6  +# version 2 of the License, or (at your option) any later version.
            7  +#
            8  +# This program is distributed in the hope that it will be useful,
            9  +# but WITHOUT ANY WARRANTY; without even the implied warranty of
           10  +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
           11  +# General Public License for more details.
           12  +# 
           13  +# You should have received a copy of the GNU General Public
           14  +# License along with this library; if not, write to the
           15  +# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
           16  +# Boston, MA  02111-1307, USA.
           17  +#
           18  +# Author contact information:
           19  +#   drh@hwaci.com
           20  +#   http://www.hwaci.com/drh/
           21  +#
           22  +#***********************************************************************
           23  +# This file implements regression tests for SQLite library.  The
           24  +# focus of this file is testing expressions.
           25  +#
           26  +# $Id: expr.test,v 1.1 2000/05/30 03:28:36 drh Exp $
           27  +
           28  +set testdir [file dirname $argv0]
           29  +source $testdir/tester.tcl
           30  +
           31  +# Create a table to work with.
           32  +#
           33  +execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
           34  +execsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')}
           35  +proc test_expr {name settings expr result} {
           36  +  do_test $name [format {
           37  +    execsql {UPDATE test1 SET %s}
           38  +    execsql {SELECT %s FROM test1}
           39  +  } $settings $expr] $result
           40  +}
           41  +
           42  +test_expr expr-1.1 {i1=10, i2=20} {i1+i2} 30
           43  +test_expr expr-1.2 {i1=10, i2=20} {i1-i2} -10
           44  +test_expr expr-1.3 {i1=10, i2=20} {i1*i2} 200
           45  +test_expr expr-1.4 {i1=10, i2=20} {i1/i2} 0.5
           46  +test_expr expr-1.5 {i1=10, i2=20} {i2/i1} 2
           47  +test_expr expr-1.6 {i1=10, i2=20} {i2<i1} 0
           48  +test_expr expr-1.7 {i1=10, i2=20} {i2<=i1} 0
           49  +test_expr expr-1.8 {i1=10, i2=20} {i2>i1} 1
           50  +test_expr expr-1.9 {i1=10, i2=20} {i2>=i1} 1
           51  +test_expr expr-1.10 {i1=10, i2=20} {i2!=i1} 1
           52  +test_expr expr-1.11 {i1=10, i2=20} {i2=i1} 0
           53  +test_expr expr-1.12 {i1=10, i2=20} {i2<>i1} 1
           54  +test_expr expr-1.13 {i1=10, i2=20} {i2==i1} 0
           55  +test_expr expr-1.14 {i1=20, i2=20} {i2<i1} 0
           56  +test_expr expr-1.15 {i1=20, i2=20} {i2<=i1} 1
           57  +test_expr expr-1.16 {i1=20, i2=20} {i2>i1} 0
           58  +test_expr expr-1.17 {i1=20, i2=20} {i2>=i1} 1
           59  +test_expr expr-1.18 {i1=20, i2=20} {i2!=i1} 0
           60  +test_expr expr-1.19 {i1=20, i2=20} {i2=i1} 1
           61  +test_expr expr-1.20 {i1=20, i2=20} {i2<>i1} 0
           62  +test_expr expr-1.21 {i1=20, i2=20} {i2==i1} 1
           63  +test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7}
           64  +test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9}
           65  +
           66  +
           67  +finish_test