diff options
author | drh <drh@noemail.net> | 2019-12-28 01:52:46 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-12-28 01:52:46 +0000 |
commit | d9670abb582fc32dcce08fa143abef5f19029e56 (patch) | |
tree | fa70e29ec2dfce1eb77c37cd451825f8622b2c04 /src/insert.c | |
parent | ad5f157791a72c1f2812d8fe76e1522fd7a6cb6b (diff) | |
download | sqlite-d9670abb582fc32dcce08fa143abef5f19029e56.tar.gz sqlite-d9670abb582fc32dcce08fa143abef5f19029e56.zip |
When an INSERT is receiving content from a SELECT, run an OP_ReleaseReg opcode
at the top of each iteration of the loop in order to prevent spurious
OP_SCopy misuse complaints. Ticket [de4b04149b9fdeae]
FossilOrigin-Name: 6afadd3b3a40b0ef29fd14fb24c2a4b9479483e5f8b9125ce02d8daae662207f
Diffstat (limited to 'src/insert.c')
-rw-r--r-- | src/insert.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/insert.c b/src/insert.c index 61b13bf2d..423087e37 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1020,6 +1020,7 @@ void sqlite3Insert( ** goto C ** D: ... */ + sqlite3VdbeReleaseRegisters(pParse, regData, pTab->nCol, 0); addrInsTop = addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm); VdbeCoverage(v); if( ipkColumn>=0 ){ @@ -1280,6 +1281,15 @@ void sqlite3Insert( sqlite3VdbeAddOp1(v, OP_Close, srcTab); }else if( pSelect ){ sqlite3VdbeGoto(v, addrCont); +#ifdef SQLITE_DEBUG + /* If we are jumping back to an OP_Yield that is preceded by an + ** OP_ReleaseReg, set the p5 flag on the OP_Goto so that the + ** OP_ReleaseReg will be included in the loop. */ + if( sqlite3VdbeGetOp(v, addrCont-1)->opcode==OP_ReleaseReg ){ + assert( sqlite3VdbeGetOp(v, addrCont)->opcode==OP_Yield ); + sqlite3VdbeChangeP5(v, 1); + } +#endif sqlite3VdbeJumpHere(v, addrInsTop); } |