diff options
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/amcmds.c | 10 | ||||
-rw-r--r-- | src/backend/commands/tablecmds.c | 17 |
2 files changed, 12 insertions, 15 deletions
diff --git a/src/backend/commands/amcmds.c b/src/backend/commands/amcmds.c index 24ca18018e1..c1603737eb5 100644 --- a/src/backend/commands/amcmds.c +++ b/src/backend/commands/amcmds.c @@ -190,6 +190,16 @@ get_index_am_oid(const char *amname, bool missing_ok) } /* + * get_table_am_oid - given an access method name, look up its OID + * and verify it corresponds to an table AM. + */ +Oid +get_table_am_oid(const char *amname, bool missing_ok) +{ + return get_am_type_oid(amname, AMTYPE_TABLE, missing_ok); +} + +/* * get_am_oid - given an access method name, look up its OID. * The type is not checked. */ diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 58eb7e1d8e8..e842f9152b7 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -832,22 +832,9 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, relkind == RELKIND_MATVIEW) accessMethod = default_table_access_method; - /* - * look up the access method, verify it can handle the requested features - */ + /* look up the access method, verify it is for a table */ if (accessMethod != NULL) - { - HeapTuple tuple; - - tuple = SearchSysCache1(AMNAME, PointerGetDatum(accessMethod)); - if (!HeapTupleIsValid(tuple)) - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("table access method \"%s\" does not exist", - accessMethod))); - accessMethodId = ((Form_pg_am) GETSTRUCT(tuple))->oid; - ReleaseSysCache(tuple); - } + accessMethodId = get_table_am_oid(accessMethod, false); /* * Create the relation. Inherited defaults and constraints are passed in |