pg_partman
pg_partman copied to clipboard
Primary Key on template table and default partition
Missing primary key on template table and default partition when running create_parent
causes issues in replicating DDL changes using EVENT Triggers in a logically replicated environment.
Requesting to add INCLUDING ALL
in the definition of partman.create_parent
on line 162 and 702 where it creates the template table and default partition
Also, requesting the ability to create_parent
without a default partition
.
If you need the primary keys to be created on the child tables from the moment that create_parent()
is called, then you will have to precreate your template table, add the relevant unique indexes required, then feed that template table name to create_parent()
with the p_template_table
parameter.
I specifically do not do INCLUDING ALL for my invocation of the CREATE TABLE command so that, if/when a new option is added, it doesn't suddenly break pg_partman. If a new option is added, I then add that explicitly in the call. Also, I specifically do not include INDEXES on that since native partitioning automatically takes care of adding and removing indexes that are created on the parent when possible. Even if I changed to using INCLUDING ALL, that wouldn't fix this issue for unique indexes that don't include the partition key. Native partitioning does not allow them to exist at all on the partition parent. Unique indexes that don't include the partition key must be handled via the template table.
I'll look into adding an option for not including a default from the start. Will likely be part of the 5.x refactor since I would like to remove some parameters to create_parent()
before adding more.
Issue #489 is used to track the default table being optional. Closing this issue for now.