From: | Nikita Malakhov <hukutoc(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Custom reloptions in TableAM |
Date: | 2025-06-20 20:09:01 |
Message-ID: | CAN-LCVNFCCrAUnwZyKwQNxgh+sURdN4hxAfHmptuys0s5dxgKg@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi hackers!
While developing an alternative Table AM I've stumbled
upon the impossibility to set custom reloptions to the table
created by Table AM, like it could be done for Index AM.
I haven't found any comments on this and implemented
a mechanism of setting custom reloptions for a relation
created with Table AM, if needed. These options are stored
in Relcache and are accessed through the rd_options field.
The main scenario for custom reloptions is something like:
CREATE TABLE t (...) USING myTableAM WITH (custom_opt1=..., ...);
and myTableAM should implement custom options function,
like Index AM, and assign in to an amoptions field:
bytea *myamoptions(Datum reloptions, bool validate)
{
myAMOptions *rdopts;
static const relopt_parse_elt tab[] = {
{"custom_opt1", RELOPT_TYPE_INT, offsetof(myAMOptions, customOpt1)},
...
};
/* Parse the user-given reloptions */
rdopts = (myAMOptions *) build_reloptions(reloptions, validate,
my_relopt_kind,
sizeof(myAMOptions),
tab,
lengthof(tab));
return (bytea *) rdopts;
}
Hope you'll find it useful.
Advice and objections are welcome.
POC patch in attachment.
--
Regards,
Nikita Malakhov
Postgres Professional
The Russian Postgres Company
https://postgrespro.ru/
Attachment | Content-Type | Size |
---|---|---|
v1-0001-tableam-relopts.patch | application/octet-stream | 7.9 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Nathan Bossart | 2025-06-20 20:31:04 | Re: add function for creating/attaching hash table in DSM registry |
Previous Message | Anne Struble | 2025-06-20 19:27:01 | Memory allocation error DDL invalidation (seen with 15.13 & 16.9) |