/ Check-in [83d5f5abce]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem by renaming a column when the schema contains an trigger program featuring an UPSERT that uses an "excluded.*" reference to a different table.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | alter-table-rename-column
Files: files | file ages | folders
SHA3-256: 83d5f5abce6be2f6d342a6fc68839289400d7bcb80eaa38194789142c93a80c3
User & Date: dan 2018-08-24 20:20:33
Context
2018-08-25
02:04
The implementation of sqlite_rename_column() must be holding the schema mutexes. check-in: f0eed21d4e user: drh tags: alter-table-rename-column
2018-08-24
20:20
Fix a problem by renaming a column when the schema contains an trigger program featuring an UPSERT that uses an "excluded.*" reference to a different table. check-in: 83d5f5abce user: dan tags: alter-table-rename-column
20:10
Fix a problem with renaming a column that occurs as an "excluded.colname" construction in an UPSERT that is part of a trigger program. check-in: bb2f723496 user: dan tags: alter-table-rename-column
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/alter.c.

  1357   1357             if( rc==SQLITE_OK ){
  1358   1358               rc = sqlite3ResolveExprListNames(&sNC, pStep->pExprList);
  1359   1359             }
  1360   1360             assert( !pStep->pUpsert || (!pStep->pWhere && !pStep->pExprList) );
  1361   1361             if( pStep->pUpsert ){
  1362   1362               Upsert *pUpsert = pStep->pUpsert;
  1363   1363               assert( rc==SQLITE_OK );
  1364         -            if( pTarget==pTab ){
  1365         -              pUpsert->pUpsertSrc = &sSrc;
  1366         -              sNC.uNC.pUpsert = pUpsert;
  1367         -              sNC.ncFlags = NC_UUpsert;
  1368         -            }
         1364  +            pUpsert->pUpsertSrc = &sSrc;
         1365  +            sNC.uNC.pUpsert = pUpsert;
         1366  +            sNC.ncFlags = NC_UUpsert;
  1369   1367               rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget);
  1370   1368               if( rc==SQLITE_OK ){
  1371   1369                 ExprList *pUpsertSet = pUpsert->pUpsertSet;
  1372   1370                 if( pTarget==pTab ){
  1373   1371                   renameColumnElistNames(&sParse, &sCtx, pUpsertSet, zOld);
  1374   1372                 }
  1375   1373                 rc = sqlite3ResolveExprListNames(&sNC, pUpsertSet);

Changes to test/altercol.test.

   683    683   } {4 5 456}
   684    684   
   685    685   do_execsql_test 16.5 {
   686    686     ALTER TABLE t2 RENAME COLUMN f TO "big f";
   687    687     INSERT INTO t1 VALUES(4, 0, 20456);
   688    688     SELECT * FROM t2;
   689    689   } {4 5 20456}
          690  +
          691  +do_execsql_test 16.6 {
          692  +  ALTER TABLE t1 RENAME COLUMN c TO "big c";
          693  +  INSERT INTO t1 VALUES(4, 0, 0);
          694  +  SELECT * FROM t2;
          695  +} {4 5 0}
   690    696   
   691    697   finish_test