aboutsummaryrefslogtreecommitdiff
path: root/src/insert.c
diff options
context:
space:
mode:
authordrh <>2022-02-28 16:44:58 +0000
committerdrh <>2022-02-28 16:44:58 +0000
commit935c37229ca9f9a02ab076756ba4e95dcb4c44d7 (patch)
tree920379a20facc3619f81726a9b58fecff06edf6f /src/insert.c
parent8552b10c45578bb8e7f37ab5c44416e8f1ed7f35 (diff)
downloadsqlite-935c37229ca9f9a02ab076756ba4e95dcb4c44d7.tar.gz
sqlite-935c37229ca9f9a02ab076756ba4e95dcb4c44d7.zip
Fix the Xfer-optimization on the INSERT statement so that it is omitted if
there is a RETURNING clause, since that optimization is not able to deal with RETURNING. See [forum:/forumpost/595e132f71|forum thread 595e132f71] for details. FossilOrigin-Name: 1d3760a517b8bd2a6be82d2d5788945f49397cdc539fe28fd23e2c0c62a1dbe2
Diffstat (limited to 'src/insert.c')
-rw-r--r--src/insert.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/insert.c b/src/insert.c
index fd3590cb3..de01be3ba 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -795,7 +795,11 @@ void sqlite3Insert(
**
** This is the 2nd template.
*/
- if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){
+ if( pColumn==0
+ && pSelect!=0
+ && pTrigger==0
+ && xferOptimization(pParse, pTab, pSelect, onError, iDb)
+ ){
assert( !pTrigger );
assert( pList==0 );
goto insert_end;
@@ -2766,18 +2770,13 @@ static int xferOptimization(
int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */
int regData, regRowid; /* Registers holding data and rowid */
- if( pSelect==0 ){
- return 0; /* Must be of the form INSERT INTO ... SELECT ... */
- }
+ assert( pSelect!=0 );
if( pParse->pWith || pSelect->pWith ){
/* Do not attempt to process this query if there are an WITH clauses
** attached to it. Proceeding may generate a false "no such table: xxx"
** error if pSelect reads from a CTE named "xxx". */
return 0;
}
- if( sqlite3TriggerList(pParse, pDest) ){
- return 0; /* tab1 must not have triggers */
- }
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( IsVirtual(pDest) ){
return 0; /* tab1 must not be a virtual table */