1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Add the OP_Undef and OP_IsUndef opcodes. With these, use the first register

in the result register range as the flag to indicate EOF on an INSERT from
a SELECT, rather than allocating a separate boolean register for that task.

FossilOrigin-Name: 6fb7448550f28a3c93053e125faeaf11de1011d0
This commit is contained in:
drh
2014-02-07 13:20:31 +00:00
parent 21a919f630
commit a5750cfe01
7 changed files with 65 additions and 53 deletions

View File

@@ -393,7 +393,7 @@ void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){
** Print the value of a register for tracing purposes:
*/
static void memTracePrint(Mem *p){
if( p->flags & MEM_Invalid ){
if( p->flags & MEM_Undefined ){
printf(" undefined");
}else if( p->flags & MEM_Null ){
printf(" NULL");
@@ -702,7 +702,6 @@ check_for_interrupt:
}
/* Opcode: Gosub P1 P2 * * *
** Synopsis: r[P1]=pc; pc=P2
**
** Write the current address onto register P1
** and then jump to address P2.
@@ -720,7 +719,6 @@ case OP_Gosub: { /* jump */
}
/* Opcode: Return P1 * * * *
** Synopsis: pc=r[P1]+1
**
** Jump to the next instruction after the address in register P1.
*/
@@ -732,7 +730,6 @@ case OP_Return: { /* in1 */
}
/* Opcode: Yield P1 * * * *
** Synopsis: swap(pc,r[P1])
**
** Swap the program counter with the value in register P1.
*/
@@ -974,7 +971,7 @@ case OP_Null: { /* out2-prerelease */
}
/* Opcode: Blob P1 P2 * P4
/* Opcode: Blob P1 P2 * P4 *
** Synopsis: r[P2]=P4 (len=P1)
**
** P4 points to a blob of data P1 bytes long. Store this
@@ -988,6 +985,21 @@ case OP_Blob: { /* out2-prerelease */
break;
}
/* Opcode: Undef P1 * * * *
** Synopsis: r[P1]=undef
**
** Mark register P1 as undefined.
*/
case OP_Undef: {
assert( pOp->p1>0 );
assert( pOp->p1<=(p->nMem-p->nCursor) );
pOut = &aMem[pOp->p1];
memAboutToChange(p, pOut);
VdbeMemRelease(pOut);
pOut->flags = MEM_Undefined;
break;
}
/* Opcode: Variable P1 P2 * P4 *
** Synopsis: r[P2]=parameter(P1,P4)
**
@@ -2142,6 +2154,19 @@ case OP_IfNot: { /* jump, in1 */
break;
}
/* Opcode: IsUndef P1 P2 * * *
** Synopsis: if r[P1]==undefined goto P2
**
** Jump to P2 if the value in register P1 is undefined
*/
case OP_IsUndef: { /* jump */
pIn1 = &aMem[pOp->p1];
if( (pIn1->flags & MEM_Undefined)!=0 ){
pc = pOp->p2 - 1;
}
break;
}
/* Opcode: IsNull P1 P2 * * *
** Synopsis: if r[P1]==NULL goto P2
**
@@ -5191,7 +5216,7 @@ case OP_Program: { /* jump */
pEnd = &VdbeFrameMem(pFrame)[pFrame->nChildMem];
for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++){
pMem->flags = MEM_Invalid;
pMem->flags = MEM_Undefined;
pMem->db = db;
}
}else{