1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Omit one or more pointless instructions that occur in between OP_NoConflict

and OP_Halt.

FossilOrigin-Name: 61e2f3575c4a94f9571c28fb2bd19da84b0edceb
This commit is contained in:
drh
2013-12-19 02:23:45 +00:00
parent 935c34711b
commit 46d03fcbfc
3 changed files with 48 additions and 47 deletions

View File

@@ -1,5 +1,5 @@
C Remove\san\sunnecessary\scolumn-cache\sflush\soperation.\s\sAdd\scode\sto\strace\sthe\ncolumn\scache\swhen\scompiled\swith\sSQLITE_DEBUG\sand\susing\nPRAGMA\svdbe_addoptrace=ON. C Omit\sone\sor\smore\spointless\sinstructions\sthat\soccur\sin\sbetween\sOP_NoConflict\nand\sOP_Halt.
D 2013-12-18T18:44:43.134 D 2013-12-19T02:23:45.916
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -183,7 +183,7 @@ F src/global.c 1d7bb7ea8254ae6a68ed9bfaf65fcb3d1690b486
F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4
F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22
F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08
F src/insert.c 3cf8012325857d162f74389420b14be7976a538d F src/insert.c d1b3fd53cd8e3f232e47675cf2c3d1b1f4101f2a
F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d
F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12 F src/legacy.c 0df0b1550b9cc1f58229644735e317ac89131f12
F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b F src/lempar.c cdf0a000315332fc9b50b62f3b5e22e080a0952b
@@ -1147,8 +1147,7 @@ F tool/vdbe-compress.tcl 0cf56e9263a152b84da86e75a5c0cdcdb7a47891
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
P 93121d3097a43997af3c0de65bd9bd7663845fa2 97fdfc6b79833011fc0c506fe5e0985c0fb1906c P 58704ed1f4cd78bb3b0c095ffd1626906a95a413
R ad4bcfdba61e39f0bb9e7693f91a62e0 R 464abf9a1fd9120477908520316caad2
T +closed 97fdfc6b79833011fc0c506fe5e0985c0fb1906c
U drh U drh
Z d67945416ae9c517bb5d46293eed5eb3 Z 1a25f8b4acb360c6ad6b1c4bc1cd07e9

View File

@@ -1 +1 @@
58704ed1f4cd78bb3b0c095ffd1626906a95a413 61e2f3575c4a94f9571c28fb2bd19da84b0edceb

View File

@@ -1503,47 +1503,49 @@ void sqlite3GenerateConstraintChecks(
/* Generate code to handle collisions */ /* Generate code to handle collisions */
regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField); regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField);
if( HasRowid(pTab) ){ if( isUpdate || onError==OE_Replace ){
sqlite3VdbeAddOp2(v, OP_IdxRowid, iThisCur, regR); if( HasRowid(pTab) ){
/* Conflict only if the rowid of the existing index entry sqlite3VdbeAddOp2(v, OP_IdxRowid, iThisCur, regR);
** is different from old-rowid */ /* Conflict only if the rowid of the existing index entry
if( isUpdate ){ ** is different from old-rowid */
sqlite3VdbeAddOp3(v, OP_Eq, regR, addrUniqueOk, regOldData); if( isUpdate ){
} sqlite3VdbeAddOp3(v, OP_Eq, regR, addrUniqueOk, regOldData);
}else{
int x;
/* Extract the PRIMARY KEY from the end of the index entry and
** store it in registers regR..regR+nPk-1 */
if( (isUpdate || onError==OE_Replace) && pIdx!=pPk ){
for(i=0; i<pPk->nKeyCol; i++){
x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i);
VdbeComment((v, "%s.%s", pTab->zName,
pTab->aCol[pPk->aiColumn[i]].zName));
} }
} }else{
if( isUpdate ){ int x;
/* If currently processing the PRIMARY KEY of a WITHOUT ROWID /* Extract the PRIMARY KEY from the end of the index entry and
** table, only conflict if the new PRIMARY KEY values are actually ** store it in registers regR..regR+nPk-1 */
** different from the old. if( (isUpdate || onError==OE_Replace) && pIdx!=pPk ){
** for(i=0; i<pPk->nKeyCol; i++){
** For a UNIQUE index, only conflict if the PRIMARY KEY values x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]);
** of the matched index row are different from the original PRIMARY sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i);
** KEY values of this row before the update. */ VdbeComment((v, "%s.%s", pTab->zName,
int addrJump = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol; pTab->aCol[pPk->aiColumn[i]].zName));
int op = OP_Ne; }
int regCmp = (pIdx->autoIndex==2 ? regIdx : regR); }
if( isUpdate ){
for(i=0; i<pPk->nKeyCol; i++){ /* If currently processing the PRIMARY KEY of a WITHOUT ROWID
char *p4 = (char*)sqlite3LocateCollSeq(pParse, pPk->azColl[i]); ** table, only conflict if the new PRIMARY KEY values are actually
x = pPk->aiColumn[i]; ** different from the old.
if( i==(pPk->nKeyCol-1) ){ **
addrJump = addrUniqueOk; ** For a UNIQUE index, only conflict if the PRIMARY KEY values
op = OP_Eq; ** of the matched index row are different from the original PRIMARY
** KEY values of this row before the update. */
int addrJump = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol;
int op = OP_Ne;
int regCmp = (pIdx->autoIndex==2 ? regIdx : regR);
for(i=0; i<pPk->nKeyCol; i++){
char *p4 = (char*)sqlite3LocateCollSeq(pParse, pPk->azColl[i]);
x = pPk->aiColumn[i];
if( i==(pPk->nKeyCol-1) ){
addrJump = addrUniqueOk;
op = OP_Eq;
}
sqlite3VdbeAddOp4(v, op,
regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ
);
} }
sqlite3VdbeAddOp4(v, op,
regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ
);
} }
} }
} }