aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/tablecmds.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-02-19 21:29:27 +0530
committerRobert Haas <rhaas@postgresql.org>2017-02-19 21:29:27 +0530
commita3dc8e495b4967fe07086a700d115c89f4f0add0 (patch)
tree19be799baaa0cc1339a1fca7635be4c308b39e9f /src/backend/commands/tablecmds.c
parent0414b26bac09379a4cbf1fbd847d1cee2293c5e4 (diff)
downloadpostgresql-a3dc8e495b4967fe07086a700d115c89f4f0add0.tar.gz
postgresql-a3dc8e495b4967fe07086a700d115c89f4f0add0.zip
Make partitions automatically inherit OIDs.
Previously, if the parent was specified as WITH OIDS, each child also had to be explicitly specified as WITH OIDS. Amit Langote, per a report from Simon Riggs. Some additional work on the documentation changes by me. Discussion: http://postgr.es/m/CANP8+jJBpWocfKrbJcaf3iBt9E3U=WPE_NC8YE6rye+YJ1sYnQ@mail.gmail.com
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r--src/backend/commands/tablecmds.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index f33aa70da69..3cea2204219 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -634,19 +634,14 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
relkind == RELKIND_PARTITIONED_TABLE));
descriptor->tdhasoid = (localHasOids || parentOidCount > 0);
- if (stmt->partbound)
- {
- /* If the parent has OIDs, partitions must have them too. */
- if (parentOidCount > 0 && !localHasOids)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("cannot create table without OIDs as partition of table with OIDs")));
- /* If the parent doesn't, partitions must not have them. */
- if (parentOidCount == 0 && localHasOids)
- ereport(ERROR,
- (errcode(ERRCODE_WRONG_OBJECT_TYPE),
- errmsg("cannot create table with OIDs as partition of table without OIDs")));
- }
+ /*
+ * If a partitioned table doesn't have the system OID column, then none
+ * of its partitions should have it.
+ */
+ if (stmt->partbound && parentOidCount == 0 && localHasOids)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("cannot create table with OIDs as partition of table without OIDs")));
/*
* Find columns with default values and prepare for insertion of the