@@ -715,7 +715,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
715715 ObjectAddress address;
716716 LOCKMODE parentLockmode;
717717 Oid accessMethodId = InvalidOid;
718- const TableAmRoutine *tableam = NULL;
719718
720719 /*
721720 * Truncate relname to appropriate length (probably a waste of time, as
@@ -851,28 +850,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
851850 if (!OidIsValid(ownerId))
852851 ownerId = GetUserId();
853852
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-
876853 /*
877854 * Parse and validate reloptions, if any.
878855 */
@@ -881,12 +858,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
881858
882859 switch (relkind)
883860 {
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;
890861 case RELKIND_VIEW:
891862 (void) view_reloptions(reloptions, true);
892863 break;
@@ -895,7 +866,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
895866 break;
896867 default:
897868 (void) heap_reloptions(relkind, reloptions, true);
898- break;
899869 }
900870
901871 if (stmt->ofTypename)
@@ -987,6 +957,28 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
987957 }
988958 }
989959
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+
990982 /*
991983 * Create the relation. Inherited defaults and constraints are passed in
992984 * for immediate handling --- since they don't need parsing, they can be
@@ -15536,8 +15528,7 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1553615528 case RELKIND_RELATION:
1553715529 case RELKIND_TOASTVALUE:
1553815530 case RELKIND_MATVIEW:
15539- (void) table_reloptions(rel, rel->rd_rel->relkind,
15540- newOptions, true);
15531+ (void) heap_reloptions(rel->rd_rel->relkind, newOptions, true);
1554115532 break;
1554215533 case RELKIND_PARTITIONED_TABLE:
1554315534 (void) partitioned_table_reloptions(newOptions, true);
0 commit comments