Hi,

we're getting back to GiST development and would like to discuss
our plans for 7.2. This discussion doesn't touch any changes in system tables
to solve index_formtuple problem.
We want to discuss implementation of null-safe interface to GiST
(for reference see thread http://fts.postgresql.org/db/mw/msg.html?mid=1025848 )

There are seven user-defined functions one should write to create GiST opclass:

1. equal - it's already null-safe. GiST core will not call 'equal'
           function if any parameter is NULL

2,3. compress/decompress - always return NULL for NULL, so we could also
          handle them inside GiST core as for 'equal'

4. penalty - accepts 2 parameters and never returns NULL. In existed
             implementations we've seen penalty returns 0 (zero) if
             any of the parameters is NULL. For this case we propose
             not to call 'penalty' if it's marked as isstrict.

5. consistent - returns 'false' if any of the parameters is NULL.
                it never returns NULL.

6. union  - accepts array of keys and returns their union. If all keys are NULL
            then returns NULL, so we don't need to call this function.
            If not all keys are NULL we could:
              a) Clean up NULLs from array
              b) don't touch this array and require 'union' function to
                handle NULL's. In this case we need an additional array
                to point NULLs if we want to support parameters pass-by-value

7. picksplit - accepts structure GIST_SPLITVEC and array of keys. It never
               returns NULL.
              there are 2 variants:
              a) Clean up NULLs from array
                 don't need to change existed opclasses
              b) Require 'picksplit' to handle NULL'
                 To support arguments passed by value we need additional
                 array as in case 6.b

Summary:

 1. Only for one function - penalty, 'isstrict' mark could be required.
    in that case 'penalty' will be not called for NULL keys,
    otherwise, it's users responsibility to write null-safe code.
    Other functions could be handled inside GiST core  without
    bothering of user. This is quite easy task.

 2. For union and picksplit we propose to clean up NULLs from array of
    keys, so support  of arguments 'passed-by-value' will not require
    changes of user interface. It would require some modification of current
    algorithm of splitting, but this wouldn't  be a complex task for us.


Proposed solution solves the problem with 'pass-by-value' interface,
while we don't see where it could be used because in GiST
key for index type of int4 is 8-byte.

	Regards,
		Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83


Fri, 3 Aug 2001 17:00:14 +0300 (GMT)
Oleg Bartunov <oleg@sai.msu.su>
Null-safe GiST interface (proposal)
Oleg Bartunov <oleg@sai.msu.su> writes:
>  2. For union and picksplit we propose to clean up NULLs from array of
>     keys, so support  of arguments 'passed-by-value' will not require
>     changes of user interface. It would require some modification of current
>     algorithm of splitting, but this wouldn't  be a complex task for us.

Seems reasonable.  Would there ever be a union or picksplit method that
would want to do anything with nulls except ignore them?  I can't think
of a reason to do differently, so you're just centralizing the logic to
ignore nulls in these methods.

			regards, tom lane

Fri, 03 Aug 2001 11:48:41 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: Null-safe GiST interface (proposal) 
Hi,

please apply patch to current CVS which implements:

1. null-safe interface to GiST
   (as proposed in http://fts.postgresql.org/db/mw/msg.html?mid=1028327)

2. support for 'pass-by-value' arguments - to test this
   we used special opclass for int4 with values in range [0-2^15]
   More testing will be done after resolving problem with
   index_formtuple and implementation of B-tree using GiST

3. small patch to contrib modules (seg,cube,rtree_gist,intarray) -
   mark functions as 'isstrict' where needed.

Patch was intensively tested (attached test.tgz contains test suite):

This is a generic test suite for GiST (7.2):

1. tests GiST multi-key indexes
2. tests null-safe interface to GiST
  (see proposal http://fts.postgresql.org/db/mw/msg.html?mid=1028327)

USAGE:

Create db and install contrib modules: intarray, rtree_gist, seg, cube.
Edit gen.pl for $pgsqlsrc
% perl gen.pl > /tmp/data
% psql TESTDB < test.sql


	Regards,
		Oleg



On Fri, 3 Aug 2001, Tom Lane wrote:

> Oleg Bartunov <oleg@sai.msu.su> writes:
> >  2. For union and picksplit we propose to clean up NULLs from array of
> >     keys, so support  of arguments 'passed-by-value' will not require
> >     changes of user interface. It would require some modification of current
> >     algorithm of splitting, but this wouldn't  be a complex task for us.
>
> Seems reasonable.  Would there ever be a union or picksplit method that
> would want to do anything with nulls except ignore them?  I can't think
> of a reason to do differently, so you're just centralizing the logic to
> ignore nulls in these methods.
>
> 			regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

	Regards,
		Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83
Tue, 7 Aug 2001 22:33:31 +0300 (GMT)
Oleg Bartunov <oleg@sai.msu.su>
Re: Re: Null-safe GiST interface (proposal) 

Your patch has been added to the PostgreSQL unapplied patches list at:

	http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

> Hi,
> 
> please apply patch to current CVS which implements:
> 
> 1. null-safe interface to GiST
>    (as proposed in http://fts.postgresql.org/db/mw/msg.html?mid=1028327)
> 
> 2. support for 'pass-by-value' arguments - to test this
>    we used special opclass for int4 with values in range [0-2^15]
>    More testing will be done after resolving problem with
>    index_formtuple and implementation of B-tree using GiST
> 
> 3. small patch to contrib modules (seg,cube,rtree_gist,intarray) -
>    mark functions as 'isstrict' where needed.
> 
> Patch was intensively tested (attached test.tgz contains test suite):
> 
> This is a generic test suite for GiST (7.2):
> 
> 1. tests GiST multi-key indexes
> 2. tests null-safe interface to GiST
>   (see proposal http://fts.postgresql.org/db/mw/msg.html?mid=1028327)
> 
> USAGE:
> 
> Create db and install contrib modules: intarray, rtree_gist, seg, cube.
> Edit gen.pl for $pgsqlsrc
> % perl gen.pl > /tmp/data
> % psql TESTDB < test.sql
> 
> 
> 	Regards,
> 		Oleg
> 
> 
> 
> On Fri, 3 Aug 2001, Tom Lane wrote:
> 
> > Oleg Bartunov <oleg@sai.msu.su> writes:
> > >  2. For union and picksplit we propose to clean up NULLs from array of
> > >     keys, so support  of arguments 'passed-by-value' will not require
> > >     changes of user interface. It would require some modification of current
> > >     algorithm of splitting, but this wouldn't  be a complex task for us.
> >
> > Seems reasonable.  Would there ever be a union or picksplit method that
> > would want to do anything with nulls except ignore them?  I can't think
> > of a reason to do differently, so you're just centralizing the logic to
> > ignore nulls in these methods.
> >
> > 			regards, tom lane
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 4: Don't 'kill -9' the postmaster
> >
> 
> 	Regards,
> 		Oleg
> _____________________________________________________________
> Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
> Sternberg Astronomical Institute, Moscow University (Russia)
> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
> phone: +007(095)939-16-83, +007(095)939-23-83

Content-Description: 

[ Attachment, skipping... ]

Content-Description: 

[ Attachment, skipping... ]

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Wed, 8 Aug 2001 11:19:50 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Re: Null-safe GiST interface (proposal)

Main patch applied.  I did not apply the test code patch.  Thanks.


> Hi,
> 
> please apply patch to current CVS which implements:
> 
> 1. null-safe interface to GiST
>    (as proposed in http://fts.postgresql.org/db/mw/msg.html?mid=1028327)
> 
> 2. support for 'pass-by-value' arguments - to test this
>    we used special opclass for int4 with values in range [0-2^15]
>    More testing will be done after resolving problem with
>    index_formtuple and implementation of B-tree using GiST
> 
> 3. small patch to contrib modules (seg,cube,rtree_gist,intarray) -
>    mark functions as 'isstrict' where needed.
> 
> Patch was intensively tested (attached test.tgz contains test suite):
> 
> This is a generic test suite for GiST (7.2):
> 
> 1. tests GiST multi-key indexes
> 2. tests null-safe interface to GiST
>   (see proposal http://fts.postgresql.org/db/mw/msg.html?mid=1028327)
> 
> USAGE:
> 
> Create db and install contrib modules: intarray, rtree_gist, seg, cube.
> Edit gen.pl for $pgsqlsrc
> % perl gen.pl > /tmp/data
> % psql TESTDB < test.sql
> 
> 
> 	Regards,
> 		Oleg
> 
> 
> 
> On Fri, 3 Aug 2001, Tom Lane wrote:
> 
> > Oleg Bartunov <oleg@sai.msu.su> writes:
> > >  2. For union and picksplit we propose to clean up NULLs from array of
> > >     keys, so support  of arguments 'passed-by-value' will not require
> > >     changes of user interface. It would require some modification of current
> > >     algorithm of splitting, but this wouldn't  be a complex task for us.
> >
> > Seems reasonable.  Would there ever be a union or picksplit method that
> > would want to do anything with nulls except ignore them?  I can't think
> > of a reason to do differently, so you're just centralizing the logic to
> > ignore nulls in these methods.
> >
> > 			regards, tom lane
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 4: Don't 'kill -9' the postmaster
> >
> 
> 	Regards,
> 		Oleg
> _____________________________________________________________
> Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
> Sternberg Astronomical Institute, Moscow University (Russia)
> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
> phone: +007(095)939-16-83, +007(095)939-23-83

Content-Description: 

[ Attachment, skipping... ]

Content-Description: 

[ Attachment, skipping... ]

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Fri, 10 Aug 2001 10:34:42 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Re: Null-safe GiST interface (proposal)