mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Progress toward getting UPDATE to work in WITHOUT ROWID tables.
FossilOrigin-Name: e557b7d80f1ede63427a31b16757bf5d8dbfb66d
This commit is contained in:
20
src/insert.c
20
src/insert.c
@@ -1145,16 +1145,16 @@ insert_cleanup:
|
||||
**
|
||||
** The regRowid parameter is the index of the register containing (1).
|
||||
**
|
||||
** If isUpdate is true and rowidChng is non-zero, then rowidChng contains
|
||||
** If isUpdate is true and pkChng is non-zero, then pkChng contains
|
||||
** the address of a register containing the rowid before the update takes
|
||||
** place. isUpdate is true for UPDATEs and false for INSERTs. If isUpdate
|
||||
** is false, indicating an INSERT statement, then a non-zero rowidChng
|
||||
** is false, indicating an INSERT statement, then a non-zero pkChng
|
||||
** indicates that the rowid was explicitly specified as part of the
|
||||
** INSERT statement. If rowidChng is false, it means that the rowid is
|
||||
** INSERT statement. If pkChng is false, it means that the rowid is
|
||||
** computed automatically in an insert or that the rowid value is not
|
||||
** modified by an update.
|
||||
**
|
||||
** The code generated by this routine store new index entries into
|
||||
** The code generated by this routine should store new index entries into
|
||||
** registers identified by aRegIdx[]. No index entry is created for
|
||||
** indices where aRegIdx[i]==0. The order of indices in aRegIdx[] is
|
||||
** the same as the order of indices on the linked list of indices
|
||||
@@ -1208,10 +1208,10 @@ insert_cleanup:
|
||||
void sqlite3GenerateConstraintChecks(
|
||||
Parse *pParse, /* The parser context */
|
||||
Table *pTab, /* the table into which we are inserting */
|
||||
int baseCur, /* Index of a read/write cursor pointing at pTab */
|
||||
int regRowid, /* Index of the range of input registers */
|
||||
int baseCur, /* A read/write cursor pointing at pTab */
|
||||
int regRowid, /* First register in a range holding values to insert */
|
||||
int *aRegIdx, /* Register used by each index. 0 for unused indices */
|
||||
int rowidChng, /* True if the rowid might collide with existing entry */
|
||||
int pkChng, /* Non-zero if the PRIMARY KEY might collide */
|
||||
int isUpdate, /* True for UPDATE, False for INSERT */
|
||||
int overrideError, /* Override onError to this if not OE_Default */
|
||||
int ignoreDest, /* Jump to this label on an OE_Ignore resolution */
|
||||
@@ -1228,7 +1228,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
Index *pIdx; /* Pointer to one of the indices */
|
||||
sqlite3 *db; /* Database connection */
|
||||
int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
|
||||
int regOldRowid = (rowidChng && isUpdate) ? rowidChng : regRowid;
|
||||
int regOldRowid = (pkChng && isUpdate) ? pkChng : regRowid;
|
||||
|
||||
db = pParse->db;
|
||||
v = sqlite3GetVdbe(pParse);
|
||||
@@ -1314,7 +1314,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
** of the new record does not previously exist. Except, if this
|
||||
** is an UPDATE and the primary key is not changing, that is OK.
|
||||
*/
|
||||
if( rowidChng ){
|
||||
if( pkChng ){
|
||||
onError = pTab->keyConf;
|
||||
if( overrideError!=OE_Default ){
|
||||
onError = overrideError;
|
||||
@@ -1323,7 +1323,7 @@ void sqlite3GenerateConstraintChecks(
|
||||
}
|
||||
|
||||
if( isUpdate ){
|
||||
j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, rowidChng);
|
||||
j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, pkChng);
|
||||
}
|
||||
j3 = sqlite3VdbeAddOp3(v, OP_NotExists, baseCur, 0, regRowid);
|
||||
switch( onError ){
|
||||
|
||||
Reference in New Issue
Block a user