create or replace function movie_showtimes_refresh_row(
  id integer
) returns timestamp with time zone
security definer
language 'plpgsql' as $$
declare
  expiry timestamp with time zone;
begin
  expiry := movie_showtime_expiry(id);
  delete
    from movie_showtimes_with_current_and_sold_out_and_dirty_and_expiry ms
    where ms.id = id;
  insert into movie_showtimes_with_current_and_sold_out_and_dirty_and_expiry
  select *, false, expiry
    from movie_showtimes_with_current_and_sold_out_unmaterialized ms
    where ms.id = id;
end
$$;

