-C All\sregression\stests\snow\spass.\s\sBut\sI\sam\ssure\sthere\smust\sstill\sbe\sproblems.\nNew\stests\sneed\sto\sbe\sadded.\s(CVS\s2666)
-D 2005-09-08T00:13:27
+C Optimizations\sand\srefinements.\s\sImprovements\sto\stest\scoverage.\s(CVS\s2667)
+D 2005-09-08T01:58:43
F Makefile.in 12784cdce5ffc8dfb707300c34e4f1eb3b8a14f1
F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/callback.c 9a1162c8f9dae9fad6d548339669aacb5f6cf76b
F src/complete.c 4de937dfdd4c79a501772ab2035b26082f337a79
F src/date.c 7444b0900a28da77e57e3337a636873cff0ae940
-F src/delete.c be1fc25c9e109cd8cbab42a43ee696263da7c04b
+F src/delete.c 16a0e19460b14d219f39ff5c7a9eef808aa1969c
F src/experimental.c 50c1e3b34f752f4ac10c36f287db095c2b61766d
F src/expr.c 38f1e135aa80dfc62e253c1e22dd6e194efd2d61
F src/func.c 713cf33a0ab8685d44ed31a9c753983a7ff9fd6e
F src/prepare.c 86f0d8e744b8d956eff6bc40e29049efee017610
F src/printf.c c01e9ad473d79463fb1f483b1eca5c3cbed2a4e5
F src/random.c 90adff4e73a3b249eb4f1fc2a6ff9cf78c7233a4
-F src/select.c 5f4a9396fc3b4f1d24224a4842737e708b13fb61
+F src/select.c 7e52f53ccf116456f1f5eebb5493973eda43c89a
F src/shell.c b21daba017b8feef2fdc65ecde57f70209494217
F src/sqlite.h.in d6561d51025d08de4f455607f3f9f9aa76e855d5
-F src/sqliteInt.h b7d841739ce478a299e46db5ebcb510e833a36c5
+F src/sqliteInt.h d2f3284eb67068fcbbd7df99b25f3bd874fa0a53
F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9
F src/tclsqlite.c ac94682f9e601dd373912c46414a5a842db2089a
F src/test1.c b569b60e35f0e3ea20e5ebfaf6e522a01c08d481
F src/test5.c 64f08b2a50ef371a1bd68ff206829e7b1b9997f5
F src/tokenize.c e1faf5637f3f4f90933785a0ecf64595f3ac3530
F src/trigger.c f51dec15921629591cb98bf2e350018e268b109a
-F src/update.c a9d2c5f504212d62da1b094476f1389c0e02f83f
+F src/update.c c2716c2115533ffae3d08bf8853aaba4f970f37e
F src/utf.c bda5eb85039ef16f2d17004c1e18c96e1ab0a80c
F src/util.c 5650f6fe5ee30e0678985ad7b94da91e3f85752b
F src/vacuum.c 829d9e1a6d7c094b80e0899686670932eafd768c
F test/cast.test 937af85faabdb189b6cd05879977f2469223be59
F test/collate1.test f79736d2ebf5492167ee4d1f4ab4c09dda776b03
F test/collate2.test 224a632ba04907c049804b08162efd234aa7871f
-F test/collate3.test 51362bdfb43a72bd2b087d90b2623b0695538e7a
+F test/collate3.test 947a77f5b8227e037a7094d0e338a5504f155cc4
F test/collate4.test daf498e294dcd596b961d425c3f2dda117e4717e
F test/collate5.test 8fb4e7e0241839356bd8710f437c32efb47bfff8
F test/collate6.test 6c9470d1606ee3e564675b229653e320c49ec638
F test/misc1.test 4ca69ca2e2ef33c7a0b0fc8b324111e37a522d29
F test/misc2.test 5c699af2fede2694736a9f45aea7e2f052686e15
F test/misc3.test 7bd937e2c62bcc6be71939faf068d506467b1e03
-F test/misc4.test 879b1eedac550b70fd3f2b7cb993505927459ed3
+F test/misc4.test a4d1368bc598b03b3cf642d0bd22d51b28d6c156
F test/misc5.test 24bd03404039ec727028ac9cf7fd9066fd209ec9
F test/misuse.test 1c7fee3c4c0cb4008717ecccf5c72281fac0008e
F test/notnull.test 7a08117a71e74b0321aaa937dbeb41a09d6eb1d0
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P a1b6d910cdbb53f12366402d9585dce2aad3ba3d
-R 798c4d51d5a5c7cc59df64f56a2ed72b
+P bcc7d722cea4487a3adf9d9b2af4b74bfbfc5f39
+R 91fa1142a737c9df354f4c8b73b255ba
U drh
-Z 7290bc3839b076b3e9d2d69315c82577
+Z 5018c1d6effebbbf13aed3b0f917e94d
-bcc7d722cea4487a3adf9d9b2af4b74bfbfc5f39
\ No newline at end of file
+7283f7c29db4f622380b6a5cb745a4dc0c8e6a25
\ No newline at end of file
** This file contains C code routines that are called by the parser
** in order to generate code for DELETE FROM statements.
**
-** $Id: delete.c,v 1.109 2005/07/21 18:23:20 drh Exp $
+** $Id: delete.c,v 1.110 2005/09/08 01:58:43 drh Exp $
*/
#include "sqliteInt.h"
if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
sqlite3BeginWriteOperation(pParse, triggers_exist, pTab->iDb);
- /* If we are trying to delete from a view, construct that view into
- ** a temporary table.
+ /* If we are trying to delete from a view, realize that view into
+ ** a ephemeral table.
*/
if( isView ){
Select *pView = sqlite3SelectDup(pTab->pSelect);
- sqlite3Select(pParse, pView, SRT_TempTable, iCur, 0, 0, 0, 0);
+ sqlite3Select(pParse, pView, SRT_VirtualTab, iCur, 0, 0, 0, 0);
sqlite3SelectDelete(pView);
}
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
-** $Id: select.c,v 1.264 2005/09/08 00:13:28 drh Exp $
+** $Id: select.c,v 1.265 2005/09/08 01:58:43 drh Exp $
*/
#include "sqliteInt.h"
*/
static void pushOntoSorter(Parse *pParse, Vdbe *v, ExprList *pOrderBy){
sqlite3ExprCodeExprList(pParse, pOrderBy);
- sqlite3VdbeAddOp(v, OP_Sequence, pOrderBy->iTab, 0);
+ sqlite3VdbeAddOp(v, OP_Sequence, pOrderBy->iECursor, 0);
sqlite3VdbeAddOp(v, OP_Pull, pOrderBy->nExpr + 1, 0);
sqlite3VdbeAddOp(v, OP_MakeRecord, pOrderBy->nExpr + 2, 0);
- sqlite3VdbeAddOp(v, OP_IdxInsert, pOrderBy->iTab, 0);
+ sqlite3VdbeAddOp(v, OP_IdxInsert, pOrderBy->iECursor, 0);
}
/*
/* Store the result as data using a unique key.
*/
case SRT_Table:
- case SRT_TempTable: {
+ case SRT_VirtualTab: {
sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0);
if( pOrderBy ){
pushOntoSorter(pParse, v, pOrderBy);
** popping the data from the stack.
*/
case SRT_Subroutine:
- case SRT_Callback:
- case SRT_Sorter: {
+ case SRT_Callback: {
if( pOrderBy ){
sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0);
pushOntoSorter(pParse, v, pOrderBy);
}else if( eDest==SRT_Subroutine ){
sqlite3VdbeAddOp(v, OP_Gosub, 0, iParm);
}else{
- assert( eDest!=SRT_Sorter );
sqlite3VdbeAddOp(v, OP_Callback, nColumn, 0);
}
break;
int iTab;
ExprList *pOrderBy = p->pOrderBy;
- if( eDest==SRT_Sorter ) return;
- iTab = pOrderBy->iTab;
+ iTab = pOrderBy->iECursor;
addr = 1 + sqlite3VdbeAddOp(v, OP_Sort, iTab, brk);
codeLimiter(v, p, cont, brk, 0);
sqlite3VdbeAddOp(v, OP_Column, iTab, pOrderBy->nExpr + 1);
switch( eDest ){
case SRT_Table:
- case SRT_TempTable: {
+ case SRT_VirtualTab: {
sqlite3VdbeAddOp(v, OP_NewRowid, iParm, 0);
sqlite3VdbeAddOp(v, OP_Pull, 1, 0);
sqlite3VdbeAddOp(v, OP_Insert, iParm, 0);
static void createSortingIndex(Parse *pParse, Select *p, ExprList *pOrderBy){
if( pOrderBy ){
int addr;
- assert( pOrderBy->iTab==0 );
- pOrderBy->iTab = pParse->nTab++;
+ assert( pOrderBy->iECursor==0 );
+ pOrderBy->iECursor = pParse->nTab++;
addr = sqlite3VdbeAddOp(pParse->pVdbe, OP_OpenVirtual,
- pOrderBy->iTab, pOrderBy->nExpr+1);
+ pOrderBy->iECursor, pOrderBy->nExpr+1);
assert( p->addrOpenVirt[2] == -1 );
p->addrOpenVirt[2] = addr;
}
/* Create the destination temporary table if necessary
*/
- if( eDest==SRT_TempTable ){
+ if( eDest==SRT_VirtualTab ){
assert( p->pEList );
assert( nSetP2<sizeof(aSetP2)/sizeof(aSetP2[0]) );
aSetP2[nSetP2++] = sqlite3VdbeAddOp(v, OP_OpenVirtual, iParm, 0);
/* If the output is destined for a temporary table, open that table.
*/
- if( eDest==SRT_TempTable ){
+ if( eDest==SRT_VirtualTab ){
sqlite3VdbeAddOp(v, OP_OpenVirtual, iParm, 1);
}
int isDistinct; /* True if the DISTINCT keyword is present */
int distinct; /* Table to use for the distinct set */
int rc = 1; /* Value to return from this function */
+ int addrSortIndex; /* Address of an OP_OpenVirtual instruction */
AggInfo sAggInfo; /* Information used by aggregate queries */
if( sqlite3_malloc_failed || pParse->nErr || p==0 ) return 1;
}else{
needRestoreContext = 0;
}
- sqlite3Select(pParse, pItem->pSelect, SRT_TempTable,
+ sqlite3Select(pParse, pItem->pSelect, SRT_VirtualTab,
pItem->iCursor, p, i, &isAgg, 0);
if( needRestoreContext ){
pParse->zAuthContext = zSavedAuthContext;
#endif
/* If there is an ORDER BY clause, resolve any collation sequences
- ** names that have been explicitly specified.
+ ** names that have been explicitly specified and create a sorting index.
+ **
+ ** This sorting index might end up being unused if the data can be
+ ** extracted in pre-sorted order. If that is the case, then the
+ ** OP_OpenVirtual instruction will be changed to an OP_Noop once
+ ** we figure out that the sorting index is not needed. The addrSortIndex
+ ** variable is used to facilitate that change.
*/
if( pOrderBy ){
struct ExprList_item *pTerm;
KeyInfo *pKeyInfo;
- int addr;
for(i=0, pTerm=pOrderBy->a; i<pOrderBy->nExpr; i++, pTerm++){
if( pTerm->zName ){
pTerm->pExpr->pColl = sqlite3LocateCollSeq(pParse, pTerm->zName, -1);
goto select_end;
}
pKeyInfo = keyInfoFromExprList(pParse, pOrderBy);
- pOrderBy->iTab = pParse->nTab++;
- addr = sqlite3VdbeOp3(v, OP_OpenVirtual, pOrderBy->iTab, pOrderBy->nExpr+2,
+ pOrderBy->iECursor = pParse->nTab++;
+ p->addrOpenVirt[2] = addrSortIndex =
+ sqlite3VdbeOp3(v, OP_OpenVirtual, pOrderBy->iECursor, pOrderBy->nExpr+2,
(char*)pKeyInfo, P3_KEYINFO_HANDOFF);
- p->addrOpenVirt[2] = addr;
+ }else{
+ addrSortIndex = -1;
}
/* Set the limiter.
/* If the output is destined for a temporary table, open that table.
*/
- if( eDest==SRT_TempTable ){
+ if( eDest==SRT_VirtualTab ){
sqlite3VdbeAddOp(v, OP_OpenVirtual, iParm, pEList->nExpr);
}
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, &pOrderBy);
if( pWInfo==0 ) goto select_end;
+ /* If sorting index that was created by a prior OP_OpenVirtual
+ ** instruction ended up not being needed, then change the OP_OpenVirtual
+ ** into an OP_Noop.
+ */
+ if( addrSortIndex>=0 && pOrderBy==0 ){
+ uncreateSortingIndex(pParse, addrSortIndex);
+ p->addrOpenVirt[2] = -1;
+ }
+
/* Use the standard inner loop
*/
if( selectInnerLoop(pParse, p, pEList, 0, 0, pOrderBy, distinct, eDest,
sNC.pSrcList = pTabList;
sNC.pAggInfo = &sAggInfo;
sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr+1 : 0;
+ sAggInfo.pGroupBy = pGroupBy;
if( sqlite3ExprAnalyzeAggList(&sNC, pEList) ){
goto select_end;
}
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.409 2005/09/07 22:48:16 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.410 2005/09/08 01:58:43 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
struct ExprList {
int nExpr; /* Number of expressions on the list */
int nAlloc; /* Number of entries allocated below */
- int iTab; /* VDBE Cursor associated with this ExprList */
+ int iECursor; /* VDBE Cursor associated with this ExprList */
struct ExprList_item {
Expr *pExpr; /* The list of expressions */
char *zName; /* Token associated with this expression */
#define SRT_Mem 5 /* Store result in a memory cell */
#define SRT_Set 6 /* Store non-null results as keys in an index */
#define SRT_Table 7 /* Store result as data and add automatic rowid */
-#define SRT_TempTable 8 /* Store result in a trasient table */
-#define SRT_Sorter 9 /* Store results in the sorter NOT USED */
-#define SRT_Subroutine 10 /* Call a subroutine to handle results */
-#define SRT_Exists 11 /* Put 0 or 1 in a memory cell */
+#define SRT_VirtualTab 8 /* Create virtual table and store results there */
+#define SRT_Subroutine 9 /* Call a subroutine to handle results */
+#define SRT_Exists 10 /* Put 0 or 1 in a memory cell */
/*
** An SQL parser context. A copy of this structure is passed through
** This file contains C code routines that are called by the parser
** to handle UPDATE statements.
**
-** $Id: update.c,v 1.110 2005/07/21 18:23:20 drh Exp $
+** $Id: update.c,v 1.111 2005/09/08 01:58:43 drh Exp $
*/
#include "sqliteInt.h"
if( pParse->nested==0 ) sqlite3VdbeCountChanges(v);
sqlite3BeginWriteOperation(pParse, 1, pTab->iDb);
- /* If we are trying to update a view, construct that view into
- ** a temporary table.
+ /* If we are trying to update a view, realize that view into
+ ** a ephemeral table.
*/
if( isView ){
Select *pView;
pView = sqlite3SelectDup(pTab->pSelect);
- sqlite3Select(pParse, pView, SRT_TempTable, iCur, 0, 0, 0, 0);
+ sqlite3Select(pParse, pView, SRT_VirtualTab, iCur, 0, 0, 0, 0);
sqlite3SelectDelete(pView);
}
# This file implements regression tests for SQLite library. The
# focus of this script is page cache subsystem.
#
-# $Id: collate3.test,v 1.10 2005/01/29 08:32:46 danielk1977 Exp $
+# $Id: collate3.test,v 1.11 2005/09/08 01:58:43 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
}
} {0 {}}
do_test collate3-2.13 {
+btree_breakpoint
catchsql {
SELECT 10 UNION ALL SELECT 20 ORDER BY 1 COLLATE string_compare;
}
# This file implements tests for miscellanous features that were
# left out of other test files.
#
-# $Id: misc4.test,v 1.18 2005/09/07 22:48:16 drh Exp $
+# $Id: misc4.test,v 1.19 2005/09/08 01:58:43 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ORDER BY 1, 2;
}
} {1 x 1 z}
+do_test misc4-3.2 {
+ catchsql {
+ SELECT ID, Value FROM Table1
+ UNION SELECT ID, max(Value) FROM Table2 GROUP BY 1, 2
+ ORDER BY 1, 2;
+ }
+} {1 {aggregate functions are not allowed in the GROUP BY clause}}
} ;# ifcapable compound
# Ticket #1047. Make sure column types are preserved in subqueries.