aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2012-12-07 22:18:54 +0000
committerdrh <drh@noemail.net>2012-12-07 22:18:54 +0000
commit953f7611da21d43454ae5173f5fb1b69465a2d45 (patch)
tree5b68b836a82c4ba563f31d536f51b2b8d53154ee
parentbd13d34b08ddc66a079f671bcbe96127b41da957 (diff)
downloadsqlite-953f7611da21d43454ae5173f5fb1b69465a2d45.tar.gz
sqlite-953f7611da21d43454ae5173f5fb1b69465a2d45.zip
Fix a long-standing issue with the distinct-as-aggregate optimization that
only expressed when the new collating-sequence logic is turned on. FossilOrigin-Name: 0aaf52a339808386984c30cca0c0c35ac2e70e7e
-rw-r--r--manifest18
-rw-r--r--manifest.uuid2
-rw-r--r--src/resolve.c11
-rw-r--r--src/select.c3
-rw-r--r--src/sqliteInt.h1
-rw-r--r--src/vdbe.c16
6 files changed, 24 insertions, 27 deletions
diff --git a/manifest b/manifest
index dae7f8ea5..f33fbc731 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sthe\sprocessing\sof\sORDER\sBY\sclauses\swith\sCOLLATE\sterms\son\scompound\nqueries.\s\s52\sveryquick\stest\sfailures\sremain.
-D 2012-12-07T21:02:47.824
+C Fix\sa\slong-standing\sissue\swith\sthe\sdistinct-as-aggregate\soptimization\sthat\nonly\sexpressed\swhen\sthe\snew\scollating-sequence\slogic\sis\sturned\son.
+D 2012-12-07T22:18:54.026
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 690d441a758cbffd13e814dc2724a721a6ebd400
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -172,14 +172,14 @@ F src/pragma.c 015723c48072781d2740e310ab04dc92956b76d1
F src/prepare.c 931ad0d852a0df48f79adcba6ce79ca5f475625c
F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
-F src/resolve.c 34168dc9c5e7b388d0ce209dac16069263ae7ed7
+F src/resolve.c 5ed606916be6c63f0e262cc2cb817712384f18b5
F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0
-F src/select.c eb3ded8d6ffcbab20dc3e65ba6a6dc13a01e7fbf
+F src/select.c 28176222b138f30a9bf25bdcec94f58980273f84
F src/shell.c e392dd1ccbb77cc1d75a8367a89b473c24bea019
F src/sqlite.h.in 4e71a210f383b6d060bd3fdf81d850f0f8c4eca3
F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0
F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477
-F src/sqliteInt.h 02e8c8d6f3001243fccbffc1cc484fb24b344ecc
+F src/sqliteInt.h d1f0866c69d94fe018a32f78c31a043e3fc0d0de
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@@ -237,7 +237,7 @@ F src/update.c 28d2d098b43a2c70dae399896ea8a02f622410ef
F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f
F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455
F src/vacuum.c 2727bdd08847fcb6b2d2da6d14f018910e8645d3
-F src/vdbe.c 5b49cb1f852e4604a4fb6c47e087ddab28af193f
+F src/vdbe.c 328cb259ca182026ff63d78a005821339a17ba09
F src/vdbe.h b52887278cb173e66188da84dfab216bea61119d
F src/vdbeInt.h 79abf9b31be406d35ca77d6999cb2d42aaf91e78
F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c
@@ -1025,7 +1025,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P f9fa7581c0371fe0feb4e97487741ade18595810
-R ffd541783cdf83fbb00a5f595a07c0f7
+P 49654453ad157693414c1f86fa3afa0918acffd4
+R 1c9591aed33110a685184b6893dbfa0d
U drh
-Z c3f0cf345664d8221c8b35557e376692
+Z 2db21ba84371cf56d0d7dbac86085c64
diff --git a/manifest.uuid b/manifest.uuid
index 88849058b..16ce20b78 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-49654453ad157693414c1f86fa3afa0918acffd4 \ No newline at end of file
+0aaf52a339808386984c30cca0c0c35ac2e70e7e \ No newline at end of file
diff --git a/src/resolve.c b/src/resolve.c
index 4b9d8fa14..d5d9d1c1a 100644
--- a/src/resolve.c
+++ b/src/resolve.c
@@ -111,20 +111,9 @@ static void resolveAlias(
}
pDup->iTable = pEList->a[iCol].iAlias;
}
-#if 1 /* FIXME */
- if( pExpr->flags & EP_Collate ){
- CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr);
- if( pColl ){
- pDup = sqlite3ExprAddCollateString(pParse, pDup, pColl->zName);
- }
- pDup->flags |= EP_Collate;
- }
-#else
- /* Should be this: */
if( pExpr->op==TK_COLLATE ){
pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);
}
-#endif
/* Before calling sqlite3ExprDelete(), set the EP_Static flag. This
** prevents ExprDelete() from deleting the Expr structure itself,
diff --git a/src/select.c b/src/select.c
index 4582d2bc1..6a7128683 100644
--- a/src/select.c
+++ b/src/select.c
@@ -2337,7 +2337,7 @@ static int multiSelectOrderBy(
pColl = sqlite3ExprCollSeq(pParse, pTerm);
}else{
pColl = multiSelectCollSeq(pParse, p, aPermute[i]);
- pTerm->flags |= EP_Collate;
+// pTerm->flags |= EP_Collate;
}
pKeyMerge->aColl[i] = pColl;
pKeyMerge->aSortOrder[i] = pOrderBy->a[i].sortOrder;
@@ -2540,6 +2540,7 @@ static int multiSelectOrderBy(
sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, (char*)aPermute, P4_INTARRAY);
sqlite3VdbeAddOp4(v, OP_Compare, destA.iSdst, destB.iSdst, nOrderBy,
(char*)pKeyMerge, P4_KEYINFO_HANDOFF);
+ sqlite3VdbeChangeP5(v, OPFLAG_PERMUTE);
sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB);
/* Release temporary registers
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index b15e0b208..2b58a808f 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -2330,6 +2330,7 @@ struct AuthContext {
#define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
#define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */
#define OPFLAG_P2ISREG 0x02 /* P2 to OP_Open** is a register number */
+#define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */
/*
* Each trigger present in the database schema is stored as an instance of
diff --git a/src/vdbe.c b/src/vdbe.c
index bbccac8a9..6b78d27fd 100644
--- a/src/vdbe.c
+++ b/src/vdbe.c
@@ -422,7 +422,9 @@ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
** Print the value of a register for tracing purposes:
*/
static void memTracePrint(FILE *out, Mem *p){
- if( p->flags & MEM_Null ){
+ if( p->flags & MEM_Invalid ){
+ fprintf(out, " undefined");
+ }else if( p->flags & MEM_Null ){
fprintf(out, " NULL");
}else if( (p->flags & (MEM_Int|MEM_Str))==(MEM_Int|MEM_Str) ){
fprintf(out, " si:%lld", p->u.i);
@@ -1077,6 +1079,9 @@ case OP_Copy: {
while( 1 ){
sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
Deephemeralize(pOut);
+#ifdef SQLITE_DEBUG
+ pOut->pScopyFrom = 0;
+#endif
REGISTER_TRACE(pOp->p2+pOp->p3-n, pOut);
if( (n--)==0 ) break;
pOut++;
@@ -1887,9 +1892,9 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
** Set the permutation used by the OP_Compare operator to be the array
** of integers in P4.
**
-** The permutation is only valid until the next OP_Permutation, OP_Compare,
-** OP_Halt, or OP_ResultRow. Typically the OP_Permutation should occur
-** immediately prior to the OP_Compare.
+** 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.
*/
case OP_Permutation: {
assert( pOp->p4type==P4_INTARRAY );
@@ -1898,7 +1903,7 @@ case OP_Permutation: {
break;
}
-/* Opcode: Compare P1 P2 P3 P4 *
+/* Opcode: Compare P1 P2 P3 P4 P5
**
** Compare two vectors of registers in reg(P1)..reg(P1+P3-1) (call this
** vector "A") and in reg(P2)..reg(P2+P3-1) ("B"). Save the result of
@@ -1922,6 +1927,7 @@ case OP_Compare: {
CollSeq *pColl; /* Collating sequence to use on this term */
int bRev; /* True for DESCENDING sort order */
+ if( (pOp->p5 & OPFLAG_PERMUTE)==0 ) aPermute = 0;
n = pOp->p3;
pKeyInfo = pOp->p4.pKeyInfo;
assert( n>0 );