Skip to content

Latest commit

 

History

History
92 lines (63 loc) · 3.72 KB

20240309_01.md

File metadata and controls

92 lines (63 loc) · 3.72 KB

PostgreSQL 17 preview - Add support for DEFAULT in ALTER TABLE .. SET ACCESS METHOD

作者

digoal

日期

2024-03-09

标签

PostgreSQL , PolarDB , DuckDB , table access method , default_table_access_method


背景

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=d61a6cad6418f643a5773352038d0dfe5d3535b8

Add support for DEFAULT in ALTER TABLE .. SET ACCESS METHOD  
  
author  Michael Paquier <michael@paquier.xyz>   
Fri, 8 Mar 2024 00:31:52 +0000 (09:31 +0900)  
committer Michael Paquier <michael@paquier.xyz>   
Fri, 8 Mar 2024 00:31:52 +0000 (09:31 +0900)  
commit  d61a6cad6418f643a5773352038d0dfe5d3535b8  
tree  10791cac8cc32610b5784768d966b2eaa0109f67  tree  
parent  4f8c1e7aaf11c42fa658eeab9baef0a035e76fe2  commit | diff  
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  

例子

+-- DEFAULT access method  
+BEGIN;  
+SET LOCAL default_table_access_method TO heap2;  
+ALTER TABLE heaptable SET ACCESS METHOD DEFAULT;  
+SELECT amname FROM pg_class c, pg_am am  
+  WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass;  
+ amname   
+--------  
+ heap2  
+(1 row)  
+  
+SET LOCAL default_table_access_method TO heap;  
+ALTER TABLE heaptable SET ACCESS METHOD DEFAULT;  
+SELECT amname FROM pg_class c, pg_am am  
+  WHERE c.relam = am.oid AND c.oid = 'heaptable'::regclass;  
+ amname   
+--------  
+ heap  
+(1 row)  
+  
+ROLLBACK;  

digoal's wechat