1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Merge the latest trunk enhancements into the bedrock branch.

FossilOrigin-Name: c09656c62155a6e82d0fa6c27bf8ec40a14854845adfa53db3cb42a0b1b29101
This commit is contained in:
drh
2025-02-18 14:48:14 +00:00
77 changed files with 1948 additions and 2477 deletions

View File

@@ -476,38 +476,32 @@ void sqlite3Update(
if( db->mallocFailed ) goto update_cleanup;
}
#endif
u8 hCol = sqlite3StrIHash(pChanges->a[i].zEName);
/* If this is an UPDATE with a FROM clause, do not resolve expressions
** here. The call to sqlite3Select() below will do that. */
if( nChangeFrom==0 && sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){
goto update_cleanup;
}
for(j=0; j<pTab->nCol; j++){
if( pTab->aCol[j].hName==hCol
&& sqlite3StrICmp(pTab->aCol[j].zCnName, pChanges->a[i].zEName)==0
){
if( j==pTab->iPKey ){
chngRowid = 1;
pRowidExpr = pChanges->a[i].pExpr;
iRowidExpr = i;
}else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){
chngPk = 1;
}
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
else if( pTab->aCol[j].colFlags & COLFLAG_GENERATED ){
testcase( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL );
testcase( pTab->aCol[j].colFlags & COLFLAG_STORED );
sqlite3ErrorMsg(pParse,
"cannot UPDATE generated column \"%s\"",
pTab->aCol[j].zCnName);
goto update_cleanup;
}
#endif
aXRef[j] = i;
break;
j = sqlite3ColumnIndex(pTab, pChanges->a[i].zEName);
if( j>=0 ){
if( j==pTab->iPKey ){
chngRowid = 1;
pRowidExpr = pChanges->a[i].pExpr;
iRowidExpr = i;
}else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){
chngPk = 1;
}
}
if( j>=pTab->nCol ){
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
else if( pTab->aCol[j].colFlags & COLFLAG_GENERATED ){
testcase( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL );
testcase( pTab->aCol[j].colFlags & COLFLAG_STORED );
sqlite3ErrorMsg(pParse,
"cannot UPDATE generated column \"%s\"",
pTab->aCol[j].zCnName);
goto update_cleanup;
}
#endif
aXRef[j] = i;
}else{
if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zEName) ){
j = -1;
chngRowid = 1;