Re: Proposal to have INCLUDE/EXCLUDE options for altering option values

From: Ayush Vatsa <ayushvatsa1810(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Proposal to have INCLUDE/EXCLUDE options for altering option values
Date: 2024-08-15 06:52:34
Message-ID: CACX+KaPB7r6Ru1iuDEbNCqLCyDw4L24tF+qbpFyVYnQctmHSCA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi PostgreSQL Community,
I would like to provide an update on the patch I previously submitted,
along with a clearer explanation of the issue it addresses
and the improvements it introduces.
Current Issue:
PostgreSQL currently supports several options with actions like ADD, SET,
and DROP for foreign servers, user mappings,
foreign tables, etc. For example, the syntax for modifying a server option
is as follows:

ALTER SERVER name [ VERSION 'new_version' ]
[ OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] ) ]

However, there is a limitations with the current approach:

If a user wants to add new values to an existing option, they can use:
ALTER SERVER foo OPTIONS (ADD extensions 'ext1,ext2');
But when modifying existing values, users must repeat all the existing
values along with the new ones:
ALTER SERVER foo OPTIONS (ADD extensions 'ext1,ext2');
ALTER SERVER foo OPTIONS (SET extensions 'ext1,ext2,ext3');

This repetition can be cumbersome and error-prone when there are large
number of comma separated values.

Proposed Solution:
To address this, I propose introducing two new actions: APPEND and REMOVE.
These will allow users to modify existing
values without needing to repeat all current entries.
ALTER SERVER foo OPTIONS (APPEND extensions 'ext4,ext5,ext6');
--extensions will be like 'ext1,ext2,ext3,ext4,ext5,ext6'
ALTER SERVER foo OPTIONS (REMOVE extensions 'ext1');
--extensions will be like 'ext2,ext4,ext5,ext6'

I had an off-site discussion with Nathan Bossart (bossartn) and have
incorporated his feedback about changing actions
name to be more clear into the updated patch. Furthermore, I noticed that
the documentation for the existing actions
could be clearer, so I have revised it as well. The documentation for the
newly proposed actions is included in a separate patch.
Looking forward to your comments and feedback.

Regards
Ayush Vatsa
AWS

Attachment Content-Type Size
v2-0001-Enhance-ALTER-statement-with-extended-support-for.patch application/octet-stream 12.2 KB
v2-0002-fix-alter_server-alter_foreign_data_wrapper-alter.patch application/octet-stream 17.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-08-15 06:56:00 Re: Remove dependence on integer wrapping
Previous Message Peter Eisentraut 2024-08-15 06:38:38 Re: Enable data checksums by default