1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-05 04:30:38 +03:00

Report an error when trying to resolve column name "rowid" in a

WITHOUT ROWID table.

FossilOrigin-Name: 36bcc9cb885523fba2f3b0d152de9e08073668c1
This commit is contained in:
drh
2013-10-23 17:39:41 +00:00
parent 55548273a3
commit 11f9b033cc
4 changed files with 30 additions and 16 deletions

View File

@@ -226,7 +226,9 @@ static int lookupName(
struct SrcList_item *pMatch = 0; /* The matching pSrcList item */
NameContext *pTopNC = pNC; /* First namecontext in the list */
Schema *pSchema = 0; /* Schema of the expression */
int isTrigger = 0;
int isTrigger = 0; /* True if resolved to a trigger column */
Table *pTab = 0; /* Table hold the row */
Column *pCol; /* A column of pTab */
assert( pNC ); /* the name context cannot be NULL. */
assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
@@ -267,9 +269,6 @@ static int lookupName(
if( pSrcList ){
for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
Table *pTab;
Column *pCol;
pTab = pItem->pTab;
assert( pTab!=0 && pTab->zName!=0 );
assert( pTab->nCol>0 );
@@ -329,9 +328,8 @@ static int lookupName(
/* If we have not already resolved the name, then maybe
** it is a new.* or old.* trigger argument reference
*/
if( zDb==0 && zTab!=0 && cnt==0 && pParse->pTriggerTab!=0 ){
if( zDb==0 && zTab!=0 && cntTab==0 && pParse->pTriggerTab!=0 ){
int op = pParse->eTriggerOp;
Table *pTab = 0;
assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );
if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){
pExpr->iTable = 1;
@@ -354,7 +352,7 @@ static int lookupName(
break;
}
}
if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) ){
if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && HasRowid(pTab) ){
iCol = -1; /* IMP: R-44911-55124 */
}
if( iCol<pTab->nCol ){
@@ -381,7 +379,8 @@ static int lookupName(
/*
** Perhaps the name is a reference to the ROWID
*/
if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){
assert( pTab!=0 || cntTab==0 );
if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) && HasRowid(pTab) ){
cnt = 1;
pExpr->iColumn = -1; /* IMP: R-44911-55124 */
pExpr->affinity = SQLITE_AFF_INTEGER;