/ Check-in [f6d6b47271]
Login

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

Overview
Comment:Do not allow ALTER TABLE RENAME COLUMN on a virtual table.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | alter-table-rename-column
Files: files | file ages | folders
SHA3-256: f6d6b472713c21deace3fd52c0b0b6901d758af043c238f004fabe52b01f730c
User & Date: drh 2018-08-14 20:38:18
Context
2018-08-14
21:03
Fix a problem when renaming an IPK column that is also part of a child key. check-in: ad15486022 user: dan tags: alter-table-rename-column
20:38
Do not allow ALTER TABLE RENAME COLUMN on a virtual table. check-in: f6d6b47271 user: drh tags: alter-table-rename-column
19:27
Improved error messages when an ALTER TABLE RENAME COLUMN fails due to a duplicate column name. check-in: 37d11b8e82 user: drh tags: alter-table-rename-column
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/alter.c.

   812    812   
   813    813     /* Locate the table to be altered */
   814    814     pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);
   815    815     if( !pTab ) goto exit_rename_column;
   816    816   
   817    817     /* Cannot alter a system table */
   818    818     if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ) goto exit_rename_column;
          819  +
          820  +  /* Cannot rename columns of a virtual table */
          821  +  if( IsVirtual(pTab) ){
          822  +    sqlite3ErrorMsg(pParse, "cannot rename columns in a virtual table (%s)",
          823  +                    pTab->zName);
          824  +    goto exit_rename_column;
          825  +  }
   819    826   
   820    827     /* Which schema holds the table to be altered */  
   821    828     iSchema = sqlite3SchemaToIndex(db, pTab->pSchema);
   822    829     assert( iSchema>=0 );
   823    830     zDb = db->aDb[iSchema].zDbSName;
   824    831   
   825    832     /* Make sure the old name really is a column name in the table to be