Ticket #2082 (closed defect: fixed)

Opened 10 months ago

Last modified 10 months ago

OGR warns about 'Multi-column primary key' but there is none

Reported by: mloskot Assigned to: mloskot
Priority: normal Milestone: 1.4.5
Component: OGR_SF Version: svn-trunk
Severity: normal Keywords: postgresql primary key
Cc:

Description

Stefan Keller reported on the FWTools list:

I have a PostgreSQL table which goes like shon below. When I'm querying the my db 'gisdb' with ogrinfo it issues a warning:

ogrinfo -ro PG:"dbname=gisdb"
Warning 1: Multi-column primary key in 'towns' detected but not supported.
INFO: Open of `PG:dbname=gisdb'
      using driver `PostgreSQL' successful.
1: towns (Multi Polygon)

So the orginfo pretends that there is a "Multi-column primary key" but there is no primary key. Someone any explanation on this?

-- Stefan

CREATE TABLE towns
( gid serial NOT NULL, objectid int8, towns_id int8, town_id int4,
  town varchar, fips_stco int4, ccd_mcd varchar, fips_place varchar,
  pop1980 int4, pop1990 int4, pop2000 int4, popch80_90 int4, popch90_00
int4,
  fourcolor int4, "type" varchar, island int4, fips_mcd int4,
  fips_count int4, shape_area numeric, shape_len numeric, the_geom geometry,
  CONSTRAINT enforce_geotype_the_geom
    CHECK (geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS
NULL),
  CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 26986)
)

Change History

12/11/07 19:44:06 changed by mloskot

  • status changed from new to assigned.
  • owner changed from warmerdam to mloskot.

12/11/07 19:50:32 changed by mloskot

I confirm this issue. This problem is caused by incorrect condition in ogrpgtablelayer.cpp line 173 and 175:

if ( hResult && PGRES_TUPLES_OK == PQresultStatus( hResult) )
{
   if ( PQntuples( hResult ) == 1 && PQgetisnull( hResult,0,0 ) == false )

The status PGRES_TUPLES_OK is also set if 0 tuples have been returned. However, this condition does not fulters 0 tuples as valid case but as multi-key case.

12/11/07 19:54:18 changed by mloskot

  • status changed from assigned to closed.
  • resolution set to fixed.

Fixed in trunk (r13330)

Thanks to Stefan Keller for reporting this issue.

12/11/07 19:54:26 changed by mloskot

  • milestone set to 1.5.0.

12/11/07 19:54:34 changed by mloskot

  • version changed from unspecified to svn-trunk.

12/12/07 11:02:53 changed by warmerdam

Is r13330 something that should also be applied in the 1.4 branch?

12/24/07 00:10:30 changed by mloskot

  • status changed from closed to reopened.
  • resolution deleted.

12/24/07 00:11:07 changed by mloskot

  • milestone changed from 1.5.0 to 1.4.5.

Frank, yes you are right. I've reopened it and I'm changing milestone to 1.4.5.

12/24/07 00:13:47 changed by mloskot

  • status changed from reopened to closed.
  • resolution set to fixed.

This fix has been ported to the branches/1.4 (r13444). It will be available in GDAL >=1.4.5