diff options
author | Robert Haas <rhaas@postgresql.org> | 2017-10-05 13:21:50 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2017-10-05 13:23:28 -0400 |
commit | 6476b26115f3ef25a9cd87880e0ac5ec5f7a05f6 (patch) | |
tree | a924f72524b20de3a67d582427dd95513561aa54 /src/backend | |
parent | 14f67a8ee282ebc0de78e773fbd597f460ab4a54 (diff) | |
download | postgresql-6476b26115f3ef25a9cd87880e0ac5ec5f7a05f6.tar.gz postgresql-6476b26115f3ef25a9cd87880e0ac5ec5f7a05f6.zip |
On CREATE TABLE, consider skipping validation of subpartitions.
This is just like commit 14f67a8ee282ebc0de78e773fbd597f460ab4a54, but
for CREATE PARTITION rather than ATTACH PARTITION.
Jeevan Ladhe, with test case changes by me.
Discussion: http://postgr.es/m/CAOgcT0MWwG8WBw8frFMtRYHAgDD=tpt6U7WcsO_L2k0KYpm4Jg@mail.gmail.com
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/catalog/partition.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c index 9777d40e663..3a8306a0552 100644 --- a/src/backend/catalog/partition.c +++ b/src/backend/catalog/partition.c @@ -953,7 +953,25 @@ check_default_allows_bound(Relation parent, Relation default_rel, /* Lock already taken above. */ if (part_relid != RelationGetRelid(default_rel)) + { part_rel = heap_open(part_relid, NoLock); + + /* + * If the partition constraints on default partition child imply + * that it will not contain any row that would belong to the new + * partition, we can avoid scanning the child table. + */ + if (PartConstraintImpliedByRelConstraint(part_rel, + def_part_constraints)) + { + ereport(INFO, + (errmsg("partition constraint for table \"%s\" is implied by existing constraints", + RelationGetRelationName(part_rel)))); + + heap_close(part_rel, NoLock); + continue; + } + } else part_rel = default_rel; |