mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Make it an error to repeat the target object/alias of an UPDATE statement in its FROM clause.
FossilOrigin-Name: d90a37e930c66afe95165955ae47efde08f52c8ce16c4fb239da0233335db050
This commit is contained in:
18
src/select.c
18
src/select.c
@@ -5823,6 +5823,24 @@ int sqlite3Select(
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If the SF_UpdateFrom flag is set, then this function is being called
|
||||
** as part of populating the temp table for an UPDATE...FROM statement.
|
||||
** In this case, it is an error if the target object (pSrc->a[0]) name
|
||||
** or alias is duplicated within FROM clause (pSrc->a[1..n]). */
|
||||
if( p->selFlags & SF_UpdateFrom ){
|
||||
struct SrcList_item *p0 = &p->pSrc->a[0];
|
||||
for(i=1; i<p->pSrc->nSrc; i++){
|
||||
struct SrcList_item *p1 = &p->pSrc->a[i];
|
||||
if( p0->pTab==p1->pTab && 0==sqlite3_stricmp(p0->zAlias, p1->zAlias) ){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"target object/alias may not appear in FROM clause: %s",
|
||||
p0->zAlias ? p0->zAlias : p0->pTab->zName
|
||||
);
|
||||
goto select_end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( pDest->eDest==SRT_Output ){
|
||||
generateColumnNames(pParse, p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user