0

I've seen some PostgreSQL extension examples that use the .control file to provide defaults for the extension's settings. This seems to be a remnant from a time in which extension settings had to be provided in the .control file for them to be valid to Postgres at all. My question is: Has putting the extension settings in the .control file ever been a required or recommended practice?

I don't see anything in the current pg_extension or pg_available_extension_versions catalogs that would suggest such a practice.

Edit 2022-01-08: My question wasn't sufficiently clear. I was specifically talking above about run-time configuration settings (such as can be set and get via current_setting() and set_config()). I was not referring to control file parameters, which are neatly described in the official documentation.

2 Answers 2

0

You didn't look at the PostgreSQL documentation. You need a .control file for an extension:

The CREATE EXTENSION command relies on a control file for each extension, which must be named the same as the extension with a suffix of .control, and must be placed in the installation's SHAREDIR/extension directory.

4
  • I apologize. My question was insufficiently clear. I was not talking about control file parameters, as you linked to, but to run-time configuration settings. I've edited my question to be more clear. To salvage my ego: I did read the documentation, enough so that my public PL/pgSQL extension count is 7 (all of them with a .control file 😉): pgxn.org/user/bigsmoke
    – BigSmoke
    Jan 8, 2023 at 17:30
  • I don't think that a parameter can be permanently set in a control file (other than with ALTER DATABASE). Could you edit the question and show an example of what you mean? Jan 9, 2023 at 5:13
  • I since found out that my question was crappy to begin with and answered it myself.
    – BigSmoke
    Jan 9, 2023 at 17:52
  • By the way: my question was not about this, but if you ever find yourself wanting to treat DB (role) settings as unalterable, my pg_safer_settings extension has a pg_db_setting(text, regrole) function as an example of how to do precisely this.
    – BigSmoke
    Jan 9, 2023 at 17:55
0

As the adage goes, “a couple of years in the laboratory can often save a few hours in the library”. But, when it comes to programming, wasting my own and others' time on stackexchange.com can often save a 5-minute experiment.

I ran the experiment. It is not even possible to add settings of the type extension_name.setting_name to the .control file. I don't know where I picked up the impression that this was ever possible. I must have mismatched some different fragments of the documentation in my head at some point.

Anyhow, apologies for wasting the time of those who paid attention to my crappy question, @laurenz-albe in particular.

Worst thing: after running the experiment, I finally did recall that I already ran the experiment once before. 🤦‍♂️

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.