aboutsummaryrefslogtreecommitdiff
path: root/src/insert.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2014-01-18 08:27:02 +0000
committerdan <dan@noemail.net>2014-01-18 08:27:02 +0000
commitebbf08a012317c757808ae48e85ffd93a0a9953c (patch)
treeee3262000e077e5269bd718f8119d95463b5f800 /src/insert.c
parent7c82932723fc9e7d7531408db34f8ce67c2bbe81 (diff)
downloadsqlite-ebbf08a012317c757808ae48e85ffd93a0a9953c.tar.gz
sqlite-ebbf08a012317c757808ae48e85ffd93a0a9953c.zip
Avoid spurious "no such table" errors in statements of the form "INSERT INTO tbl WITH xxx AS (...) SELECT * FROM xxx".
FossilOrigin-Name: cccff8a0b427feb05cc8952a765b829e731394fd
Diffstat (limited to 'src/insert.c')
-rw-r--r--src/insert.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/insert.c b/src/insert.c
index b4bd6b716..a2366360c 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -667,8 +667,7 @@ void sqlite3Insert(
**
** This is the 2nd template.
*/
- if( pColumn==0 && pParse->pWith==0
- && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){
+ if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){
assert( !pTrigger );
assert( pList==0 );
goto insert_end;
@@ -1859,6 +1858,12 @@ static int xferOptimization(
if( pSelect==0 ){
return 0; /* Must be of the form INSERT INTO ... SELECT ... */
}
+ 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 */
}