@@ -217,17 +217,17 @@ sub write_tuple
217
217
my $relpath = " $pgdata /$rel " ;
218
218
219
219
# Insert data and freeze public.test
220
- use constant ROWCOUNT => 17;
220
+ my $ ROWCOUNT = 17;
221
221
$node -> safe_psql(
222
222
' postgres' , qq(
223
223
INSERT INTO public.test (a, b, c)
224
- VALUES (
224
+ SELECT
225
225
x'DEADF9F9DEADF9F9'::bigint,
226
226
'abcdefg',
227
227
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
+ );
231
231
232
232
my $relfrozenxid = $node -> safe_psql(' postgres' ,
233
233
q( select relfrozenxid from pg_class where relname = 'test') );
@@ -246,16 +246,13 @@ sub write_tuple
246
246
}
247
247
248
248
# 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" );
259
256
260
257
# Sanity check that our 'test' table on disk layout matches expectations. If
261
258
# this is not so, we will have to skip the test until somebody updates the test
@@ -267,7 +264,7 @@ sub write_tuple
267
264
binmode $file ;
268
265
269
266
my $ENDIANNESS ;
270
- for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx ++)
267
+ for (my $tupidx = 0; $tupidx < $ ROWCOUNT ; $tupidx ++)
271
268
{
272
269
my $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
273
270
my $offset = $lp_off [$tupidx ];
@@ -345,7 +342,7 @@ sub header
345
342
or BAIL_OUT(" open failed: $! " );
346
343
binmode $file ;
347
344
348
- for (my $tupidx = 0; $tupidx < ROWCOUNT; $tupidx ++)
345
+ for (my $tupidx = 0; $tupidx < $ ROWCOUNT ; $tupidx ++)
349
346
{
350
347
my $offnum = $tupidx + 1; # offnum is 1-based, not zero-based
351
348
my $offset = $lp_off [$tupidx ];
@@ -522,7 +519,7 @@ sub header
522
519
$tup -> {t_infomask } &= ~HEAP_XMIN_INVALID;
523
520
524
521
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 +/ ;
526
523
}
527
524
write_tuple($file , $offset , $tup );
528
525
}
0 commit comments