Feature: Add reloption support for table access method

From: 吴昊 <wuhao(at)hashdata(dot)cn>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Feature: Add reloption support for table access method
Date: 2023-05-05 08:44:39
Message-ID: AMUA1wBBBxfc3tKRLLdU64rb.1.1683276279979.Hmail.wuhao@hashdata.cn
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi pg-hackers,

When I wrote an extension to implement a new storage by table access method. I found some issues
that the existing code has strong assumptions for heap tables now. Here are 3 issues that I currently have:

1. Index access method has a callback to handle reloptions, but table access method hasn't. We can't
add storage-specific parameters by `WITH` clause when creating a table.
2. Existing code strongly assumes that the data file of a table structures by a serial physical files named
in a hard coded rule: <relfilenode>[.<segno>]. It may only fit for heap like tables. A new storage may have its
owner structure on how the data files are organized. The problem happens when dropping a table.

3. The existing code also assumes that the data file consists of a series of fix-sized block. It may not
be desired by other storage. Is there any suggestions on this situation?

The rest of this mail is to talk about the first issue. It looks reasonable to add a similar callback in
struct TableAmRoutine, and parse reloptions by the callback. This patch is in the attachment file.

Another thing about reloption is that the current API passes a parameter `validate` to tell the parse
functioin to check and whether to raise an error. It doesn't have enough context when these reloptioins
are used:
1. CREATE TABLE ... WITH(...)
2. ALTER TABLE ... SET ...
3. ALTER TABLE ... RESET ...
The reason why the context matters is that some reloptions are disallowed to change after creating
the table, while some reloptions are allowed.

I wonder if this change makes sense for you.

The attached patch only supports callback for TAM-specific implementation, not include the change
about usage context.

Regards,
Hao Wu

Attachment Content-Type Size
reloptions.diffs application/octet-stream 22.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2023-05-05 09:15:36 Re: A bug with ExecCheckPermissions
Previous Message Drouvot, Bertrand 2023-05-05 07:46:41 Re: Add two missing tests in 035_standby_logical_decoding.pl