Skip to content

Conversation

@japinli
Copy link
Contributor

@japinli japinli commented Jun 6, 2025

Here is a sentence about session_preload_libraries in the PostgreSQL documentation:

Only superusers and users with the appropriate SET privilege can change this setting.

For a non-superuser without SET privilege, the ALTER DATABASE <dbname> SET session_preload_libraries = ... will cause a permission denied.

postgres=# CREATE USER u01;
CREATE ROLE
postgres=# CREATE DATABASE db01 OWNER u01;
CREATE DATABASE
postgres=# \c db01 u01
You are now connected to database "db01" as user "u01".
db01=> DO $$
BEGIN
    EXECUTE format('ALTER DATABASE %I SET session_preload_libraries = ''$libdir/plugins/pgtt''', current_database());
END
$$;
ERROR:  permission denied to set parameter "session_preload_libraries"
CONTEXT:  SQL statement "ALTER DATABASE db01 SET session_preload_libraries = '$libdir/plugins/pgtt'"
PL/pgSQL function inline_code_block line 3 at EXECUTE

This PR also removes the LOAD '$libdir/plugins/pgtt'; command in the example, because we use session_preload_libraries to load this library.

If we want to keep this command, we should revert the commit ef79a91, since we should link the library into $libdir/plugins.

japinli and others added 2 commits June 6, 2025 13:31
Remove the documentation about suggesting non-superusers can set
session_preload_libraries.  This is incorrect as it triggers a
"permission denied" error, as confirmed by PostgreSQL documentation
stating only superusers or those with SET privilege can modify this
setting [1].

[1]: https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-SESSION-PRELOAD-LIBRARIES
As noted in commit ef79a91, explicit loading is redundant when a library
is managed by session_preload_libraries.
@darold darold merged commit d2e1f9f into darold:master Jun 8, 2025
5 checks passed
@japinli japinli deleted the fix-docs branch June 9, 2025 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants