Opened 10 years ago

Closed 18 months ago

#3814 closed defect (wontfix)

[PATCH] OGR OCI Driver does not support Append mode: FID values always start at 1

Reported by: PeterHalls Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: default Version: 1.6.3
Severity: normal Keywords:


The OGROCI driver does not support Append mode activity properly: the FID column should contain unique values, appropriate for a Primary Key, but ogrocitablelayer always starts each invocation at 1. The attached patch submits code to obtain the initial value for iNextFIDToWrite from the database, introducing a new local function GetNextFIDToWrite.

GetNextFIDToWrite performs a SELECT max(fidfield) FROM tablename The SELECT returns a value of -1 for newly created tables, 0 for empty tables or the value of the largest value for the column. GetNextFIDToWrite returns 1 or the current largest value plus one.

Other than calling GetNextFIDToWrite to initialise the value for iNextFIDToWrite, this patch makes no other changes to the code: the new FID value is, therefore, reported back to the caller within the feature object as before.

Note: this patch does not support multiple updaters working on a common table. After reviewing the options it was concluded that a) there is no 100% fail-safe way to achieve this; b) that there is likely a performance hit from introducing such support; and c) that the whole driver needs review and potential amendment in order to support such activity. In performance terms, this patch will impact slightly the very first write to a table, through seeking the highest current value for the FID column, but this is once per table.

Attachments (1)

ogrocitablelayer.append (4.8 KB) - added by PeterHalls 10 years ago.

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by PeterHalls

Attachment: ogrocitablelayer.append added

comment:1 Changed 10 years ago by PeterHalls

Version: unspecified1.6.3

comment:2 Changed 6 years ago by Jukka Rahkonen

Summary: OGR OCI Driver does not support Append mode: FID values always start at 1[PATCH] OGR OCI Driver does not support Append mode: FID values always start at 1

comment:3 Changed 18 months ago by Even Rouault

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: newclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub?. If you believe this ticket is still valid, you may file it to if it is not already reported there.

Note: See TracTickets for help on using tickets.