diff options
author | drh <drh@noemail.net> | 2013-11-11 22:55:26 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-11-11 22:55:26 +0000 |
commit | cbf1b8ef7d20e0281eaa218023450d33b0b1a138 (patch) | |
tree | e6da66a1c54ab2f11fa150ad989271ccc80b8b63 /src/resolve.c | |
parent | d63d4b7bd7a5c84972dd16524610782fe301556c (diff) | |
parent | 14ec33f73be78acb450dfeb66bda59c1993bc7a5 (diff) | |
download | sqlite-cbf1b8ef7d20e0281eaa218023450d33b0b1a138.tar.gz sqlite-cbf1b8ef7d20e0281eaa218023450d33b0b1a138.zip |
Merge in the WITHOUT ROWID changes. A few tests are failing now. They will
be fixed in a follow-on check-in.
FossilOrigin-Name: 5addd1234ded59ce60fb633b76ac87d483377edd
Diffstat (limited to 'src/resolve.c')
-rw-r--r-- | src/resolve.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/resolve.c b/src/resolve.c index 92fbaaf15..b41f23442 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -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; @@ -345,8 +343,7 @@ static int lookupName( int iCol; pSchema = pTab->pSchema; cntTab++; - for(iCol=0; iCol<pTab->nCol; iCol++){ - Column *pCol = &pTab->aCol[iCol]; + for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){ if( sqlite3StrICmp(pCol->zName, zCol)==0 ){ if( iCol==pTab->iPKey ){ iCol = -1; @@ -354,7 +351,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 +378,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; |