/ Check-in [92f7ad43]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Revise the affinity returned for expressions flagged as 'generic'. Fix for [9a8b09f8e6].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 92f7ad43dbfe4e02490df2f932c3c74fb89064d6
User & Date: mistachkin 2014-06-26 21:28:21
Context
2014-06-26
22:17
Add some more IN operator tests. check-in: fb32e374 user: mistachkin tags: trunk
21:28
Revise the affinity returned for expressions flagged as 'generic'. Fix for [9a8b09f8e6]. check-in: 92f7ad43 user: mistachkin tags: trunk
2014-06-24
20:19
Fix showstat4.c so that it decodes typecodes 8 and 9 correctly. check-in: 9ca737c0 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/expr.c.

    29     29   ** SELECT * FROM t1 WHERE a;
    30     30   ** SELECT a AS b FROM t1 WHERE b;
    31     31   ** SELECT * FROM t1 WHERE (select a from t1);
    32     32   */
    33     33   char sqlite3ExprAffinity(Expr *pExpr){
    34     34     int op;
    35     35     pExpr = sqlite3ExprSkipCollate(pExpr);
    36         -  if( pExpr->flags & EP_Generic ) return SQLITE_AFF_NONE;
           36  +  if( pExpr->flags & EP_Generic ) return 0;
    37     37     op = pExpr->op;
    38     38     if( op==TK_SELECT ){
    39     39       assert( pExpr->flags&EP_xIsSelect );
    40     40       return sqlite3ExprAffinity(pExpr->x.pSelect->pEList->a[0].pExpr);
    41     41     }
    42     42   #ifndef SQLITE_OMIT_CAST
    43     43     if( op==TK_CAST ){

Added test/tkt-9a8b09f8e6.test.

            1  +# 2014 June 26
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.
           12  +#
           13  +# This file implements tests to verify that ticket [9a8b09f8e6] has been
           14  +# fixed.
           15  +#
           16  +
           17  +set testdir [file dirname $argv0]
           18  +source $testdir/tester.tcl
           19  +set testprefix tkt-9a8b09f8e6
           20  +
           21  +do_test 1.1 {
           22  +  execsql {
           23  +    CREATE TABLE t1(x TEXT);
           24  +    INSERT INTO t1 VALUES('1');
           25  +  }
           26  +} {}
           27  +
           28  +do_test 1.2 {
           29  +  execsql {
           30  +    CREATE TABLE t2(x INTEGER);
           31  +    INSERT INTO t2 VALUES(1);
           32  +  }
           33  +} {}
           34  +
           35  +do_test 1.3 {
           36  +  execsql {
           37  +    CREATE TABLE t3(x REAL);
           38  +    INSERT INTO t3 VALUES(1.0);
           39  +  }
           40  +} {}
           41  +
           42  +do_test 1.4 {
           43  +  execsql {
           44  +    CREATE TABLE t4(x REAL);
           45  +    INSERT INTO t4 VALUES(1.11);
           46  +  }
           47  +} {}
           48  +
           49  +do_test 2.1 {
           50  +  execsql {
           51  +    SELECT x FROM t1 WHERE x IN (1);
           52  +  }
           53  +} {1}
           54  +
           55  +do_test 2.2 {
           56  +  execsql {
           57  +    SELECT x FROM t1 WHERE x IN (1.0);
           58  +  }
           59  +} {}
           60  +
           61  +do_test 2.3 {
           62  +  execsql {
           63  +    SELECT x FROM t1 WHERE x IN ('1');
           64  +  }
           65  +} {1}
           66  +
           67  +do_test 2.4 {
           68  +  execsql {
           69  +    SELECT x FROM t1 WHERE x IN ('1.0');
           70  +  }
           71  +} {}
           72  +
           73  +do_test 2.5 {
           74  +  execsql {
           75  +    SELECT x FROM t1 WHERE 1 IN (x);
           76  +  }
           77  +} {}
           78  +
           79  +do_test 2.6 {
           80  +  execsql {
           81  +    SELECT x FROM t1 WHERE 1.0 IN (x);
           82  +  }
           83  +} {}
           84  +
           85  +do_test 2.7 {
           86  +  execsql {
           87  +    SELECT x FROM t1 WHERE '1' IN (x);
           88  +  }
           89  +} {1}
           90  +
           91  +do_test 2.8 {
           92  +  execsql {
           93  +    SELECT x FROM t1 WHERE '1.0' IN (x);
           94  +  }
           95  +} {}
           96  +
           97  +do_test 3.1 {
           98  +  execsql {
           99  +    SELECT x FROM t2 WHERE x IN (1);
          100  +  }
          101  +} {1}
          102  +
          103  +do_test 3.2 {
          104  +  execsql {
          105  +    SELECT x FROM t2 WHERE x IN (1.0);
          106  +  }
          107  +} {1}
          108  +
          109  +do_test 3.3 {
          110  +  execsql {
          111  +    SELECT x FROM t2 WHERE x IN ('1');
          112  +  }
          113  +} {1}
          114  +
          115  +do_test 3.4 {
          116  +  execsql {
          117  +    SELECT x FROM t2 WHERE x IN ('1.0');
          118  +  }
          119  +} {1}
          120  +
          121  +do_test 3.5 {
          122  +  execsql {
          123  +    SELECT x FROM t2 WHERE 1 IN (x);
          124  +  }
          125  +} {1}
          126  +
          127  +do_test 3.6 {
          128  +  execsql {
          129  +    SELECT x FROM t2 WHERE 1.0 IN (x);
          130  +  }
          131  +} {1}
          132  +
          133  +do_test 3.7 {
          134  +  execsql {
          135  +    SELECT x FROM t2 WHERE '1' IN (x);
          136  +  }
          137  +} {}
          138  +
          139  +do_test 3.8 {
          140  +  execsql {
          141  +    SELECT x FROM t2 WHERE '1.0' IN (x);
          142  +  }
          143  +} {}
          144  +
          145  +do_test 4.1 {
          146  +  execsql {
          147  +    SELECT x FROM t3 WHERE x IN (1);
          148  +  }
          149  +} {1.0}
          150  +
          151  +do_test 4.2 {
          152  +  execsql {
          153  +    SELECT x FROM t3 WHERE x IN (1.0);
          154  +  }
          155  +} {1.0}
          156  +
          157  +do_test 4.3 {
          158  +  execsql {
          159  +    SELECT x FROM t3 WHERE x IN ('1');
          160  +  }
          161  +} {1.0}
          162  +
          163  +do_test 4.4 {
          164  +  execsql {
          165  +    SELECT x FROM t3 WHERE x IN ('1.0');
          166  +  }
          167  +} {1.0}
          168  +
          169  +do_test 4.5 {
          170  +  execsql {
          171  +    SELECT x FROM t3 WHERE 1 IN (x);
          172  +  }
          173  +} {1.0}
          174  +
          175  +do_test 4.6 {
          176  +  execsql {
          177  +    SELECT x FROM t3 WHERE 1.0 IN (x);
          178  +  }
          179  +} {1.0}
          180  +
          181  +do_test 4.7 {
          182  +  execsql {
          183  +    SELECT x FROM t3 WHERE '1' IN (x);
          184  +  }
          185  +} {}
          186  +
          187  +do_test 4.8 {
          188  +  execsql {
          189  +    SELECT x FROM t3 WHERE '1.0' IN (x);
          190  +  }
          191  +} {}
          192  +
          193  +do_test 5.1 {
          194  +  execsql {
          195  +    SELECT x FROM t4 WHERE x IN (1);
          196  +  }
          197  +} {}
          198  +
          199  +do_test 5.2 {
          200  +  execsql {
          201  +    SELECT x FROM t4 WHERE x IN (1.0);
          202  +  }
          203  +} {}
          204  +
          205  +do_test 5.3 {
          206  +  execsql {
          207  +    SELECT x FROM t4 WHERE x IN ('1');
          208  +  }
          209  +} {}
          210  +
          211  +do_test 5.4 {
          212  +  execsql {
          213  +    SELECT x FROM t4 WHERE x IN ('1.0');
          214  +  }
          215  +} {}
          216  +
          217  +do_test 5.5 {
          218  +  execsql {
          219  +    SELECT x FROM t4 WHERE x IN (1.11);
          220  +  }
          221  +} {1.11}
          222  +
          223  +do_test 5.6 {
          224  +  execsql {
          225  +    SELECT x FROM t4 WHERE x IN ('1.11');
          226  +  }
          227  +} {1.11}
          228  +
          229  +do_test 5.7 {
          230  +  execsql {
          231  +    SELECT x FROM t4 WHERE 1 IN (x);
          232  +  }
          233  +} {}
          234  +
          235  +do_test 5.8 {
          236  +  execsql {
          237  +    SELECT x FROM t4 WHERE 1.0 IN (x);
          238  +  }
          239  +} {}
          240  +
          241  +do_test 5.9 {
          242  +  execsql {
          243  +    SELECT x FROM t4 WHERE '1' IN (x);
          244  +  }
          245  +} {}
          246  +
          247  +do_test 5.10 {
          248  +  execsql {
          249  +    SELECT x FROM t4 WHERE '1.0' IN (x);
          250  +  }
          251  +} {}
          252  +
          253  +do_test 5.11 {
          254  +  execsql {
          255  +    SELECT x FROM t4 WHERE 1.11 IN (x);
          256  +  }
          257  +} {1.11}
          258  +
          259  +do_test 5.12 {
          260  +  execsql {
          261  +    SELECT x FROM t4 WHERE '1.11' IN (x);
          262  +  }
          263  +} {}
          264  +
          265  +finish_test