aboutsummaryrefslogtreecommitdiff
path: root/src/alter.c
diff options
context:
space:
mode:
authordrh <>2025-02-08 14:15:42 +0000
committerdrh <>2025-02-08 14:15:42 +0000
commit9d90a3af2fa1108ee3c914f9cb5b602bfb04949d (patch)
treee41f27f557b6df1df69d32f543e6c19916270624 /src/alter.c
parent03c65171b8ff533b28927a1e5fb7939b87077de0 (diff)
downloadsqlite-9d90a3af2fa1108ee3c914f9cb5b602bfb04949d.tar.gz
sqlite-9d90a3af2fa1108ee3c914f9cb5b602bfb04949d.zip
Use the sqlite3ColumnIndex() routine to look up a column in a table, rather
than using a custom loop. Performance improvement, size reduction, and complexity decrease. FossilOrigin-Name: 351dbbc2bf0b23efdc625ddaa5dc2239cf2990addf071a04bd41612b341de8c8
Diffstat (limited to 'src/alter.c')
-rw-r--r--src/alter.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/alter.c b/src/alter.c
index ff2075758..5f706b513 100644
--- a/src/alter.c
+++ b/src/alter.c
@@ -632,10 +632,8 @@ void sqlite3AlterRenameColumn(
** altered. Set iCol to be the index of the column being renamed */
zOld = sqlite3NameFromToken(db, pOld);
if( !zOld ) goto exit_rename_column;
- for(iCol=0; iCol<pTab->nCol; iCol++){
- if( 0==sqlite3StrICmp(pTab->aCol[iCol].zCnName, zOld) ) break;
- }
- if( iCol==pTab->nCol ){
+ iCol = sqlite3ColumnIndex(pTab, zOld);
+ if( iCol<0 ){
sqlite3ErrorMsg(pParse, "no such column: \"%T\"", pOld);
goto exit_rename_column;
}