[postgis-users] how to define an alias for && operator?

Jean-Pierre Quirion jpquirion at yahoo.ca
Fri Nov 4 07:13:52 PST 2005


--- Mark Cave-Ayland <m.cave-ayland at webbased.co.uk> a écrit :
> 
> > -----Original Message-----
> > From: postgis-users-bounces at postgis.refractions.net 
> > [mailto:postgis-users-bounces at postgis.refractions.net] On 
> > Behalf Of Jean-Pierre Quirion
> > Sent: 04 November 2005 13:26
> > To: postgis-users at postgis.refractions.net
> > Subject: [postgis-users] how to define an alias for && operator?
> > 
> > 
> > Hi, 
> > 
> > Postgis 1.0 
> > Postgres 8.0
> > 
> > We are desperately trying to define an alias for the && 
> > operator (that use the same indexes!). We copied the 
> > definition of the && operator ("CREATE OPERATOR &&...") that 
> > works fine. For index usage we need to add a new operator to 
> > the operator class "gist_geometry_ops" but that seems 
> > impossible without deleting the && operator, "operator number 
> > 3 appears more than once", because && and our new operator 
> > should use the same strategy.
> > 
> > How would you define an alias? We need the alias in order to 
> > circumvent Hibernate. Any ideas?
> > 
> > Jean-Pierre
> 
> 
> Hi Jean-Pierre,
> 
> Can you show us the exact text you are trying to use in your CREATE OPERATOR
> statement?

Hi Mark,

Of Course: Our alias operator shall be "<<<"

CREATE OPERATOR <<<(
  PROCEDURE = geometry_overlap,
  LEFTARG = geometry,
  RIGHTARG = geometry,
  COMMUTATOR = <<<,
  RESTRICT = postgis_gist_sel,
  JOIN = postgis_gist_joinsel);

DROP OPERATOR CLASS gist_geometry_ops USING gist CASCADE;

CREATE OPERATOR CLASS gist_geometry_ops DEFAULT
   FOR TYPE geometry USING gist AS
   OPERATOR 1  << RECHECK,
   OPERATOR 2  &< RECHECK,
   OPERATOR 3  && RECHECK,
   OPERATOR 4  &> RECHECK,
   OPERATOR 5  >> RECHECK,
   OPERATOR 6  ~= RECHECK,
   OPERATOR 7  ~ RECHECK,
   OPERATOR 8  @ RECHECK,
   OPERATOR 9  &<| RECHECK,
   OPERATOR 10  <<| RECHECK,
   OPERATOR 11  |>> RECHECK,
   OPERATOR 12  |&> RECHECK,
   OPERATOR 3  <<< RECHECK,
   FUNCTION 1  lwgeom_gist_consistent(internal, geometry, int4),
   FUNCTION 2  lwgeom_gist_union(bytea, internal),
   FUNCTION 3  lwgeom_gist_compress(internal),
   FUNCTION 4  lwgeom_gist_decompress(internal),
   FUNCTION 5  lwgeom_gist_penalty(internal, internal, internal),
   FUNCTION 6  lwgeom_gist_picksplit(internal, internal),
   FUNCTION 7  lwgeom_gist_same(box2d, box2d, internal),
   STORAGE box2d;


The "OPERATOR 3  <<< RECHECK," line has been added. And this does not work. Apparently you can not
reuse a strategy_number, is this right (3 in this case). [My assumptions are based on
http://www.postgresql.org/docs/8.0/interactive/sql-createopclass.html]
Our problem is not the operator (it works), but the association with an index aka operator class.
If we used a new strategy number like 13, we would have to define a new strategy in
"lwgeom_gist.c" . I am looking for an easier solution.

Jean-Pierre








	

	
		
__________________________________________________________
Lèche-vitrine ou lèche-écran ?
magasinage.yahoo.ca



More information about the postgis-users mailing list