diff options
author | drh <drh@noemail.net> | 2018-04-19 23:52:39 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-04-19 23:52:39 +0000 |
commit | 796369131419dac03306ee3d2275cf68dab4b1b8 (patch) | |
tree | c7c45aba515ab2522bba19b64af0f59af8cbc74d /src/insert.c | |
parent | 2633b289832043967d56fbfd46b7b0bd201e9a08 (diff) | |
download | sqlite-796369131419dac03306ee3d2275cf68dab4b1b8.tar.gz sqlite-796369131419dac03306ee3d2275cf68dab4b1b8.zip |
Fix the handling of "PRAGMA count_changes=ON" with UPSERT. Also improved
the implementation of count_changes in other places, without changing the
behavior.
FossilOrigin-Name: c6f71115eb933c2aee295bc31e5139112463c28e15a3b3ea242fd9bac168aed9
Diffstat (limited to 'src/insert.c')
-rw-r--r-- | src/insert.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/insert.c b/src/insert.c index e522d4664..b3a313836 100644 --- a/src/insert.c +++ b/src/insert.c @@ -784,7 +784,10 @@ void sqlite3Insert( /* Initialize the count of rows to be inserted */ - if( db->flags & SQLITE_CountRows ){ + if( (db->flags & SQLITE_CountRows)!=0 + && !pParse->nested + && !pParse->pTriggerTab + ){ regRowCount = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount); } @@ -1040,7 +1043,7 @@ void sqlite3Insert( /* Update the count of rows that are inserted */ - if( (db->flags & SQLITE_CountRows)!=0 ){ + if( regRowCount ){ sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1); } @@ -1077,7 +1080,7 @@ insert_end: ** generating code because of a call to sqlite3NestedParse(), do not ** invoke the callback function. */ - if( (db->flags&SQLITE_CountRows) && !pParse->nested && !pParse->pTriggerTab ){ + if( regRowCount ){ sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC); |