/ Check-in [6e6a2bfd]
Login

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

Overview
Comment:Fix a problem when renaming an IPK column that is also part of a child key.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | edit-trigger-wrapper
Files: files | file ages | folders
SHA3-256: 6e6a2bfdbbfd4ffc14be88962ff97bf3c626fef9d1a337715d2a4be1a657fb0d
User & Date: dan 2018-08-14 21:05:35
Context
2018-08-15
20:28
Have ALTER TABLE RENAME COLUMN edit trigger programs. Only partly working. check-in: e272dc2b user: dan tags: edit-trigger-wrapper
2018-08-14
21:05
Fix a problem when renaming an IPK column that is also part of a child key. check-in: 6e6a2bfd user: dan tags: edit-trigger-wrapper
21:03
Fix a problem when renaming an IPK column that is also part of a child key. check-in: ad154860 user: dan tags: alter-table-rename-column
20:40
Merge latest trunk and ALTER TABLE error message improvements into this branch. check-in: 7a45802d user: dan tags: edit-trigger-wrapper
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/alter.c.

1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
        for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){
          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);
          }







|







1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
        for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){
          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==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);
          }

Changes to test/altercol.test.

70
71
72
73
74
75
76



77
78
79
80
81
82
83
    {CREATE TABLE t1(a INTEGER, d TEXT, c BLOB, PRIMARY KEY(d))}

 15 {CREATE TABLE t1(a INTEGER, b INTEGER, c BLOB, PRIMARY KEY(b))}
    {CREATE TABLE t1(a INTEGER, d INTEGER, c BLOB, PRIMARY KEY(d))}

 16 {CREATE TABLE t1(a INTEGER, b INTEGER PRIMARY KEY, c BLOB)}
    {CREATE TABLE t1(a INTEGER, d INTEGER PRIMARY KEY, c BLOB)}




} {
  reset_db
  do_execsql_test 1.$tn.0 $before

  do_execsql_test 1.$tn.1 {
    INSERT INTO t1 VALUES(1, 2, 3);







>
>
>







70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
    {CREATE TABLE t1(a INTEGER, d TEXT, c BLOB, PRIMARY KEY(d))}

 15 {CREATE TABLE t1(a INTEGER, b INTEGER, c BLOB, PRIMARY KEY(b))}
    {CREATE TABLE t1(a INTEGER, d INTEGER, c BLOB, PRIMARY KEY(d))}

 16 {CREATE TABLE t1(a INTEGER, b INTEGER PRIMARY KEY, c BLOB)}
    {CREATE TABLE t1(a INTEGER, d INTEGER PRIMARY KEY, c BLOB)}

 17  {CREATE TABLE t1(a INTEGER, b INTEGER PRIMARY KEY, c BLOB, FOREIGN KEY (b) REFERENCES t2)}
     {CREATE TABLE t1(a INTEGER, d INTEGER PRIMARY KEY, c BLOB, FOREIGN KEY (d) REFERENCES t2)}

} {
  reset_db
  do_execsql_test 1.$tn.0 $before

  do_execsql_test 1.$tn.1 {
    INSERT INTO t1 VALUES(1, 2, 3);