Why a privileged user can't access newly created partition?
PostgreSQL version: 10.0
Suppose my PostgreSQL sever has a user called app
with following permissions:
GRANT SELECT, INSERT, UPDATE ON ALL TABLES IN SCHEMA public TO app;
GRANT USAGE ON ALL SEQUENCES IN SCHEMA public to app;
Now this user app
can do select, insert and update action for "existing" table/partition (for example: mytable_partition_old
) just as my expectation, everything goes well so far.
However, a master
account creates a new partition of a table after the GRANT
command above by following:
CREATE TABLE IF NOT EXISTS "mytable_partition_new" PARTITION OF mytable FOR VALUES IN('some_value');
After mytable_partition_new
is created, the user app
got "permission denied for this relation" by executing INSERT INTO mytable_partition_new values (...)
command.
I understand it can be resolved by issue GRANT SELECT, .... TO app
again.
My question is if there any better way to achieve it?
(we don't have a dedicated DBA and got stucked in this situation for a while..)