1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Add support for DEFAULT in ALTER TABLE .. SET ACCESS METHOD

This option can be used to switch a relation to use the access method
set by default_table_access_method when running the command.

This has come up when discussing the possibility to support setting
pg_class.relam for partitioned tables (left out here as future work),
while being useful on its own for relations with physical storage as
these must have an access method set.

Per suggestion from Justin Pryzby.

Author: Michael Paquier
Reviewed-by: Justin Pryzby
Discussion: https://postgr.es/m/ZeCZ89xAVFeOmrQC@pryzbyj2023
This commit is contained in:
Michael Paquier
2024-03-08 09:31:52 +09:00
parent 4f8c1e7aaf
commit d61a6cad64
6 changed files with 52 additions and 6 deletions

View File

@ -15202,6 +15202,7 @@ ATExecDropCluster(Relation rel, LOCKMODE lockmode)
*
* Check that access method exists. If it is the same as the table's current
* access method, it is a no-op. Otherwise, a table rewrite is necessary.
* If amname is NULL, select default_table_access_method as access method.
*/
static void
ATPrepSetAccessMethod(AlteredTableInfo *tab, Relation rel, const char *amname)
@ -15209,7 +15210,8 @@ ATPrepSetAccessMethod(AlteredTableInfo *tab, Relation rel, const char *amname)
Oid amoid;
/* Check that the table access method exists */
amoid = get_table_am_oid(amname, false);
amoid = get_table_am_oid(amname ? amname : default_table_access_method,
false);
if (rel->rd_rel->relam == amoid)
return;