pgsql: Harden tableam against nonexistant / wrong kind of AMs. - Mailing list pgsql-committers

From Andres Freund
Subject pgsql: Harden tableam against nonexistant / wrong kind of AMs.
Date
Msg-id E1hCCxS-0006lM-PV@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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).

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ea97e440b8570ffd1a6cd6604f2ef882c0a72291

Modified Files
--------------
src/backend/access/table/tableamapi.c     | 110 +++++-------------------------
src/backend/commands/amcmds.c             |  10 +++
src/backend/commands/tablecmds.c          |  17 +----
src/include/access/tableam.h              |   1 -
src/include/commands/defrem.h             |   1 +
src/test/regress/expected/create_am.out   |  33 +++++++++
src/test/regress/expected/type_sanity.out |  18 +++++
src/test/regress/sql/create_am.sql        |  27 ++++++++
src/test/regress/sql/type_sanity.sql      |  12 ++++
9 files changed, 119 insertions(+), 110 deletions(-)


pgsql-committers by date:

Previous
From: Peter Geoghegan
Date:
Subject: pgsql: Add test coverage for rootdescend verification.
Next
From: Michael Paquier
Date:
Subject: pgsql: Fix some documentation in pg_rewind