diff options
author | drh <drh@noemail.net> | 2013-11-04 18:34:46 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-11-04 18:34:46 +0000 |
commit | c3e356fe100da85a09c21b426ed64d001cf6a844 (patch) | |
tree | de72438a89f8104a055c16eb8102ec2b5ee9505e /src | |
parent | 5838340b0ebbd35a5cc9061ac102827449b69719 (diff) | |
download | sqlite-c3e356fe100da85a09c21b426ed64d001cf6a844.tar.gz sqlite-c3e356fe100da85a09c21b426ed64d001cf6a844.zip |
Add another test case file for WITHOUT ROWID and fix the bugs that the new
test file uncovered.
FossilOrigin-Name: bc2a06eb8e57573d08e77800a7937eee5af3f035
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 2 | ||||
-rw-r--r-- | src/update.c | 27 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/build.c b/src/build.c index 0b5e349dc..41e738cac 100644 --- a/src/build.c +++ b/src/build.c @@ -1709,6 +1709,8 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ } assert( pPk->nColumn==j ); assert( pTab->nCol==j ); + }else{ + pPk->nColumn = pTab->nCol; } } diff --git a/src/update.c b/src/update.c index a63110169..82975c650 100644 --- a/src/update.c +++ b/src/update.c @@ -95,7 +95,7 @@ void sqlite3Update( ){ int i, j; /* Loop counters */ Table *pTab; /* The table to be updated */ - int addr = 0; /* VDBE instruction address of the start of the loop */ + int addrTop = 0; /* VDBE instruction address of the start of the loop */ WhereInfo *pWInfo; /* Information about the WHERE clause */ Vdbe *v; /* The virtual database engine */ Index *pIdx; /* For looping over indices */ @@ -419,19 +419,18 @@ void sqlite3Update( /* Top of the update loop */ labelBreak = sqlite3VdbeMakeLabel(v); - labelContinue = sqlite3VdbeMakeLabel(v); if( pPk ){ + labelContinue = sqlite3VdbeMakeLabel(v); sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); - addr = sqlite3VdbeAddOp2(v, OP_RowKey, iEph, regKey); + addrTop = sqlite3VdbeAddOp2(v, OP_RowKey, iEph, regKey); sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0); }else if( okOnePass ){ - int a1 = sqlite3VdbeAddOp1(v, OP_NotNull, regOldRowid); - addr = sqlite3VdbeAddOp2(v, OP_Goto, 0, labelBreak); - sqlite3VdbeJumpHere(v, a1); + labelContinue = labelBreak; + sqlite3VdbeAddOp2(v, OP_IsNull, regOldRowid, labelBreak); }else{ - addr = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, labelBreak, + labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, labelBreak, regOldRowid); - sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addr, regOldRowid); + sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid); } /* If the record number will change, set register regNewRowid to @@ -510,7 +509,7 @@ void sqlite3Update( sqlite3VdbeAddOp2(v, OP_Affinity, regNew, pTab->nCol); sqlite3TableAffinityStr(v, pTab); sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, - TRIGGER_BEFORE, pTab, regOldRowid, onError, addr); + TRIGGER_BEFORE, pTab, regOldRowid, onError, labelContinue); /* The row-trigger may have deleted the row being updated. In this ** case, jump to the next row. No updates or AFTER triggers are @@ -521,7 +520,7 @@ void sqlite3Update( if( pPk ){ sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0); }else{ - sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addr, regOldRowid); + sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid); } /* If it did not delete it, the row-trigger may still have modified @@ -542,7 +541,7 @@ void sqlite3Update( /* Do constraint checks. */ assert( regOldRowid>0 ); sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur, - regNewRowid, regOldRowid, chngKey, onError, addr, 0); + regNewRowid, regOldRowid, chngKey, onError, labelContinue, 0); /* Do FK constraint checks. */ if( hasFK ){ @@ -590,16 +589,16 @@ void sqlite3Update( } sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, - TRIGGER_AFTER, pTab, regOldRowid, onError, addr); + TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue); /* Repeat the above with the next record to be updated, until ** all record selected by the WHERE clause have been updated. */ if( pPk ){ sqlite3VdbeResolveLabel(v, labelContinue); - sqlite3VdbeAddOp2(v, OP_Next, iEph, addr); + sqlite3VdbeAddOp2(v, OP_Next, iEph, addrTop); }else if( !okOnePass ){ - sqlite3VdbeAddOp2(v, OP_Goto, 0, addr); + sqlite3VdbeAddOp2(v, OP_Goto, 0, labelContinue); } sqlite3VdbeResolveLabel(v, labelBreak); |