How to fan out rows with a specified range of values?
This can be achieved using generate_series()

with test_data (id, "first", "last") as (
   values (42, 5, 8), 
          (43, 6, 9)
)
select td.id, g.nr
from test_data td
  cross join lateral generate_series(td."first", td."last", 1) as g(nr)
order by td.id, g.nr;


Online example: https://rextester.com/TWE47868