SQLite

Check-in [67d0b2c152]
Login

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

Overview
Comment:Fix a problem in sqlite3ExprCompare() associated with UPSERT.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 67d0b2c15299dd20bca7254ecb33e71b5eee6024e2709bfdc36f877bf2a5679f
User & Date: drh 2018-04-23 20:38:40.741
Context
2018-04-24
00:08
Fix to check-in [ca34c2dd20ee071e] - avoid a NULL pointer dereference following an OOM. (check-in: c7e6e848fa user: drh tags: trunk)
2018-04-23
20:38
Fix a problem in sqlite3ExprCompare() associated with UPSERT. (check-in: 67d0b2c152 user: drh tags: trunk)
20:04
Fix a formatting issue in the TreeView output for bare expression lists. (check-in: a635681781 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/expr.c.
4916
4917
4918
4919
4920
4921
4922
4923

4924
4925
4926
4927
4928
4929
4930
  }
  if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
  if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
    if( combinedFlags & EP_xIsSelect ) return 2;
    if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
    if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
    if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
    if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){

      if( pA->iColumn!=pB->iColumn ) return 2;
      if( pA->iTable!=pB->iTable 
       && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
    }
  }
  return 0;
}







|
>







4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
  }
  if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
  if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
    if( combinedFlags & EP_xIsSelect ) return 2;
    if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
    if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
    if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
    assert( (combinedFlags & EP_Reduced)==0 );
    if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
      if( pA->iColumn!=pB->iColumn ) return 2;
      if( pA->iTable!=pB->iTable 
       && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
    }
  }
  return 0;
}
Changes to test/upsert1.test.
99
100
101
102
103
104
105








106
107
      ON CONFLICT(a) DO UPDATE SET b=b+1;
} {1}
do_execsql_test upsert1-410 {
  PRAGMA count_changes=OFF;
  SELECT a, b FROM t2 ORDER BY a;
} {four 1 one 3 three 2 two 1}










finish_test







>
>
>
>
>
>
>
>


99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
      ON CONFLICT(a) DO UPDATE SET b=b+1;
} {1}
do_execsql_test upsert1-410 {
  PRAGMA count_changes=OFF;
  SELECT a, b FROM t2 ORDER BY a;
} {four 1 one 3 three 2 two 1}

# Problem found by AFL prior to any release
do_execsql_test upsert1-500 {
  DROP TABLE t1;
  CREATE TABLE t1(x INTEGER PRIMARY KEY, y INT UNIQUE);
  INSERT INTO t1(x,y) SELECT 1,2 WHERE true
    ON CONFLICT(x) DO UPDATE SET y=max(t1.y,excluded.y) AND true;
  SELECT * FROM t1;
} {1 2}

finish_test