1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

All legacy tests are passing.

FossilOrigin-Name: 2c436806b8d5f57de99c00f6154b038454fb9ae427d00d7b4a46ab9c7c69bcb9
This commit is contained in:
drh
2023-11-28 13:35:53 +00:00
parent 5026ddb83d
commit ec1f59f0cd
3 changed files with 20 additions and 15 deletions

View File

@@ -5177,24 +5177,32 @@ static int jsonMergePatchBlob(
if( pTarget->oom ) return JSON_MERGE_OOM;
}else{
/* Algorithm line 12 */
int rc = jsonMergePatchBlob(pTarget, iTValue, pPatch, iPValue);
int rc, savedDelta = pTarget->delta;
pTarget->delta = 0;
rc = jsonMergePatchBlob(pTarget, iTValue, pPatch, iPValue);
if( rc ) return rc;
pTarget->delta += savedDelta;
}
}else if( x>0 ){ /* Algorithm line 13 */
/* No match and patch value is not NULL */
u32 szNew = szPLabel+nPLabel;
if( (pPatch->aBlob[iPValue] & 0x0f)!=JSONB_OBJECT ){ /* Line 14 */
jsonBlobEdit(pTarget, iTEnd, 0,
pPatch->aBlob+iPValue, szPValue+nPValue);
jsonBlobEdit(pTarget, iTEnd, 0, 0, szPValue+nPValue+szNew);
if( pTarget->oom ) return JSON_MERGE_OOM;
memcpy(&pTarget->aBlob[iTEnd], &pPatch->aBlob[iPLabel], szNew);
memcpy(&pTarget->aBlob[iTEnd+szNew],
&pPatch->aBlob[iPValue], szPValue+nPValue);
}else{
int rc;
u32 szNew = szPLabel+nPLabel;
int rc, savedDelta;
jsonBlobEdit(pTarget, iTEnd, 0, 0, szNew+1);
if( pTarget->oom ) return JSON_MERGE_OOM;
memcpy(&pTarget->aBlob[iTEnd], &pPatch->aBlob[iPLabel], szNew);
pTarget->aBlob[iTEnd+szNew] = 0x00;
savedDelta = pTarget->delta;
pTarget->delta = 0;
rc = jsonMergePatchBlob(pTarget, iTEnd+szNew,pPatch,iPValue);
if( rc ) return rc;
pTarget->delta += savedDelta;
}
}
}