[Gdal-dev] Re: PostGis layers

Charles F. I. Savage cfis at interserv.com
Sun Sep 25 13:45:22 EDT 2005


I suppose its worth mentioning that this still leaves the problem of
having the same table name in two different schemas - say I have a table
called completechain in a tiger_2004 schema and one in a tiger_2002
schema.  I know that there is already a bug about postgresql schemas,
but no fix yet.

I think there is an argument that the layer name should not be
"completechain" but instead should be "tiger_2004.completechain" or
"tiger_2002.completechain" or the default "public.completechain."

Otherwise, if I write dataSource.getLayerByName("completechain") then
what happens?  I get the first layer named "completechain" I'd guess but
obviously that's not a very good solution.

I think you could probably make this backward compatible by tacking on
"public." to a layer name when a user calles getLayerName without
specifying a schema.  Thus dataSource.getLayerByName("completechain")
becomes dataSource.getLayerByName("public.completechain").

An alternative approach is to set the "search_path" when ogr logs into
postgresql (as mentioned in the bug report), but I don't see how that
can solve the problem of the same table name in multiple schemas.


Thanks,

Charlie




Charles F. I. Savage wrote:
> Hi everyone - working with OGR and PostGis.
> 
> When OGR opens a Postgis enabled database, it finds its layers via this 
> query (I added the select g.f_table_name part to show a problem below):
> 
> SELECT c.relname, g.f_table_name FROM pg_class c, geometry_columns g
> WHERE (c.relkind in ('r','v') AND c.relname !~ '^pg'
> AND c.relname ~ g.f_table_name)
> 
> I've pasted the results of this query below.  Note that the 
> polygoncorrections and polgyoneconomics layer show up twice!  This is 
> caused by this part of the query:
> 
> AND c.relname ~ g.f_table_name)
> 
> Shouldn't it be a direct match without a regular expression, like this:
> 
> AND c.relname = g.f_table_name)
> 
> 
> Charlie
> 
> 
> "altname";"altname"
> "arealandmarks";"arealandmarks"
> "arealandmarks";"landmarks"
> "completechain";"completechain"
> "entitynames";"entitynames"
> "featureids";"featureids"
> "idhistory";"idhistory"
> "landmarks";"landmarks"
> "overunder";"overunder"
> "pip";"pip"
> "polychainlink";"polychainlink"
> "polygon";"polygon"
> "polygoncorrections";"polygon"
> "polygoncorrections";"polygoncorrections"
> "polygoneconomic";"polygon"
> "polygoneconomic";"polygoneconomic"
> "tlidrange";"tlidrange"
> "zerocellid";"zerocellid"
> "zipcodes";"zipcodes"
> "zipplus4";"zipplus4"
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/gdal-dev


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2781 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20050925/da6cd238/smime.bin


More information about the Gdal-dev mailing list