Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Do not open a statement journal unless absolutely necessary. (CVS 2499) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
989573a53b58c1e959ad276119298ba2 |
User & Date: | drh 2005-06-07 01:43:41.000 |
Context
2005-06-07
| ||
02:12 | Add tests to make sure statement journals are only opened when necessary. (CVS 2500) (check-in: 914d6e6549 user: drh tags: trunk) | |
01:43 | Do not open a statement journal unless absolutely necessary. (CVS 2499) (check-in: 989573a53b user: drh tags: trunk) | |
2005-06-06
| ||
21:19 | Reference count Table structures so that they are not deallocated too soon. Ticket #1210. (CVS 2498) (check-in: e73d25c741 user: drh tags: trunk) | |
Changes
Changes to src/vdbeaux.c.
︙ | ︙ | |||
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | ** ** Variable *pMaxFuncArgs is set to the maximum value of any P1 argument ** to an OP_Function or P2 to an OP_AggFunc opcode. This is used by ** sqlite3VdbeMakeReady() to size the Vdbe.apArg[] array. ** ** The integer *pMaxStack is set to the maximum number of vdbe stack ** entries that static analysis reveals this program might need. */ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs, int *pMaxStack){ int i; int nMaxArgs = 0; int nMaxStack = p->nOp; Op *pOp; int *aLabel = p->aLabel; for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){ u8 opcode = pOp->opcode; /* Todo: Maybe OP_AggFunc should change to use P1 in the same * way as OP_Function. */ if( opcode==OP_Function ){ if( pOp->p1>nMaxArgs ) nMaxArgs = pOp->p1; }else if( opcode==OP_AggFunc ){ if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; } if( opcodeNoPush(opcode) ){ nMaxStack--; } if( pOp->p2>=0 ) continue; assert( -1-pOp->p2<p->nLabel ); pOp->p2 = aLabel[-1-pOp->p2]; } sqliteFree(p->aLabel); p->aLabel = 0; *pMaxFuncArgs = nMaxArgs; *pMaxStack = nMaxStack; } /* ** Return the address of the next instruction to be inserted. */ int sqlite3VdbeCurrentAddr(Vdbe *p){ assert( p->magic==VDBE_MAGIC_INIT ); | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | ** ** Variable *pMaxFuncArgs is set to the maximum value of any P1 argument ** to an OP_Function or P2 to an OP_AggFunc opcode. This is used by ** sqlite3VdbeMakeReady() to size the Vdbe.apArg[] array. ** ** The integer *pMaxStack is set to the maximum number of vdbe stack ** entries that static analysis reveals this program might need. ** ** This routine also does the following optimization: It scans for ** Halt instructions where P1==SQLITE_CONSTRAINT or P2==OE_Abort or for ** IdxPut instructions where P2!=0. If no such instruction is ** found, then every Statement instruction is changed to a Noop. In ** this way, we avoid creating the statement journal file unnecessarily. */ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs, int *pMaxStack){ int i; int nMaxArgs = 0; int nMaxStack = p->nOp; Op *pOp; int *aLabel = p->aLabel; int doesStatementRollback = 0; int hasStatementBegin = 0; for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){ u8 opcode = pOp->opcode; /* Todo: Maybe OP_AggFunc should change to use P1 in the same * way as OP_Function. */ if( opcode==OP_Function ){ if( pOp->p1>nMaxArgs ) nMaxArgs = pOp->p1; }else if( opcode==OP_AggFunc ){ if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; }else if( opcode==OP_Halt ){ if( pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort ){ doesStatementRollback = 1; } }else if( opcode==OP_IdxPut ){ if( pOp->p2 ){ doesStatementRollback = 1; } }else if( opcode==OP_Statement ){ hasStatementBegin = 1; } if( opcodeNoPush(opcode) ){ nMaxStack--; } if( pOp->p2>=0 ) continue; assert( -1-pOp->p2<p->nLabel ); pOp->p2 = aLabel[-1-pOp->p2]; } sqliteFree(p->aLabel); p->aLabel = 0; *pMaxFuncArgs = nMaxArgs; *pMaxStack = nMaxStack; /* If we never rollback a statement transaction, then statement ** transactions are not needed. So change every OP_Statement ** opcode into an OP_Noop. This avoid a call to sqlite3OsOpenExclusive() ** which can be expensive on some platforms. */ if( hasStatementBegin && !doesStatementRollback ){ for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){ if( pOp->opcode==OP_Statement ){ pOp->opcode = OP_Noop; } } } } /* ** Return the address of the next instruction to be inserted. */ int sqlite3VdbeCurrentAddr(Vdbe *p){ assert( p->magic==VDBE_MAGIC_INIT ); |
︙ | ︙ | |||
685 686 687 688 689 690 691 | * state. */ p->magic = VDBE_MAGIC_RUN; /* No instruction ever pushes more than a single element onto the ** stack. And the stack never grows on successive executions of the ** same loop. So the total number of instructions is an upper bound | | > > | 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 | * state. */ p->magic = VDBE_MAGIC_RUN; /* No instruction ever pushes more than a single element onto the ** stack. And the stack never grows on successive executions of the ** same loop. So the total number of instructions is an upper bound ** on the maximum stack depth required. (Added later:) The ** resolveP2Values() call computes a tighter upper bound on the ** stack size. ** ** Allocation all the stack space we will ever need. */ if( p->aStack==0 ){ int nArg; /* Maximum number of args passed to a user function. */ int nStack; /* Maximum number of stack entries required */ resolveP2Values(p, &nArg, &nStack); |
︙ | ︙ |