diff options
Diffstat (limited to 'src/backend/tcop')
-rw-r--r-- | src/backend/tcop/utility.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 4992c22bbbf..79aba2acbcb 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -995,6 +995,7 @@ ProcessUtilitySlow(ParseState *pstate, { List *stmts; ListCell *l; + RangeVar *table_rv = NULL; /* Run parse analysis ... */ stmts = transformCreateStmt((CreateStmt *) parsetree, @@ -1007,11 +1008,15 @@ ProcessUtilitySlow(ParseState *pstate, if (IsA(stmt, CreateStmt)) { + CreateStmt *cstmt = (CreateStmt *) stmt; Datum toast_options; static char *validnsps[] = HEAP_RELOPT_NAMESPACES; + /* Remember transformed RangeVar for LIKE */ + table_rv = cstmt->relation; + /* Create the table itself */ - address = DefineRelation((CreateStmt *) stmt, + address = DefineRelation(cstmt, RELKIND_RELATION, InvalidOid, NULL, queryString); @@ -1030,7 +1035,7 @@ ProcessUtilitySlow(ParseState *pstate, * table */ toast_options = transformRelOptions((Datum) 0, - ((CreateStmt *) stmt)->options, + cstmt->options, "toast", validnsps, true, @@ -1044,12 +1049,17 @@ ProcessUtilitySlow(ParseState *pstate, } else if (IsA(stmt, CreateForeignTableStmt)) { + CreateForeignTableStmt *cstmt = (CreateForeignTableStmt *) stmt; + + /* Remember transformed RangeVar for LIKE */ + table_rv = cstmt->base.relation; + /* Create the table itself */ - address = DefineRelation((CreateStmt *) stmt, + address = DefineRelation(&cstmt->base, RELKIND_FOREIGN_TABLE, InvalidOid, NULL, queryString); - CreateForeignTable((CreateForeignTableStmt *) stmt, + CreateForeignTable(cstmt, address.objectId); EventTriggerCollectSimpleCommand(address, secondaryObject, @@ -1064,10 +1074,11 @@ ProcessUtilitySlow(ParseState *pstate, * to-do list. */ TableLikeClause *like = (TableLikeClause *) stmt; - RangeVar *rv = ((CreateStmt *) parsetree)->relation; List *morestmts; - morestmts = expandTableLikeClause(rv, like); + Assert(table_rv != NULL); + + morestmts = expandTableLikeClause(table_rv, like); stmts = list_concat(stmts, morestmts); /* |