Bug report #20418

PostGIS Split Fails With Data Loss

Added by Spencer Gardner over 5 years ago. Updated over 5 years ago.

Status:Closed
Priority:High
Assignee:-
Category:Editing
Affected QGIS version:3.4.1 Regression?:Yes
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:Yes Copied to github as #:28238

Description

To reproduce:

--------------------------
create table test (
id serial primary key,
geom geometry(linestring,4326)
);

insert into test (geom)
select st_setsrid(st_makeline(st_makepoint(1,2),st_makepoint(3,4)),4326)
;
--------------------------

  1. Add layer "test" to map
  2. Start editing session
  3. Split line into three features with a single split operation
  4. Save edits
  5. After error is given, quit editing session by discarding changes

What should happen:
Layer saves the three features.

What happens:
Error is given indicating a failure to save edits because of a duplicate key violation. One of the three features is saved,
the other two are deleted from the dataset, despite having discarded all edits when prompted.

History

#1 Updated by Giovanni Manghi over 5 years ago

  • Operating System deleted (Windows)

#2 Updated by Bernhard Ströbl over 5 years ago

I can reproduce the behaviour (with one of my PosGIS layers)

While splitting I get the following warnings in the PostGIS-Tab of the log
WARNING Query: DECLARE qgis_24 BINARY CURSOR FOR SELECT "gid","href1"::text,"href2"::text,"level_name"::text,"gidb"::text,"datum"::text,"nocheinint"::text FROM "myschema"."mytable" WHERE ("gid" = 'nextval(''myschema.mytable_gid_seq''::regclass)') LIMIT 1 returned 7 [ERROR: invalid input syntax for integer: "nextval('myschema.mytable_gid_seq'::regclass)"
WARNING 1 cursor states lost.
SQL: DECLARE qgis_6 BINARY CURSOR FOR SELECT "gid","href1"::text,"href2"::text,"level_name"::text,"gidb"::text,"datum"::text,"nocheinint"::text FROM "myshema"."mytable" WHERE ("gid" = 'nextval(''myschema.mytable_gid_seq''::regclass)') LIMIT 2
Result: 7 (ERROR: invalid input syntax for integer: "nextval('myschema.mytable_gid_seq'::regclass)"

gid is an integer field

#3 Updated by Bernhard Ströbl over 5 years ago

I can save the split features when ticking Evaluate default values on provider side in Project Properties - Data Sources
@Spencer: could you check if that works for you?
Nevertheless the issue is still valid as the data is corrupted although Discard changes is chosen.

#4 Updated by Jan Lippmann over 5 years ago

I can confirm. In my case with polygons.

I think this problem has a relationship with #20431 , because:

1. Step: If i split one feature in only two parts..if i don't save edits..there is no issue
2. Step: If i split another one feature in only two parts...there is a problem with duplicate key violation

BTW: If i save edits after step 1., there is no problem with duplicate key violation

#5 Updated by Stephen Knox over 5 years ago

I can't reproduce this on 3.5 master - I get three seperate lines after splitting, with no errors

#6 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Open to Feedback

Stephen Knox wrote:

I can't reproduce this on 3.5 master - I get three seperate lines after splitting, with no errors

The original reporter also confirms?

#7 Updated by Spencer Gardner over 5 years ago

I'm on vacation for a few more days so I won't be able to confirm until then. I strongly suspect Jan is correct about this being related to #20431 which has been resolved.

#8 Updated by Jan Lippmann over 5 years ago

My Test with 3.4.3: There is no more issue. I think 32b7d7e5ddeef7a66592267819e234085c44a7bc solved the problem. Ticket can be closed...

#9 Updated by Nyall Dawson over 5 years ago

  • Resolution set to fixed/implemented
  • Status changed from Feedback to Closed

Also available in: Atom PDF