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.

Oleg Bartunov
This commit is contained in:
Bruce Momjian 2001-08-10 14:34:28 +00:00
parent 77a69a2ed1
commit 13923be7c8
7 changed files with 474 additions and 369 deletions

View File

@ -28,25 +28,25 @@ COMMENT ON TYPE cube IS
-- Left/Right methods
CREATE FUNCTION cube_over_left(cube, cube) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION cube_over_left(cube, cube) IS
'is over and left of (NOT IMPLEMENTED)';
CREATE FUNCTION cube_over_right(cube, cube) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION cube_over_right(cube, cube) IS
'is over and right of (NOT IMPLEMENTED)';
CREATE FUNCTION cube_left(cube, cube) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION cube_left(cube, cube) IS
'is left of (NOT IMPLEMENTED)';
CREATE FUNCTION cube_right(cube, cube) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION cube_right(cube, cube) IS
'is right of (NOT IMPLEMENTED)';
@ -55,43 +55,43 @@ COMMENT ON FUNCTION cube_right(cube, cube) IS
-- Comparison methods
CREATE FUNCTION cube_lt(cube, cube) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION cube_lt(cube, cube) IS
'lower than';
CREATE FUNCTION cube_gt(cube, cube) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION cube_gt(cube, cube) IS
'greater than';
CREATE FUNCTION cube_contains(cube, cube) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION cube_contains(cube, cube) IS
'contains';
CREATE FUNCTION cube_contained(cube, cube) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION cube_contained(cube, cube) IS
'contained in';
CREATE FUNCTION cube_overlap(cube, cube) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION cube_overlap(cube, cube) IS
'overlaps';
CREATE FUNCTION cube_same(cube, cube) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION cube_same(cube, cube) IS
'same as';
CREATE FUNCTION cube_different(cube, cube) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION cube_different(cube, cube) IS
'different';
@ -99,13 +99,13 @@ COMMENT ON FUNCTION cube_different(cube, cube) IS
-- support routines for indexing
CREATE FUNCTION cube_union(cube, cube) RETURNS cube
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION cube_inter(cube, cube) RETURNS cube
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION cube_size(cube) RETURNS float4
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
-- Misc N-dimensional functions
@ -113,7 +113,7 @@ CREATE FUNCTION cube_size(cube) RETURNS float4
-- proximity routines
CREATE FUNCTION cube_distance(cube, cube) RETURNS float4
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
--
@ -199,7 +199,7 @@ CREATE FUNCTION g_cube_decompress(opaque) RETURNS opaque
AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_cube_penalty(opaque,opaque,opaque) RETURNS opaque
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION g_cube_picksplit(opaque, opaque) RETURNS opaque
AS 'MODULE_PATHNAME' LANGUAGE 'c';

View File

@ -9,7 +9,7 @@ BEGIN TRANSACTION;
-- Comparison methods
CREATE FUNCTION _int_contains(_int4, _int4) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
INSERT INTO pg_description (objoid, description)
SELECT oid, 'contains'::text
@ -17,7 +17,7 @@ INSERT INTO pg_description (objoid, description)
WHERE proname = '_int_contains'::name;
CREATE FUNCTION _int_contained(_int4, _int4) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
INSERT INTO pg_description (objoid, description)
SELECT oid, 'contained in'::text
@ -25,7 +25,7 @@ INSERT INTO pg_description (objoid, description)
WHERE proname = '_int_contained'::name;
CREATE FUNCTION _int_overlap(_int4, _int4) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
INSERT INTO pg_description (objoid, description)
SELECT oid, 'overlaps'::text
@ -33,7 +33,7 @@ INSERT INTO pg_description (objoid, description)
WHERE proname = '_int_overlap'::name;
CREATE FUNCTION _int_same(_int4, _int4) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
INSERT INTO pg_description (objoid, description)
SELECT oid, 'same as'::text
@ -41,7 +41,7 @@ INSERT INTO pg_description (objoid, description)
WHERE proname = '_int_same'::name;
CREATE FUNCTION _int_different(_int4, _int4) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
INSERT INTO pg_description (objoid, description)
SELECT oid, 'different'::text
@ -51,10 +51,10 @@ INSERT INTO pg_description (objoid, description)
-- support routines for indexing
CREATE FUNCTION _int_union(_int4, _int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION _int_inter(_int4, _int4) RETURNS _int4
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
--
-- OPERATORS
@ -223,7 +223,7 @@ CREATE FUNCTION g_intbig_decompress(opaque) RETURNS opaque
AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION g_intbig_penalty(opaque,opaque,opaque) RETURNS opaque
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION g_intbig_picksplit(opaque, opaque) RETURNS opaque
AS 'MODULE_PATHNAME' LANGUAGE 'c';

View File

@ -13,7 +13,7 @@ create function gbox_compress(opaque) returns opaque as 'MODULE_PATHNAME' langua
create function rtree_decompress(opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
create function gbox_penalty(opaque,opaque,opaque) returns opaque as 'MODULE_PATHNAME' language 'C';
create function gbox_penalty(opaque,opaque,opaque) returns opaque as 'MODULE_PATHNAME' language 'C' with (isstrict);
create function gbox_picksplit(opaque, opaque) returns opaque as 'MODULE_PATHNAME' language 'C';

View File

@ -28,25 +28,25 @@ COMMENT ON TYPE seg IS
-- Left/Right methods
CREATE FUNCTION seg_over_left(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_over_left(seg, seg) IS
'is over and left of';
CREATE FUNCTION seg_over_right(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_over_right(seg, seg) IS
'is over and right of';
CREATE FUNCTION seg_left(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_left(seg, seg) IS
'is left of';
CREATE FUNCTION seg_right(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_right(seg, seg) IS
'is right of';
@ -55,55 +55,55 @@ COMMENT ON FUNCTION seg_right(seg, seg) IS
-- Comparison methods
CREATE FUNCTION seg_lt(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_lt(seg, seg) IS
'less than';
CREATE FUNCTION seg_le(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_le(seg, seg) IS
'less than or equal';
CREATE FUNCTION seg_gt(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_gt(seg, seg) IS
'greater than';
CREATE FUNCTION seg_ge(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_ge(seg, seg) IS
'greater than or equal';
CREATE FUNCTION seg_contains(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_contains(seg, seg) IS
'contains';
CREATE FUNCTION seg_contained(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_contained(seg, seg) IS
'contained in';
CREATE FUNCTION seg_overlap(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_overlap(seg, seg) IS
'overlaps';
CREATE FUNCTION seg_same(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_same(seg, seg) IS
'same as';
CREATE FUNCTION seg_different(seg, seg) RETURNS bool
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
COMMENT ON FUNCTION seg_different(seg, seg) IS
'different';
@ -111,21 +111,21 @@ COMMENT ON FUNCTION seg_different(seg, seg) IS
-- support routines for indexing
CREATE FUNCTION seg_union(seg, seg) RETURNS seg
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION seg_inter(seg, seg) RETURNS seg
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION seg_size(seg) RETURNS float4
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
-- miscellaneous
CREATE FUNCTION seg_upper(seg) RETURNS float4
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION seg_lower(seg) RETURNS float4
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
--
@ -223,7 +223,7 @@ CREATE FUNCTION gseg_decompress(opaque) RETURNS opaque
AS 'MODULE_PATHNAME' LANGUAGE 'c';
CREATE FUNCTION gseg_penalty(opaque,opaque,opaque) RETURNS opaque
AS 'MODULE_PATHNAME' LANGUAGE 'c';
AS 'MODULE_PATHNAME' LANGUAGE 'c' with (isstrict);
CREATE FUNCTION gseg_picksplit(opaque, opaque) RETURNS opaque
AS 'MODULE_PATHNAME' LANGUAGE 'c';

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.28 2001/05/31 18:16:54 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.29 2001/08/10 14:34:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -254,7 +254,7 @@ gistindex_keytest(IndexTuple tuple,
gistdentryinit(giststate, key[0].sk_attno-1, &de,
datum, r, p, offset,
IndexTupleSize(tuple) - sizeof(IndexTupleData),
FALSE);
FALSE, isNull);
if (key[0].sk_flags & SK_COMMUTE)
{

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: gist.h,v 1.29 2001/07/15 22:48:18 tgl Exp $
* $Id: gist.h,v 1.30 2001/08/10 14:34:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -72,6 +72,7 @@ typedef struct GISTSTATE
FmgrInfo penaltyFn[INDEX_MAX_KEYS];
FmgrInfo picksplitFn[INDEX_MAX_KEYS];
FmgrInfo equalFn[INDEX_MAX_KEYS];
bool attbyval[INDEX_MAX_KEYS];
bool haskeytype;
bool keytypbyval;
} GISTSTATE;
@ -124,12 +125,14 @@ typedef struct GIST_SPLITVEC
Datum spl_ldatum; /* Union of keys in spl_left */
Datum spl_lattr[INDEX_MAX_KEYS]; /* Union of subkeys in spl_left */
int spl_lattrsize[INDEX_MAX_KEYS];
bool spl_lisnull[INDEX_MAX_KEYS];
OffsetNumber *spl_right; /* array of entries that go right */
int spl_nright; /* size of the array */
Datum spl_rdatum; /* Union of keys in spl_right */
Datum spl_rattr[INDEX_MAX_KEYS]; /* Union of subkeys in spl_right */
int spl_rattrsize[INDEX_MAX_KEYS];
bool spl_risnull[INDEX_MAX_KEYS];
int *spl_idgrp;
int *spl_ngrp; /* number in each group */
@ -168,7 +171,7 @@ extern void gistfreestack(GISTSTACK *s);
extern void initGISTstate(GISTSTATE *giststate, Relation index);
extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
Datum k, Relation r, Page pg, OffsetNumber o,
int b, bool l);
int b, bool l, bool isNull);
extern StrategyNumber RelationGetGISTStrategy(Relation, AttrNumber,
RegProcedure);