[PATCH] SET search_path += octopus

From: Abhijit Menon-Sen <ams(at)toroid(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [PATCH] SET search_path += octopus
Date: 2020-09-28 03:39:24
Message-ID: 20200928033924.GA998042@toroid.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


The first attached patch
(0001-Accept-SET-xyz-pqr-to-add-pqr-to-the-current-setting.patch) adds
support for commands like the following, applicable to any configuration
settings that are represented as a comma-separated list of strings

postgres=# SET search_path += octopus;
postgres=# SET search_path += "giant squid", kraken, narwhal; -- [1]
postgres=# SET search_path -= public, narwhal;
postgres=# SHOW search_path;
│ search_path │
│ "$user", octopus, "giant squid", kraken │
(1 row)

The implementation extends to ALTER SYSTEM SET with next to no effort,
so you can also add entries to shared_preload_libraries without having
to know its current value:

ALTER SYSTEM SET shared_preload_libraries += auto_explain;

The second patch
(0002-Support-SET-syntax-for-numeric-configuration-setting.patch) adds
support to modify numeric configuration settings:

postgres=# SET cpu_tuple_cost += 0.02;
postgres=# SET effective_cache_size += '2GB';
postgres=# SHOW effective_cache_size;
│ effective_cache_size │
│ 6GB │
(1 row)
postgres=# ALTER SYSTEM SET max_worker_processes += 4;

Being able to safely modify shared_preload_libraries (in particular) and
max_worker_processes during automated extension deployments is a problem
I've struggled with more than once in the past.

These patches do not affect configuration file parsing in any way: its
use is limited to "SET" and "ALTER xxx SET". (After I started working on
this, I came to know that this idea has been proposed in different forms
in the past, and objections to those proposals centred around various
difficulties involved in adding this syntax to configuration files. I'm
not particularly fond of that idea, and it's not what I've done here.)

(Another feature that could be implemented using this framework is to
ensure the current setting is at least as large as a given value:

ALTER SYSTEM SET shared_buffers >= '8GB';

This would not change shared_buffers if it were already larger than 8GB.
I have not implemented this, pending feedback on what's already there,
but it would be simple to do.)

Comments welcome.

-- Abhijit

1. This feature supports a wide variety of marine creatures, with no
implied judgement about their status, real or mythical; however,
adding them to shared_preload_libraries is not advisable.

Attachment Content-Type Size
0001-Accept-SET-xyz-pqr-to-add-pqr-to-the-current-setting.patch text/x-diff 13.6 KB
0002-Support-SET-syntax-for-numeric-configuration-setting.patch text/x-diff 5.5 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Hou, Zhijie 2020-09-28 03:42:21 The return value of SPI_connect
Previous Message Greg Nancarrow 2020-09-28 03:14:27 Re: Parallel INSERT (INTO ... SELECT ...)