Skip to content

Commit 91b0e85

Browse files
committed
Don't use Perl pack('Q') in 039_end_of_wal.pl.
'Q' for 64 bit integers turns out not to work on 32 bit Perl, as revealed by the build farm. Use 'II' instead, and deal with endianness. Back-patch to 12, like bae868c. Discussion: https://postgr.es/m/ZQ4r1vHcryBsSi_V%40paquier.xyz
1 parent bae868c commit 91b0e85

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/test/recovery/t/039_end_of_wal.pl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313

1414
use integer; # causes / operator to use integer math
1515

16+
# Is this a big-endian system ("network" byte order)? We can't use 'Q' in
17+
# pack() calls because it's not available in some perl builds, so we need to
18+
# break 64 bit LSN values into two 'I' values. Fortunately we don't need to
19+
# deal with high values, so we can just write 0 for the high order 32 bits, but
20+
# we need to know the endianness to do that.
21+
my $BIG_ENDIAN = pack("L", 0x12345678) eq pack("N", 0x12345678);
22+
1623
# Header size of record header.
1724
my $RECORD_HEADER_SIZE = 24;
1825

@@ -125,13 +132,16 @@ sub build_record_header
125132
# This needs to follow the structure XLogRecord:
126133
# I for xl_tot_len
127134
# I for xl_xid
128-
# Q for xl_prev
135+
# II for xl_prev
129136
# C for xl_info
130137
# C for xl_rmid
131138
# BB for two bytes of padding
132139
# I for xl_crc
133-
return pack("IIQCCBBI",
134-
$xl_tot_len, $xl_xid, $xl_prev, $xl_info, $xl_rmid, 0, 0, $xl_crc);
140+
return pack("IIIICCBBI",
141+
$xl_tot_len, $xl_xid,
142+
$BIG_ENDIAN ? 0 : $xl_prev,
143+
$BIG_ENDIAN ? $xl_prev : 0,
144+
$xl_info, $xl_rmid, 0, 0, $xl_crc);
135145
}
136146

137147
# Build a fake WAL page header, based on the data given by the caller
@@ -149,10 +159,12 @@ sub build_page_header
149159
# S for xlp_magic
150160
# S for xlp_info
151161
# I for xlp_tli
152-
# Q for xlp_pageaddr
162+
# II for xlp_pageaddr
153163
# I for xlp_rem_len
154-
return pack("SSIQI",
155-
$xlp_magic, $xlp_info, $xlp_tli, $xlp_pageaddr, $xlp_rem_len);
164+
return pack("SSIIII",
165+
$xlp_magic, $xlp_info, $xlp_tli,
166+
$BIG_ENDIAN ? 0 : $xlp_pageaddr,
167+
$BIG_ENDIAN ? $xlp_pageaddr : 0, $xlp_rem_len);
156168
}
157169

158170
# Make sure we are far away enough from the end of a page that we could insert

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy