diff -Npur -x .git sqlite.3.31.1_CVE-2020-11655_c415d910_patch002/manifest sqlite.3.31.1_CVE-2020-11656_fb99e388_4db7ab53_patch003/manifest
--- sqlite.3.31.1_CVE-2020-11655_c415d910_patch002/manifest	2020-05-25 09:50:05.352246036 +0800
+++ sqlite.3.31.1_CVE-2020-11656_fb99e388_4db7ab53_patch003/manifest	2020-05-25 10:00:45.272851274 +0800
@@ -1,5 +1,5 @@
 C Version\s3.31.1
-D 2020-04-03T13:19:03.054
+D 2020-04-03T11:52:59.198
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -465,9 +465,9 @@ F spec.template 86a4a43b99ebb3e75e6b9a73
 F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
 F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
 F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
-F src/alter.c f48a4423c8f198d7f1ae4940f74b606707d05384ac79fb219be8e3323af2a2de
-F src/analyze.c b3ceec3fc052df8a96ca8a8c858d455dc5029ba681b4be98bb5c5a9162cfa58c
-F src/attach.c df0ead9091042c68964856ecc08dba55d5403ad5f3ca865d9d396d71528c511a
+F src/alter.c ac9d737cace62b5cd88bff5310e53e299bc0919f08b5934a2bd0f8e8e65d770e
+F src/analyze.c 831bb090988477a00d3b4c000746e1b0454dcc93b10b793e6ebe1c47f25d193a
+F src/attach.c ff2daea0fe62080192e3f262670e4f61f5a86c1e7bea9cec34e960fe79852aa1
 F src/auth.c a3d5bfdba83d25abed1013a8c7a5f204e2e29b0c25242a56bc02bb0c07bf1e06
 F src/backup.c f70077d40c08b7787bfe934e4d1da8030cb0cc57d46b345fba2294b7d1be23ab
 F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
@@ -639,7 +639,7 @@ F test/altercol.test 1d6a6fe698b81e626ba
 F test/alterlegacy.test 82022721ce0de29cedc9a7af63bc9fcc078b0ee000f8283b4b6ea9c3eab2f44b
 F test/altermalloc.test 167a47de41b5c638f5f5c6efb59784002b196fff70f98d9b4ed3cd74a3fb80c9
 F test/altermalloc2.test fa7b1c1139ea39b8dec407cf1feb032ca8e0076bd429574969b619175ad0174b
-F test/altertab.test bd61e5b73d495ec4707133db91b07f09d57e339d988de5ec5a76d34a2198e8f2
+F test/altertab.test 523ba6368e0da19f462f7c05563c569675736d946724cac1c4ae848f76783434
 F test/altertab2.test b0d62f323ca5dab42b0bc028c52e310ebdd13e655e8fac070fe622bad7852c2b
 F test/altertab3.test 155b8dc225ce484454a7fb4c8ba745680b6fa0fc3e08919cbbc19f9309d128ff
 F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f
@@ -1857,10 +1857,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 684293882c302600e112cf52553c19d84fdb31663d96e5dd7f8ac17dda00a026
-R dbb40938a904f2e39c11078dcedb87b0
+P d09f8c3621d5f7f8c6d99d7d82bcaa8421855b3f470bea2b26c858106382b906
+R 800f7c7b57166aa2318c88ff52f2e7ab
 T +bgcolor * #d0c0ff
 T +sym-release *
 T +sym-version-3.31.1 *
-U drh
-Z 1c021fc7d9ac6b5d0e31d06cd9bb3304
+U dan
+Z 369e72d27cf5a202a4749d0a2e3d428e
diff -Npur -x .git sqlite.3.31.1_CVE-2020-11655_c415d910_patch002/manifest.uuid sqlite.3.31.1_CVE-2020-11656_fb99e388_4db7ab53_patch003/manifest.uuid
--- sqlite.3.31.1_CVE-2020-11655_c415d910_patch002/manifest.uuid	2020-05-25 09:50:19.076317552 +0800
+++ sqlite.3.31.1_CVE-2020-11656_fb99e388_4db7ab53_patch003/manifest.uuid	2020-05-25 10:01:03.568710038 +0800
@@ -1 +1 @@
-4a302b42c7bf5e11ddb5522ca999f74aba397d3a7eb91b1844bb02852f772441
+684293882c302600e112cf52553c19d84fdb31663d96e5dd7f8ac17dda00a026
diff -Npur -x .git sqlite.3.31.1_CVE-2020-11655_c415d910_patch002/src/alter.c sqlite.3.31.1_CVE-2020-11656_fb99e388_4db7ab53_patch003/src/alter.c
--- sqlite.3.31.1_CVE-2020-11655_c415d910_patch002/src/alter.c	2020-05-25 09:43:54.350324669 +0800
+++ sqlite.3.31.1_CVE-2020-11656_fb99e388_4db7ab53_patch003/src/alter.c	2020-05-25 09:57:36.168219061 +0800
@@ -756,6 +756,21 @@ static void renameWalkWith(Walker *pWalk
 }
 
 /*
+** Unmap all tokens in the IdList object passed as the second argument.
+*/
+static void unmapColumnIdlistNames(
+  Parse *pParse,
+  IdList *pIdList
+){
+  if( pIdList ){
+    int ii;
+    for(ii=0; ii<pIdList->nId; ii++){
+      sqlite3RenameTokenRemap(pParse, 0, (void*)pIdList->a[ii].zName);
+    }
+  }
+}
+
+/*
 ** Walker callback used by sqlite3RenameExprUnmap().
 */
 static int renameUnmapSelectCb(Walker *pWalker, Select *p){
@@ -776,6 +791,7 @@ static int renameUnmapSelectCb(Walker *p
     for(i=0; i<pSrc->nSrc; i++){
       sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName);
       if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort;
+      unmapColumnIdlistNames(pParse, pSrc->a[i].pUsing);
     }
   }
 
@@ -984,6 +1000,7 @@ static void renameColumnIdlistNames(
   }
 }
 
+
 /*
 ** Parse the SQL statement zSql using Parse object (*p). The Parse object
 ** is initialized by this function before it is used.
diff -Npur -x .git sqlite.3.31.1_CVE-2020-11655_c415d910_patch002/src/resolve.c sqlite.3.31.1_CVE-2020-11656_fb99e388_4db7ab53_patch003/src/resolve.c
--- sqlite.3.31.1_CVE-2020-11655_c415d910_patch002/src/resolve.c	2020-05-25 09:43:54.362324731 +0800
+++ sqlite.3.31.1_CVE-2020-11656_fb99e388_4db7ab53_patch003/src/resolve.c	2020-05-25 10:00:02.705658443 +0800
@@ -1177,7 +1177,7 @@ static int resolveOrderByTermToExprList(
   nc.nErr = 0;
   db = pParse->db;
   savedSuppErr = db->suppressErr;
-  db->suppressErr = 1;
+  if( IN_RENAME_OBJECT==0 ) db->suppressErr = 1;
   rc = sqlite3ResolveExprNames(&nc, pE);
   db->suppressErr = savedSuppErr;
   if( rc ) return 0;
diff -Npur -x .git sqlite.3.31.1_CVE-2020-11655_c415d910_patch002/test/altertab.test sqlite.3.31.1_CVE-2020-11656_fb99e388_4db7ab53_patch003/test/altertab.test
--- sqlite.3.31.1_CVE-2020-11655_c415d910_patch002/test/altertab.test	2020-05-25 09:43:54.462325244 +0800
+++ sqlite.3.31.1_CVE-2020-11656_fb99e388_4db7ab53_patch003/test/altertab.test	2020-05-25 10:00:02.697658682 +0800
@@ -594,7 +594,6 @@ reset_db
 do_execsql_test 18.1.0 {
   CREATE TABLE t0 (c0 INTEGER, PRIMARY KEY(c0)) WITHOUT ROWID;
 }
-breakpoint
 do_execsql_test 18.1.1 {
   ALTER TABLE t0 RENAME COLUMN c0 TO c1;
 }
@@ -613,4 +612,51 @@ do_execsql_test 18.2.2 {
   SELECT sql FROM sqlite_master;
 } {{CREATE TABLE t0 (c1 INTEGER, PRIMARY KEY(c1))}}
 
+# 2020-02-23 ticket f50af3e8a565776b
+reset_db
+do_execsql_test 19.100 {
+  CREATE TABLE t1(x);
+  CREATE VIEW t2 AS SELECT 1 FROM t1, (t1 AS a0, t1);
+  ALTER TABLE t1 RENAME TO t3;
+  SELECT sql FROM sqlite_master;
+} {{CREATE TABLE "t3"(x)} {CREATE VIEW t2 AS SELECT 1 FROM "t3", ("t3" AS a0, "t3")}}
+do_execsql_test 19.110 {
+  INSERT INTO t3(x) VALUES(123);
+  SELECT * FROM t2;
+} {1}
+do_execsql_test 19.120 {
+  INSERT INTO t3(x) VALUES('xyz');
+  SELECT * FROM t2;
+} {1 1 1 1 1 1 1 1}
+
+# Ticket 4722bdab08cb14
+reset_db
+do_execsql_test 20.0 {
+  CREATE TABLE a(a);
+  CREATE VIEW b AS SELECT(SELECT *FROM c JOIN a USING(d, a, a, a) JOIN a) IN();
+}
+do_execsql_test 20.1 {
+  ALTER TABLE a RENAME a TO e;
+} {}
+
+reset_db
+do_execsql_test 21.0 {
+  CREATE TABLE a(b);
+  CREATE VIEW c AS 
+      SELECT NULL INTERSECT 
+      SELECT NULL ORDER BY
+      likelihood(NULL, (d, (SELECT c)));
+} {}
+do_catchsql_test 21.1 {
+  SELECT likelihood(NULL, (d, (SELECT c)));
+} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
+do_catchsql_test 21.2 {
+  SELECT * FROM c;
+} {1 {1st ORDER BY term does not match any column in the result set}}
+
+do_catchsql_test 21.3 {
+  ALTER TABLE a RENAME TO e;
+} {1 {error in view c: 1st ORDER BY term does not match any column in the result set}}
+
+
 finish_test
