[postgis-users] length and area in the schema

strk at refractions.net strk at refractions.net
Tue Jun 20 02:15:02 PDT 2006


On Tue, Jun 20, 2006 at 08:07:55AM +0200, Emilia Venturato wrote:
> Alle 02:54, lunedì 19 giugno 2006, strk at refractions.net ha probabilmente 
> scritto:
> > On Fri, Jun 16, 2006 at 02:53:20PM +0200, Emilia Venturato wrote:
> > > Hi all,
> > > I use postgresql/postgis (PostgreSQL 8.1.4/ POSTGIS 1.1.2) on Debian
> > > etch. I have database with schemas.
> > > I found a problem with length and area functions when geometric tables
> > > are in the schema.
> > > It seems use different function for lenght where search_path is limited
> > > to the schema.
> > > I think this is misleading, as the user have problems knowing which
> > > length and area (s)he's getting.
> > >
> > > Someone could help me?
> >
> > Do you think it would it help to have all postgis functions defined
> > in the 'postgis' schema ? You can try this yourself by setting
> > the first item in the search_path to 'postgis' before including
> > the lwpostgis.sql and spatial_ref_sys.sql files.
> >
> > I'm actually not sure everything would work, but it's worth a try.
> 
> 
> I think it's a semantic problem. Having two functions with same name is the 
> problem. User can set his db to include functions in a schema, but he must do 
> that in every schema he uses.
> Maybe  a better solution could be to use different function name.
> Don't you think so?

PostgreSQL allows functions overloading, which is there can be
multiple functions with same name but with different argument types.
length(geometry) is the postgis one. The only reason to NOT use
it is it is NOT found in your search path. If I'm not wrong the
failure case you had was with a search_path that didn't include
the 'public' schema, where postgis is commonly installed.
Since length(geometry) was not found it is likely that length(text)
was run, having found that function and an implicit cast from
geometry to text.
A possibility could be to remove the "implicit" flag from
the geometry to text cast, but as long as there is an implicit
cast chain taking to a valid argument to any length() function
this won't be enough.
Try adding 'public' to your search_path, even at the end of
it and see if that fixes your problem.

--strk;




More information about the postgis-users mailing list