SQLite

Check-in [f0eed21d4e]
Login

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

Overview
Comment:The implementation of sqlite_rename_column() must be holding the schema mutexes.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | alter-table-rename-column
Files: files | file ages | folders
SHA3-256: f0eed21d4e2e1f2c8e680a510a283ac21156c9766efec5b80a362a040424bce7
User & Date: drh 2018-08-25 02:04:05.318
Context
2018-08-25
03:29
Remove an unnecessary IN_RENAME_COLUMN macro from resolve.c. (check-in: 5858c0bde7 user: drh tags: alter-table-rename-column)
02:04
The implementation of sqlite_rename_column() must be holding the schema mutexes. (check-in: f0eed21d4e user: drh tags: alter-table-rename-column)
2018-08-24
20:20
Fix a problem by renaming a column when the schema contains an trigger program featuring an UPSERT that uses an "excluded.*" reference to a different table. (check-in: 83d5f5abce user: dan tags: alter-table-rename-column)
Changes
Unified Diff Show Whitespace Changes Patch
Changes to src/alter.c.
1205
1206
1207
1208
1209
1210
1211

1212
1213



1214
1215
1216
1217
1218
1219
1220
  Table *pTab;

  UNUSED_PARAMETER(NotUsed);
  if( zSql==0 ) return;
  if( zTable==0 ) return;
  if( zNew==0 ) return;
  if( iCol<0 ) return;

  pTab = sqlite3FindTable(db, zTable, zDb);
  if( pTab==0 || iCol>=pTab->nCol ) return;



  zOld = pTab->aCol[iCol].zName;
  memset(&sCtx, 0, sizeof(sCtx));
  sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol);

  /* Parse the SQL statement passed as the first argument. If no error
  ** occurs and the parse does not result in a new table, index or
  ** trigger object, the database must be corrupt. */







>

|
>
>
>







1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
  Table *pTab;

  UNUSED_PARAMETER(NotUsed);
  if( zSql==0 ) return;
  if( zTable==0 ) return;
  if( zNew==0 ) return;
  if( iCol<0 ) return;
  sqlite3BtreeEnterAll(db);
  pTab = sqlite3FindTable(db, zTable, zDb);
  if( pTab==0 || iCol>=pTab->nCol ){
    sqlite3BtreeLeaveAll(db);
    return;
  }
  zOld = pTab->aCol[iCol].zName;
  memset(&sCtx, 0, sizeof(sCtx));
  sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol);

  /* Parse the SQL statement passed as the first argument. If no error
  ** occurs and the parse does not result in a new table, index or
  ** trigger object, the database must be corrupt. */
1472
1473
1474
1475
1476
1477
1478

1479
1480
1481
1482
1483
1484
1485
  if( sParse.pNewIndex ) sqlite3FreeIndex(db, sParse.pNewIndex);
  sqlite3DeleteTrigger(db, sParse.pNewTrigger);
  renameTokenFree(db, sParse.pRename);
  renameTokenFree(db, sCtx.pList);
  sqlite3DbFree(db, sParse.zErrMsg);
  sqlite3ParserReset(&sParse);
  sqlite3_free(zQuot);

}

/*
** Register built-in functions used to help implement ALTER TABLE
*/
void sqlite3AlterFunctions(void){
  static FuncDef aAlterTableFuncs[] = {







>







1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
  if( sParse.pNewIndex ) sqlite3FreeIndex(db, sParse.pNewIndex);
  sqlite3DeleteTrigger(db, sParse.pNewTrigger);
  renameTokenFree(db, sParse.pRename);
  renameTokenFree(db, sCtx.pList);
  sqlite3DbFree(db, sParse.zErrMsg);
  sqlite3ParserReset(&sParse);
  sqlite3_free(zQuot);
  sqlite3BtreeLeaveAll(db);
}

/*
** Register built-in functions used to help implement ALTER TABLE
*/
void sqlite3AlterFunctions(void){
  static FuncDef aAlterTableFuncs[] = {