1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-04 20:11:56 +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:
Alexander Korotkov
2024-04-08 11:23:28 +03:00
parent 6f3d8d5e7c
commit 9bd99f4c26
29 changed files with 639 additions and 161 deletions

View File

@@ -750,7 +750,7 @@ table_block_relation_estimate_size(Relation rel, int32 *attr_widths,
* The other branch considers it implicitly by calculating density
* from actual relpages/reltuples statistics.
*/
fillfactor = RelationGetFillFactor(rel, HEAP_DEFAULT_FILLFACTOR);
fillfactor = HeapGetFillFactor(rel, HEAP_DEFAULT_FILLFACTOR);
tuple_width = get_rel_data_width(rel, attr_widths);
tuple_width += overhead_bytes_per_tuple;

View File

@@ -13,9 +13,11 @@
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/pg_am.h"
#include "commands/defrem.h"
#include "miscadmin.h"
#include "utils/guc_hooks.h"
#include "utils/syscache.h"
/*
@@ -98,6 +100,29 @@ GetTableAmRoutine(Oid amhandler)
return routine;
}
/*
* GetTableAmRoutineByAmOid
* Given the table access method oid get its TableAmRoutine struct, which
* will be palloc'd in the caller's memory context.
*/
const TableAmRoutine *
GetTableAmRoutineByAmOid(Oid amoid)
{
HeapTuple ht_am;
Form_pg_am amrec;
const TableAmRoutine *tableam = NULL;
ht_am = SearchSysCache1(AMOID, ObjectIdGetDatum(amoid));
if (!HeapTupleIsValid(ht_am))
elog(ERROR, "cache lookup failed for access method %u",
amoid);
amrec = (Form_pg_am) GETSTRUCT(ht_am);
tableam = GetTableAmRoutine(amrec->amhandler);
ReleaseSysCache(ht_am);
return tableam;
}
/* check_hook: validate new default_table_access_method */
bool
check_default_table_access_method(char **newval, void **extra, GucSource source)