pgsql: Harden tableam against nonexistant / wrong kind of AMs.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Harden tableam against nonexistant / wrong kind of AMs.
Date: 2019-04-05 00:43:50
Message-ID: E1hCCxS-0006lM-PV@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2019-04-05 01:39:36 pgsql: Fix some documentation in pg_rewind
Previous Message Peter Geoghegan 2019-04-05 00:26:24 pgsql: Add test coverage for rootdescend verification.