mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Fix a problem when renaming an IPK column that is also part of a child key.
FossilOrigin-Name: ad15486022209205c65fb5ffdbe30a7b99379170451e6aff4bab6e90b549d6c7
This commit is contained in:
25
src/alter.c
25
src/alter.c
@@ -1116,6 +1116,18 @@ static void renameColumnFunc(
|
||||
if( sParse.pNewTable ){
|
||||
int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName);
|
||||
FKey *pFKey;
|
||||
for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
for(i=0; i<pFKey->nCol; i++){
|
||||
if( bFKOnly==0 && pFKey->aCol[i].iFrom==sCtx.iCol ){
|
||||
renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]);
|
||||
}
|
||||
if( 0==sqlite3_stricmp(pFKey->zTo, zTable)
|
||||
&& 0==sqlite3_stricmp(pFKey->aCol[i].zCol, zOld)
|
||||
){
|
||||
renameTokenFind(&sParse, &sCtx, (void*)pFKey->aCol[i].zCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
if( bFKOnly==0 ){
|
||||
renameTokenFind(
|
||||
&sParse, &sCtx, (void*)sParse.pNewTable->aCol[sCtx.iCol].zName
|
||||
@@ -1130,19 +1142,6 @@ static void renameColumnFunc(
|
||||
sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
|
||||
}
|
||||
}
|
||||
|
||||
for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
|
||||
for(i=0; i<pFKey->nCol; i++){
|
||||
if( bFKOnly==0 && pFKey->aCol[i].iFrom==sCtx.iCol ){
|
||||
renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]);
|
||||
}
|
||||
if( 0==sqlite3_stricmp(pFKey->zTo, zTable)
|
||||
&& 0==sqlite3_stricmp(pFKey->aCol[i].zCol, zOld)
|
||||
){
|
||||
renameTokenFind(&sParse, &sCtx, (void*)pFKey->aCol[i].zCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
sqlite3WalkExprList(&sWalker, sParse.pNewIndex->aColExpr);
|
||||
sqlite3WalkExpr(&sWalker, sParse.pNewIndex->pPartIdxWhere);
|
||||
|
||||
Reference in New Issue
Block a user