@@ -715,6 +715,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
715715 ObjectAddress address;
716716 LOCKMODE parentLockmode;
717717 Oid accessMethodId = InvalidOid;
718+ const TableAmRoutine *tableam = NULL;
718719
719720 /*
720721 * Truncate relname to appropriate length (probably a waste of time, as
@@ -850,6 +851,28 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
850851 if (!OidIsValid(ownerId))
851852 ownerId = GetUserId();
852853
854+ /*
855+ * For relations with table AM and partitioned tables, select access
856+ * method to use: an explicitly indicated one, or (in the case of a
857+ * partitioned table) the parent's, if it has one.
858+ */
859+ if (stmt->accessMethod != NULL)
860+ {
861+ Assert(RELKIND_HAS_TABLE_AM(relkind) || relkind == RELKIND_PARTITIONED_TABLE);
862+ accessMethodId = get_table_am_oid(stmt->accessMethod, false);
863+ }
864+ else if (RELKIND_HAS_TABLE_AM(relkind) || relkind == RELKIND_PARTITIONED_TABLE)
865+ {
866+ if (stmt->partbound)
867+ {
868+ Assert(list_length(inheritOids) == 1);
869+ accessMethodId = get_rel_relam(linitial_oid(inheritOids));
870+ }
871+
872+ if (RELKIND_HAS_TABLE_AM(relkind) && !OidIsValid(accessMethodId))
873+ accessMethodId = get_table_am_oid(default_table_access_method, false);
874+ }
875+
853876 /*
854877 * Parse and validate reloptions, if any.
855878 */
@@ -858,6 +881,12 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
858881
859882 switch (relkind)
860883 {
884+ case RELKIND_RELATION:
885+ case RELKIND_TOASTVALUE:
886+ case RELKIND_MATVIEW:
887+ tableam = GetTableAmRoutineByAmOid(accessMethodId);
888+ (void) tableam_reloptions(tableam, relkind, reloptions, true);
889+ break;
861890 case RELKIND_VIEW:
862891 (void) view_reloptions(reloptions, true);
863892 break;
@@ -866,6 +895,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
866895 break;
867896 default:
868897 (void) heap_reloptions(relkind, reloptions, true);
898+ break;
869899 }
870900
871901 if (stmt->ofTypename)
@@ -957,28 +987,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
957987 }
958988 }
959989
960- /*
961- * For relations with table AM and partitioned tables, select access
962- * method to use: an explicitly indicated one, or (in the case of a
963- * partitioned table) the parent's, if it has one.
964- */
965- if (stmt->accessMethod != NULL)
966- {
967- Assert(RELKIND_HAS_TABLE_AM(relkind) || relkind == RELKIND_PARTITIONED_TABLE);
968- accessMethodId = get_table_am_oid(stmt->accessMethod, false);
969- }
970- else if (RELKIND_HAS_TABLE_AM(relkind) || relkind == RELKIND_PARTITIONED_TABLE)
971- {
972- if (stmt->partbound)
973- {
974- Assert(list_length(inheritOids) == 1);
975- accessMethodId = get_rel_relam(linitial_oid(inheritOids));
976- }
977-
978- if (RELKIND_HAS_TABLE_AM(relkind) && !OidIsValid(accessMethodId))
979- accessMethodId = get_table_am_oid(default_table_access_method, false);
980- }
981-
982990 /*
983991 * Create the relation. Inherited defaults and constraints are passed in
984992 * for immediate handling --- since they don't need parsing, they can be
@@ -15524,7 +15532,8 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1552415532 case RELKIND_RELATION:
1552515533 case RELKIND_TOASTVALUE:
1552615534 case RELKIND_MATVIEW:
15527- (void) heap_reloptions(rel->rd_rel->relkind, newOptions, true);
15535+ (void) table_reloptions(rel, rel->rd_rel->relkind,
15536+ newOptions, true);
1552815537 break;
1552915538 case RELKIND_PARTITIONED_TABLE:
1553015539 (void) partitioned_table_reloptions(newOptions, true);
0 commit comments