1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Fix a problem with concatenating patchsets containing DELETE and INSERT operations on the same row.

FossilOrigin-Name: 4d8537eafb40e3687abc057ba26a1f7014f2c2d9
This commit is contained in:
dan
2014-09-26 10:52:21 +00:00
parent cbf6d2d2aa
commit fa29ecc4ed
4 changed files with 22 additions and 18 deletions

View File

@ -22,11 +22,6 @@ ifcapable !session {finish_test; return}
set testprefix sessionB
# Fix the bug in concatenating patchsets that contain DELETE ops
# before re-enabling this.
finish_test
return
#
# 1.*: Test that the blobs returned by the session_patchset() API are
# as expected. Also the sqlite3_changeset_iter functions.

View File

@ -597,11 +597,15 @@ static void sessionMergeRecord(
** as to point to the next value in the record.
**
** If, when this function is called, *paTwo points to a valid value (i.e.
** *paTwo[0] is not 0x00 - the "no value" placeholder), a copy of the *paOne
** *paTwo[0] is not 0x00 - the "no value" placeholder), a copy of the *paTwo
** pointer is returned and *pnVal is set to the number of bytes in the
** serialized value. Otherwise, a copy of *paOne is returned and *pnVal
** set to the number of bytes in the value at *paOne. If *paOne points
** to the "no value" placeholder, *pnVal is set to 1.
** to the "no value" placeholder, *pnVal is set to 1. In other words:
**
** if( *paTwo is valid ) return *paTwo;
** return *paOne;
**
*/
static u8 *sessionMergeValue(
u8 **paOne, /* IN/OUT: Left-hand buffer pointer */
@ -3723,10 +3727,15 @@ static int sessionChangeMerge(
}else if( op1==SQLITE_DELETE ){ /* DELETE + INSERT */
assert( op2==SQLITE_INSERT );
pNew->op = SQLITE_UPDATE;
if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aExist, 0, aRec, 0) ){
if( bPatchset ){
memcpy(aCsr, aRec, nRec);
aCsr += nRec;
}else{
if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aExist, 0,aRec,0) ){
sqlite3_free(pNew);
pNew = 0;
}
}
}else if( op2==SQLITE_UPDATE ){ /* UPDATE + UPDATE */
u8 *a1 = aExist;
u8 *a2 = aRec;

View File

@ -1,5 +1,5 @@
C Add\sstreaming\sversion\sof\ssqlite3changeset_concat().
D 2014-09-25T20:43:28.741
C Fix\sa\sproblem\swith\sconcatenating\spatchsets\scontaining\sDELETE\sand\sINSERT\soperations\son\sthe\ssame\srow.
D 2014-09-26T10:52:21.193
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in dd5f245aa8c741bc65845747203c8ce2f3fb6c83
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -155,10 +155,10 @@ F ext/session/session6.test 443789bc2fca12e4f7075cf692c60b8a2bea1a26
F ext/session/session8.test 7d35947ad329b8966f095d34f9617a9eff52dc65
F ext/session/session9.test 776e46785c29c11cda01f5205d0f1e8f8f9a46bf
F ext/session/sessionA.test eb05c13e4ef1ca8046a3a6dbf2d5f6f5b04a11d4
F ext/session/sessionB.test c414583719a6a1b430bbb4b32cdffc6089d2b139
F ext/session/sessionB.test d4ac901b43d4922a17dff08bbaa2f5354487ce4d
F ext/session/session_common.tcl 1539d8973b2aea0025c133eb0cc4c89fcef541a5
F ext/session/sessionfault.test e7965159a73d385c1a4af12d82c3a039ebdd71a6
F ext/session/sqlite3session.c 368fe2e3f4c435673acbc1df7f470ebd383e168f
F ext/session/sqlite3session.c ade9fa2f7341b822dddaa865115ec964a030df94
F ext/session/sqlite3session.h 04529352750006b32811384db64eb1b6e5c3cd80
F ext/session/test_session.c 194083ee1f0f6f38404f662fe9b50849abd3b7ee
F ext/userauth/sqlite3userauth.h 19cb6f0e31316d0ee4afdfb7a85ef9da3333a220
@ -1216,7 +1216,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 8ded6a46794c7bff1c8b790c662ba7e92f576380
R ee60d24169659791aff86861c22f5852
P 88eb6656bdb047a104837a2e15e7fe18c0a7a159
R 81a0c7112c65d31bc1808253eb2f372f
U dan
Z 192d45bf138dc22ddb0bc36d2880342f
Z a169087f5f6ea34184b5d5b4868830f7

View File

@ -1 +1 @@
88eb6656bdb047a104837a2e15e7fe18c0a7a159
4d8537eafb40e3687abc057ba26a1f7014f2c2d9