Reserve prefixes for loaded libraries proposal - Mailing list pgsql-hackers

From Florin Irion
Subject Reserve prefixes for loaded libraries proposal
Date
Msg-id CA+HEvJDhWuuTpGTJT9Tgbdzm4QS4EzPAwDBScWK18H2Q=FVJFw@mail.gmail.com
Whole thread Raw
Responses Re: Reserve prefixes for loaded libraries proposal
Re: Reserve prefixes for loaded libraries proposal
List pgsql-hackers
Hello,

If we set a parameter in the postgresql.conf that the loaded library doesn't
recognize at startup, it throws a warning.
For example if one sets `plpgsql.no_such_setting` for plpgsql:

```
WARNING: unrecognized configuration parameter "plpgsql.no_such_setting"
```

We could also help users get a warning if they set a parameter with the `SET`
command. I've seen many cases where users make typos and break things badly,
check the following example:

```
postgres=# BEGIN;
BEGIN
postgres=*# SET plpgsql.no_such_setting = false;
SET
postgres=*# -- do critical queries taking into account that plpgsql.no_such_setting is false;
postgres=*# COMMIT;
COMMIT
```

I propose to make the user aware of such mistakes. I also made the patch only
to warn the user but still correctly `SET` the parameter so that he is the one
that chooses if he wants to continue or `ROLLBACK`. I don't know if this last
part is correct, but at least it doesn't break any previous implementation.

This is what I mean:

```
postgres=# BEGIN;
BEGIN
postgres=*# SET plpgsql.no_such_setting = false;
WARNING: unrecognized configuration parameter "plpgsql.no_such_setting"
DETAIL: "plpgsql" is a reserved prefix.
HINT: If you need to create a custom placeholder use a different prefix.
SET
postgres=*# -- choose to continue or not based on the warning
postgres=*# ROLLBACK or COMMIT
```

The patch I'm attaching is registering the prefix for all the loaded libraries,
and eventually, it uses them to check if any parameter is recognized,just as we
do at startup.

Please, let me know what you think.

Cheers,
Florin Irion

Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: PATH manipulation in 001_libpq_pipeline.pl fails on windows
Next
From: David Rowley
Date:
Subject: Re: Record a Bitmapset of non-pruned partitions