I am trying to run then load the result of a PostGIS query using the DB Manager on QGIS 3.30.2. The query is a call to a PostGIS custom function defined in the database that generates some polygons. That function uses many temporary tablesand the first lines it executes are checking if the temporary tables exist and deleting them if they do exist (before creating them again during the new function run).
- I manage to get the proper result in the Viewing panel of the DB manager (a table of features with their attributes their QByteArray geometries in a "geom" column) but when I ask to load the result as a new layer I am getting a layer with no geometry drawn and an empty attribute table.
- When looking at the PostGIS logs I see several identical errors that say
"Cannot execute DROP TABLE in a read-only transaction"
(one such statement for each
DROP TABLE
statement on each temporary table actually).
I tried several techinques to make sure I am getting a proper column with unique values, and I am still getting the same problem. I manage to load the result of the same query in R software so I know the geometries created are correct.
Is the problem simply coming from the fact that the transaction is read-only and cannot drop a table? And if yes is it possible to change it on load (since it seems to work in the Viewer of the DB manager itself!)?