Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a bug causing ALTER TABLE RENAME COLUMN to fail when renaming an IPK column that is used in a CHECK constraint. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | alter-table-rename-column |
Files: | files | file ages | folders |
SHA3-256: |
6595c8811f13719d0aed8041abc7e1ca |
User & Date: | dan 2018-08-11 17:49:23.862 |
Context
2018-08-11
| ||
18:34 | Avoid an assert() sometimes triggered by ALTER TABLE RENAME COLUMN in non-debug builds. (check-in: 520c1c75da user: dan tags: alter-table-rename-column) | |
17:49 | Fix a bug causing ALTER TABLE RENAME COLUMN to fail when renaming an IPK column that is used in a CHECK constraint. (check-in: 6595c8811f user: dan tags: alter-table-rename-column) | |
17:34 | Fix a bug causing all ALTER TABLE RENAME COLUMN commands to fail if ANALYZE had been run on the database. Also prevent the user from renaming the columns of system tables. (check-in: ca644a2877 user: dan tags: alter-table-rename-column) | |
Changes
Changes to src/alter.c.
︙ | ︙ | |||
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 | int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName); FKey *pFKey; if( bFKOnly==0 ){ sCtx.pList = renameTokenFind( &sParse, (void*)sParse.pNewTable->aCol[sCtx.iCol].zName ); sCtx.nList = 1; sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck); for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){ sqlite3WalkExprList(&sWalker, pIdx->aColExpr); } } for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){ | > > > > | 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 | int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName); FKey *pFKey; if( bFKOnly==0 ){ sCtx.pList = renameTokenFind( &sParse, (void*)sParse.pNewTable->aCol[sCtx.iCol].zName ); sCtx.nList = 1; assert( sCtx.iCol>=0 ); if( sParse.pNewTable->iPKey==sCtx.iCol ){ sCtx.iCol = -1; } sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck); for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){ sqlite3WalkExprList(&sWalker, pIdx->aColExpr); } } for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){ |
︙ | ︙ |
Changes to test/altercol.test.
︙ | ︙ | |||
178 179 180 181 182 183 184 185 186 187 | ALTER TABLE t5 RENAME b TO big; SELECT big FROM t5; } {2 5} do_catchsql_test 6.1 { ALTER TABLE sqlite_stat1 RENAME tbl TO thetable; } {1 {table sqlite_stat1 may not be altered}} finish_test | > > > > > > > > > > > > > > > > > | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | ALTER TABLE t5 RENAME b TO big; SELECT big FROM t5; } {2 5} do_catchsql_test 6.1 { ALTER TABLE sqlite_stat1 RENAME tbl TO thetable; } {1 {table sqlite_stat1 may not be altered}} #------------------------------------------------------------------------- do_execsql_test 6.0 { CREATE TABLE blob( rid INTEGER PRIMARY KEY, rcvid INTEGER, size INTEGER, uuid TEXT UNIQUE NOT NULL, content BLOB, CHECK( length(uuid)>=40 AND rid>0 ) ); } breakpoint do_execsql_test 6.1 { ALTER TABLE "blob" RENAME COLUMN "rid" TO "a1"; } finish_test |