@@ -217,17 +217,17 @@ sub write_tuple
217217my $relpath = " $pgdata /$rel " ;
218218
219219# Insert data and freeze public.test
220- use constant ROWCOUNT => 17;
220+ my $ ROWCOUNT = 17;
221221$node -> safe_psql(
222222 ' postgres' , qq(
223223 INSERT INTO public.test (a, b, c)
224- VALUES (
224+ SELECT
225225 x'DEADF9F9DEADF9F9'::bigint,
226226 'abcdefg',
227227 repeat('w', 10000)
228- );
229- VACUUM FREEZE public.test
230- ) ) for (1 .. ROWCOUNT );
228+ FROM generate_series(1, $ROWCOUNT );
229+ VACUUM FREEZE public.test; )
230+ );
231231
232232my $relfrozenxid = $node -> safe_psql(' postgres' ,
233233 q( select relfrozenxid from pg_class where relname = 'test') );
@@ -246,16 +246,13 @@ sub write_tuple
246246}
247247
248248# Find where each of the tuples is located on the page.
249- my @lp_off ;
250- for my $tup (0 .. ROWCOUNT - 1)
251- {
252- push (
253- @lp_off ,
254- $node -> safe_psql(
255- ' postgres' , qq(
256- select lp_off from heap_page_items(get_raw_page('test', 'main', 0))
257- offset $tup limit 1) ));
258- }
249+ my @lp_off = split ' \n' , $node -> safe_psql(
250+ ' postgres' , qq(
251+ select lp_off from heap_page_items(get_raw_page('test', 'main', 0))
252+ where lp <= $ROWCOUNT
253+ )
254+ );
255+ is(scalar @lp_off , $ROWCOUNT , " acquired row offsets" );
259256
260257# Sanity check that our 'test' table on disk layout matches expectations. If
261258# this is not so, we will have to skip the test until somebody updates the test
@@ -267,7 +264,7 @@ sub write_tuple
267264binmode $file ;
268265
269266my $ENDIANNESS ;
270- for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx ++)
267+ for (my $tupidx = 0; $tupidx < $ ROWCOUNT ; $tupidx ++)
271268{
272269 my $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
273270 my $offset = $lp_off [$tupidx ];
@@ -345,7 +342,7 @@ sub header
345342 or BAIL_OUT(" open failed: $! " );
346343binmode $file ;
347344
348- for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx ++)
345+ for (my $tupidx = 0; $tupidx < $ ROWCOUNT ; $tupidx ++)
349346{
350347 my $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
351348 my $offset = $lp_off [$tupidx ];
@@ -522,7 +519,7 @@ sub header
522519 $tup -> {t_infomask } &= ~HEAP_XMIN_INVALID;
523520
524521 push @expected ,
525- qr /${$header} xmin ${xmin} equals or exceeds next valid transaction ID 0:\d +/ ;
522+ qr /${$header} xmin ${xmin} equals or exceeds next valid transaction ID 0:\d +/ ;
526523 }
527524 write_tuple($file , $offset , $tup );
528525}
0 commit comments