From ca29bbce2f7124c56ee3be96989a620e196a545d Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 27 May 2022 15:33:51 +0000 Subject: [PATCH] Fix another problem with ALTER TABLE and UPDATE...FROM in triggers. FossilOrigin-Name: 33cf12235e6469ba17cfb72cef0e480dfd0dea81ed412fb1fb24b05dbeb8dc02 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/alter.c | 5 +---- test/altermalloc3.test | 7 +++++++ test/altertrig.test | 17 +++++++++++++++++ 5 files changed, 34 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 618e033d9b..f033407924 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sfurther\sissues\swith\sALTER\sTABLE\sand\striggers\sthat\scontain\sUPDATE..FROM\sstatements. -D 2022-05-27T15:04:43.439 +C Fix\sanother\sproblem\swith\sALTER\sTABLE\sand\sUPDATE...FROM\sin\striggers. +D 2022-05-27T15:33:51.795 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -500,7 +500,7 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a -F src/alter.c da06f14f959f6b5d0776e1aa65df100f40fdca72c25888a80ee1fac686449458 +F src/alter.c d8671d56a89123dfeb517efbd580043a67b5859a615c31745f533567fd42e69b F src/analyze.c aabdf3769c7fd9954a8ec508eb7041ae174b66f88d12c47199fabbea9a646467 F src/attach.c 4431f82f0247bf3aaf91589acafdff77d1882235c95407b36da1585c765fbbc8 F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf @@ -680,12 +680,12 @@ F test/alterfault.test 289067108947bedca27534edd4ff251bcd298cf84402d7b24eaa37493 F test/alterlegacy.test f38c6d06cda39e1f7b955bbce57f2e3ef5b7cb566d3d1234502093e228c15811 F test/altermalloc.test 167a47de41b5c638f5f5c6efb59784002b196fff70f98d9b4ed3cd74a3fb80c9 F test/altermalloc2.test 17fb3724c4b004c469c27dc4ef181608aa644555fbd3f3236767584f73747c81 -F test/altermalloc3.test 55e606edf4b0acfbbd851ddfe93cfdddfae43d103644dcfd6008ae4ab3c44adf +F test/altermalloc3.test 8531b3086f0a7889f43971a579a8c81832d5123f4703d8c86b89ba1136c63b9a F test/alterqf.test ff6c6f881485c29ed699b8ef4774864ca1b0c01a6c08f5cdd624a008e4b40fca F test/altertab.test 7273b8506eab46342be016af78028df49f3bd99037412f997a8f1011b37a6912 F test/altertab2.test 62597b6fd08feaba1b6bfe7d31dac6117c67e06dc9ce9c478a3abe75b5926de0 F test/altertab3.test 6c432fbb9963e0bd6549bf1422f6861d744ee5a80cb3298564e81e556481df16 -F test/altertrig.test 88e135a1b12e47d5e58907e5377e11886138fdb2595ee28d90eafa413dd7b76c +F test/altertrig.test fb5951d21a2c954be3b8a8cf8e10b5c0fa20687c53fd67d63cea88d08dd058d5 F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f F test/analyze.test 547bb700f903107b38611b014ca645d6b5bb819f5210d7bf39c40802aafeb7d7 F test/analyze3.test 4440c4932247adb2b4e0c838f657c19dc7af4f56859255436dc4e855f39b9324 @@ -1970,8 +1970,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P f56473f9cc1b476b3219fe5b70ba2e4b269b20c880b99ba34c744ed893042081 -R 0ae7a7d81b6be8208e4b3991ef96f464 +P 53fbc269ddbabc4a97d297e881e5f9cd2bfbcd24af4af1b7cf9db412a3a51813 +R 782c6ab6608c09278d06be6bd8fb58f8 U dan -Z 40c01dde42ad7fab93128120ceda9147 +Z 229c3e01bc73b34742f015169bd23836 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index a57fbddcd2..88e3da28af 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -53fbc269ddbabc4a97d297e881e5f9cd2bfbcd24af4af1b7cf9db412a3a51813 \ No newline at end of file +33cf12235e6469ba17cfb72cef0e480dfd0dea81ed412fb1fb24b05dbeb8dc02 \ No newline at end of file diff --git a/src/alter.c b/src/alter.c index 12bf3d5ae8..9ccab37c78 100644 --- a/src/alter.c +++ b/src/alter.c @@ -1318,21 +1318,18 @@ static int renameResolveTrigger(Parse *pParse){ SrcList *pSrc = sqlite3TriggerStepSrc(pParse, pStep); if( pSrc ){ Select *pSel = sqlite3SelectNew( - pParse, pStep->pExprList, pSrc, pStep->pWhere, 0, 0, 0, 0, 0 + pParse, pStep->pExprList, pSrc, 0, 0, 0, 0, 0, 0 ); if( pSel==0 ){ pStep->pExprList = 0; - pStep->pWhere = 0; pSrc = 0; rc = SQLITE_NOMEM; }else{ sqlite3SelectPrep(pParse, pSel, 0); rc = pParse->nErr ? SQLITE_ERROR : SQLITE_OK; assert( pStep->pExprList==0 || pStep->pExprList==pSel->pEList ); - assert( pStep->pWhere==pSel->pWhere ); assert( pSrc==pSel->pSrc ); if( pStep->pExprList ) pSel->pEList = 0; - pSel->pWhere = 0; pSel->pSrc = 0; sqlite3SelectDelete(db, pSel); } diff --git a/test/altermalloc3.test b/test/altermalloc3.test index 7023b1c0f6..2dc0b46f29 100644 --- a/test/altermalloc3.test +++ b/test/altermalloc3.test @@ -21,6 +21,7 @@ ifcapable !altertable { return } + set ::TMPDBERROR [list 1 \ {unable to open a temporary database file for storing temporary tables} ] @@ -47,6 +48,7 @@ do_faultsim_test 1 -prep { faultsim_test_result {0 {}} $::TMPDBERROR } + #------------------------------------------------------------------------- # dbsqlfuzz e3dd84cda3848016a6a6024c7249d09bc2ef2615 # @@ -59,6 +61,11 @@ do_execsql_test 2.0 { SELECT a FROM cte1 ), 1); END; + + CREATE TRIGGER r1 AFTER INSERT ON t2 BEGIN + UPDATE t2 SET k=1 FROM t2 AS one, t2 AS two NATURAL JOIN t2 AS three + WHERE one.k=two.v; + END; } faultsim_save_and_close diff --git a/test/altertrig.test b/test/altertrig.test index 71aae563cd..934a636669 100644 --- a/test/altertrig.test +++ b/test/altertrig.test @@ -118,6 +118,22 @@ foreach {tn alter update final} { } { UPDATE t1 SET a=t2.abc FROM t2, t3 } + + 7 { + ALTER TABLE t4 RENAME e TO abc + } { + UPDATE t1 SET a=1 FROM t3 NATURAL JOIN t4 WHERE t4.e=a + } { + UPDATE t1 SET a=1 FROM t3 NATURAL JOIN t4 WHERE t4.abc=a + } + + 8 { + ALTER TABLE t4 RENAME TO abc + } { + UPDATE t1 SET a=1 FROM t3 NATURAL JOIN t4 WHERE t4.e=a + } { + UPDATE t1 SET a=1 FROM t3 NATURAL JOIN "abc" WHERE "abc".e=a + } } { reset_db @@ -125,6 +141,7 @@ foreach {tn alter update final} { CREATE TABLE t1(a,b); CREATE TABLE t2(c,d); CREATE TABLE t3(e,f); + CREATE TABLE t4(e,f); } do_execsql_test 2.$tn.2 " CREATE TRIGGER r1 INSERT ON t1 BEGIN