Skip to content

Owner for partitions is not equal to parent table #51

Closed
@IVolzhev

Description

@IVolzhev

Hi!

When range partition is created it is owned by default user which is not equal to parent table owner (see below).
Is it possible to set the same owner for partitions?

drop role if exists test_owner;
drop table if exists testing_part_owner cascade; 

create role test_owner login nosuperuser;

create table if not exists testing_part_owner(
  range_field      timestamp not null,
  data             integer
)
with (oids = false);

create index if not exists testing_part_owner_i on testing_part_owner(data);

alter table testing_part_owner owner to test_owner;
grant all privileges on testing_part_owner to test_owner;

select
create_range_partitions(
  'testing_part_owner',
  'range_field',
  date_trunc('day', localtimestamp)::timestamp,
  '1 day'::interval,
  1
);

select b.rolname as object_owner, a.relkind as object_type, a.relname as object_name
from pg_class a inner join pg_roles b on a.relowner = b.oid
where a.relname like 'testing\_part\_owner%' escape '\';

Result:

 object_owner | object_type |          object_name          
--------------+-------------+-------------------------------
 test_owner   | r           | testing_part_owner
 postgres     | r           | testing_part_owner_1
 postgres     | i           | testing_part_owner_1_data_idx
 test_owner   | i           | testing_part_owner_i
 postgres     | S           | testing_part_owner_seq
(5 rows)


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions