diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/commands/tablecmds.c | 3 | ||||
-rw-r--r-- | src/backend/parser/gram.y | 1 | ||||
-rw-r--r-- | src/backend/tcop/utility.c | 6 |
3 files changed, 9 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index d219d220691..82dabe636f8 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -20391,6 +20391,7 @@ createPartitionTable(RangeVar *newPartName, Relation modelRel, tlc->options = CREATE_TABLE_LIKE_ALL & ~(CREATE_TABLE_LIKE_INDEXES | CREATE_TABLE_LIKE_IDENTITY | CREATE_TABLE_LIKE_STATISTICS); tlc->relationOid = InvalidOid; + tlc->newRelationOid = InvalidOid; createStmt->tableElts = lappend(createStmt->tableElts, tlc); /* Need to make a wrapper PlannedStmt. */ @@ -20414,7 +20415,7 @@ createPartitionTable(RangeVar *newPartName, Relation modelRel, * Open the new partition with no lock, because we already have * AccessExclusiveLock placed there after creation. */ - newRel = table_openrv(newPartName, NoLock); + newRel = table_open(tlc->newRelationOid, NoLock); /* * We intended to create the partition with the same persistence as the diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index a043fd4c669..f92580c3181 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -4138,6 +4138,7 @@ TableLikeClause: n->relation = $2; n->options = $3; n->relationOid = InvalidOid; + n->newRelationOid = InvalidOid; $$ = (Node *) n; } ; diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index fa66b8017ed..b317c9ae9d6 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -1225,6 +1225,12 @@ ProcessUtilitySlow(ParseState *pstate, morestmts = expandTableLikeClause(table_rv, like); stmts = list_concat(morestmts, stmts); + + /* + * Store the OID of newly created relation to the + * TableLikeClause for the caller to use it. + */ + like->newRelationOid = address.objectId; } else { |