SQLite

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
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.441
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
Unified Diff Ignore Whitespace Patch
Changes to src/alter.c.
812
813
814
815
816
817
818







819
820
821
822
823
824
825

  /* Locate the table to be altered */
  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);
  if( !pTab ) goto exit_rename_column;

  /* Cannot alter a system table */
  if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ) goto exit_rename_column;








  /* Which schema holds the table to be altered */  
  iSchema = sqlite3SchemaToIndex(db, pTab->pSchema);
  assert( iSchema>=0 );
  zDb = db->aDb[iSchema].zDbSName;

  /* Make sure the old name really is a column name in the table to be







>
>
>
>
>
>
>







812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832

  /* Locate the table to be altered */
  pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]);
  if( !pTab ) goto exit_rename_column;

  /* Cannot alter a system table */
  if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ) goto exit_rename_column;

  /* Cannot rename columns of a virtual table */
  if( IsVirtual(pTab) ){
    sqlite3ErrorMsg(pParse, "cannot rename columns in a virtual table (%s)",
                    pTab->zName);
    goto exit_rename_column;
  }

  /* Which schema holds the table to be altered */  
  iSchema = sqlite3SchemaToIndex(db, pTab->pSchema);
  assert( iSchema>=0 );
  zDb = db->aDb[iSchema].zDbSName;

  /* Make sure the old name really is a column name in the table to be