/ Check-in [507014e4]
Login

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

Overview
Comment:Fix the handling of OP_Eq opcodes that compare a register against itself and that require an affinity change.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 507014e4c7a70cd09410c89c8ed466c8edab39d2
User & Date: drh 2016-06-25 11:43:47
Context
2016-06-26
04:06
Prevent the WhereLoop.rSetup cost estimate from going negative on complex queries. check-in: f8105085 user: drh tags: trunk
2016-06-25
11:43
Fix the handling of OP_Eq opcodes that compare a register against itself and that require an affinity change. check-in: 507014e4 user: drh tags: trunk
2016-06-24
06:23
Fix the ctime.test script so that it works with clang. check-in: 77e4f7a3 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  2012   2012     }else{
  2013   2013       /* Neither operand is NULL.  Do a comparison. */
  2014   2014       affinity = pOp->p5 & SQLITE_AFF_MASK;
  2015   2015       if( affinity>=SQLITE_AFF_NUMERIC ){
  2016   2016         if( (flags1 | flags3)&MEM_Str ){
  2017   2017           if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
  2018   2018             applyNumericAffinity(pIn1,0);
         2019  +          flags3 = pIn3->flags;
  2019   2020           }
  2020   2021           if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
  2021   2022             applyNumericAffinity(pIn3,0);
  2022   2023           }
  2023   2024         }
  2024   2025       }else if( affinity==SQLITE_AFF_TEXT ){
  2025   2026         if( (flags1 & MEM_Str)==0 && (flags1 & (MEM_Int|MEM_Real))!=0 ){
  2026   2027           testcase( pIn1->flags & MEM_Int );
  2027   2028           testcase( pIn1->flags & MEM_Real );
  2028   2029           sqlite3VdbeMemStringify(pIn1, encoding, 1);
  2029   2030           testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
  2030   2031           flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
         2032  +        flags3 = pIn3->flags;
  2031   2033         }
  2032   2034         if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){
  2033   2035           testcase( pIn3->flags & MEM_Int );
  2034   2036           testcase( pIn3->flags & MEM_Real );
  2035   2037           sqlite3VdbeMemStringify(pIn3, encoding, 1);
  2036   2038           testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) );
  2037   2039           flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask);

Changes to test/selectA.test.

  1429   1429   } {
  1430   1430     SELECT * FROM t8 EXCEPT SELECT c, d FROM t9 ORDER BY d, t8.a COLLATE NOCASE
  1431   1431   }
  1432   1432   
  1433   1433   do_catchsql_test 5.4 {
  1434   1434     SELECT * FROM t8 UNION SELECT * FROM t9 ORDER BY a+b COLLATE NOCASE
  1435   1435   } {1 {1st ORDER BY term does not match any column in the result set}}
         1436  +
         1437  +do_execsql_test 6.1 {
         1438  +  DROP TABLE IF EXISTS t1;
         1439  +  DROP TABLE IF EXISTS t2;
         1440  +  CREATE TABLE t1(a INTEGER);
         1441  +  CREATE TABLE t2(b TEXT);
         1442  +  INSERT INTO t2(b) VALUES('12345');
         1443  +  SELECT * FROM (SELECT a FROM t1 UNION SELECT b FROM t2) WHERE a=a;
         1444  +} {12345}
  1436   1445   
  1437   1446   
  1438   1447   finish_test