-C Added\sthe\sspeed4p.test\sscript\sfor\stesting\sperformance\sof\sviews\sand\striggers.\s(CVS\s4923)
-D 2008-03-27T15:07:05
+C Allow\screation\sof\sephemeral\spseudo-tables\s-\spseudo-tables\sthat\scopy\sa\spointer\sto\sa\srow\swhen\sinserted\sinstead\sof\scopying\sthe\srow\sdata.\s(CVS\s4924)
+D 2008-03-27T17:59:02
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in cf434ce8ca902e69126ae0f94fc9f7dc7428a5fa
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
F src/prepare.c 185fb47f1fb3e45a345d523eb391d673f5eb367c
F src/printf.c 05d2b44d7b5b80c8a4a09108ddad9c20e254370d
F src/random.c 2b2db2de4ab491f5a14d3480466f8f4b5a5db74a
-F src/select.c 5b5197016a0b751fdb78758370ba127175d3f786
+F src/select.c f47faa4af940d0acd0cff92a1a77ebb27331a31a
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 22297fffa6f00a6c6d44020fa13b1184a1bb372d
F src/sqlite.h.in b1ac824d9fc163a5d2226ebf5990b09a02a11117
F src/utf.c 32b00d6e19010025e58f2ecb2f921d5e126771b4
F src/util.c dba9e04121eb17ec4643d6ca231ff859452cf0e2
F src/vacuum.c 3524411bfb58aac0d87eadd3e5b7cd532772af30
-F src/vdbe.c 0068703495a197e7b77dbdff604b42896722a1cc
+F src/vdbe.c f8e6d7f96f27c273e252c475a54d485943f0bb24
F src/vdbe.h f72201a0657d5f3d6cc008d1f8d9cc65768518c9
-F src/vdbeInt.h 2584494757e7d8e7015754d4017b36f758c2adef
+F src/vdbeInt.h 73a3162979585cc15d02e47cec2a1033df768246
F src/vdbeapi.c f74189e4cae0d93b2744386b9ac57f5ab60c5133
-F src/vdbeaux.c c77a88c97cf5836eb1f68ca6fea967569472712b
+F src/vdbeaux.c 0bdcfad81941f7f6b0b5f2f489d65804d4bdaf02
F src/vdbeblob.c cc713c142c3d4952b380c98ee035f850830ddbdb
F src/vdbefifo.c a30c237b2a3577e1415fb6e288cbb6b8ed1e5736
F src/vdbemem.c d48a71d66a7afd564b6537ab7e7442f7729fa5af
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 8c2f69521f13bc24cf005520efbe0589eeadd763
-R 0fca44539a2917afad155100f6434a4c
-U drh
-Z 074101a796f99fca1a50c6aac650887e
+P adf7645f9a1e12389a7511d2adca9013b7f330fa
+R c27119a978dd6220ce607704acf25a98
+U danielk1977
+Z 2fd91019f3a606466497fa3759b61fc9
-adf7645f9a1e12389a7511d2adca9013b7f330fa
\ No newline at end of file
+1a58a87023f7780aee813ac64dda1a80021002a7
\ No newline at end of file
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
-** $Id: select.c,v 1.421 2008/03/26 12:50:15 drh Exp $
+** $Id: select.c,v 1.422 2008/03/27 17:59:02 danielk1977 Exp $
*/
#include "sqliteInt.h"
if( eDest==SRT_Callback || eDest==SRT_Subroutine ){
pseudoTab = pParse->nTab++;
sqlite3VdbeAddOp2(v, OP_SetNumColumns, 0, nColumn);
- sqlite3VdbeAddOp2(v, OP_OpenPseudo, pseudoTab, 0);
+ sqlite3VdbeAddOp2(v, OP_OpenPseudo, pseudoTab, eDest==SRT_Callback);
}
addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, brk);
codeOffset(v, p, cont);
sqlite3VdbeAddOp2(v, OP_Integer, 1, regRowid);
sqlite3VdbeAddOp3(v, OP_Insert, pseudoTab, regRow, regRowid);
for(i=0; i<nColumn; i++){
+ assert( regRow!=pDest->iMem+i );
sqlite3VdbeAddOp3(v, OP_Column, pseudoTab, i, pDest->iMem+i);
}
if( eDest==SRT_Callback ){
** 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.718 2008/03/25 17:23:33 drh Exp $
+** $Id: vdbe.c,v 1.719 2008/03/27 17:59:02 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
break;
}
-/* Opcode: OpenPseudo P1 * * * *
+/* Opcode: OpenPseudo P1 P2 * * *
**
** Open a new cursor that points to a fake table that contains a single
** row of data. Any attempt to write a second row of data causes the
** NEW or OLD tables in a trigger. Also used to hold the a single
** row output from the sorter so that the row can be decomposed into
** individual columns using the OP_Column opcode.
+**
+** When OP_Insert is executed to insert a row in to the pseudo table,
+** the pseudo-table cursor may or may not make it's own copy of the
+** original row data. If P2 is 0, then the pseudo-table will copy the
+** original row data. Otherwise, a pointer to the original memory cell
+** is stored. In this case, the vdbe program must ensure that the
+** memory cell containing the row data is not overwritten until the
+** pseudo table is closed (or a new row is inserted into it).
*/
case OP_OpenPseudo: {
int i = pOp->p1;
if( pCx==0 ) goto no_mem;
pCx->nullRow = 1;
pCx->pseudoTable = 1;
+ pCx->ephemPseudoTable = pOp->p2;
pCx->pIncrKey = &pCx->bogusIncrKey;
pCx->isTable = 1;
pCx->isIndex = 0;
assert( pData->flags & (MEM_Blob|MEM_Str) );
}
if( pC->pseudoTable ){
- sqlite3_free(pC->pData);
+ if( !pC->ephemPseudoTable ){
+ sqlite3_free(pC->pData);
+ }
pC->iKey = iKey;
pC->nData = pData->n;
if( pData->flags & MEM_Dyn ){
pC->pData = pData->z;
- pData->flags &= ~MEM_Dyn;
- pData->flags |= MEM_Ephem;
+ if( !pC->ephemPseudoTable ){
+ pData->flags &= ~MEM_Dyn;
+ pData->flags |= MEM_Ephem;
+ }
}else{
pC->pData = sqlite3_malloc( pC->nData+2 );
if( !pC->pData ) goto no_mem;
Bool nullRow; /* True if pointing to a row with no data */
Bool nextRowidValid; /* True if the nextRowid field is valid */
Bool pseudoTable; /* This is a NEW or OLD pseudo-tables of a trigger */
+ Bool ephemPseudoTable;
Bool deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */
Bool isTable; /* True if a table requiring integer keys */
Bool isIndex; /* True if an index containing keys only - no data */
p->inVtabMethod = 0;
}
#endif
- sqlite3_free(pCx->pData);
+ if( !pCx->ephemPseudoTable ){
+ sqlite3_free(pCx->pData);
+ }
memset(pCx, 0, sizeof(Cursor));
/* sqlite3_free(pCx->aType); */
/* sqlite3_free(pCx); */