/ Check-in [520c1c75]
Login

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

Overview
Comment:Avoid an assert() sometimes triggered by ALTER TABLE RENAME COLUMN in non-debug builds.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | alter-table-rename-column
Files: files | file ages | folders
SHA3-256: 520c1c75dae5e3f4695fcdf0aad5fb9f492f0e528b5fbb49d5d3b5fc02762f47
User & Date: dan 2018-08-11 18:34:25
Context
2018-08-11
20:38
If the new column name in an ALTER TABLE RENAME COLUMN statement is quoted, then also use quotes for the column name in the edited SQL statements. check-in: ca5184a2 user: dan tags: alter-table-rename-column
18:34
Avoid an assert() sometimes triggered by ALTER TABLE RENAME COLUMN in non-debug builds. check-in: 520c1c75 user: dan tags: alter-table-rename-column
17:49
Fix a bug causing ALTER TABLE RENAME COLUMN to fail when renaming an IPK column that is used in a CHECK constraint. check-in: 6595c881 user: dan tags: alter-table-rename-column
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  5746   5746     iDb = pOp->p1;
  5747   5747     assert( iDb>=0 && iDb<db->nDb );
  5748   5748     assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );
  5749   5749   
  5750   5750   #ifndef SQLITE_OMIT_ALTERTABLE
  5751   5751     if( pOp->p4.z==0 ){
  5752   5752       sqlite3SchemaClear(db->aDb[iDb].pSchema);
         5753  +    db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
  5753   5754       rc = sqlite3InitOne(db, iDb, &p->zErrMsg);
  5754   5755       db->mDbFlags |= DBFLAG_SchemaChange;
  5755   5756     }else
  5756   5757   #endif
  5757   5758     /* Used to be a conditional */ {
  5758   5759       zMaster = MASTER_NAME;
  5759   5760       initData.db = db;

Changes to test/altercol.test.

   180    180   } {2 5}
   181    181   
   182    182   do_catchsql_test 6.1 {
   183    183     ALTER TABLE sqlite_stat1 RENAME tbl TO thetable;
   184    184   } {1 {table sqlite_stat1 may not be altered}}
   185    185   
   186    186   #-------------------------------------------------------------------------
          187  +#
   187    188   do_execsql_test 6.0 {
   188    189     CREATE TABLE blob(
   189    190       rid INTEGER PRIMARY KEY,
   190    191       rcvid INTEGER,
   191    192       size INTEGER,
   192    193       uuid TEXT UNIQUE NOT NULL,
   193    194       content BLOB,
   194    195       CHECK( length(uuid)>=40 AND rid>0 )
   195    196     );
   196    197   }
   197    198   
   198         -breakpoint
   199    199   do_execsql_test 6.1 {
   200    200     ALTER TABLE "blob" RENAME COLUMN "rid" TO "a1";
   201    201   }
   202    202   
   203    203   finish_test
   204    204