mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Eliminate the OP_SortMakeRec and OP_SortCallback opcodes. Sort using the
standard record format. (CVS 1426) FossilOrigin-Name: 25643a0137d395572f16cfec3ab3327d913138ba
This commit is contained in:
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.
|
||||
|
Reference in New Issue
Block a user