/ Check-in [d48f7bbd]
Login

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

Overview
Comment:Fix a problem with renaming columns on tables with REFERENCES clauses that specify a large number of columns.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | alter-table-rename-column
Files: files | file ages | folders
SHA3-256:d48f7bbdf4a1686c25e634a8dec6ead88bf2866fee94ed8e5058f830363424a8
User & Date: dan 2018-08-10 14:23:41
Context
2018-08-10
15:27
Merge latest trunk changes with this branch. check-in: c355a837 user: dan tags: alter-table-rename-column
14:23
Fix a problem with renaming columns on tables with REFERENCES clauses that specify a large number of columns. check-in: d48f7bbd user: dan tags: alter-table-rename-column
2018-08-09
20:47
Experimental implementation of ALTER TABLE ... RENAME COLUMN. Still buggy. check-in: fa0fc01e user: dan tags: alter-table-rename-column
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

  2759   2759         if( j>=p->nCol ){
  2760   2760           sqlite3ErrorMsg(pParse, 
  2761   2761             "unknown column \"%s\" in foreign key definition", 
  2762   2762             pFromCol->a[i].zName);
  2763   2763           goto fk_end;
  2764   2764         }
  2765   2765         if( IN_RENAME_COLUMN ){
  2766         -        sqlite3MoveRenameToken(pParse, &pFKey->aCol[i], &pFromCol->a[i]);
         2766  +        sqlite3MoveRenameToken(pParse, &pFKey->aCol[i], pFromCol->a[i].zName);
  2767   2767         }
  2768   2768       }
  2769   2769     }
  2770   2770     if( pToCol ){
  2771   2771       for(i=0; i<nCol; i++){
  2772   2772         int n = sqlite3Strlen30(pToCol->a[i].zName);
  2773   2773         pFKey->aCol[i].zCol = z;

Changes to src/parse.y.

  1308   1308           && pParse->db->init.busy==0
  1309   1309       ){
  1310   1310         sqlite3ErrorMsg(pParse, "syntax error after column name \"%.*s\"",
  1311   1311                            pIdToken->n, pIdToken->z);
  1312   1312       }
  1313   1313       sqlite3ExprListSetName(pParse, p, pIdToken, 1);
  1314   1314       if( IN_RENAME_COLUMN ){
  1315         -      sqlite3RenameToken(pParse, (void*)&(p->a[p->nExpr-1]), pIdToken);
         1315  +      sqlite3RenameToken(pParse, (void*)(p->a[p->nExpr-1].zName), pIdToken);
  1316   1316       }
  1317   1317       return p;
  1318   1318     }
  1319   1319   } // end %include
  1320   1320   
  1321   1321   eidlist_opt(A) ::= .                         {A = 0;}
  1322   1322   eidlist_opt(A) ::= LP eidlist(X) RP.         {A = X;}

Changes to test/altercol.test.

    88     88       set res [list $after]
    89     89     }
    90     90     do_execsql_test 1.$tn.4 {
    91     91       SELECT sql FROM sqlite_master WHERE tbl_name='t1' AND sql!=''
    92     92     } $res
    93     93   }
    94     94   
           95  +#-------------------------------------------------------------------------
           96  +do_execsql_test 2.0 {
           97  +  CREATE TABLE t3(a, b, c, d, e, f, g, h, i, j, k, l, m, FOREIGN KEY (b, c, d, e, f, g, h, i, j, k, l, m) REFERENCES t4);
           98  +}
           99  +
          100  +do_execsql_test 2.1 {
          101  +  ALTER TABLE t3 RENAME b TO biglongname;
          102  +  SELECT sql FROM sqlite_master WHERE name='t3';
          103  +} {{CREATE TABLE t3(a, biglongname, c, d, e, f, g, h, i, j, k, l, m, FOREIGN KEY (biglongname, c, d, e, f, g, h, i, j, k, l, m) REFERENCES t4)}}
          104  +
    95    105   finish_test
    96    106   
    97    107