mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Code review for logical decoding patch.
Post-commit review identified a number of places where addition was used instead of multiplication or memory wasn't zeroed where it should have been. This commit also fixes one case where a structure member was mis-initialized, and moves another memory allocation closer to the place where the allocated storage is used for clarity. Andres Freund
This commit is contained in:
@ -2064,15 +2064,15 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
|
||||
if (snap->xcnt)
|
||||
{
|
||||
memcpy(data, snap->xip,
|
||||
sizeof(TransactionId) + snap->xcnt);
|
||||
data += sizeof(TransactionId) + snap->xcnt;
|
||||
sizeof(TransactionId) * snap->xcnt);
|
||||
data += sizeof(TransactionId) * snap->xcnt;
|
||||
}
|
||||
|
||||
if (snap->subxcnt)
|
||||
{
|
||||
memcpy(data, snap->subxip,
|
||||
sizeof(TransactionId) + snap->subxcnt);
|
||||
data += sizeof(TransactionId) + snap->subxcnt;
|
||||
sizeof(TransactionId) * snap->subxcnt);
|
||||
data += sizeof(TransactionId) * snap->subxcnt;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -2168,15 +2168,12 @@ ReorderBufferRestoreChanges(ReorderBuffer *rb, ReorderBufferTXN *txn,
|
||||
|
||||
}
|
||||
|
||||
ReorderBufferSerializeReserve(rb, sizeof(ReorderBufferDiskChange));
|
||||
|
||||
|
||||
/*
|
||||
* Read the statically sized part of a change which has information
|
||||
* about the total size. If we couldn't read a record, we're at the
|
||||
* end of this file.
|
||||
*/
|
||||
|
||||
ReorderBufferSerializeReserve(rb, sizeof(ReorderBufferDiskChange));
|
||||
readBytes = read(*fd, rb->outbuf, sizeof(ReorderBufferDiskChange));
|
||||
|
||||
/* eof */
|
||||
|
Reference in New Issue
Block a user