mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +03:00
Custom reloptions for table AM
Let table AM define custom reloptions for its tables. This allows specifying AM-specific parameters by the WITH clause when creating a table. The reloptions, which could be used outside of table AM, are now extracted into the CommonRdOptions data structure. These options could be by decision of table AM directly specified by a user or calculated in some way. The new test module test_tam_options evaluates the ability to set up custom reloptions and calculate fields of CommonRdOptions on their base. The code may use some parts from prior work by Hao Wu. Discussion: https://postgr.es/m/CAPpHfdurb9ycV8udYqM%3Do0sPS66PJ4RCBM1g-bBpvzUfogY0EA%40mail.gmail.com Discussion: https://postgr.es/m/AMUA1wBBBxfc3tKRLLdU64rb.1.1683276279979.Hmail.wuhao%40hashdata.cn Reviewed-by: Reviewed-by: Pavel Borisov, Matthias van de Meent, Jess Davis
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "access/heapam.h"
|
||||
#include "access/heaptoast.h"
|
||||
#include "access/multixact.h"
|
||||
#include "access/reloptions.h"
|
||||
#include "access/rewriteheap.h"
|
||||
#include "access/syncscan.h"
|
||||
#include "access/tableam.h"
|
||||
@@ -2161,6 +2162,17 @@ heapam_relation_toast_am(Relation rel)
|
||||
return rel->rd_rel->relam;
|
||||
}
|
||||
|
||||
static bytea *
|
||||
heapam_reloptions(char relkind, Datum reloptions,
|
||||
CommonRdOptions *common, bool validate)
|
||||
{
|
||||
Assert(relkind == RELKIND_RELATION ||
|
||||
relkind == RELKIND_TOASTVALUE ||
|
||||
relkind == RELKIND_MATVIEW);
|
||||
|
||||
return heap_reloptions(relkind, reloptions, common, validate);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* Planner related callbacks for the heap AM
|
||||
@@ -2710,6 +2722,7 @@ static const TableAmRoutine heapam_methods = {
|
||||
.relation_needs_toast_table = heapam_relation_needs_toast_table,
|
||||
.relation_toast_am = heapam_relation_toast_am,
|
||||
.relation_fetch_toast_slice = heap_fetch_toast_slice,
|
||||
.reloptions = heapam_reloptions,
|
||||
|
||||
.relation_estimate_size = heapam_estimate_rel_size,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user