 				default:    res = res>=0; break;
 				}
 
-				if (op->P5 & AFF_STOREP2)
+				if (op->P5 & AFF_BIT_STOREP2)
 				{
 					out_ = &mems[op->P2];
-					MemAboutToChange(p, out_);
+					MemAboutToChange(this, out_);
 					MemSetTypeFlag(out_, MEM_Int);
-					out_->u.i = res;
+					out_->u.I = res;
 					REGISTER_TRACE(op->P2, out_);
 				}
 				else if (res)
 					pc = op->P2-1;
 
 				// Undo any changes made by applyAffinity() to the input registers.
-				in1->Flags = (in1->Flags&~MEM_TypeMask) | (flags1&MEM_TypeMask);
-				in3->Flags = (in3->Flags&~MEM_TypeMask) | (flags3&MEM_TypeMask);
+				in1->Flags = (MEM)(in1->Flags&~MEM_TypeMask) | (flags1&MEM_TypeMask);
+				in3->Flags = (MEM)(in3->Flags&~MEM_TypeMask) | (flags3&MEM_TypeMask);
 				break; }
 			case OP_Permutation: {
 				// Opcode: Permutation * * * P4 *

		Mem *in2 = 0; // 2nd input operand
		Mem *in3 = 0; // 3rd input operand
		Mem *out_ = 0; // Output operand
		int iCompare = 0; // Result of last OP_Compare operation
		int *permutes = 0; // Permutation of columns for OP_Compare
		int64 lastRowid = ctx->LastRowID; // Saved value of the last insert ROWID


				// If the record is stored in a cursor, the complete record text might be available in the  pC->aRow cache.  Or it might not be.
				// If the data is unavailable,  zRec is set to NULL.
				//
				// We also compute the number of columns in the record.  For cursors, the number of columns is stored in the VdbeCursor.Fields element.
				VdbeCursor *c = Cursors[p1]; // The VDBE cursor
				_assert(c);
#ifndef OMIT_VIRTUALTABLE
				_assert(!c->VtabCursor);
