-C Add\sextra\stests\sto\swith2.test.
-D 2014-01-17T20:36:17.628
+C Avoid\sspurious\s"no\ssuch\stable"\serrors\sin\sstatements\sof\sthe\sform\s"INSERT\sINTO\stbl\sWITH\sxxx\sAS\s(...)\sSELECT\s*\sFROM\sxxx".
+D 2014-01-18T08:27:02.507
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4
F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
-F src/insert.c cb4c8ad02b6feb95d34614d94a3c68e0116fbf07
+F src/insert.c a4450f0c46a9f221622e6551ab0953b03c4f8ee8
F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12
F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b
F test/win32lock.test 7a6bd73a5dcdee39b5bb93e92395e1773a194361
F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d
F test/with1.test 6e49c7841abb5603425f8f1316ab077f6a9bbb49
-F test/with2.test eaafa54aa7aec8dd824de7d166a2452a63156737
+F test/with2.test 5f7ea3453c998a6b9ed3456f251c80d94722f22a
F test/withM.test 52448ce23e1c2ecba79d10e130ee49ce9f9a2a7a
F test/without_rowid1.test aaa26da19d543cd8d3d2d0e686dfa255556c15c8
F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 2031004d960526d6426d50d7b732f37b281534e2
-R 18aca364b17ce09cd2d25269185d295f
+P eecc325afd72e37d7d565787c8cea68aad6d7a5c
+R 2a1f6d87654c7bd1758f1648d991f83e
U dan
-Z d7942df5ea7f32fd101e4ac65d1e6fab
+Z bdd16ade1b5f6c0b188978b71304d4f1
-eecc325afd72e37d7d565787c8cea68aad6d7a5c
\ No newline at end of file
+cccff8a0b427feb05cc8952a765b829e731394fd
\ No newline at end of file
**
** 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;
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 */
}
do_execsql_test 4.6 [genstmt $nLimit] 1
do_catchsql_test 4.7 [genstmt [expr $nLimit+1]] {1 {too many columns in index}}
+#---------------------------------------------------------------------------
+# Check that adding a WITH clause to an INSERT disables the xfer
+# optimization.
+#
+proc do_xfer_test {tn bXfer sql {res {}}} {
+ set ::sqlite3_xferopt_count 0
+ uplevel [list do_test $tn [subst -nocommands {
+ set dres [db eval {$sql}]
+ list [set ::sqlite3_xferopt_count] [set dres]
+ }] [list $bXfer $res]]
+}
+
+do_execsql_test 5.1 {
+ DROP TABLE IF EXISTS t1;
+ DROP TABLE IF EXISTS t2;
+ CREATE TABLE t1(a, b);
+ CREATE TABLE t2(a, b);
+}
+
+do_xfer_test 5.2 1 { INSERT INTO t1 SELECT * FROM t2 }
+do_xfer_test 5.3 0 { INSERT INTO t1 SELECT a, b FROM t2 }
+do_xfer_test 5.4 0 { INSERT INTO t1 SELECT b, a FROM t2 }
+do_xfer_test 5.5 0 {
+ WITH x AS (SELECT a, b FROM t2) INSERT INTO t1 SELECT * FROM x
+}
+do_xfer_test 5.6 0 {
+ WITH x AS (SELECT a, b FROM t2) INSERT INTO t1 SELECT * FROM t2
+}
+do_xfer_test 5.7 0 {
+ INSERT INTO t1 WITH x AS ( SELECT * FROM t2 ) SELECT * FROM x
+}
+do_xfer_test 5.8 0 {
+ INSERT INTO t1 WITH x(a,b) AS ( SELECT * FROM t2 ) SELECT * FROM x
+}
+
finish_test