mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-06 15:49:35 +03:00
Remove redundant opcodes OP_MakeKey and OP_MakeIdxKey. (CVS 1612)
FossilOrigin-Name: a71a9ff114f2162696d8d37fbc87b315568f6dcb
This commit is contained in:
22
manifest
22
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Handle\sconflicting\sON\sCONFLICT\sclauses\sin\stable\sdefinitions.\s(CVS\s1611)
|
C Remove\sredundant\sopcodes\sOP_MakeKey\sand\sOP_MakeIdxKey.\s(CVS\s1612)
|
||||||
D 2004-06-17T06:13:34
|
D 2004-06-17T07:53:02
|
||||||
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
|
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
|
||||||
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
||||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||||
@@ -30,13 +30,13 @@ F src/btree.c 0cf8a52a57a7eb13d50719114ee1fa353e89d7d3
|
|||||||
F src/btree.h 32f96abef464cf8765b23ca669acfe90d191fcc5
|
F src/btree.h 32f96abef464cf8765b23ca669acfe90d191fcc5
|
||||||
F src/build.c ed0bff93bf8cbcf853f0ddf0a99c8e5fd02d0db0
|
F src/build.c ed0bff93bf8cbcf853f0ddf0a99c8e5fd02d0db0
|
||||||
F src/date.c 65b483caeb0e4dd663667d2f927caa058168ebff
|
F src/date.c 65b483caeb0e4dd663667d2f927caa058168ebff
|
||||||
F src/delete.c 1e94ef693e45b441f5c828ea0a064ac339008f8e
|
F src/delete.c a5191011b7429dff939df631b8bdcc1714b8d7aa
|
||||||
F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37
|
F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37
|
||||||
F src/expr.c 657ca11f63a06aefd78014e6bc51dab6c735cc63
|
F src/expr.c 01cdf6a632ff66acfff667932c41bb79d18d5077
|
||||||
F src/func.c 1959a0c2f5328b2b9934620f9492964f080f4a71
|
F src/func.c 1959a0c2f5328b2b9934620f9492964f080f4a71
|
||||||
F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f
|
F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f
|
||||||
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
|
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
|
||||||
F src/insert.c 15575e57917ea2e5702a2b5935583c84139699c3
|
F src/insert.c 1428887f4a7515a7d34e82aaeb76297c79ba378b
|
||||||
F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
|
F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
|
||||||
F src/main.c 63c30e17cae13cbe9ccc037507cd03a27fc3d67b
|
F src/main.c 63c30e17cae13cbe9ccc037507cd03a27fc3d67b
|
||||||
F src/md5.c d77a389955759c8329bb357e3d71bac3d6eb710b
|
F src/md5.c d77a389955759c8329bb357e3d71bac3d6eb710b
|
||||||
@@ -54,7 +54,7 @@ F src/parse.y 097438674976355a10cf177bd97326c548820b86
|
|||||||
F src/pragma.c b51bd2034a54f62a72ad454028712afaa294ff94
|
F src/pragma.c b51bd2034a54f62a72ad454028712afaa294ff94
|
||||||
F src/printf.c 7e7f83a747bbd0601dcb4ee2885fb3ce3e994a9f
|
F src/printf.c 7e7f83a747bbd0601dcb4ee2885fb3ce3e994a9f
|
||||||
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
|
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
|
||||||
F src/select.c ee37ea91bea336e9cb3356e0790d3e8787b6ba13
|
F src/select.c 91570af7f13d1c5584f3b711676e1226ee12194e
|
||||||
F src/shell.c ca519519dcbbc582f6d88f7d0e7583b857fd3469
|
F src/shell.c ca519519dcbbc582f6d88f7d0e7583b857fd3469
|
||||||
F src/sqlite.h.in 36c253844656186ca53e1999efa6ef7b44f88779
|
F src/sqlite.h.in 36c253844656186ca53e1999efa6ef7b44f88779
|
||||||
F src/sqliteInt.h 59c1e1b637e7cf329f39425469bc4dbeab1fa1d5
|
F src/sqliteInt.h 59c1e1b637e7cf329f39425469bc4dbeab1fa1d5
|
||||||
@@ -71,13 +71,13 @@ F src/update.c f9a03233577e0c3d57234d1957963875fc941da2
|
|||||||
F src/utf.c 92f0dd69bd1c1e4eff93c6038dd91b37ac1b9a65
|
F src/utf.c 92f0dd69bd1c1e4eff93c6038dd91b37ac1b9a65
|
||||||
F src/util.c 6e93dad9a17b34f37fc270ba871b224240168bf0
|
F src/util.c 6e93dad9a17b34f37fc270ba871b224240168bf0
|
||||||
F src/vacuum.c f9561c8095407a970af4e6a304b77c4083433d3e
|
F src/vacuum.c f9561c8095407a970af4e6a304b77c4083433d3e
|
||||||
F src/vdbe.c 35ae18345a8c35b17a37226cf868a99623288139
|
F src/vdbe.c 22dcf0e98c6316d0a8328d828cce4adc5b8668bb
|
||||||
F src/vdbe.h 46f74444a213129bc4b5ce40124dd8ed613b0cde
|
F src/vdbe.h 46f74444a213129bc4b5ce40124dd8ed613b0cde
|
||||||
F src/vdbeInt.h 4e636b1b6c18d1d85b085fe0e5a19d45ad85f382
|
F src/vdbeInt.h 4e636b1b6c18d1d85b085fe0e5a19d45ad85f382
|
||||||
F src/vdbeapi.c ee350b552fc4c1c695b760f914f69e9c5556e829
|
F src/vdbeapi.c ee350b552fc4c1c695b760f914f69e9c5556e829
|
||||||
F src/vdbeaux.c dc0e7d3bdf3b6f322448b4bee29fe5bec656b4d4
|
F src/vdbeaux.c dc0e7d3bdf3b6f322448b4bee29fe5bec656b4d4
|
||||||
F src/vdbemem.c c00e939cfb19380fc80349e143b541a45ab53424
|
F src/vdbemem.c c00e939cfb19380fc80349e143b541a45ab53424
|
||||||
F src/where.c 4955f34f7b46c9ca5c4e50e2db440f5e356f04dd
|
F src/where.c 6507074d8ce3f78e7a4cd33f667f11e62020553e
|
||||||
F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
|
F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
|
||||||
F test/attach.test aed659e52635662bcd5069599aaca823533edf5a
|
F test/attach.test aed659e52635662bcd5069599aaca823533edf5a
|
||||||
F test/attach2.test 579d6cb94cb944e0d87a2bf8d6696e2036847e6a
|
F test/attach2.test 579d6cb94cb944e0d87a2bf8d6696e2036847e6a
|
||||||
@@ -224,7 +224,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248
|
|||||||
F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
|
F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
|
||||||
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
||||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||||
P b9493c5facea4d24a6cbc4f6fa2f75dc2399a11d
|
P 12e77e759ec5b45b7fb94aa815435127f395162e
|
||||||
R da2b683145f062d232a7ec22a0664baa
|
R aebc8fd8caefcbe7b2df44794110fc94
|
||||||
U danielk1977
|
U danielk1977
|
||||||
Z e775c4725bc272bf6ec66a50b08f1692
|
Z f3b130fff0bc0063d640a9d3c08bfe60
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
12e77e759ec5b45b7fb94aa815435127f395162e
|
a71a9ff114f2162696d8d37fbc87b315568f6dcb
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
** This file contains C code routines that are called by the parser
|
** This file contains C code routines that are called by the parser
|
||||||
** to handle DELETE FROM statements.
|
** to handle DELETE FROM statements.
|
||||||
**
|
**
|
||||||
** $Id: delete.c,v 1.74 2004/06/16 12:00:49 danielk1977 Exp $
|
** $Id: delete.c,v 1.75 2004/06/17 07:53:02 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -413,6 +413,6 @@ void sqlite3GenerateIndexKey(
|
|||||||
sqlite3VdbeAddOp(v, OP_Column, iCur, idx);
|
sqlite3VdbeAddOp(v, OP_Column, iCur, idx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlite3VdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
|
sqlite3VdbeAddOp(v, OP_MakeRecord, pIdx->nColumn, (1<<24));
|
||||||
sqlite3IndexAffinityStr(v, pIdx);
|
sqlite3IndexAffinityStr(v, pIdx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
** This file contains routines used for analyzing expressions and
|
** This file contains routines used for analyzing expressions and
|
||||||
** for generating VDBE code that evaluates expressions in SQLite.
|
** for generating VDBE code that evaluates expressions in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: expr.c,v 1.143 2004/06/16 12:00:50 danielk1977 Exp $
|
** $Id: expr.c,v 1.144 2004/06/17 07:53:03 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -911,7 +911,7 @@ int sqlite3ExprResolveIds(
|
|||||||
|
|
||||||
/* Evaluate the expression and insert it into the temp table */
|
/* Evaluate the expression and insert it into the temp table */
|
||||||
sqlite3ExprCode(pParse, pE2);
|
sqlite3ExprCode(pParse, pE2);
|
||||||
sqlite3VdbeOp3(v, OP_MakeKey, 1, 0, affStr, P3_STATIC);
|
sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, affStr, P3_STATIC);
|
||||||
sqlite3VdbeAddOp(v, OP_String8, 0, 0);
|
sqlite3VdbeAddOp(v, OP_String8, 0, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_PutStrKey, pExpr->iTable, 0);
|
sqlite3VdbeAddOp(v, OP_PutStrKey, pExpr->iTable, 0);
|
||||||
}
|
}
|
||||||
@@ -1314,7 +1314,7 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
|
|||||||
|
|
||||||
/* Figure out the affinity to use to create a key from the results
|
/* Figure out the affinity to use to create a key from the results
|
||||||
** of the expression. affinityStr stores a static string suitable for
|
** of the expression. affinityStr stores a static string suitable for
|
||||||
** P3 of OP_MakeKey.
|
** P3 of OP_MakeRecord.
|
||||||
*/
|
*/
|
||||||
affStr = sqlite3AffinityString(comparisonAffinity(pExpr));
|
affStr = sqlite3AffinityString(comparisonAffinity(pExpr));
|
||||||
|
|
||||||
@@ -1329,7 +1329,7 @@ void sqlite3ExprCode(Parse *pParse, Expr *pExpr){
|
|||||||
sqlite3VdbeAddOp(v, OP_Pop, 2, 0);
|
sqlite3VdbeAddOp(v, OP_Pop, 2, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_String8, 0, 0);
|
sqlite3VdbeAddOp(v, OP_String8, 0, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_Goto, 0, addr+7);
|
sqlite3VdbeAddOp(v, OP_Goto, 0, addr+7);
|
||||||
sqlite3VdbeOp3(v, OP_MakeKey, 1, 0, affStr, P3_STATIC); /* addr + 4 */
|
sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, affStr, P3_STATIC); /* addr + 4 */
|
||||||
sqlite3VdbeAddOp(v, OP_Found, pExpr->iTable, addr+7);
|
sqlite3VdbeAddOp(v, OP_Found, pExpr->iTable, addr+7);
|
||||||
sqlite3VdbeAddOp(v, OP_AddImm, -1, 0); /* addr + 6 */
|
sqlite3VdbeAddOp(v, OP_AddImm, -1, 0); /* addr + 6 */
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
** This file contains C code routines that are called by the parser
|
** This file contains C code routines that are called by the parser
|
||||||
** to handle INSERT statements in SQLite.
|
** to handle INSERT statements in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: insert.c,v 1.111 2004/06/16 12:00:54 danielk1977 Exp $
|
** $Id: insert.c,v 1.112 2004/06/17 07:53:03 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -867,7 +867,7 @@ void sqlite3GenerateConstraintChecks(
|
|||||||
sqlite3VdbeAddOp(v, OP_Dup, i+extra+nCol-idx, 1);
|
sqlite3VdbeAddOp(v, OP_Dup, i+extra+nCol-idx, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jumpInst1 = sqlite3VdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
|
jumpInst1 = sqlite3VdbeAddOp(v, OP_MakeRecord, pIdx->nColumn, (1<<24));
|
||||||
sqlite3IndexAffinityStr(v, pIdx);
|
sqlite3IndexAffinityStr(v, pIdx);
|
||||||
|
|
||||||
/* Find out what action to take in case there is an indexing conflict */
|
/* Find out what action to take in case there is an indexing conflict */
|
||||||
@@ -936,8 +936,9 @@ void sqlite3GenerateConstraintChecks(
|
|||||||
default: assert(0);
|
default: assert(0);
|
||||||
}
|
}
|
||||||
contAddr = sqlite3VdbeCurrentAddr(v);
|
contAddr = sqlite3VdbeCurrentAddr(v);
|
||||||
|
assert( contAddr<(1<<24) );
|
||||||
#if NULL_DISTINCT_FOR_UNIQUE
|
#if NULL_DISTINCT_FOR_UNIQUE
|
||||||
sqlite3VdbeChangeP2(v, jumpInst1, contAddr);
|
sqlite3VdbeChangeP2(v, jumpInst1, contAddr | (1<<24));
|
||||||
#endif
|
#endif
|
||||||
sqlite3VdbeChangeP2(v, jumpInst2, contAddr);
|
sqlite3VdbeChangeP2(v, jumpInst2, contAddr);
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/select.c
17
src/select.c
@@ -12,7 +12,7 @@
|
|||||||
** This file contains C code routines that are called by the parser
|
** This file contains C code routines that are called by the parser
|
||||||
** to handle SELECT statements in SQLite.
|
** to handle SELECT statements in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: select.c,v 1.191 2004/06/16 12:02:47 danielk1977 Exp $
|
** $Id: select.c,v 1.192 2004/06/17 07:53:03 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ static void pushOntoSorter(Parse *pParse, Vdbe *v, ExprList *pOrderBy){
|
|||||||
for(i=0; i<pOrderBy->nExpr; i++){
|
for(i=0; i<pOrderBy->nExpr; i++){
|
||||||
sqlite3ExprCode(pParse, pOrderBy->a[i].pExpr);
|
sqlite3ExprCode(pParse, pOrderBy->a[i].pExpr);
|
||||||
}
|
}
|
||||||
sqlite3VdbeAddOp(v, OP_MakeKey, pOrderBy->nExpr, 0);
|
sqlite3VdbeAddOp(v, OP_MakeRecord, pOrderBy->nExpr, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_SortPut, 0, 0);
|
sqlite3VdbeAddOp(v, OP_SortPut, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,8 +384,9 @@ static int selectInnerLoop(
|
|||||||
#if NULL_ALWAYS_DISTINCT
|
#if NULL_ALWAYS_DISTINCT
|
||||||
sqlite3VdbeAddOp(v, OP_IsNull, -pEList->nExpr, sqlite3VdbeCurrentAddr(v)+7);
|
sqlite3VdbeAddOp(v, OP_IsNull, -pEList->nExpr, sqlite3VdbeCurrentAddr(v)+7);
|
||||||
#endif
|
#endif
|
||||||
/* Deliberately leave the affinity string off of the following OP_MakeKey */
|
/* Deliberately leave the affinity string off of the following
|
||||||
sqlite3VdbeAddOp(v, OP_MakeKey, pEList->nExpr, 1);
|
** OP_MakeRecord */
|
||||||
|
sqlite3VdbeAddOp(v, OP_MakeRecord, pEList->nExpr * -1, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_Distinct, distinct, sqlite3VdbeCurrentAddr(v)+3);
|
sqlite3VdbeAddOp(v, OP_Distinct, distinct, sqlite3VdbeCurrentAddr(v)+3);
|
||||||
sqlite3VdbeAddOp(v, OP_Pop, pEList->nExpr+1, 0);
|
sqlite3VdbeAddOp(v, OP_Pop, pEList->nExpr+1, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_Goto, 0, iContinue);
|
sqlite3VdbeAddOp(v, OP_Goto, 0, iContinue);
|
||||||
@@ -452,7 +453,7 @@ static int selectInnerLoop(
|
|||||||
char aff = (iParm>>16)&0xFF;
|
char aff = (iParm>>16)&0xFF;
|
||||||
aff = sqlite3CompareAffinity(pEList->a[0].pExpr, aff);
|
aff = sqlite3CompareAffinity(pEList->a[0].pExpr, aff);
|
||||||
affStr = sqlite3AffinityString(aff);
|
affStr = sqlite3AffinityString(aff);
|
||||||
sqlite3VdbeOp3(v, OP_MakeKey, 1, 0, affStr, P3_STATIC);
|
sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, affStr, P3_STATIC);
|
||||||
sqlite3VdbeAddOp(v, OP_String8, 0, 0);
|
sqlite3VdbeAddOp(v, OP_String8, 0, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_PutStrKey, (iParm&0x0000FFFF), 0);
|
sqlite3VdbeAddOp(v, OP_PutStrKey, (iParm&0x0000FFFF), 0);
|
||||||
}
|
}
|
||||||
@@ -579,7 +580,7 @@ static void generateSortTail(
|
|||||||
sqlite3VdbeAddOp(v, OP_NotNull, -1, sqlite3VdbeCurrentAddr(v)+3);
|
sqlite3VdbeAddOp(v, OP_NotNull, -1, sqlite3VdbeCurrentAddr(v)+3);
|
||||||
sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
|
sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+3);
|
sqlite3VdbeAddOp(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+3);
|
||||||
sqlite3VdbeOp3(v, OP_MakeKey, 1, 0, "n", P3_STATIC);
|
sqlite3VdbeOp3(v, OP_MakeRecord, 1, 0, "n", P3_STATIC);
|
||||||
sqlite3VdbeAddOp(v, OP_String8, 0, 0);
|
sqlite3VdbeAddOp(v, OP_String8, 0, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_PutStrKey, (iParm&0x0000FFFF), 0);
|
sqlite3VdbeAddOp(v, OP_PutStrKey, (iParm&0x0000FFFF), 0);
|
||||||
break;
|
break;
|
||||||
@@ -2514,9 +2515,9 @@ int sqlite3Select(
|
|||||||
for(i=0; i<pGroupBy->nExpr; i++){
|
for(i=0; i<pGroupBy->nExpr; i++){
|
||||||
sqlite3ExprCode(pParse, pGroupBy->a[i].pExpr);
|
sqlite3ExprCode(pParse, pGroupBy->a[i].pExpr);
|
||||||
}
|
}
|
||||||
/* No affinity string is attached to the following OP_MakeKey
|
/* No affinity string is attached to the following OP_MakeRecord
|
||||||
** because we do not need to do any coercion of datatypes. */
|
** because we do not need to do any coercion of datatypes. */
|
||||||
sqlite3VdbeAddOp(v, OP_MakeKey, pGroupBy->nExpr, 0);
|
sqlite3VdbeAddOp(v, OP_MakeRecord, pGroupBy->nExpr, 0);
|
||||||
lbl1 = sqlite3VdbeMakeLabel(v);
|
lbl1 = sqlite3VdbeMakeLabel(v);
|
||||||
sqlite3VdbeAddOp(v, OP_AggFocus, 0, lbl1);
|
sqlite3VdbeAddOp(v, OP_AggFocus, 0, lbl1);
|
||||||
for(i=0, pAgg=pParse->aAgg; i<pParse->nAgg; i++, pAgg++){
|
for(i=0, pAgg=pParse->aAgg; i<pParse->nAgg; i++, pAgg++){
|
||||||
|
|||||||
106
src/vdbe.c
106
src/vdbe.c
@@ -43,7 +43,7 @@
|
|||||||
** in this file for details. If in doubt, do not deviate from existing
|
** in this file for details. If in doubt, do not deviate from existing
|
||||||
** commenting and indentation practices when changing or adding code.
|
** commenting and indentation practices when changing or adding code.
|
||||||
**
|
**
|
||||||
** $Id: vdbe.c,v 1.377 2004/06/16 12:02:54 danielk1977 Exp $
|
** $Id: vdbe.c,v 1.378 2004/06/17 07:53:03 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
@@ -2092,66 +2092,6 @@ case OP_Column: {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Opcode: MakeKey P1 P2 P3
|
|
||||||
**
|
|
||||||
** Convert the top P1 entries of the stack into a single entry suitable
|
|
||||||
** for use as the key in an index. If P2 is zero, then the original
|
|
||||||
** entries are popped off the stack. If P2 is not zero, the original
|
|
||||||
** entries remain on the stack.
|
|
||||||
**
|
|
||||||
** P3 is interpreted in the same way as for MakeIdxKey.
|
|
||||||
*/
|
|
||||||
/* Opcode: MakeIdxKey P1 P2 P3
|
|
||||||
**
|
|
||||||
** Convert the top P1 entries of the stack into a single entry suitable
|
|
||||||
** for use as the key in an index. In addition, take one additional integer
|
|
||||||
** off of the stack, treat that integer as an eight-byte record number, and
|
|
||||||
** append the integer to the key as a varint. Thus a total of P1+1 entries
|
|
||||||
** are popped from the stack for this instruction and a single entry is
|
|
||||||
** pushed back.
|
|
||||||
**
|
|
||||||
** If P2 is not zero and one or more of the P1 entries that go into the
|
|
||||||
** generated key is NULL, then jump to P2 after the new key has been
|
|
||||||
** pushed on the stack. In other words, jump to P2 if the key is
|
|
||||||
** guaranteed to be unique. This jump can be used to skip a subsequent
|
|
||||||
** uniqueness test.
|
|
||||||
**
|
|
||||||
** P3 may be a string that is P1 characters long. The nth character of the
|
|
||||||
** string indicates the column affinity that should be used for the nth
|
|
||||||
** field of the index key (i.e. the first character of P3 corresponds to the
|
|
||||||
** lowest element on the stack).
|
|
||||||
**
|
|
||||||
** Character Column affinity
|
|
||||||
** ------------------------------
|
|
||||||
** 'n' NUMERIC
|
|
||||||
** 'i' INTEGER
|
|
||||||
** 't' TEXT
|
|
||||||
** 'o' NONE
|
|
||||||
**
|
|
||||||
** If P3 is NULL then no datatype coercion occurs.
|
|
||||||
*/
|
|
||||||
/* Opcode MakeRecord P1 * P3
|
|
||||||
**
|
|
||||||
** Convert the top P1 entries of the stack into a single entry
|
|
||||||
** suitable for use as a data record in a database table. The
|
|
||||||
** details of the format are irrelavant as long as the OP_Column
|
|
||||||
** opcode can decode the record later. Refer to source code
|
|
||||||
** comments for the details of the record format.
|
|
||||||
**
|
|
||||||
** P3 may be a string that is P1 characters long. The nth character of the
|
|
||||||
** string indicates the column affinity that should be used for the nth
|
|
||||||
** field of the index key (i.e. the first character of P3 corresponds to the
|
|
||||||
** lowest element on the stack).
|
|
||||||
**
|
|
||||||
** Character Column affinity
|
|
||||||
** ------------------------------
|
|
||||||
** 'n' NUMERIC
|
|
||||||
** 'i' INTEGER
|
|
||||||
** 't' TEXT
|
|
||||||
** 'o' NONE
|
|
||||||
**
|
|
||||||
** If P3 is NULL then all index fields have the affinity NONE.
|
|
||||||
*/
|
|
||||||
/* Opcode MakeRecord P1 P2 P3
|
/* Opcode MakeRecord P1 P2 P3
|
||||||
**
|
**
|
||||||
** Convert the top abs(P1) entries of the stack into a single entry
|
** Convert the top abs(P1) entries of the stack into a single entry
|
||||||
@@ -2165,8 +2105,12 @@ case OP_Column: {
|
|||||||
** The original stack entries are popped from the stack if P1>0 but
|
** The original stack entries are popped from the stack if P1>0 but
|
||||||
** remain on the stack if P1<0.
|
** remain on the stack if P1<0.
|
||||||
**
|
**
|
||||||
** If P2 is not zero and one or more of the entries are NULL, then jump
|
** The P2 argument is divided into two 16-bit words before it is processed.
|
||||||
** to P2. This feature can be used to skip a uniqueness test on indices.
|
** If the hi-word is non-zero, then an extra integer is read from the stack
|
||||||
|
** and appended to the record as a varint. If the low-word of P2 is not
|
||||||
|
** zero and one or more of the entries are NULL, then jump to the value of
|
||||||
|
** the low-word of P2. This feature can be used to skip a uniqueness test
|
||||||
|
** on indices.
|
||||||
**
|
**
|
||||||
** P3 may be a string that is P1 characters long. The nth character of the
|
** P3 may be a string that is P1 characters long. The nth character of the
|
||||||
** string indicates the column affinity that should be used for the nth
|
** string indicates the column affinity that should be used for the nth
|
||||||
@@ -2182,8 +2126,6 @@ case OP_Column: {
|
|||||||
**
|
**
|
||||||
** If P3 is NULL then all index fields have the affinity NONE.
|
** If P3 is NULL then all index fields have the affinity NONE.
|
||||||
*/
|
*/
|
||||||
case OP_MakeKey:
|
|
||||||
case OP_MakeIdxKey:
|
|
||||||
case OP_MakeRecord: {
|
case OP_MakeRecord: {
|
||||||
/* Assuming the record contains N fields, the record format looks
|
/* Assuming the record contains N fields, the record format looks
|
||||||
** like this:
|
** like this:
|
||||||
@@ -2200,24 +2142,32 @@ case OP_MakeRecord: {
|
|||||||
** hdr-size field is also a varint which is the offset from the beginning
|
** hdr-size field is also a varint which is the offset from the beginning
|
||||||
** of the record to data0.
|
** of the record to data0.
|
||||||
*/
|
*/
|
||||||
int nField = pOp->p1;
|
|
||||||
unsigned char *zNewRecord;
|
unsigned char *zNewRecord;
|
||||||
unsigned char *zCsr;
|
unsigned char *zCsr;
|
||||||
char *zAffinity;
|
|
||||||
Mem *pRec;
|
Mem *pRec;
|
||||||
Mem *pRowid = 0;
|
Mem *pRowid = 0;
|
||||||
int nData = 0; /* Number of bytes of data space */
|
int nData = 0; /* Number of bytes of data space */
|
||||||
int nHdr = 0; /* Number of bytes of header space */
|
int nHdr = 0; /* Number of bytes of header space */
|
||||||
int nByte = 0; /* Space required for this record */
|
int nByte = 0; /* Space required for this record */
|
||||||
int addRowid; /* True to append a rowid column at the end */
|
|
||||||
u32 serial_type; /* Type field */
|
u32 serial_type; /* Type field */
|
||||||
int containsNull; /* True if any of the data fields are NULL */
|
int containsNull = 0; /* True if any of the data fields are NULL */
|
||||||
char zTemp[NBFS]; /* Space to hold small records */
|
char zTemp[NBFS]; /* Space to hold small records */
|
||||||
|
Mem *pData0;
|
||||||
|
|
||||||
Mem *pData0 = &pTos[1-nField];
|
int leaveOnStack; /* If true, leave the entries on the stack */
|
||||||
assert( pData0>=p->aStack );
|
int nField; /* Number of fields in the record */
|
||||||
|
int jumpIfNull; /* Jump here if non-zero and any entries are NULL. */
|
||||||
|
int addRowid; /* True to append a rowid column at the end */
|
||||||
|
char *zAffinity; /* The affinity string for the record */
|
||||||
|
|
||||||
|
leaveOnStack = ((pOp->p1<0)?1:0);
|
||||||
|
nField = pOp->p1 * (leaveOnStack?-1:1);
|
||||||
|
jumpIfNull = (pOp->p2 & 0x00FFFFFF);
|
||||||
|
addRowid = ((pOp->p2>>24) & 0x0000FFFF)?1:0;
|
||||||
zAffinity = pOp->p3;
|
zAffinity = pOp->p3;
|
||||||
addRowid = pOp->opcode==OP_MakeIdxKey;
|
|
||||||
|
pData0 = &pTos[1-nField];
|
||||||
|
assert( pData0>=p->aStack );
|
||||||
containsNull = 0;
|
containsNull = 0;
|
||||||
|
|
||||||
/* Loop through the elements that will make up the record to figure
|
/* Loop through the elements that will make up the record to figure
|
||||||
@@ -2293,8 +2243,8 @@ case OP_MakeRecord: {
|
|||||||
goto abort_due_to_error;
|
goto abort_due_to_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pop nField entries from the stack and push the new entry on */
|
/* Pop entries off the stack if required. Push the new record on. */
|
||||||
if( addRowid || pOp->p2==0 ){
|
if( !leaveOnStack ){
|
||||||
popStack(&pTos, nField+addRowid);
|
popStack(&pTos, nField+addRowid);
|
||||||
}
|
}
|
||||||
pTos++;
|
pTos++;
|
||||||
@@ -2311,11 +2261,9 @@ case OP_MakeRecord: {
|
|||||||
pTos->xDel = 0;
|
pTos->xDel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If P2 is non-zero, and if the key contains a NULL value, and if this
|
/* If a NULL was encountered and jumpIfNull is non-zero, take the jump. */
|
||||||
** was an OP_MakeIdxKey instruction, not OP_MakeKey, jump to P2.
|
if( jumpIfNull && containsNull ){
|
||||||
*/
|
pc = jumpIfNull - 1;
|
||||||
if( pOp->p2 && containsNull && addRowid ){
|
|
||||||
pc = pOp->p2 - 1;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
** This module contains C code that generates VDBE code used to process
|
** This module contains C code that generates VDBE code used to process
|
||||||
** the WHERE clause of SQL statements.
|
** the WHERE clause of SQL statements.
|
||||||
**
|
**
|
||||||
** $Id: where.c,v 1.106 2004/06/16 12:03:10 danielk1977 Exp $
|
** $Id: where.c,v 1.107 2004/06/17 07:53:04 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@@ -827,7 +827,7 @@ WhereInfo *sqlite3WhereBegin(
|
|||||||
sqlite3VdbeAddOp(v, OP_Goto, 0, brk);
|
sqlite3VdbeAddOp(v, OP_Goto, 0, brk);
|
||||||
|
|
||||||
/* Generate an index key from the top nColumn elements of the stack */
|
/* Generate an index key from the top nColumn elements of the stack */
|
||||||
sqlite3VdbeAddOp(v, OP_MakeKey, nColumn, 0);
|
sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0);
|
||||||
sqlite3IndexAffinityStr(v, pIdx);
|
sqlite3IndexAffinityStr(v, pIdx);
|
||||||
sqlite3VdbeAddOp(v, OP_MemStore, pLevel->iMem, 0);
|
sqlite3VdbeAddOp(v, OP_MemStore, pLevel->iMem, 0);
|
||||||
|
|
||||||
@@ -1029,7 +1029,7 @@ WhereInfo *sqlite3WhereBegin(
|
|||||||
sqlite3VdbeAddOp(v, OP_NotNull, -nCol, sqlite3VdbeCurrentAddr(v)+3);
|
sqlite3VdbeAddOp(v, OP_NotNull, -nCol, sqlite3VdbeCurrentAddr(v)+3);
|
||||||
sqlite3VdbeAddOp(v, OP_Pop, nCol, 0);
|
sqlite3VdbeAddOp(v, OP_Pop, nCol, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_Goto, 0, brk);
|
sqlite3VdbeAddOp(v, OP_Goto, 0, brk);
|
||||||
sqlite3VdbeAddOp(v, OP_MakeKey, nCol, 0);
|
sqlite3VdbeAddOp(v, OP_MakeRecord, nCol, 0);
|
||||||
sqlite3IndexAffinityStr(v, pIdx);
|
sqlite3IndexAffinityStr(v, pIdx);
|
||||||
if( pLevel->bRev ){
|
if( pLevel->bRev ){
|
||||||
int op = leFlag ? OP_MoveLe : OP_MoveLt;
|
int op = leFlag ? OP_MoveLe : OP_MoveLt;
|
||||||
@@ -1083,7 +1083,7 @@ WhereInfo *sqlite3WhereBegin(
|
|||||||
sqlite3VdbeAddOp(v, OP_NotNull, -nCol, sqlite3VdbeCurrentAddr(v)+3);
|
sqlite3VdbeAddOp(v, OP_NotNull, -nCol, sqlite3VdbeCurrentAddr(v)+3);
|
||||||
sqlite3VdbeAddOp(v, OP_Pop, nCol, 0);
|
sqlite3VdbeAddOp(v, OP_Pop, nCol, 0);
|
||||||
sqlite3VdbeAddOp(v, OP_Goto, 0, brk);
|
sqlite3VdbeAddOp(v, OP_Goto, 0, brk);
|
||||||
sqlite3VdbeAddOp(v, OP_MakeKey, nCol, 0);
|
sqlite3VdbeAddOp(v, OP_MakeRecord, nCol, 0);
|
||||||
sqlite3IndexAffinityStr(v, pIdx);
|
sqlite3IndexAffinityStr(v, pIdx);
|
||||||
if( pLevel->bRev ){
|
if( pLevel->bRev ){
|
||||||
pLevel->iMem = pParse->nMem++;
|
pLevel->iMem = pParse->nMem++;
|
||||||
|
|||||||
Reference in New Issue
Block a user