Ticket #3814 (new defect)
OGR OCI Driver does not support Append mode: FID values always start at 1
| Reported by: | PeterHalls | Owned by: | warmerdam |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | default | Version: | 1.6.3 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
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.

