create table if not exists test_extend (num int, str text);
truncate table test_extend;

-- fill in 2 blocks with as many large records as will fit
insert into test_extend select g, rpad('', 1024, 'a') from generate_series(1,7*2) g;
select pg_relation_size('test_extend', 'main') as heap, pg_relation_size('test_extend', 'fsm') as fsm;

alter system set client_min_messages to DEBUG1;
select pg_reload_conf();

-- clear some space on block 0
delete from test_extend where num <= 5;
vacuum test_extend;

-- insert short record in block 1 to reset cached targetBlock
insert into test_extend values(99, 'hello');

-- insert large record and see if it goes in block 0
insert into test_extend values (101, rpad('', 1024, 'a'));
select pg_relation_size('test_extend', 'main') as heap, pg_relation_size('test_extend', 'fsm') as fsm;

alter system set client_min_messages to DEFAULT;
select pg_reload_conf();
