diff options
Diffstat (limited to 'src/backend/tcop/utility.c')
-rw-r--r-- | src/backend/tcop/utility.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index fa66b8017ed..c6bb3e45da4 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -65,6 +65,7 @@ #include "utils/acl.h" #include "utils/guc.h" #include "utils/lsyscache.h" +#include "access/relation.h" /* Hook for plugins to get control in ProcessUtility() */ ProcessUtility_hook_type ProcessUtility_hook = NULL; @@ -1156,6 +1157,9 @@ ProcessUtilitySlow(ParseState *pstate, CreateStmt *cstmt = (CreateStmt *) stmt; Datum toast_options; static char *validnsps[] = HEAP_RELOPT_NAMESPACES; + const TableAmRoutine *tableam = NULL; + Oid accessMethodId; + Relation rel; /* Remember transformed RangeVar for LIKE */ table_rv = cstmt->relation; @@ -1185,9 +1189,27 @@ ProcessUtilitySlow(ParseState *pstate, validnsps, true, false); - (void) heap_reloptions(RELKIND_TOASTVALUE, - toast_options, - true); + + /* + * Get toast table AM to validate its options. + * Only relevant if table itself has a table AM. + * We don't need to place the lock given that + * DefineRelation() already placed the + * AccessExclusiveLock. + */ + rel = relation_open(address.objectId, NoLock); + accessMethodId = rel->rd_tableam ? + table_relation_toast_am(rel) : InvalidOid; + relation_close(rel, NoLock); + + if (OidIsValid(accessMethodId)) + { + tableam = GetTableAmRoutineByAmOid(accessMethodId); + (void) tableam_reloptions(tableam, RELKIND_TOASTVALUE, + toast_options, + NULL, + true); + } NewRelationCreateToastTable(address.objectId, toast_options); |