1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Fix confusion on the padding of GIDs in on commit and abort records.

Review of commit 1eb6d652: It's pointless to add padding to the GID fields,
when the code that follows assumes that there is no alignment, and uses
memcpy(). Remove the pointless padding.

Update comments to note the new fields in the WAL records.

Reviewed-by: Michael Paquier
Discussion: https://www.postgresql.org/message-id/33b787bf-dc20-1161-54e9-3f3b607bf59d%40iki.fi
This commit is contained in:
Heikki Linnakangas
2018-04-17 16:10:42 -04:00
parent b7e2cbc5b4
commit cf5a189059
5 changed files with 17 additions and 32 deletions

View File

@@ -104,18 +104,18 @@ ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *pars
if (parsed->xinfo & XACT_XINFO_HAS_GID)
{
int gidlen;
strlcpy(parsed->twophase_gid, data, sizeof(parsed->twophase_gid));
gidlen = strlen(data) + 1;
data += MAXALIGN(gidlen);
data += strlen(data) + 1;
}
}
/* Note: no alignment is guaranteed after this point */
if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
{
xl_xact_origin xl_origin;
/* we're only guaranteed 4 byte alignment, so copy onto stack */
/* no alignment is guaranteed, so copy onto stack */
memcpy(&xl_origin, data, sizeof(xl_origin));
parsed->origin_lsn = xl_origin.origin_lsn;
@@ -188,18 +188,18 @@ ParseAbortRecord(uint8 info, xl_xact_abort *xlrec, xl_xact_parsed_abort *parsed)
if (parsed->xinfo & XACT_XINFO_HAS_GID)
{
int gidlen;
strlcpy(parsed->twophase_gid, data, sizeof(parsed->twophase_gid));
gidlen = strlen(data) + 1;
data += MAXALIGN(gidlen);
data += strlen(data) + 1;
}
}
/* Note: no alignment is guaranteed after this point */
if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
{
xl_xact_origin xl_origin;
/* we're only guaranteed 4 byte alignment, so copy onto stack */
/* no alignment is guaranteed, so copy onto stack */
memcpy(&xl_origin, data, sizeof(xl_origin));
parsed->origin_lsn = xl_origin.origin_lsn;