-C Simplify\sthe\swhere.c\slogic\sby\sflipping\sexpression\sover\sso\sthat\sthe\scontrolling\nvariable\sis\salways\son\sthe\sleft.\s(CVS\s1838)
-D 2004-07-20T18:23:15
+C Minor\scoding\senhancements.\s(CVS\s1839)
+D 2004-07-21T02:53:30
F Makefile.in 4a5e570a9e2d35b09c31b3cf01b78cea764ade4b
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
F src/date.c e1bb384a7856c18dce9cadb0afbe6934ba5ddb00
F src/delete.c e81545e546f6bc87d7508a93a09ca70695265af3
F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37
-F src/expr.c df21bde644eca66276eafe0c97734fc8f930f4ab
+F src/expr.c a4e8ac69c872f86bc207364be0e32d0638f61e90
F src/func.c b163fb49efec999eb7bf982f7de5b9be388301f3
F src/hash.c f0a2f22c2a7052d67053b5f4690ea3010bb3fb9f
F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
F src/utf.c f03535db72bfa09e24202ccdd245f21d2fc65f0a
F src/util.c 2aacc79b7bf5df5859813dafd3bf3258f67a5234
F src/vacuum.c b8546f4921719458cc537b9e736df52a8256399c
-F src/vdbe.c a88514694be86eca792dd4d291e766f3c1831876
+F src/vdbe.c 5a7d1ee9d7356df6b53be64c1776824a33f6f2fb
F src/vdbe.h 75b241c02431b9c0f16eaa9cdbb34146c6287f52
F src/vdbeInt.h 7160653a006b6d2c4a00d204112a095bdf842ab6
F src/vdbeapi.c c5c6d8f162a9581dde497b1a4034f9a0bf54c355
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 3c5aa850eeec5c75c5200a3707852cc5fc9e780b
-R 85614d781cba6751b913b133092132cd
+P ec8bfa3891dbf0f3172e31cf322974c03f9af59a
+R 9e5a169fd77b5347506f033f7c0bac3e
U drh
-Z 550b1f0e24b844483d3dbfa3a8f89d17
+Z 16e953d85e2aa59a57853642a9ecf96b
** 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.402 2004/07/19 17:25:25 drh Exp $
+** $Id: vdbe.c,v 1.403 2004/07/21 02:53:30 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
**
*/
static void applyAffinity(Mem *pRec, char affinity, u8 enc){
- switch( affinity ){
- case SQLITE_AFF_INTEGER:
- case SQLITE_AFF_NUMERIC:
- if( 0==(pRec->flags&(MEM_Real|MEM_Int)) ){
- /* pRec does not have a valid integer or real representation.
- ** Attempt a conversion if pRec has a string representation and
- ** it looks like a number.
- */
- int realnum;
- sqlite3VdbeMemNulTerminate(pRec);
- if( pRec->flags&MEM_Str && sqlite3IsNumber(pRec->z, &realnum, enc) ){
- if( realnum ){
- Realify(pRec);
- }else{
- Integerify(pRec);
- }
+ if( affinity==SQLITE_AFF_NONE ){
+ /* do nothing */
+ }else if( affinity==SQLITE_AFF_TEXT ){
+ /* Only attempt the conversion to TEXT if there is an integer or real
+ ** representation (blob and NULL do not get converted) but no string
+ ** representation.
+ */
+ if( 0==(pRec->flags&MEM_Str) && (pRec->flags&(MEM_Real|MEM_Int)) ){
+ sqlite3VdbeMemStringify(pRec, enc);
+ }
+ pRec->flags &= ~(MEM_Real|MEM_Int);
+ }else{
+ if( 0==(pRec->flags&(MEM_Real|MEM_Int)) ){
+ /* pRec does not have a valid integer or real representation.
+ ** Attempt a conversion if pRec has a string representation and
+ ** it looks like a number.
+ */
+ int realnum;
+ sqlite3VdbeMemNulTerminate(pRec);
+ if( pRec->flags&MEM_Str && sqlite3IsNumber(pRec->z, &realnum, enc) ){
+ if( realnum ){
+ Realify(pRec);
+ }else{
+ Integerify(pRec);
}
}
+ }
- if( affinity==SQLITE_AFF_INTEGER ){
- /* For INTEGER affinity, try to convert a real value to an int */
- if( (pRec->flags&MEM_Real) && !(pRec->flags&MEM_Int) ){
- pRec->i = pRec->r;
- if( ((double)pRec->i)==pRec->r ){
- pRec->flags |= MEM_Int;
- }
+ if( affinity==SQLITE_AFF_INTEGER ){
+ /* For INTEGER affinity, try to convert a real value to an int */
+ if( (pRec->flags&MEM_Real) && !(pRec->flags&MEM_Int) ){
+ pRec->i = pRec->r;
+ if( ((double)pRec->i)==pRec->r ){
+ pRec->flags |= MEM_Int;
}
}
- break;
-
- case SQLITE_AFF_TEXT:
- /* Only attempt the conversion if there is an integer or real
- ** representation (blob and NULL do not get converted) but no string
- ** representation.
- */
- if( 0==(pRec->flags&MEM_Str) && (pRec->flags&(MEM_Real|MEM_Int)) ){
- sqlite3VdbeMemStringify(pRec, enc);
- }
- pRec->flags &= ~(MEM_Real|MEM_Int);
-
- break;
-
- case SQLITE_AFF_NONE:
- /* Affinity NONE. Do nothing. */
- break;
-
- default:
- assert(0);
+ }
}
}
** with a fatal error.
*/
case OP_Gosub: {
- if( p->returnDepth>=sizeof(p->returnStack)/sizeof(p->returnStack[0]) ){
- sqlite3SetString(&p->zErrMsg, "return address stack overflow", (char*)0);
- p->rc = SQLITE_INTERNAL;
- return SQLITE_ERROR;
- }
+ assert( p->returnDepth<sizeof(p->returnStack)/sizeof(p->returnStack[0]) );
p->returnStack[p->returnDepth++] = pc+1;
pc = pOp->p2 - 1;
break;
** processing aborts with a fatal error.
*/
case OP_Return: {
- if( p->returnDepth<=0 ){
- sqlite3SetString(&p->zErrMsg, "return address stack underflow", (char*)0);
- p->rc = SQLITE_INTERNAL;
- return SQLITE_ERROR;
- }
+ assert( p->returnDepth>0 );
p->returnDepth--;
pc = p->returnStack[p->returnDepth] - 1;
break;
if( pOp->p1!=SQLITE_OK ){
p->rc = pOp->p1;
p->errorAction = pOp->p2;
- if( pOp->p3 ){
- sqlite3SetString(&p->zErrMsg, pOp->p3, (char*)0);
- }
+ sqlite3SetString(&p->zErrMsg, pOp->p3, (char*)0);
return SQLITE_ERROR;
}else{
p->rc = SQLITE_OK;
assert( j>=0 && j<p->nVar );
pTos++;
+ /* sqlite3VdbeMemCopyStatic(pTos, &p->apVar[j]); */
memcpy(pTos, &p->apVar[j], sizeof(*pTos)-NBFS);
pTos->xDel = 0;
if( pTos->flags&(MEM_Str|MEM_Blob) ){
/* Opcode: ShiftLeft * * *
**
** Pop the top two elements from the stack. Convert both elements
-** to integers. Push back onto the stack the top element shifted
-** left by N bits where N is the second element on the stack.
+** to integers. Push back onto the stack the second element shifted
+** left by N bits where N is the top element on the stack.
** If either operand is NULL, the result is NULL.
*/
/* Opcode: ShiftRight * * *
**
** Pop the top two elements from the stack. Convert both elements
-** to integers. Push back onto the stack the top element shifted
-** right by N bits where N is the second element on the stack.
+** to integers. Push back onto the stack the second element shifted
+** right by N bits where N is the top element on the stack.
** If either operand is NULL, the result is NULL.
*/
case OP_BitAnd:
pTos->flags = MEM_Null;
break;
}
- a = sqlite3VdbeIntValue(pTos);
- b = sqlite3VdbeIntValue(pNos);
+ a = sqlite3VdbeIntValue(pNos);
+ b = sqlite3VdbeIntValue(pTos);
switch( pOp->opcode ){
case OP_BitAnd: a &= b; break;
case OP_BitOr: a |= b; break;
case OP_ForceInt: {
int v;
assert( pTos>=p->aStack );
- if( (pTos->flags & (MEM_Int|MEM_Real))==0 && ((pTos->flags & MEM_Str)==0
- || sqlite3IsNumber(pTos->z, 0, db->enc)==0) ){
+ applyAffinity(pTos, SQLITE_AFF_INTEGER, db->enc);
+ if( (pTos->flags & (MEM_Int|MEM_Real))==0 ){
Release(pTos);
pTos--;
pc = pOp->p2 - 1;
*/
case OP_MustBeInt: {
assert( pTos>=p->aStack );
- if( pTos->flags & MEM_Int ){
- /* Do nothing */
- }else if( pTos->flags & MEM_Real ){
- int i = (int)pTos->r;
- double r = (double)i;
- if( r!=pTos->r ){
- goto mismatch;
- }
- pTos->i = i;
- }else if( pTos->flags & MEM_Str ){
- i64 v;
- if( sqlite3VdbeChangeEncoding(pTos, SQLITE_UTF8)
- || sqlite3VdbeMemNulTerminate(pTos) ){
- goto no_mem;
- }
- if( !sqlite3atoi64(pTos->z, &v) ){
- double r;
- if( !sqlite3IsNumber(pTos->z, 0, SQLITE_UTF8) ){
- goto mismatch;
- }
- Realify(pTos);
- v = (int)pTos->r;
- r = (double)v;
- if( r!=pTos->r ){
- goto mismatch;
- }
+ applyAffinity(pTos, SQLITE_AFF_INTEGER, db->enc);
+ if( (pTos->flags & MEM_Int)==0 ){
+ if( pOp->p2==0 ){
+ rc = SQLITE_MISMATCH;
+ goto abort_due_to_error;
+ }else{
+ if( pOp->p1 ) popStack(&pTos, 1);
+ pc = pOp->p2 - 1;
}
- pTos->i = v;
- }else{
- goto mismatch;
- }
- Release(pTos);
- pTos->flags = MEM_Int;
- break;
-
-mismatch:
- if( pOp->p2==0 ){
- rc = SQLITE_MISMATCH;
- goto abort_due_to_error;
}else{
- if( pOp->p1 ) popStack(&pTos, 1);
- pc = pOp->p2 - 1;
+ Release(pTos);
+ pTos->flags = MEM_Int;
}
break;
}