mirror of
https://github.com/postgres/postgres.git
synced 2025-10-15 05:46:52 +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:
@@ -85,6 +85,9 @@ create_ctas_internal(List *attrList, IntoClause *into)
|
||||
Datum toast_options;
|
||||
static char *validnsps[] = HEAP_RELOPT_NAMESPACES;
|
||||
ObjectAddress intoRelationAddr;
|
||||
const TableAmRoutine *tableam = NULL;
|
||||
Oid accessMethodId = InvalidOid;
|
||||
Relation rel;
|
||||
|
||||
/* This code supports both CREATE TABLE AS and CREATE MATERIALIZED VIEW */
|
||||
is_matview = (into->viewQuery != NULL);
|
||||
@@ -125,7 +128,15 @@ create_ctas_internal(List *attrList, IntoClause *into)
|
||||
validnsps,
|
||||
true, false);
|
||||
|
||||
(void) heap_reloptions(RELKIND_TOASTVALUE, toast_options, true);
|
||||
rel = relation_open(intoRelationAddr.objectId, AccessShareLock);
|
||||
accessMethodId = table_relation_toast_am(rel);
|
||||
relation_close(rel, AccessShareLock);
|
||||
|
||||
if (OidIsValid(accessMethodId))
|
||||
{
|
||||
tableam = GetTableAmRoutineByAmOid(accessMethodId);
|
||||
(void) tableam_reloptions(tableam, RELKIND_TOASTVALUE, toast_options, NULL, true);
|
||||
}
|
||||
|
||||
NewRelationCreateToastTable(intoRelationAddr.objectId, toast_options);
|
||||
|
||||
|
Reference in New Issue
Block a user