Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostGIS error while changing attributes (field value and geometry): prepared statement "updatefeature" already exists #45100

Closed
1 of 2 tasks
sicasley opened this issue Sep 16, 2021 · 0 comments · Fixed by #45266
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PostGIS data provider

Comments

@sicasley
Copy link

What is the bug or the crash?

When editing both geometry and field values of a PostGIS feature at the same time, if the edit fails due to a Postgres constraint violation (or any other Postgres error), the next time I try and save a valid geometry and attribute edit I get the following error:

Could not commit changes to layer ...

Errors: 
  Provider errors:
      PostGIS error while changing attributes: ERROR:  prepared statement "updatefeature" already exists

Edits to just geometry or just attribute values save, but edits involving both will continue to fail with this error until either QGIS is restarted or the layer is removed and re-added.

I'm not entirely sure but, having poked around in qgspostgresprovider.cpp, it looks like there may be a missing "DEALLOCATE updatefeature" in QgsPostgresProvider::changeFeatures after the rollback (line 3508).

Steps to reproduce the issue

  1. Start editing a PostGIS layer with a NOT NULL constraint on one of its fields (uncheck enforce not null constraint).
  2. Change a feature's geometry and set it's field value to NULL (so as to cause the postgres error).
  3. Try to save layer edits (get the expected constraint violation error).
  4. Stop editing and discard edits.
  5. Start editing again and change (any) feature's geometry and field value to something valid.
  6. Save layer edits (get prepared statement "updatefeature" already exists error).

Versions

Tested on QGIS 3.16.8, Postgres 10

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

No response

@sicasley sicasley added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Sep 16, 2021
@elpaso elpaso self-assigned this Sep 27, 2021
elpaso added a commit to elpaso/QGIS that referenced this issue Sep 27, 2021
The problem was that throwing an exception the prepared statement
was not deallocated.

Fix qgis#45100
elpaso added a commit to elpaso/QGIS that referenced this issue Sep 27, 2021
The problem was that throwing an exception the prepared statement
was not deallocated.

Fix qgis#45100
rouault pushed a commit that referenced this issue Oct 6, 2021
The problem was that throwing an exception the prepared statement
was not deallocated.

Fix #45100
qgis-bot pushed a commit that referenced this issue Oct 6, 2021
The problem was that throwing an exception the prepared statement
was not deallocated.

Fix #45100
nyalldawson pushed a commit that referenced this issue Oct 7, 2021
The problem was that throwing an exception the prepared statement
was not deallocated.

Fix #45100
nyalldawson pushed a commit that referenced this issue Nov 1, 2021
The problem was that throwing an exception the prepared statement
was not deallocated.

Fix #45100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PostGIS data provider
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants