diff options
author | drh <drh@noemail.net> | 2018-07-11 13:34:24 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-07-11 13:34:24 +0000 |
commit | 222a384a068339bc938fdcbddb2c99847518a0e8 (patch) | |
tree | 1eac219070fa99afe0e1e4d6193c951c194c6283 /src/insert.c | |
parent | 9341916ed542e0ffb580ca5df0365fa977341a57 (diff) | |
download | sqlite-222a384a068339bc938fdcbddb2c99847518a0e8.tar.gz sqlite-222a384a068339bc938fdcbddb2c99847518a0e8.zip |
On an UPSERT when the order of constraint checks is rearranged, make sure
that the affinity transformations on the inserted content occur before
any of the constraint checks. Fix for ticket [79cad5e4b2e219dd197242e9e5f4e].
FossilOrigin-Name: d120c45f3dc79f67afed0e44e5133569f784bc6792b15f5d79529deac2d13072
Diffstat (limited to 'src/insert.c')
-rw-r--r-- | src/insert.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/insert.c b/src/insert.c index 78b07a025..44fb0e752 100644 --- a/src/insert.c +++ b/src/insert.c @@ -1632,6 +1632,10 @@ void sqlite3GenerateConstraintChecks( int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */ if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */ + if( bAffinityDone==0 ){ + sqlite3TableAffinity(v, pTab, regNewData+1); + bAffinityDone = 1; + } if( pUpIdx==pIdx ){ addrUniqueOk = sAddr.upsertBtm; upsertBypass = sqlite3VdbeGoto(v, 0); @@ -1641,10 +1645,6 @@ void sqlite3GenerateConstraintChecks( addrUniqueOk = sqlite3VdbeMakeLabel(v); } VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName)); - if( bAffinityDone==0 ){ - sqlite3TableAffinity(v, pTab, regNewData+1); - bAffinityDone = 1; - } iThisCur = iIdxCur+ix; |