Opened 16 years ago

Closed 16 years ago

#2082 closed defect (fixed)

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

Reported by: Mateusz Łoskot Owned by: Mateusz Łoskot
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 (9)

comment:1 by Mateusz Łoskot, 16 years ago

Owner: changed from warmerdam to Mateusz Łoskot
Status: newassigned

comment:2 by Mateusz Łoskot, 16 years ago

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.

comment:3 by Mateusz Łoskot, 16 years ago

Resolution: fixed
Status: assignedclosed

Fixed in trunk (r13330)

Thanks to Stefan Keller for reporting this issue.

comment:4 by Mateusz Łoskot, 16 years ago

Milestone: 1.5.0

comment:5 by Mateusz Łoskot, 16 years ago

Version: unspecifiedsvn-trunk

comment:6 by warmerdam, 16 years ago

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

comment:7 by Mateusz Łoskot, 16 years ago

Resolution: fixed
Status: closedreopened

comment:8 by Mateusz Łoskot, 16 years ago

Milestone: 1.5.01.4.5

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

comment:9 by Mateusz Łoskot, 16 years ago

Resolution: fixed
Status: reopenedclosed

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

Note: See TracTickets for help on using tickets.