Skip to content

Commit 945d2cb

Browse files
committed
In pg_amcheck tests, don't depend on perl's Q/q pack code.
It does not work on all versions of perl across all platforms. To avoid endian-ness issues, pick a new value for column a that has the same upper 4 bytes as lower 4 bytes. Try to make it something that isn't likely to occur anywhere nearby in the page. Discussion: http://postgr.es/m/29DA079B-0658-4E66-BDAA-0EFD7B64D9C6@enterprisedb.com
1 parent 9e294d0 commit 945d2cb

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/bin/pg_amcheck/t/004_verify_heapam.pl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
# L = "Unsigned 32-bit Long",
5858
# S = "Unsigned 16-bit Short",
5959
# C = "Unsigned 8-bit Octet",
60-
# q = "signed 64-bit quadword"
6160
#
6261
# Each tuple in our table has a layout as follows:
6362
#
@@ -71,7 +70,7 @@
7170
# xx xx t_infomask: xx offset = 20 S
7271
# xx t_hoff: x offset = 22 C
7372
# xx t_bits: x offset = 23 C
74-
# xx xx xx xx xx xx xx xx 'a': xxxxxxxx offset = 24 q
73+
# xx xx xx xx xx xx xx xx 'a': xxxxxxxx offset = 24 LL
7574
# xx xx xx xx xx xx xx xx 'b': xxxxxxxx offset = 32 CCCCCCCC
7675
# xx xx xx xx xx xx xx xx 'c': xxxxxxxx offset = 40 CCllLL
7776
# xx xx xx xx xx xx xx xx : xxxxxxxx ...continued
@@ -81,7 +80,7 @@
8180
# it is convenient enough to do it this way. We define packing code
8281
# constants here, where they can be compared easily against the layout.
8382

84-
use constant HEAPTUPLE_PACK_CODE => 'LLLSSSSSCCqCCCCCCCCCCllLL';
83+
use constant HEAPTUPLE_PACK_CODE => 'LLLSSSSSCCLLCCCCCCCCCCllLL';
8584
use constant HEAPTUPLE_PACK_LENGTH => 58; # Total size
8685

8786
# Read a tuple of our table from a heap page.
@@ -112,7 +111,8 @@ sub read_tuple
112111
t_infomask => shift,
113112
t_hoff => shift,
114113
t_bits => shift,
115-
a => shift,
114+
a_1 => shift,
115+
a_2 => shift,
116116
b_header => shift,
117117
b_body1 => shift,
118118
b_body2 => shift,
@@ -156,7 +156,8 @@ sub write_tuple
156156
$tup->{t_infomask},
157157
$tup->{t_hoff},
158158
$tup->{t_bits},
159-
$tup->{a},
159+
$tup->{a_1},
160+
$tup->{a_2},
160161
$tup->{b_header},
161162
$tup->{b_body1},
162163
$tup->{b_body2},
@@ -227,7 +228,7 @@ sub write_tuple
227228
$node->safe_psql('postgres', qq(
228229
INSERT INTO public.test (a, b, c)
229230
VALUES (
230-
12345678,
231+
x'DEADF9F9DEADF9F9'::bigint,
231232
'abcdefg',
232233
repeat('w', 10000)
233234
);
@@ -275,13 +276,15 @@ sub write_tuple
275276
my $tup = read_tuple($file, $offset);
276277

277278
# Sanity-check that the data appears on the page where we expect.
278-
my $a = $tup->{a};
279+
my $a_1 = $tup->{a_1};
280+
my $a_2 = $tup->{a_2};
279281
my $b = $tup->{b};
280-
if ($a ne '12345678' || $b ne 'abcdefg')
282+
if ($a_1 != 0xDEADF9F9 || $a_2 != 0xDEADF9F9 || $b ne 'abcdefg')
281283
{
282284
close($file); # ignore errors on close; we're exiting anyway
283285
$node->clean_node;
284-
plan skip_all => qq(Page layout differs from our expectations: expected (12345678, "abcdefg"), got ($a, "$b"));
286+
plan skip_all => sprintf("Page layout differs from our expectations: expected (%x, %x, \"%s\"), got (%x, %x, \"%s\")",
287+
0xDEADF9F9, 0xDEADF9F9, "abcdefg", $a_1, $a_2, $b);
285288
exit;
286289
}
287290

0 commit comments

Comments
 (0)