Thread
-
Custom reloptions in TableAM
Nikita Malakhov <hukutoc@gmail.com> — 2025-06-20T20:09:01Z
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/ -
Re: Custom reloptions in TableAM
Srinath Reddy Sadipiralla <srinath2133@gmail.com> — 2025-06-21T02:54:15Z
On Sat, Jun 21, 2025 at 1:39 AM Nikita Malakhov <hukutoc@gmail.com> wrote: > 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=..., ...); > I think there are some similar efforts going on ,you can check in this thread [0]. [0] https://www.postgresql.org/message-id/flat/20250302085641.hmjom5ru3w554t2n%40poseidon.home.virt -- Thanks, Srinath Reddy Sadipiralla EDB: https://www.enterprisedb.com/
-
Re: Custom reloptions in TableAM
Nikita Malakhov <hukutoc@gmail.com> — 2025-06-21T03:04:22Z
Hi! Thank you very much, I'll check it out. -- Regards, Nikita Malakhov Postgres Professional The Russian Postgres Company https://postgrespro.ru/
-
Re: Custom reloptions in TableAM
Michael Paquier <michael@paquier.xyz> — 2025-06-21T03:54:15Z
On Fri, Jun 20, 2025 at 11:09:01PM +0300, Nikita Malakhov wrote: > 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. Your patch touches the backend, but there is no real way to check whether it is correct. I would suggest revisiting an idea of dummy table AM module added to src/test/modules/. This has been proposed one year ago if I recall correctly on pgsql-hackers, and I did argue that there was little value in having it as long as it does not provide specific test coverage. The additions you are suggesting to would be a reason enough for having such a module, IMO, validating the correctness of what you are proposing. -- Michael