What is the bug or the crash?
The “Session Role” function does not seem to work correctly in QGIS 3.40.6.
When editing the PostGIS connection, I can specify the session role. When I click “Test Connection” and then ‘OK’, I can see in the diagnostic tools that the command SET Role ‘xx’; is executed.
However, when I then load a dataset from a schema into QGIS, a new session is created. Accordingly, the permissions of the role using the SET ROLE command are not applied.
To verify the behavior of QGIS, I analyzed the PostgreSQL logs. After closing the PostGIS connection window, QGIS executes the command SET ROLE XX as shown in the diagnostic tools. When loading a DB table, a new session with the DB is then started. The sessions all have different PIDs, which means that SET ROLE XX does not apply to subsequent sessions.
We use QGIS in conjunction with a PostgreSQL/PostGIS database (version 15.14). In pgAdmin, I can use the same commands within a session to adjust the permissions with the SET ROLE function.
Steps to reproduce the issue
- Set a "Session Role" in the PostGIS Connection
- Check if you can load a DB-table, where you should not have access to, according to the indicated session role.
Versions
| QGIS-Version | 3.40.6-Bratislava |
| QGIS-Codeversion | 5d7f6a3e26 |
| |
| Bibliotheken |
| Qt-Version | 5.15.13 |
| Python-Version | 3.12.10 |
| GDAL-Version | 3.10.3 |
| PROJ-Version | 9.6.0 |
| EPSG-Registraturdatenbankversion | v12.004 (2025-03-02) |
| GEOS-Version | 3.13.1-CAPI-1.19.2 |
| SQLite-Version | 3.46.1 |
| PDAL-Version | 2.8.3 |
| PostgreSQL-Client-Version | unknown |
| SpatiaLite-Version | 5.1.0 |
| QWT-Version | 6.3.0 |
| QScintilla2-Version | 2.14.1 |
| BS-Version | Windows 11 Version 2009 |
| |
| Aktive Python-Erweiterungen |
| ThurgisToolbar | 1.1 |
| custom_news_feed | v1.2.3 |
| QgisModelBaker | v7.11.2 |
| lrseditor | 1.4.0 |
| processing | 2.12.99 |
| swiss_locator | 4.0.0 |
Supported QGIS version
New profile
Additional context
No response
What is the bug or the crash?
The “Session Role” function does not seem to work correctly in QGIS 3.40.6.
When editing the PostGIS connection, I can specify the session role. When I click “Test Connection” and then ‘OK’, I can see in the diagnostic tools that the command
SET Role ‘xx’;is executed.However, when I then load a dataset from a schema into QGIS, a new session is created. Accordingly, the permissions of the role using the
SET ROLEcommand are not applied.To verify the behavior of QGIS, I analyzed the PostgreSQL logs. After closing the PostGIS connection window, QGIS executes the command
SET ROLE XXas shown in the diagnostic tools. When loading a DB table, a new session with the DB is then started. The sessions all have different PIDs, which means thatSET ROLE XXdoes not apply to subsequent sessions.We use QGIS in conjunction with a PostgreSQL/PostGIS database (version 15.14). In pgAdmin, I can use the same commands within a session to adjust the permissions with the SET ROLE function.
Steps to reproduce the issue
Versions
Supported QGIS version
New profile
Additional context
No response