1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Fix for explicitly inserting a NULL value into the rowid column of a virtual table. (CVS 5343)

FossilOrigin-Name: a7f3b431669f7392a6acba8cd8f3fa5297a916b5
This commit is contained in:
danielk1977
2008-07-04 10:56:07 +00:00
parent 2f425f6b64
commit bb50e7ad76
5 changed files with 47 additions and 17 deletions

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
** $Id: insert.c,v 1.243 2008/06/24 12:46:31 drh Exp $
** $Id: insert.c,v 1.244 2008/07/04 10:56:08 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -836,7 +836,7 @@ void sqlite3Insert(
VdbeOp *pOp;
sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr, regRowid);
pOp = sqlite3VdbeGetOp(v, sqlite3VdbeCurrentAddr(v) - 1);
if( pOp && pOp->opcode==OP_Null ){
if( pOp && pOp->opcode==OP_Null && !IsVirtual(pTab) ){
appendFlag = 1;
pOp->opcode = OP_NewRowid;
pOp->p1 = baseCur;
@@ -849,9 +849,14 @@ void sqlite3Insert(
*/
if( !appendFlag ){
int j1;
j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid);
sqlite3VdbeAddOp3(v, OP_NewRowid, baseCur, regRowid, regAutoinc);
sqlite3VdbeJumpHere(v, j1);
if( !IsVirtual(pTab) ){
j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid);
sqlite3VdbeAddOp3(v, OP_NewRowid, baseCur, regRowid, regAutoinc);
sqlite3VdbeJumpHere(v, j1);
}else{
j1 = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp2(v, OP_IsNull, regRowid, j1+2);
}
sqlite3VdbeAddOp1(v, OP_MustBeInt, regRowid);
}
}else if( IsVirtual(pTab) ){