diff options
author | Andres Freund <andres@anarazel.de> | 2019-04-04 17:17:50 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2019-04-04 17:39:39 -0700 |
commit | ea97e440b8570ffd1a6cd6604f2ef882c0a72291 (patch) | |
tree | 97a95c62374d8cfa6ff2a8f1e539faf5314464be /src/backend/commands/amcmds.c | |
parent | 344b7e11bbaf5e11f2497b11405e63d190043cfe (diff) |
Harden tableam against nonexistant / wrong kind of AMs.
Previously it was allowed to set default_table_access_method to an
empty string. That makes sense for default_tablespace, where that was
copied from, as it signals falling back to the database's default
tablespace. As there is no equivalent for table AMs, forbid that.
Also make sure to throw a usable error when creating a table using an
index AM, by using get_am_type_oid() to implement get_table_am_oid()
instead of a separate copy. Previously we'd error out only later, in
GetTableAmRoutine().
Thirdly remove GetTableAmRoutineByAmId() - it was only used in an
earlier version of 8586bf7ed8.
Add tests for the above (some for index AMs as well).
Diffstat (limited to 'src/backend/commands/amcmds.c')
-rw-r--r-- | src/backend/commands/amcmds.c | 10 |
1 files changed, 10 insertions, 0 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. */ |