My question is related to this one: how to lock a table for writing
I found the simple solution, but I am not sure is it safe for side-effects.
So:
update pg_class set relkind = 'm' where relname = '<table_name>';
(surely it should be more complex to take in account the table schema)
However in my simple tests it makes the trick:
create table t(i int); insert into t values(1);
update pg_class set relkind = 'm' where relname = 't';
insert into t values(1);
-- ERROR: cannot change materialized view "t"
select * from t;
-- i
-- ---
-- 1
-- (1 row)
So, my question (totally theoretical for now) is: Does something could to going wrong with this solution?