Ticket #1889 (closed defect: fixed)
Postgres primary key logic disabled, needs to be re-enabled
| Reported by: | warmerdam | Owned by: | mloskot |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.4.4 |
| Component: | OGR_SF | Version: | 1.4.2 |
| Severity: | normal | Keywords: | postgresql postgis constraints PK |
| Cc: | darkblueB |
Description
Mateusz,
The automatic recognition of primary keys as FIDs in the PG driver is currently (trunk and 1.4.x) broken and this makes it impossible to do some operations on tables (such as DeleteFeature?()) that weren't created by OGR (thus using the recognisable ogc_fid name as fid).
/* TODO make changes corresponded to Frank issues
sprintf ( szCommand,
"SELECT a.attname "
"FROM pg_attribute a, pg_constraint c, pg_class cl "
"WHERE c.contype='p' AND c.conrelid=cl.oid "
"AND a.attnum = c.conkey[1] AND a.attrelid=cl.oid "
"AND cl.relname = '%s'",
pszTableIn );
hResult = PQexec(hPGConn, szCommand );
if ( hResult && PQntuples( hResult ) == 1 && PQgetisnull( hResult,0,0 ) == false )
{
sprintf( szPrimaryKey, "%s", PQgetvalue(hResult,0,0) );
CPLDebug( "OGR_PG", "Primary key name (FID): %s", szPrimaryKey );
}
else
{
CPLError( CE_Failure, CPLE_AppDefined,
"%s", PQerrorMessage(hPGConn) );
CPLError( CE_Warning, CPLE_AppDefined,
"Unable to detect table primary key. Use default 'ogc_fid'");
}*/
I don't know what Frank issues the comment refers to off hand, though it could be that we need to confirm the primary key is an integer field. Once this logic has been appropriately reenable we need to add a test to the postgres testsuite and ensure it is operational on at least one buildbot platform (likely telascience-full).
Change History
Note: See
TracTickets for help on using
tickets.
