/ Check-in [83d5f5ab]
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: f0eed21d 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: 83d5f5ab 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: bb2f7234 user: dan tags: alter-table-rename-column
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/alter.c.

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







<
|
|
|
<







1357
1358
1359
1360
1361
1362
1363

1364
1365
1366

1367
1368
1369
1370
1371
1372
1373
          if( rc==SQLITE_OK ){
            rc = sqlite3ResolveExprListNames(&sNC, pStep->pExprList);
          }
          assert( !pStep->pUpsert || (!pStep->pWhere && !pStep->pExprList) );
          if( pStep->pUpsert ){
            Upsert *pUpsert = pStep->pUpsert;
            assert( rc==SQLITE_OK );

            pUpsert->pUpsertSrc = &sSrc;
            sNC.uNC.pUpsert = pUpsert;
            sNC.ncFlags = NC_UUpsert;

            rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget);
            if( rc==SQLITE_OK ){
              ExprList *pUpsertSet = pUpsert->pUpsertSet;
              if( pTarget==pTab ){
                renameColumnElistNames(&sParse, &sCtx, pUpsertSet, zOld);
              }
              rc = sqlite3ResolveExprListNames(&sNC, pUpsertSet);

Changes to test/altercol.test.

683
684
685
686
687
688
689
690






691
} {4 5 456}

do_execsql_test 16.5 {
  ALTER TABLE t2 RENAME COLUMN f TO "big f";
  INSERT INTO t1 VALUES(4, 0, 20456);
  SELECT * FROM t2;
} {4 5 20456}







finish_test








>
>
>
>
>
>

683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
} {4 5 456}

do_execsql_test 16.5 {
  ALTER TABLE t2 RENAME COLUMN f TO "big f";
  INSERT INTO t1 VALUES(4, 0, 20456);
  SELECT * FROM t2;
} {4 5 20456}

do_execsql_test 16.6 {
  ALTER TABLE t1 RENAME COLUMN c TO "big c";
  INSERT INTO t1 VALUES(4, 0, 0);
  SELECT * FROM t2;
} {4 5 0}

finish_test