Eliminate the OP_SortMakeRec and OP_SortCallback opcodes. Sort using the
standard record format. (CVS 1426) FossilOrigin-Name: 25643a0137d395572f16cfec3ab3327d913138ba
This commit is contained in:
parent
736c22b803
commit
ce665cf60e
16
manifest
16
manifest
@ -1,5 +1,5 @@
|
||||
C Most\ssorting\sproblems\sare\sfixed.\s\sDead\scode\shas\sbeen\sremoved.\s\s3\stest\sfailures\nremain\sbut\swill\sbe\sfixed\sby\sthe\snew\sfunction\sAPI\sonce\sit\sgets\simplemented.\s(CVS\s1425)
|
||||
D 2004-05-21T02:14:25
|
||||
C Eliminate\sthe\sOP_SortMakeRec\sand\sOP_SortCallback\sopcodes.\s\sSort\susing\sthe\nstandard\srecord\sformat.\s(CVS\s1426)
|
||||
D 2004-05-21T03:01:59
|
||||
F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
|
||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||
@ -47,7 +47,7 @@ F src/parse.y 567718866b94d58a6c7681cc45ba7987771d583a
|
||||
F src/pragma.c aeeba7dc5bc32a6f0980e6516cb2a48a50973fab
|
||||
F src/printf.c ef750e8e2398ca7e8b58be991075f08c6a7f0e53
|
||||
F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
|
||||
F src/select.c 4cd54ac74b7f3216d6a75ae3e9df86bb1938d3f6
|
||||
F src/select.c 7d77a8bed7eeac23216d42fc1be006fb4352fcdc
|
||||
F src/shell.c 0c4662e13bfbfd3d13b066c5859cc97ad2f95d21
|
||||
F src/sqlite.h.in de337e211905c6bd4ad901916f78df28f1467df4
|
||||
F src/sqliteInt.h 2e5533ba50106d266cddfb00b2eb3ab6944b8f3e
|
||||
@ -64,7 +64,7 @@ F src/update.c 1a5e9182596f3ea8c7a141e308a3d2a7e5689fee
|
||||
F src/utf.c c27c4f1120f7aaef00cd6942b3d9e3f4ca4fe0e4
|
||||
F src/util.c 5cbeb452da09cfc7248de9948c15b14d840723f7
|
||||
F src/vacuum.c c134702e023db8778e6be59ac0ea7b02315b5476
|
||||
F src/vdbe.c c722738619bb57bca5033628ead49bd28d62129d
|
||||
F src/vdbe.c 4138d2f3ec2dd2b62251fc2b34e3c73322d8288e
|
||||
F src/vdbe.h d6f66896137af3e313d44553618228d882a2cf85
|
||||
F src/vdbeInt.h cea492c1fcd85fb78f031e274d1844885d5222e2
|
||||
F src/vdbeaux.c 51f7d0cc6c515111b11576e2d82f4637156075cd
|
||||
@ -154,7 +154,7 @@ F test/vacuum.test 7b5f504636a13992344871f8155b8557b683232a
|
||||
F test/varint.test ab7b110089a08b9926ed7390e7e97bdefeb74102
|
||||
F test/version.test 2ba212ba06380e65e476bdf2fcd390e8b05af5a0
|
||||
F test/view.test 1ee12c6f8f4791a2c0655120d5562a49400cfe53
|
||||
F test/where.test c69c5080b1c207c906686cdaca9b6250cbc866df
|
||||
F test/where.test 9c5752b807b78078fab8da6f52e689832579ca20
|
||||
F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b
|
||||
F tool/lemon.c f4fb7226c930435e994441a470ed60a7c540f518
|
||||
F tool/lempar.c 0b5e7a58634e0d448929b8e85f7981c2aa708d57
|
||||
@ -195,7 +195,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
|
||||
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
|
||||
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
|
||||
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
|
||||
P d1af1a4acce77b87367049da93b13746b743e831
|
||||
R 63c080a8ff93f4c04e0dc6d5440a017a
|
||||
P 3b55095e036d68886d007239333bbf90acd15692
|
||||
R 9a5fbb7a46e686efdfa0c212c6a2c893
|
||||
U drh
|
||||
Z e6a7770528e2b613e6d7a88c745f4110
|
||||
Z 7b75e8f9ceca75d3da616e75f7688bd6
|
||||
|
@ -1 +1 @@
|
||||
3b55095e036d68886d007239333bbf90acd15692
|
||||
25643a0137d395572f16cfec3ab3327d913138ba
|
15
src/select.c
15
src/select.c
@ -12,7 +12,7 @@
|
||||
** This file contains C code routines that are called by the parser
|
||||
** to handle SELECT statements in SQLite.
|
||||
**
|
||||
** $Id: select.c,v 1.173 2004/05/21 02:14:25 drh Exp $
|
||||
** $Id: select.c,v 1.174 2004/05/21 03:01:59 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -486,7 +486,7 @@ static int selectInnerLoop(
|
||||
case SRT_Callback:
|
||||
case SRT_Sorter: {
|
||||
if( pOrderBy ){
|
||||
sqlite3VdbeAddOp(v, OP_SortMakeRec, nColumn, 0);
|
||||
sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0);
|
||||
pushOntoSorter(pParse, v, pOrderBy);
|
||||
}else{
|
||||
assert( eDest==SRT_Callback );
|
||||
@ -566,10 +566,6 @@ static void generateSortTail(
|
||||
sqlite3VdbeAddOp(v, OP_MemIncr, p->iLimit, end2);
|
||||
}
|
||||
switch( eDest ){
|
||||
case SRT_Callback: {
|
||||
sqlite3VdbeAddOp(v, OP_SortCallback, nColumn, 0);
|
||||
break;
|
||||
}
|
||||
case SRT_Table:
|
||||
case SRT_TempTable: {
|
||||
sqlite3VdbeAddOp(v, OP_NewRecno, iParm, 0);
|
||||
@ -593,6 +589,7 @@ static void generateSortTail(
|
||||
sqlite3VdbeAddOp(v, OP_Goto, 0, end1);
|
||||
break;
|
||||
}
|
||||
case SRT_Callback:
|
||||
case SRT_Subroutine: {
|
||||
int i;
|
||||
sqlite3VdbeAddOp(v, OP_Integer, p->pEList->nExpr, 0);
|
||||
@ -600,7 +597,11 @@ static void generateSortTail(
|
||||
for(i=0; i<nColumn; i++){
|
||||
sqlite3VdbeAddOp(v, OP_Column, -1-i, i);
|
||||
}
|
||||
sqlite3VdbeAddOp(v, OP_Gosub, 0, iParm);
|
||||
if( eDest==SRT_Callback ){
|
||||
sqlite3VdbeAddOp(v, OP_Callback, nColumn, 0);
|
||||
}else{
|
||||
sqlite3VdbeAddOp(v, OP_Gosub, 0, iParm);
|
||||
}
|
||||
sqlite3VdbeAddOp(v, OP_Pop, 2, 0);
|
||||
break;
|
||||
}
|
||||
|
66
src/vdbe.c
66
src/vdbe.c
@ -43,7 +43,7 @@
|
||||
** in this file for details. If in doubt, do not deviate from existing
|
||||
** commenting and indentation practices when changing or adding code.
|
||||
**
|
||||
** $Id: vdbe.c,v 1.311 2004/05/21 02:14:25 drh Exp $
|
||||
** $Id: vdbe.c,v 1.312 2004/05/21 03:01:59 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@ -4192,51 +4192,6 @@ case OP_SortPut: {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: SortMakeRec P1 * *
|
||||
**
|
||||
** The top P1 elements are the arguments to a callback. Form these
|
||||
** elements into a single data entry that can be stored on a sorter
|
||||
** using SortPut and later fed to a callback using SortCallback.
|
||||
*/
|
||||
case OP_SortMakeRec: {
|
||||
char *z;
|
||||
char **azArg;
|
||||
int nByte;
|
||||
int nField;
|
||||
int i;
|
||||
Mem *pRec;
|
||||
|
||||
nField = pOp->p1;
|
||||
pRec = &pTos[1-nField];
|
||||
assert( pRec>=p->aStack );
|
||||
nByte = 0;
|
||||
for(i=0; i<nField; i++, pRec++){
|
||||
if( (pRec->flags & MEM_Null)==0 ){
|
||||
Stringify(pRec);
|
||||
nByte += pRec->n;
|
||||
}
|
||||
}
|
||||
nByte += sizeof(char*)*(nField+1);
|
||||
azArg = sqliteMallocRaw( nByte );
|
||||
if( azArg==0 ) goto no_mem;
|
||||
z = (char*)&azArg[nField+1];
|
||||
for(pRec=&pTos[1-nField], i=0; i<nField; i++, pRec++){
|
||||
if( pRec->flags & MEM_Null ){
|
||||
azArg[i] = 0;
|
||||
}else{
|
||||
azArg[i] = z;
|
||||
memcpy(z, pRec->z, pRec->n);
|
||||
z += pRec->n;
|
||||
}
|
||||
}
|
||||
popStack(&pTos, nField);
|
||||
pTos++;
|
||||
pTos->n = nByte;
|
||||
pTos->z = (char*)azArg;
|
||||
pTos->flags = MEM_Str | MEM_Dyn;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: Sort * * P3
|
||||
**
|
||||
** Sort all elements on the sorter. The algorithm is a
|
||||
@ -4300,25 +4255,6 @@ case OP_SortNext: {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Opcode: SortCallback P1 * *
|
||||
**
|
||||
** The top of the stack contains a callback record built using
|
||||
** the SortMakeRec operation with the same P1 value as this
|
||||
** instruction. Pop this record from the stack and invoke the
|
||||
** callback on it.
|
||||
*/
|
||||
case OP_SortCallback: {
|
||||
assert( pTos>=p->aStack );
|
||||
assert( pTos->flags & MEM_Str );
|
||||
p->nCallback++;
|
||||
p->pc = pc+1;
|
||||
p->azResColumn = (char**)pTos->z;
|
||||
assert( p->nResColumn==pOp->p1 );
|
||||
p->popStack = 1;
|
||||
p->pTos = pTos;
|
||||
return SQLITE_ROW;
|
||||
}
|
||||
|
||||
/* Opcode: SortReset * * *
|
||||
**
|
||||
** Remove any elements that remain on the sorter.
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the use of indices in WHERE clases.
|
||||
#
|
||||
# $Id: where.test,v 1.20 2004/05/21 02:14:25 drh Exp $
|
||||
# $Id: where.test,v 1.21 2004/05/21 03:01:59 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -364,7 +364,7 @@ do_test where-5.14 {
|
||||
proc cksort {sql} {
|
||||
set data [execsql $sql]
|
||||
set prog [execsql "EXPLAIN $sql"]
|
||||
if {[regexp SortCallback $prog]} {set x sort} {set x nosort}
|
||||
if {[regexp Sort $prog]} {set x sort} {set x nosort}
|
||||
lappend data $x
|
||||
return $data
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user