-- Set a column as non-nullable
select alter_materialized_view_alter_column_set_not_null('my_materialized_view', 'my_column', true);
Because modifying pg_catalog.pg_attribute
requires superuser, but making a column's nullability is something a non-superuser may want to do, the function is defined with security definer
and should be created as superuser.
security definer
works a bit like the setuid bit on Unix, it makes the function run with its definer's permissions.