[FWTools] ogrinfo warns about 'Multi-column primary key' but
there is none
Mateusz Loskot
mateusz at loskot.net
Tue Dec 11 19:33:29 EST 2007
Mateusz Loskot wrote:
> Stefan Keller wrote:
>> 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)
>> )
>
> Hi Stefan,
>
> This i strange.
> It looks like the condition in following line
>
> http://trac.osgeo.org/gdal/browser/trunk/gdal/ogr/ogrsf_frmts/pg/ogrpgtablelayer.cpp#L173
>
> is insufficient.
>
> I just tested non-PK table and I confirm this problem occurs.
>
> Shortly, if query status is PGRES_TUPLES_OK then PQntuples should return
> value greater than 0. In other words, following condition is supposed to
> *never* happen as true (according to the PostgreSQL manual):
>
> PGRES_TUPLES_OK == PQresultStatus(hResult) && 0 == PQntuples(hResult)
>
> but what we are experiencing is that this condition actually occurs :-)
>
> I'm investigating it. Thanks for the report.
Certainly, I'm incorrect here and the condition presented above is
perfectly valid in PostgreSQL :-) PGRES_TUPLES_OK is set also if 0 rows
have been returned.
I'm fixing this issue in GDAL.
Cheers
--
Mateusz Loskot
http://mateusz.loskot.net
More information about the FWTools
mailing list