Try removing security definer ... It should work.
--Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html