https://issues.qgis.org/https://issues.qgis.org/favicon.ico2012-09-27T05:31:08ZQGIS Issue TrackingQGIS Application - Bug report #6422: QGIS delete Postgis features after trying to merge themhttps://issues.qgis.org/issues/6422?journal_id=354142012-09-27T05:31:08ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Crashes QGIS or corrupts data</strong> changed from <i>No</i> to <i>Yes</i></li></ul> QGIS Application - Bug report #6422: QGIS delete Postgis features after trying to merge themhttps://issues.qgis.org/issues/6422?journal_id=354152012-09-27T05:42:50ZJürgen Fischerjef@norbit.de
<ul><li><strong>Category</strong> changed from <i>Data Provider/PostGIS</i> to <i>Data Provider</i></li></ul><p><code>addFeatures</code> and <code>deleteFeatures</code> are independant operations on provider level. This would need a change in the provider interface. The duplicate key is also a problem on provider level - we currently don't have a way to expose which attributes are part of the primary key and need to be skipped, when copying attributes of existing features to new features. See also <a class="issue tracker-1 status-5 priority-10 priority- closed" href="https://issues.qgis.org/issues/5475" title="Problem to insert splitted geometries in postgis (Closed)">#5475</a>.</p> QGIS Application - Bug report #6422: QGIS delete Postgis features after trying to merge themhttps://issues.qgis.org/issues/6422?journal_id=354162012-09-27T06:00:43ZRegis Haubourgregis.haubourg@oslandia.com
<ul></ul><p>OK, but saving does call AddFeature before deleteFeature if I read logs well. Any reason not to call DeleteFeature first?</p> QGIS Application - Bug report #6422: QGIS delete Postgis features after trying to merge themhttps://issues.qgis.org/issues/6422?journal_id=377172012-12-14T01:56:16ZRegis Haubourgregis.haubourg@oslandia.com
<ul></ul><p>Hi, <a class="issue tracker-1 status-5 priority-10 priority- closed" href="https://issues.qgis.org/issues/6872" title=""ERROR: duplicate key value violates unique constraint "XXXX_pkey" always pops up when merging P... (Closed)">#6872</a> points same bug. A little up on my last comment. Can we have provider delete features before trying to add them. It could be a way to prevent adding duplicates. <br />We should also embed this into a begin / rollback on error so that error message is raised and no commit to data is made. <br />Régis</p> QGIS Application - Bug report #6422: QGIS delete Postgis features after trying to merge themhttps://issues.qgis.org/issues/6422?journal_id=377182012-12-14T03:42:15ZJürgen Fischerjef@norbit.de
<ul></ul><p>regis Haubourg wrote:</p>
<blockquote>
<p>We should also embed this into a begin / rollback on error so that error message is raised and no commit to data is made.</p>
</blockquote>
<p>As said, that's not possible, unless we change the provider interface.</p> QGIS Application - Bug report #6422: QGIS delete Postgis features after trying to merge themhttps://issues.qgis.org/issues/6422?journal_id=377492012-12-16T08:23:49ZRegis Haubourgregis.haubourg@oslandia.com
<ul></ul><p>Thanks Jurgen, <br />I maybe should ask differently, sorry. This bug is a blocker since it destroys data. Is changing provider interface hard or complex thing? does it break anything? <br />Who is capable of doing it? Does it help funding some work? <br />Regards<br />Régis</p> QGIS Application - Bug report #6422: QGIS delete Postgis features after trying to merge themhttps://issues.qgis.org/issues/6422?journal_id=377512012-12-16T08:57:58ZJürgen Fischerjef@norbit.de
<ul></ul><p>regis Haubourg wrote:</p>
<blockquote>
<p>I maybe should ask differently, sorry. This bug is a blocker since it destroys data. Is changing provider interface hard or complex thing? does it break anything?</p>
</blockquote>
<p>I was only referring to the "embed this into begin/rollback" part - just changing the commit order of operation (delete first, insert after) in the vector layer would probably already fix this and not require a big change.</p>
<p>But adding transaction on a higher level would require that we add transactions to the vector layer provider interface and update all the vector data providers (delimitedtext, gpx, grass, memory, mssql, ogr, osm, postgres, spatialite & sqlanywhere) to support it.</p>
<p>Some providers (or their respective backend) might already support transactions (I suppose all database providers do) and some might not (gpx, delimitedtext, memory...) and some might optionally (OGR - depending on the respective datasource there, GRASS?). Some might already use transactions internally and need a change to make it available to the outside.</p>
<p>So "transactions" would probably need to be an optional provider capability.</p>
<blockquote>
<p>Who is capable of doing it? Does it help funding some work?</p>
</blockquote>
<p>Um, I suppose most of our devs are and I guess funding always help - but the amount of work above is not easy to estimate...</p> QGIS Application - Bug report #6422: QGIS delete Postgis features after trying to merge themhttps://issues.qgis.org/issues/6422?journal_id=377522012-12-16T11:07:02ZRegis Haubourgregis.haubourg@oslandia.com
<ul></ul><p>Thanks Jurgen<br />could we try to estimate the benefits of having transaction implemented for providers? <br />I see at least: <br />- recover of any commit error (network disconnection, constraint error, database failure)</p>
<p>Any other ?</p>
<p>Switching delete/insert order is fine for PK constraints, but not for other constraints (geometrytype..). Do we have other issues raised for other constraints? If not, we should keep simple as suggested. <br />Regis</p> QGIS Application - Bug report #6422: QGIS delete Postgis features after trying to merge themhttps://issues.qgis.org/issues/6422?journal_id=377552012-12-16T13:20:01ZJürgen Fischerjef@norbit.de
<ul></ul><p>regis Haubourg wrote:</p>
<blockquote>
<p>Thanks Jurgen<br />could we try to estimate the benefits of having transaction implemented for providers? <br />I see at least: <br />- recover of any commit error (network disconnection, constraint error, database failure)</p>
</blockquote>
<p>The changes are applied by operation, ie. add features, delete features, change attributes, change geometries.</p>
<p>For postgres each part of a operation is already done in a transaction. If one piece of the operation fails, the whole operation is rolled back, reported as unsuccessful and therefore kept in the editing session.</p>
<p>That means if you add multiple features in one session, you either have all features saved to the database or none. In the latter case the editing session will be kept open (as the addFeatures failed) and the changes are still there and pending - so for the cases above you could still commit the changes, when the database comes back or fix the changes that violate constraints.</p>
<p>If you mix operations in one session, it might lead into a limbo state. The successful operations are applied and removed from the editing session and the unsuccessful parts stay in the editing session.</p>
<p>For postgres, that brings up the question - sure if that worked, it would still be ugly - if trying to commit twice would help in the ticket case. In the first attempt the add fails, but the delete is successful, in the second attempt the add is also successful, because the conflicting feature was already deleted in the first run. If so there at least isn't a data loss - unless you decide to discard the session.</p>
<p>For other providers it might be worse as the provider might not be able to rollback unsuccessful operations completely: the successful parts of the failing operation would be already applied to the data source, but still be kept in the editing session as if they weren't, because the operation wasn't completely successful. So if you decide to the discard the session later, you would be still have a partly changed data source.</p> QGIS Application - Bug report #6422: QGIS delete Postgis features after trying to merge themhttps://issues.qgis.org/issues/6422?journal_id=379222012-12-27T11:53:57ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Priority</strong> changed from <i>High</i> to <i>Severe/Regression</i></li></ul> QGIS Application - Bug report #6422: QGIS delete Postgis features after trying to merge themhttps://issues.qgis.org/issues/6422?journal_id=381962013-01-04T15:10:26ZJürgen Fischerjef@norbit.de
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Fixed in changeset <a class="changeset" href="https://issues.qgis.org/projects/qgis/repository/revisions/94156deda42421745df16132a9722fe836975c82" title="QgsVectorLayer: delete before adding/changing features (fixes #6422)">94156deda42421745df16132a9722fe836975c82</a>.</p>