From: drh Date: Sat, 30 Jan 2016 00:45:18 +0000 (+0000) Subject: Change the P4_INTARRAY so that always begins with a length integer. Print X-Git-Tag: version-3.11.0~81^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fcovering-or;p=thirdparty%2Fsqlite.git Change the P4_INTARRAY so that always begins with a length integer. Print the content of the INTARRAY on EXPLAIN output. FossilOrigin-Name: 6c520d5726e80b4251338c43c405270d150ea81e --- diff --git a/manifest b/manifest index b6defac38e..6b3a40d3f9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sfor\sthe\schange\son\sthis\sbranch. -D 2016-01-29T21:16:13.360 +C Change\sthe\sP4_INTARRAY\sso\sthat\salways\sbegins\swith\sa\slength\sinteger.\s\sPrint\nthe\scontent\sof\sthe\sINTARRAY\son\sEXPLAIN\soutput. +D 2016-01-30T00:45:18.967 F Makefile.in 027c1603f255390c43a426671055a31c0a65fdb4 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 72b7858f02017611c3ac1ddc965251017fed0845 @@ -347,7 +347,7 @@ F src/printf.c af589a27b7d40f6f4f704e9eea99f02f18ad6d32 F src/random.c ba2679f80ec82c4190062d756f22d0c358180696 F src/resolve.c 9f7ce3a3c087afb7597b7c916c99126ff3f12f0c F src/rowset.c eccf6af6d620aaa4579bd3b72c1b6395d9e9fa1e -F src/select.c c34292c8ce7fe69c7cf890d933834a22572bd301 +F src/select.c ea6f3b0c279aa37eb3701792d094673a7ad1bf88 F src/shell.c dcd7a83645ef2a58ee9c6d0ea4714d877d7835c4 F src/sqlite.h.in 214476a62012e578f42133a9a3b4f97a9aa421a3 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 @@ -412,11 +412,11 @@ F src/update.c 17332f9fe818cbc0444c36a811800af8498af4c3 F src/utf.c 32d7f82aa921322f3e1c956f4b58f019ebd2c6b3 F src/util.c 72d40df0a52d3f30b462a15f0e094fcbade6dc82 F src/vacuum.c 2ddd5cad2a7b9cef7f9e431b8c7771634c6b1701 -F src/vdbe.c 2e0c42bba0aee55b06b636feb5ad41d77c75abe3 +F src/vdbe.c 0686ef5ee103935548d1aa2c0c28e52f1ae6e5a8 F src/vdbe.h 7a733ea8aac1b77305a67698e784fa3484ee3337 F src/vdbeInt.h 171fdc5f6af4eeb0ff0559dbf0a71244d726a670 F src/vdbeapi.c ffae8f5af4570fbd548504e815e9fb7227f0822e -F src/vdbeaux.c 657402ba7d253963e3fca323c6ad9f7b29a9efb9 +F src/vdbeaux.c 108124021ed02fa4fc6f90a53dcaf58ac3bab941 F src/vdbeblob.c 37c3d11a753e403698c69e17383d282e1ae73e75 F src/vdbemem.c b9181e77eca2a095929d46250daf85c8d2621fc0 F src/vdbesort.c ef3c6d1f1a7d44cf67bb2bee59ea3d1fe5bad174 @@ -428,7 +428,7 @@ F src/wal.h 2f7c831cf3b071fa548bf2d5cac640846a7ff19c F src/walker.c 0f142b5bd3ed2041fc52d773880748b212e63354 F src/where.c af9bf5dcec1a0e52726c550924aa91d837166251 F src/whereInt.h 78b6b4de94db84aecbdc07fe3e38f648eb391e9a -F src/wherecode.c 1b2a96c425048bf96eb97ba49235c71f54917b1d +F src/wherecode.c 3c4757ae85e8237808a4ec1a25c513d83e1395e0 F src/whereexpr.c 197a448b52073aee43eca3a2233fc113369eb2d4 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd @@ -1422,7 +1422,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6e3dcb6d7d960bb513d9a4a002b6cf5ab7159686 -R 56d45fd4fdb64a9d12152455ff1bc2b7 -U dan -Z 8c3eb3de3f58e27647eefba9e15f6f8b +P 7cb697f82932a2581af69350117a29c9c8a2544f +R e4149e0b983ab1835709b124e27b8f90 +U drh +Z 9c9e55627bd1b33e50ca6caf5cedf1b5 diff --git a/manifest.uuid b/manifest.uuid index c7e676919d..95c87154e9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7cb697f82932a2581af69350117a29c9c8a2544f \ No newline at end of file +6c520d5726e80b4251338c43c405270d150ea81e \ No newline at end of file diff --git a/src/select.c b/src/select.c index ea4298e677..891b123543 100644 --- a/src/select.c +++ b/src/select.c @@ -2870,10 +2870,11 @@ static int multiSelectOrderBy( ** to the right and the left are evaluated, they use the correct ** collation. */ - aPermute = sqlite3DbMallocRaw(db, sizeof(int)*nOrderBy); + aPermute = sqlite3DbMallocRaw(db, sizeof(int)*(nOrderBy + 1)); if( aPermute ){ struct ExprList_item *pItem; - for(i=0, pItem=pOrderBy->a; ia; i<=nOrderBy; i++, pItem++){ assert( pItem->u.x.iOrderByCol>0 ); assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr ); aPermute[i] = pItem->u.x.iOrderByCol - 1; diff --git a/src/vdbe.c b/src/vdbe.c index 8ad1a17c39..b7c0258ce6 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -2067,11 +2067,14 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ ** The permutation is only valid until the next OP_Compare that has ** the OPFLAG_PERMUTE bit set in P5. Typically the OP_Permutation should ** occur immediately prior to the OP_Compare. +** +** The first integer in the P4 integer array is the length of the array +** and does not become part of the permutation. */ case OP_Permutation: { assert( pOp->p4type==P4_INTARRAY ); assert( pOp->p4.ai ); - aPermute = pOp->p4.ai; + aPermute = pOp->p4.ai + 1; break; } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 6e368cfdbd..aaba2d3d0c 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -1288,7 +1288,21 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){ } #endif case P4_INTARRAY: { - sqlite3_snprintf(nTemp, zTemp, "intarray"); + int i, j; + int *ai = pOp->p4.ai; + int n = ai[0]; /* The first element of an INTARRAY is always the + ** count of the number of elements to follow */ + zTemp[0] = '['; + for(i=j=1; i1 ) zTemp[j++] = ','; + sqlite3_snprintf(nTemp-j, zTemp+j, "%d", ai[i]); + j += sqlite3Strlen30(zTemp+j); + } + if( ieCurType==CURTYPE_BTREE ){ if( p->deferredMoveto ){ - if( p->aAltMap && p->aAltMap[*piCol] ){ + int iMap; + if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 ){ *pp = p->pAltCursor; - *piCol = p->aAltMap[*piCol] - 1; + *piCol = iMap - 1; return SQLITE_OK; } return handleDeferredMoveto(p); diff --git a/src/wherecode.c b/src/wherecode.c index eacd6d08d1..fea397c543 100644 --- a/src/wherecode.c +++ b/src/wherecode.c @@ -783,11 +783,12 @@ static void codeDeferredSeek( ){ int i; Table *pTab = pIdx->pTable; - int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int) * pTab->nCol); + int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1)); if( ai ){ + ai[0] = pTab->nCol; for(i=0; inColumn-1; i++){ assert( pIdx->aiColumn[i]nCol ); - if( pIdx->aiColumn[i]>=0 ) ai[pIdx->aiColumn[i]] = i+1; + if( pIdx->aiColumn[i]>=0 ) ai[pIdx->aiColumn[i]+1] = i+1; } sqlite3VdbeChangeP4(v, -1, (char*)ai, P4_INTARRAY); }