|
|
03a7db |
From 0990c415f65d2556a5e4122cbe5727d500411aeb Mon Sep 17 00:00:00 2001
|
|
|
03a7db |
From: drh <drh@noemail.net>
|
|
|
03a7db |
Date: Sun, 23 Feb 2020 17:34:45 +0000
|
|
|
03a7db |
Subject: [PATCH] Fix a problem with ALTER TABLE for views that have a nested
|
|
|
03a7db |
FROM clause. Ticket [f50af3e8a565776b].
|
|
|
03a7db |
|
|
|
03a7db |
FossilOrigin-Name: c431b3fd8fd0f6a6974bba3e9366b0430ec003d570e7ce70ceefbcff5fe4b6fa
|
|
|
03a7db |
---
|
|
|
03a7db |
src/select.c | 2 +-
|
|
|
03a7db |
test/altertab.test | 17 +++++++++++++++++
|
|
|
03a7db |
4 files changed, 18 insertions(+), 1 deletions(-)
|
|
|
03a7db |
|
|
|
03a7db |
diff --git a/src/select.c b/src/select.c
|
|
|
03a7db |
index c60ff2700..fe0229ca8 100644
|
|
|
03a7db |
--- a/src/select.c
|
|
|
03a7db |
+++ b/src/select.c
|
|
|
03a7db |
@@ -5046,7 +5046,7 @@ static int selectExpander(Walker *pWalker, Select *p){
|
|
|
03a7db |
pNew = sqlite3ExprListAppend(pParse, pNew, pExpr);
|
|
|
03a7db |
sqlite3TokenInit(&sColname, zColname);
|
|
|
03a7db |
sqlite3ExprListSetName(pParse, pNew, &sColname, 0);
|
|
|
03a7db |
- if( pNew && (p->selFlags & SF_NestedFrom)!=0 ){
|
|
|
03a7db |
+ if( pNew && (p->selFlags & SF_NestedFrom)!=0 && !IN_RENAME_OBJECT){
|
|
|
03a7db |
struct ExprList_item *pX = &pNew->a[pNew->nExpr-1];
|
|
|
03a7db |
if( pSub ){
|
|
|
03a7db |
pX->zSpan = sqlite3DbStrDup(db, pSub->pEList->a[j].zSpan);
|
|
|
03a7db |
|
|
|
03a7db |
diff --git a/test/altertab.test b/test/altertab.test
|
|
|
03a7db |
index a3642070e..520502c3d 100644
|
|
|
03a7db |
--- a/test/altertab.test
|
|
|
03a7db |
+++ b/test/altertab.test
|
|
|
03a7db |
@@ -578,5 +578,21 @@ ifcapable fts3 {
|
|
|
03a7db |
SELECT * FROM z1_segments;
|
|
|
03a7db |
}
|
|
|
03a7db |
}
|
|
|
03a7db |
+# 2020-02-23 ticket f50af3e8a565776b
|
|
|
03a7db |
+reset_db
|
|
|
03a7db |
+do_execsql_test 19.100 {
|
|
|
03a7db |
+ CREATE TABLE t1(x);
|
|
|
03a7db |
+ CREATE VIEW t2 AS SELECT 1 FROM t1, (t1 AS a0, t1);
|
|
|
03a7db |
+ ALTER TABLE t1 RENAME TO t3;
|
|
|
03a7db |
+ SELECT sql FROM sqlite_master;
|
|
|
03a7db |
+} {{CREATE TABLE "t3"(x)} {CREATE VIEW t2 AS SELECT 1 FROM "t3", ("t3" AS a0, "t3")}}
|
|
|
03a7db |
+do_execsql_test 19.110 {
|
|
|
03a7db |
+ INSERT INTO t3(x) VALUES(123);
|
|
|
03a7db |
+ SELECT * FROM t2;
|
|
|
03a7db |
+} {1}
|
|
|
03a7db |
+do_execsql_test 19.120 {
|
|
|
03a7db |
+ INSERT INTO t3(x) VALUES('xyz');
|
|
|
03a7db |
+ SELECT * FROM t2;
|
|
|
03a7db |
+} {1 1 1 1 1 1 1 1}
|
|
|
03a7db |
|
|
|
03a7db |
finish_test
|
|
|
03a7db |
--
|
|
|
03a7db |
2.37.3
|
|
|
03a7db |
|