SQLite
Check-in [520c1c75da]
Not logged in
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: ca5184a25f 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: 520c1c75da 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: 6595c8811f user: dan tags: alter-table-rename-column
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

5746
5747
5748
5749
5750
5751
5752

5753
5754
5755
5756
5757
5758
5759
  iDb = pOp->p1;
  assert( iDb>=0 && iDb<db->nDb );
  assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );

#ifndef SQLITE_OMIT_ALTERTABLE
  if( pOp->p4.z==0 ){
    sqlite3SchemaClear(db->aDb[iDb].pSchema);

    rc = sqlite3InitOne(db, iDb, &p->zErrMsg);
    db->mDbFlags |= DBFLAG_SchemaChange;
  }else
#endif
  /* Used to be a conditional */ {
    zMaster = MASTER_NAME;
    initData.db = db;







>







5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
  iDb = pOp->p1;
  assert( iDb>=0 && iDb<db->nDb );
  assert( DbHasProperty(db, iDb, DB_SchemaLoaded) );

#ifndef SQLITE_OMIT_ALTERTABLE
  if( pOp->p4.z==0 ){
    sqlite3SchemaClear(db->aDb[iDb].pSchema);
    db->mDbFlags &= ~DBFLAG_SchemaKnownOk;
    rc = sqlite3InitOne(db, iDb, &p->zErrMsg);
    db->mDbFlags |= DBFLAG_SchemaChange;
  }else
#endif
  /* Used to be a conditional */ {
    zMaster = MASTER_NAME;
    initData.db = db;

Changes to test/altercol.test.

180
181
182
183
184
185
186

187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
} {2 5}

do_catchsql_test 6.1 {
  ALTER TABLE sqlite_stat1 RENAME tbl TO thetable;
} {1 {table sqlite_stat1 may not be altered}}

#-------------------------------------------------------------------------

do_execsql_test 6.0 {
  CREATE TABLE blob(
    rid INTEGER PRIMARY KEY,
    rcvid INTEGER,
    size INTEGER,
    uuid TEXT UNIQUE NOT NULL,
    content BLOB,
    CHECK( length(uuid)>=40 AND rid>0 )
  );
}

breakpoint
do_execsql_test 6.1 {
  ALTER TABLE "blob" RENAME COLUMN "rid" TO "a1";
}

finish_test








>











<






180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198

199
200
201
202
203
204
} {2 5}

do_catchsql_test 6.1 {
  ALTER TABLE sqlite_stat1 RENAME tbl TO thetable;
} {1 {table sqlite_stat1 may not be altered}}

#-------------------------------------------------------------------------
#
do_execsql_test 6.0 {
  CREATE TABLE blob(
    rid INTEGER PRIMARY KEY,
    rcvid INTEGER,
    size INTEGER,
    uuid TEXT UNIQUE NOT NULL,
    content BLOB,
    CHECK( length(uuid)>=40 AND rid>0 )
  );
}


do_execsql_test 6.1 {
  ALTER TABLE "blob" RENAME COLUMN "rid" TO "a1";
}

finish_test