diff options
author | drh <> | 2021-06-11 13:18:56 +0000 |
---|---|---|
committer | drh <> | 2021-06-11 13:18:56 +0000 |
commit | 35e6cd09f2387cb75d4b971413d2efa3f8d91b13 (patch) | |
tree | 25e7a91e8eca660a3a96403b8d836e7af5b6f636 /src/alter.c | |
parent | cf145047b0d0ef57ffaaaad3e7d17dcf653a3244 (diff) | |
download | sqlite-35e6cd09f2387cb75d4b971413d2efa3f8d91b13.tar.gz sqlite-35e6cd09f2387cb75d4b971413d2efa3f8d91b13.zip |
Reapply two recent ALTER TABLE error checks that turned out to be necessary
after all. dbsqlfuzz fc5a9deefda00dda914748985155a6d4c44174e5.
FossilOrigin-Name: 230fedd923c87741d20caf55f29e8464cc6df344536f9b89331e0a0059a926f7
Diffstat (limited to 'src/alter.c')
-rw-r--r-- | src/alter.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/alter.c b/src/alter.c index e5f1eb315..de0dd4e4d 100644 --- a/src/alter.c +++ b/src/alter.c @@ -802,27 +802,27 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){ if( pWith ){ Parse *pParse = pWalker->pParse; int i; - With *pCopy; - - /* Push a copy of the With object onto the with-stack. We use a copy - ** here as the original will be expanded and resolved (flags SF_Expanded - ** and SF_Resolved) below. And the parser code that uses the with-stack - ** fails if the Select objects on it have already been expanded and - ** resolved. */ + With *pCopy = 0; assert( pWith->nCte>0 ); - assert( (pWith->a[0].pSelect->selFlags & SF_Expanded)==0 ); - pCopy = sqlite3WithDup(pParse->db, pWith); - if( pCopy ){ + if( (pWith->a[0].pSelect->selFlags & SF_Expanded)==0 ){ + /* Push a copy of the With object onto the with-stack. We use a copy + ** here as the original will be expanded and resolved (flags SF_Expanded + ** and SF_Resolved) below. And the parser code that uses the with-stack + ** fails if the Select objects on it have already been expanded and + ** resolved. */ + pCopy = sqlite3WithDup(pParse->db, pWith); sqlite3WithPush(pParse, pCopy, 1); - for(i=0; i<pWith->nCte; i++){ - Select *p = pWith->a[i].pSelect; - NameContext sNC; - memset(&sNC, 0, sizeof(sNC)); - sNC.pParse = pParse; - sqlite3SelectPrep(sNC.pParse, p, &sNC); - sqlite3WalkSelect(pWalker, p); - sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols); - } + } + for(i=0; i<pWith->nCte; i++){ + Select *p = pWith->a[i].pSelect; + NameContext sNC; + memset(&sNC, 0, sizeof(sNC)); + sNC.pParse = pParse; + if( pCopy ) sqlite3SelectPrep(sNC.pParse, p, &sNC); + sqlite3WalkSelect(pWalker, p); + sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols); + } + if( pCopy && pParse->pWith==pCopy ){ pParse->pWith = pCopy->pOuter; } } |