#1632 closed defect (fixed)
OGRLayer::CreateFeature() not updating FID (MySQL & SQLite)
Reported by: | Kosta | Owned by: | Kosta |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | FID MySQL SQLite |
Cc: | mchapman, hobu |
Description
The docs for OGRLayer::CreateFeature() state that the feature ID will be updated upon successful insertion:
Upon successful return the passed feature will have been updated with the new feature id.
This is not true for at least the MySQL and SQLite drivers (they do not modify the FIDs of the provided features).
Implementing this behavior, however, can be difficult and/or result in very bad performance for certain drivers...
What's next: changing the docs or changing the impls?
Change History (8)
comment:1 by , 17 years ago
Status: | new → assigned |
---|
comment:2 by , 17 years ago
For the MySQL driver this can be fixed easily by inserting the following lines of code just after a successful feature insertion:
const my_ulonglong iFID = mysql_insert_id( poDS->GetConn() ); poFeature->SetFID( iFID );
comment:4 by , 17 years ago
Cc: | added |
---|
Konstantin,
Is the my_insert_id() expensive against MySQL? I know that on some RDBMSes it requires expensive roundtripping to the database. If you are fairly comfortable with the change, go ahead and apply it in trunk. I'm less confident about applying it in 1.4 branch.
comment:5 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
OK, I have checked it in into the main trunk. I haven't seen a performance drop after the bug fix, though I haven't done explicit performance timings yet (w.r.t. this bug fix)...
But the MySQL documentation state, that this function operates on a per connection basis only, so no round trip should be done, I think:
'The value of mysql_insert_id() is affected only by statements issued within the current client connection. It is not affected by statements issued by other clients.'
comment:6 by , 17 years ago
Kosta,
Feel free to close this report if you think it is addressed.
I'd like to suggest you extend the mysql test script to verify fid creation, but I see there is no such thing. :-(
comment:7 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Added fix for the SQLite driver, too (changeset [11762])
comment:8 by , 17 years ago
I have fixed the gdalautotest/ogr/ogr_sqlite.py script which was failing some tests after this change since that script was erroneously not expecting fid update. (r11855).
Good question. I will try and consider this in the coming week.