1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +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

@@ -338,6 +338,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> alter_identity_column_option_list
%type <defelt> alter_identity_column_option
%type <node> set_statistics_value
%type <str> set_access_method_name
%type <list> createdb_opt_list createdb_opt_items copy_opt_list
transaction_mode_list
@@ -2859,8 +2860,8 @@ alter_table_cmd:
n->newowner = $3;
$$ = (Node *) n;
}
/* ALTER TABLE <name> SET ACCESS METHOD <amname> */
| SET ACCESS METHOD name
/* ALTER TABLE <name> SET ACCESS METHOD { <amname> | DEFAULT } */
| SET ACCESS METHOD set_access_method_name
{
AlterTableCmd *n = makeNode(AlterTableCmd);
@@ -3076,6 +3077,11 @@ set_statistics_value:
| DEFAULT { $$ = NULL; }
;
set_access_method_name:
ColId { $$ = $1; }
| DEFAULT { $$ = NULL; }
;
PartitionBoundSpec:
/* a HASH partition */
FOR VALUES WITH '(' hash_partbound ')'