aboutsummaryrefslogtreecommitdiff
path: root/src/resolve.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2013-10-23 17:39:41 +0000
committerdrh <drh@noemail.net>2013-10-23 17:39:41 +0000
commit11f9b033cc9063f3bf532ce6fcdb1efe11ea86ad (patch)
tree264e1f0d9cbad2faa6a8a3208042f28319abaf43 /src/resolve.c
parent55548273a3b5a0b4f7d6dad610d8b7e767e6b5d6 (diff)
downloadsqlite-11f9b033cc9063f3bf532ce6fcdb1efe11ea86ad.tar.gz
sqlite-11f9b033cc9063f3bf532ce6fcdb1efe11ea86ad.zip
Report an error when trying to resolve column name "rowid" in a
WITHOUT ROWID table. FossilOrigin-Name: 36bcc9cb885523fba2f3b0d152de9e08073668c1
Diffstat (limited to 'src/resolve.c')
-rw-r--r--src/resolve.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/resolve.c b/src/resolve.c
index 92fbaaf15..e17e488e3 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;
@@ -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;