Skip to content

Commit 82314db

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 e8f3c06 commit 82314db

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

@@ -131,13 +138,16 @@ sub build_record_header
131138
# This needs to follow the structure XLogRecord:
132139
# I for xl_tot_len
133140
# I for xl_xid
134-
# Q for xl_prev
141+
# II for xl_prev
135142
# C for xl_info
136143
# C for xl_rmid
137144
# BB for two bytes of padding
138145
# I for xl_crc
139-
return pack("IIQCCBBI",
140-
$xl_tot_len, $xl_xid, $xl_prev, $xl_info, $xl_rmid, 0, 0, $xl_crc);
146+
return pack("IIIICCBBI",
147+
$xl_tot_len, $xl_xid,
148+
$BIG_ENDIAN ? 0 : $xl_prev,
149+
$BIG_ENDIAN ? $xl_prev : 0,
150+
$xl_info, $xl_rmid, 0, 0, $xl_crc);
141151
}
142152

143153
# Build a fake WAL page header, based on the data given by the caller
@@ -155,10 +165,12 @@ sub build_page_header
155165
# S for xlp_magic
156166
# S for xlp_info
157167
# I for xlp_tli
158-
# Q for xlp_pageaddr
168+
# II for xlp_pageaddr
159169
# I for xlp_rem_len
160-
return pack("SSIQI",
161-
$xlp_magic, $xlp_info, $xlp_tli, $xlp_pageaddr, $xlp_rem_len);
170+
return pack("SSIIII",
171+
$xlp_magic, $xlp_info, $xlp_tli,
172+
$BIG_ENDIAN ? 0 : $xlp_pageaddr,
173+
$BIG_ENDIAN ? $xlp_pageaddr : 0, $xlp_rem_len);
162174
}
163175

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

0 commit comments

Comments
 (0)