Commit e7e16942 authored by Tom Lane's avatar Tom Lane

Migrate rtree_gist functionality into the core system, and add some

basic regression tests for GiST to the standard regression tests.
I took the opportunity to add an rtree-equivalent gist opclass for
circles; the contrib version only covered boxes and polygons, but
indexing circles is very handy for distance searches.
parent 875efad4
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Makefile for access/gist # Makefile for access/gist
# #
# IDENTIFICATION # IDENTIFICATION
# $PostgreSQL: pgsql/src/backend/access/gist/Makefile,v 1.14 2005/06/20 10:29:36 teodor Exp $ # $PostgreSQL: pgsql/src/backend/access/gist/Makefile,v 1.15 2005/07/01 19:19:02 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -12,7 +12,8 @@ subdir = src/backend/access/gist ...@@ -12,7 +12,8 @@ subdir = src/backend/access/gist
top_builddir = ../../../.. top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
OBJS = gist.o gistutil.o gistxlog.o gistvacuum.o gistget.o gistscan.o OBJS = gist.o gistutil.o gistxlog.o gistvacuum.o gistget.o gistscan.o \
gistproc.o
all: SUBSYS.o all: SUBSYS.o
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.89 2005/06/24 20:53:31 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.90 2005/07/01 19:19:02 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -4605,8 +4605,7 @@ circle_contain(PG_FUNCTION_ARGS) ...@@ -4605,8 +4605,7 @@ circle_contain(PG_FUNCTION_ARGS)
} }
/* circle_positionop - /* circle_below - is circle1 strictly below circle2?
* is circle1 entirely {above,below} circle2?
*/ */
Datum Datum
circle_below(PG_FUNCTION_ARGS) circle_below(PG_FUNCTION_ARGS)
...@@ -4614,18 +4613,46 @@ circle_below(PG_FUNCTION_ARGS) ...@@ -4614,18 +4613,46 @@ circle_below(PG_FUNCTION_ARGS)
CIRCLE *circle1 = PG_GETARG_CIRCLE_P(0); CIRCLE *circle1 = PG_GETARG_CIRCLE_P(0);
CIRCLE *circle2 = PG_GETARG_CIRCLE_P(1); CIRCLE *circle2 = PG_GETARG_CIRCLE_P(1);
PG_RETURN_BOOL(FPle(circle1->center.y + circle1->radius, PG_RETURN_BOOL(FPlt((circle1->center.y + circle1->radius),
circle2->center.y - circle2->radius)); (circle2->center.y - circle2->radius)));
} }
/* circle_above - is circle1 strictly above circle2?
*/
Datum Datum
circle_above(PG_FUNCTION_ARGS) circle_above(PG_FUNCTION_ARGS)
{ {
CIRCLE *circle1 = PG_GETARG_CIRCLE_P(0); CIRCLE *circle1 = PG_GETARG_CIRCLE_P(0);
CIRCLE *circle2 = PG_GETARG_CIRCLE_P(1); CIRCLE *circle2 = PG_GETARG_CIRCLE_P(1);
PG_RETURN_BOOL(FPge(circle1->center.y - circle1->radius, PG_RETURN_BOOL(FPgt((circle1->center.y - circle1->radius),
circle2->center.y + circle2->radius)); (circle2->center.y + circle2->radius)));
}
/* circle_overbelow - is the upper edge of circle1 at or below
* the upper edge of circle2?
*/
Datum
circle_overbelow(PG_FUNCTION_ARGS)
{
CIRCLE *circle1 = PG_GETARG_CIRCLE_P(0);
CIRCLE *circle2 = PG_GETARG_CIRCLE_P(1);
PG_RETURN_BOOL(FPle((circle1->center.y + circle1->radius),
(circle2->center.y + circle2->radius)));
}
/* circle_overabove - is the lower edge of circle1 at or above
* the lower edge of circle2?
*/
Datum
circle_overabove(PG_FUNCTION_ARGS)
{
CIRCLE *circle1 = PG_GETARG_CIRCLE_P(0);
CIRCLE *circle2 = PG_GETARG_CIRCLE_P(1);
PG_RETURN_BOOL(FPge((circle1->center.y - circle1->radius),
(circle2->center.y - circle2->radius)));
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.283 2005/06/28 05:09:04 tgl Exp $ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.284 2005/07/01 19:19:02 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 200506272 #define CATALOG_VERSION_NO 200507011
#endif #endif
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.64 2005/06/24 20:53:31 tgl Exp $ * $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.65 2005/07/01 19:19:03 tgl Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -619,4 +619,55 @@ DATA(insert ( 2232 0 1 f 2334 )); ...@@ -619,4 +619,55 @@ DATA(insert ( 2232 0 1 f 2334 ));
/* aclitem_ops */ /* aclitem_ops */
DATA(insert ( 2235 0 1 f 974 )); DATA(insert ( 2235 0 1 f 974 ));
/*
* gist box_ops
*/
DATA(insert ( 2593 0 1 f 493 ));
DATA(insert ( 2593 0 2 f 494 ));
DATA(insert ( 2593 0 3 f 500 ));
DATA(insert ( 2593 0 4 f 495 ));
DATA(insert ( 2593 0 5 f 496 ));
DATA(insert ( 2593 0 6 f 499 ));
DATA(insert ( 2593 0 7 f 498 ));
DATA(insert ( 2593 0 8 f 497 ));
DATA(insert ( 2593 0 9 f 2571 ));
DATA(insert ( 2593 0 10 f 2570 ));
DATA(insert ( 2593 0 11 f 2573 ));
DATA(insert ( 2593 0 12 f 2572 ));
/*
* gist poly_ops (supports polygons)
*/
DATA(insert ( 2594 0 1 t 485 ));
DATA(insert ( 2594 0 2 t 486 ));
DATA(insert ( 2594 0 3 t 492 ));
DATA(insert ( 2594 0 4 t 487 ));
DATA(insert ( 2594 0 5 t 488 ));
DATA(insert ( 2594 0 6 t 491 ));
DATA(insert ( 2594 0 7 t 490 ));
DATA(insert ( 2594 0 8 t 489 ));
DATA(insert ( 2594 0 9 t 2575 ));
DATA(insert ( 2594 0 10 t 2574 ));
DATA(insert ( 2594 0 11 t 2577 ));
DATA(insert ( 2594 0 12 t 2576 ));
/*
* gist circle_ops
*/
DATA(insert ( 2595 0 1 t 1506 ));
DATA(insert ( 2595 0 2 t 1507 ));
DATA(insert ( 2595 0 3 t 1513 ));
DATA(insert ( 2595 0 4 t 1508 ));
DATA(insert ( 2595 0 5 t 1509 ));
DATA(insert ( 2595 0 6 t 1512 ));
DATA(insert ( 2595 0 7 t 1511 ));
DATA(insert ( 2595 0 8 t 1510 ));
DATA(insert ( 2595 0 9 t 2589 ));
DATA(insert ( 2595 0 10 t 1515 ));
DATA(insert ( 2595 0 11 t 1514 ));
DATA(insert ( 2595 0 12 t 2590 ));
#endif /* PG_AMOP_H */ #endif /* PG_AMOP_H */
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/pg_amproc.h,v 1.53 2005/04/14 01:38:20 tgl Exp $ * $PostgreSQL: pgsql/src/include/catalog/pg_amproc.h,v 1.54 2005/07/01 19:19:03 tgl Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -170,4 +170,28 @@ DATA(insert ( 2231 0 1 456 )); ...@@ -170,4 +170,28 @@ DATA(insert ( 2231 0 1 456 ));
DATA(insert ( 2232 0 1 455 )); DATA(insert ( 2232 0 1 455 ));
DATA(insert ( 2235 0 1 329 )); DATA(insert ( 2235 0 1 329 ));
/* gist */
DATA(insert ( 2593 0 1 2578 ));
DATA(insert ( 2593 0 2 2583 ));
DATA(insert ( 2593 0 3 2579 ));
DATA(insert ( 2593 0 4 2580 ));
DATA(insert ( 2593 0 5 2581 ));
DATA(insert ( 2593 0 6 2582 ));
DATA(insert ( 2593 0 7 2584 ));
DATA(insert ( 2594 0 1 2585 ));
DATA(insert ( 2594 0 2 2583 ));
DATA(insert ( 2594 0 3 2586 ));
DATA(insert ( 2594 0 4 2580 ));
DATA(insert ( 2594 0 5 2581 ));
DATA(insert ( 2594 0 6 2582 ));
DATA(insert ( 2594 0 7 2584 ));
DATA(insert ( 2595 0 1 2591 ));
DATA(insert ( 2595 0 2 2583 ));
DATA(insert ( 2595 0 3 2592 ));
DATA(insert ( 2595 0 4 2580 ));
DATA(insert ( 2595 0 5 2581 ));
DATA(insert ( 2595 0 6 2582 ));
DATA(insert ( 2595 0 7 2584 ));
#endif /* PG_AMPROC_H */ #endif /* PG_AMPROC_H */
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/pg_opclass.h,v 1.65 2005/06/28 05:09:07 tgl Exp $ * $PostgreSQL: pgsql/src/include/catalog/pg_opclass.h,v 1.66 2005/07/01 19:19:03 tgl Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -175,5 +175,8 @@ DATA(insert OID = 2232 ( 405 name_pattern_ops PGNSP PGUID 19 f 0 )); ...@@ -175,5 +175,8 @@ DATA(insert OID = 2232 ( 405 name_pattern_ops PGNSP PGUID 19 f 0 ));
DATA(insert OID = 2233 ( 403 reltime_ops PGNSP PGUID 703 t 0 )); DATA(insert OID = 2233 ( 403 reltime_ops PGNSP PGUID 703 t 0 ));
DATA(insert OID = 2234 ( 403 tinterval_ops PGNSP PGUID 704 t 0 )); DATA(insert OID = 2234 ( 403 tinterval_ops PGNSP PGUID 704 t 0 ));
DATA(insert OID = 2235 ( 405 aclitem_ops PGNSP PGUID 1033 t 0 )); DATA(insert OID = 2235 ( 405 aclitem_ops PGNSP PGUID 1033 t 0 ));
DATA(insert OID = 2593 ( 783 box_ops PGNSP PGUID 603 t 0 ));
DATA(insert OID = 2594 ( 783 poly_ops PGNSP PGUID 604 t 603 ));
DATA(insert OID = 2595 ( 783 circle_ops PGNSP PGUID 718 t 603 ));
#endif /* PG_OPCLASS_H */ #endif /* PG_OPCLASS_H */
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.135 2005/06/28 05:09:07 tgl Exp $ * $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.136 2005/07/01 19:19:03 tgl Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -568,8 +568,8 @@ DATA(insert OID = 1510 ( "@" PGNSP PGUID b f 718 718 16 1511 0 0 0 0 0 ...@@ -568,8 +568,8 @@ DATA(insert OID = 1510 ( "@" PGNSP PGUID b f 718 718 16 1511 0 0 0 0 0
DATA(insert OID = 1511 ( "~" PGNSP PGUID b f 718 718 16 1510 0 0 0 0 0 circle_contain contsel contjoinsel )); DATA(insert OID = 1511 ( "~" PGNSP PGUID b f 718 718 16 1510 0 0 0 0 0 circle_contain contsel contjoinsel ));
DATA(insert OID = 1512 ( "~=" PGNSP PGUID b f 718 718 16 1512 0 0 0 0 0 circle_same eqsel eqjoinsel )); DATA(insert OID = 1512 ( "~=" PGNSP PGUID b f 718 718 16 1512 0 0 0 0 0 circle_same eqsel eqjoinsel ));
DATA(insert OID = 1513 ( "&&" PGNSP PGUID b f 718 718 16 1513 0 0 0 0 0 circle_overlap areasel areajoinsel )); DATA(insert OID = 1513 ( "&&" PGNSP PGUID b f 718 718 16 1513 0 0 0 0 0 circle_overlap areasel areajoinsel ));
DATA(insert OID = 1514 ( ">^" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_above positionsel positionjoinsel )); DATA(insert OID = 1514 ( "|>>" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_above positionsel positionjoinsel ));
DATA(insert OID = 1515 ( "<^" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_below positionsel positionjoinsel )); DATA(insert OID = 1515 ( "<<|" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_below positionsel positionjoinsel ));
DATA(insert OID = 1516 ( "+" PGNSP PGUID b f 718 600 718 0 0 0 0 0 0 circle_add_pt - - )); DATA(insert OID = 1516 ( "+" PGNSP PGUID b f 718 600 718 0 0 0 0 0 0 circle_add_pt - - ));
DATA(insert OID = 1517 ( "-" PGNSP PGUID b f 718 600 718 0 0 0 0 0 0 circle_sub_pt - - )); DATA(insert OID = 1517 ( "-" PGNSP PGUID b f 718 600 718 0 0 0 0 0 0 circle_sub_pt - - ));
...@@ -874,6 +874,8 @@ DATA(insert OID = 2574 ( "<<|" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 ...@@ -874,6 +874,8 @@ DATA(insert OID = 2574 ( "<<|" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0
DATA(insert OID = 2575 ( "&<|" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_overbelow positionsel positionjoinsel )); DATA(insert OID = 2575 ( "&<|" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_overbelow positionsel positionjoinsel ));
DATA(insert OID = 2576 ( "|&>" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_overabove positionsel positionjoinsel )); DATA(insert OID = 2576 ( "|&>" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_overabove positionsel positionjoinsel ));
DATA(insert OID = 2577 ( "|>>" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_above positionsel positionjoinsel )); DATA(insert OID = 2577 ( "|>>" PGNSP PGUID b f 604 604 16 0 0 0 0 0 0 poly_above positionsel positionjoinsel ));
DATA(insert OID = 2589 ( "&<|" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_overbelow positionsel positionjoinsel ));
DATA(insert OID = 2590 ( "|&>" PGNSP PGUID b f 718 718 16 0 0 0 0 0 0 circle_overabove positionsel positionjoinsel ));
/* /*
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.372 2005/06/28 05:09:09 tgl Exp $ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.373 2005/07/01 19:19:03 tgl Exp $
* *
* NOTES * NOTES
* The script catalog/genbki.sh reads this file and generates .bki * The script catalog/genbki.sh reads this file and generates .bki
...@@ -3675,6 +3675,34 @@ DATA(insert OID = 2568 ( poly_overabove PGNSP PGUID 12 f f t f i 2 16 "604 60 ...@@ -3675,6 +3675,34 @@ DATA(insert OID = 2568 ( poly_overabove PGNSP PGUID 12 f f t f i 2 16 "604 60
DESCR("overlaps or is above"); DESCR("overlaps or is above");
DATA(insert OID = 2569 ( poly_above PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_above - _null_ )); DATA(insert OID = 2569 ( poly_above PGNSP PGUID 12 f f t f i 2 16 "604 604" _null_ _null_ _null_ poly_above - _null_ ));
DESCR("is above"); DESCR("is above");
DATA(insert OID = 2587 ( circle_overbelow PGNSP PGUID 12 f f t f i 2 16 "718 718" _null_ _null_ _null_ circle_overbelow - _null_ ));
DESCR("overlaps or is below");
DATA(insert OID = 2588 ( circle_overabove PGNSP PGUID 12 f f t f i 2 16 "718 718" _null_ _null_ _null_ circle_overabove - _null_ ));
DESCR("overlaps or is above");
/* support functions for GiST r-tree emulation */
DATA(insert OID = 2578 ( gist_box_consistent PGNSP PGUID 12 f f t f i 3 16 "2281 603 23" _null_ _null_ _null_ gist_box_consistent - _null_ ));
DESCR("GiST support");
DATA(insert OID = 2579 ( gist_box_compress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_box_compress - _null_ ));
DESCR("GiST support");
DATA(insert OID = 2580 ( gist_box_decompress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_box_decompress - _null_ ));
DESCR("GiST support");
DATA(insert OID = 2581 ( gist_box_penalty PGNSP PGUID 12 f f t f i 3 2281 "2281 2281 2281" _null_ _null_ _null_ gist_box_penalty - _null_ ));
DESCR("GiST support");
DATA(insert OID = 2582 ( gist_box_picksplit PGNSP PGUID 12 f f t f i 2 2281 "2281 2281" _null_ _null_ _null_ gist_box_picksplit - _null_ ));
DESCR("GiST support");
DATA(insert OID = 2583 ( gist_box_union PGNSP PGUID 12 f f t f i 2 603 "2281 2281" _null_ _null_ _null_ gist_box_union - _null_ ));
DESCR("GiST support");
DATA(insert OID = 2584 ( gist_box_same PGNSP PGUID 12 f f t f i 3 2281 "603 603 2281" _null_ _null_ _null_ gist_box_same - _null_ ));
DESCR("GiST support");
DATA(insert OID = 2585 ( gist_poly_consistent PGNSP PGUID 12 f f t f i 3 16 "2281 604 23" _null_ _null_ _null_ gist_poly_consistent - _null_ ));
DESCR("GiST support");
DATA(insert OID = 2586 ( gist_poly_compress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_poly_compress - _null_ ));
DESCR("GiST support");
DATA(insert OID = 2591 ( gist_circle_consistent PGNSP PGUID 12 f f t f i 3 16 "2281 718 23" _null_ _null_ _null_ gist_circle_consistent - _null_ ));
DESCR("GiST support");
DATA(insert OID = 2592 ( gist_circle_compress PGNSP PGUID 12 f f t f i 1 2281 "2281" _null_ _null_ _null_ gist_circle_compress - _null_ ));
DESCR("GiST support");
/* /*
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/utils/geo_decls.h,v 1.47 2005/06/24 20:53:33 tgl Exp $ * $PostgreSQL: pgsql/src/include/utils/geo_decls.h,v 1.48 2005/07/01 19:19:04 tgl Exp $
* *
* NOTE * NOTE
* These routines do *not* use the float types from adt/. * These routines do *not* use the float types from adt/.
...@@ -379,6 +379,8 @@ extern Datum circle_contained(PG_FUNCTION_ARGS); ...@@ -379,6 +379,8 @@ extern Datum circle_contained(PG_FUNCTION_ARGS);
extern Datum circle_contain(PG_FUNCTION_ARGS); extern Datum circle_contain(PG_FUNCTION_ARGS);
extern Datum circle_below(PG_FUNCTION_ARGS); extern Datum circle_below(PG_FUNCTION_ARGS);
extern Datum circle_above(PG_FUNCTION_ARGS); extern Datum circle_above(PG_FUNCTION_ARGS);
extern Datum circle_overbelow(PG_FUNCTION_ARGS);
extern Datum circle_overabove(PG_FUNCTION_ARGS);
extern Datum circle_eq(PG_FUNCTION_ARGS); extern Datum circle_eq(PG_FUNCTION_ARGS);
extern Datum circle_ne(PG_FUNCTION_ARGS); extern Datum circle_ne(PG_FUNCTION_ARGS);
extern Datum circle_lt(PG_FUNCTION_ARGS); extern Datum circle_lt(PG_FUNCTION_ARGS);
...@@ -404,7 +406,7 @@ extern Datum poly_circle(PG_FUNCTION_ARGS); ...@@ -404,7 +406,7 @@ extern Datum poly_circle(PG_FUNCTION_ARGS);
extern Datum circle_poly(PG_FUNCTION_ARGS); extern Datum circle_poly(PG_FUNCTION_ARGS);
extern Datum circle_area(PG_FUNCTION_ARGS); extern Datum circle_area(PG_FUNCTION_ARGS);
/* support routines for the rtree access method (rtproc.c) */ /* support routines for the rtree access method (access/rtree/rtproc.c) */
extern Datum rt_box_union(PG_FUNCTION_ARGS); extern Datum rt_box_union(PG_FUNCTION_ARGS);
extern Datum rt_box_inter(PG_FUNCTION_ARGS); extern Datum rt_box_inter(PG_FUNCTION_ARGS);
extern Datum rt_box_size(PG_FUNCTION_ARGS); extern Datum rt_box_size(PG_FUNCTION_ARGS);
...@@ -412,6 +414,19 @@ extern Datum rt_poly_size(PG_FUNCTION_ARGS); ...@@ -412,6 +414,19 @@ extern Datum rt_poly_size(PG_FUNCTION_ARGS);
extern Datum rt_poly_union(PG_FUNCTION_ARGS); extern Datum rt_poly_union(PG_FUNCTION_ARGS);
extern Datum rt_poly_inter(PG_FUNCTION_ARGS); extern Datum rt_poly_inter(PG_FUNCTION_ARGS);
/* support routines for the GiST access method (access/gist/gistproc.c) */
extern Datum gist_box_compress(PG_FUNCTION_ARGS);
extern Datum gist_box_decompress(PG_FUNCTION_ARGS);
extern Datum gist_box_union(PG_FUNCTION_ARGS);
extern Datum gist_box_picksplit(PG_FUNCTION_ARGS);
extern Datum gist_box_consistent(PG_FUNCTION_ARGS);
extern Datum gist_box_penalty(PG_FUNCTION_ARGS);
extern Datum gist_box_same(PG_FUNCTION_ARGS);
extern Datum gist_poly_compress(PG_FUNCTION_ARGS);
extern Datum gist_poly_consistent(PG_FUNCTION_ARGS);
extern Datum gist_circle_compress(PG_FUNCTION_ARGS);
extern Datum gist_circle_consistent(PG_FUNCTION_ARGS);
/* geo_selfuncs.c */ /* geo_selfuncs.c */
extern Datum areasel(PG_FUNCTION_ARGS); extern Datum areasel(PG_FUNCTION_ARGS);
extern Datum areajoinsel(PG_FUNCTION_ARGS); extern Datum areajoinsel(PG_FUNCTION_ARGS);
......
This diff is collapsed.
...@@ -54,7 +54,28 @@ CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 name_ops) ...@@ -54,7 +54,28 @@ CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 name_ops)
-- benchmark). -- benchmark).
-- --
CREATE INDEX rect2ind ON fast_emp4000 USING rtree (home_base); CREATE INDEX rect2ind ON fast_emp4000 USING rtree (home_base);
-- there's no easy way to check that this command actually is using SET enable_seqscan = ON;
SET enable_indexscan = OFF;
SET enable_bitmapscan = OFF;
SELECT * FROM fast_emp4000
WHERE home_base @ '(200,200),(2000,1000)'::box
ORDER BY home_base USING <<;
home_base
-----------------------
(337,455),(240,359)
(1444,403),(1346,344)
(2 rows)
SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box;
count
-------
2
(1 row)
SET enable_seqscan = OFF;
SET enable_indexscan = ON;
SET enable_bitmapscan = ON;
-- there's no easy way to check that these commands actually use
-- the index, unfortunately. (EXPLAIN would work, but its output -- the index, unfortunately. (EXPLAIN would work, but its output
-- changes too often for me to want to put an EXPLAIN in the test...) -- changes too often for me to want to put an EXPLAIN in the test...)
SELECT * FROM fast_emp4000 SELECT * FROM fast_emp4000
...@@ -66,6 +87,125 @@ SELECT * FROM fast_emp4000 ...@@ -66,6 +87,125 @@ SELECT * FROM fast_emp4000
(1444,403),(1346,344) (1444,403),(1346,344)
(2 rows) (2 rows)
SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box;
count
-------
2
(1 row)
DROP INDEX rect2ind;
--
-- GiST (rtree-equivalent opclasses only)
--
CREATE INDEX grect2ind ON fast_emp4000 USING gist (home_base);
CREATE INDEX gpolygonind ON polygon_tbl USING gist (f1);
CREATE INDEX gcircleind ON circle_tbl USING gist (f1);
CREATE TEMP TABLE gpolygon_tbl AS
SELECT polygon(home_base) AS f1 FROM slow_emp4000;
CREATE TEMP TABLE gcircle_tbl AS
SELECT circle(home_base) AS f1 FROM slow_emp4000;
CREATE INDEX ggpolygonind ON gpolygon_tbl USING gist (f1);
CREATE INDEX ggcircleind ON gcircle_tbl USING gist (f1);
SET enable_seqscan = ON;
SET enable_indexscan = OFF;
SET enable_bitmapscan = OFF;
SELECT * FROM fast_emp4000
WHERE home_base @ '(200,200),(2000,1000)'::box
ORDER BY home_base USING <<;
home_base
-----------------------
(337,455),(240,359)
(1444,403),(1346,344)
(2 rows)
SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box;
count
-------
2
(1 row)
SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon
ORDER BY f1 USING <<;
f1
---------------------
((2,0),(2,4),(0,0))
(1 row)
SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1)
ORDER BY f1 USING <<;
f1
---------------
<(1,3),5>
<(1,2),100>
<(1,2),3>
<(100,1),115>
(4 rows)
SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon;
count
-------
2
(1 row)
SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle;
count
-------
2
(1 row)
SET enable_seqscan = OFF;
SET enable_indexscan = ON;
SET enable_bitmapscan = ON;
-- there's no easy way to check that these commands actually use
-- the index, unfortunately. (EXPLAIN would work, but its output
-- changes too often for me to want to put an EXPLAIN in the test...)
SELECT * FROM fast_emp4000
WHERE home_base @ '(200,200),(2000,1000)'::box
ORDER BY home_base USING <<;
home_base
-----------------------
(337,455),(240,359)
(1444,403),(1346,344)
(2 rows)
SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box;
count
-------
2
(1 row)
SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon
ORDER BY f1 USING <<;
f1
---------------------
((2,0),(2,4),(0,0))
(1 row)
SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1)
ORDER BY f1 USING <<;
f1
---------------
<(1,3),5>
<(1,2),100>
<(1,2),3>
<(100,1),115>
(4 rows)
SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon;
count
-------
2
(1 row)
SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle;
count
-------
2
(1 row)
RESET enable_seqscan;
RESET enable_indexscan;
RESET enable_bitmapscan;
-- --
-- HASH -- HASH
-- --
......
...@@ -765,9 +765,12 @@ WHERE p1.amopclaid = p3.oid AND p3.opcamid = p2.oid AND ...@@ -765,9 +765,12 @@ WHERE p1.amopclaid = p3.oid AND p3.opcamid = p2.oid AND
-- Detect missing pg_amop entries: should have as many strategy operators -- Detect missing pg_amop entries: should have as many strategy operators
-- as AM expects for each opclass for the AM. When nondefault subtypes are -- as AM expects for each opclass for the AM. When nondefault subtypes are
-- present, enforce condition separately for each subtype. -- present, enforce condition separately for each subtype.
-- We have to exclude GiST, unfortunately, since it hasn't got any fixed
-- requirements about strategy operators.
SELECT p1.oid, p1.amname, p2.oid, p2.opcname, p3.amopsubtype SELECT p1.oid, p1.amname, p2.oid, p2.opcname, p3.amopsubtype
FROM pg_am AS p1, pg_opclass AS p2, pg_amop AS p3 FROM pg_am AS p1, pg_opclass AS p2, pg_amop AS p3
WHERE p2.opcamid = p1.oid AND p3.amopclaid = p2.oid AND WHERE p2.opcamid = p1.oid AND p3.amopclaid = p2.oid AND
p1.amname != 'gist' AND
p1.amstrategies != (SELECT count(*) FROM pg_amop AS p4 p1.amstrategies != (SELECT count(*) FROM pg_amop AS p4
WHERE p4.amopclaid = p2.oid AND WHERE p4.amopclaid = p2.oid AND
p4.amopsubtype = p3.amopsubtype); p4.amopsubtype = p3.amopsubtype);
...@@ -819,7 +822,19 @@ ORDER BY 1, 2, 3; ...@@ -819,7 +822,19 @@ ORDER BY 1, 2, 3;
403 | 5 | ~>~ 403 | 5 | ~>~
405 | 1 | = 405 | 1 | =
405 | 1 | ~=~ 405 | 1 | ~=~
(24 rows) 783 | 1 | <<
783 | 2 | &<
783 | 3 | &&
783 | 4 | &>
783 | 5 | >>
783 | 6 | ~=
783 | 7 | ~
783 | 8 | @
783 | 9 | &<|
783 | 10 | <<|
783 | 11 | |>>
783 | 12 | |&>
(36 rows)
-- Check that all operators linked to by opclass entries have selectivity -- Check that all operators linked to by opclass entries have selectivity
-- estimators. This is not absolutely required, but it seems a reasonable -- estimators. This is not absolutely required, but it seems a reasonable
......
...@@ -14,6 +14,7 @@ SELECT relname, relhasindex ...@@ -14,6 +14,7 @@ SELECT relname, relhasindex
bt_i4_heap | t bt_i4_heap | t
bt_name_heap | t bt_name_heap | t
bt_txt_heap | t bt_txt_heap | t
circle_tbl | t
fast_emp4000 | t fast_emp4000 | t
func_index_heap | t func_index_heap | t
hash_f8_heap | t hash_f8_heap | t
...@@ -59,11 +60,12 @@ SELECT relname, relhasindex ...@@ -59,11 +60,12 @@ SELECT relname, relhasindex
pg_tablespace | t pg_tablespace | t
pg_trigger | t pg_trigger | t
pg_type | t pg_type | t
polygon_tbl | t
road | t road | t
shighway | t shighway | t
tenk1 | t tenk1 | t
tenk2 | t tenk2 | t
(53 rows) (55 rows)
-- --
-- another sanity check: every system catalog that has OIDs should have -- another sanity check: every system catalog that has OIDs should have
......
...@@ -77,13 +77,98 @@ CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 name_ops) ...@@ -77,13 +77,98 @@ CREATE INDEX onek2_stu1_prtl ON onek2 USING btree(stringu1 name_ops)
-- --
CREATE INDEX rect2ind ON fast_emp4000 USING rtree (home_base); CREATE INDEX rect2ind ON fast_emp4000 USING rtree (home_base);
-- there's no easy way to check that this command actually is using SET enable_seqscan = ON;
SET enable_indexscan = OFF;
SET enable_bitmapscan = OFF;
SELECT * FROM fast_emp4000
WHERE home_base @ '(200,200),(2000,1000)'::box
ORDER BY home_base USING <<;
SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box;
SET enable_seqscan = OFF;
SET enable_indexscan = ON;
SET enable_bitmapscan = ON;
-- there's no easy way to check that these commands actually use
-- the index, unfortunately. (EXPLAIN would work, but its output
-- changes too often for me to want to put an EXPLAIN in the test...)
SELECT * FROM fast_emp4000
WHERE home_base @ '(200,200),(2000,1000)'::box
ORDER BY home_base USING <<;
SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box;
DROP INDEX rect2ind;
--
-- GiST (rtree-equivalent opclasses only)
--
CREATE INDEX grect2ind ON fast_emp4000 USING gist (home_base);
CREATE INDEX gpolygonind ON polygon_tbl USING gist (f1);
CREATE INDEX gcircleind ON circle_tbl USING gist (f1);
CREATE TEMP TABLE gpolygon_tbl AS
SELECT polygon(home_base) AS f1 FROM slow_emp4000;
CREATE TEMP TABLE gcircle_tbl AS
SELECT circle(home_base) AS f1 FROM slow_emp4000;
CREATE INDEX ggpolygonind ON gpolygon_tbl USING gist (f1);
CREATE INDEX ggcircleind ON gcircle_tbl USING gist (f1);
SET enable_seqscan = ON;
SET enable_indexscan = OFF;
SET enable_bitmapscan = OFF;
SELECT * FROM fast_emp4000
WHERE home_base @ '(200,200),(2000,1000)'::box
ORDER BY home_base USING <<;
SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box;
SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon
ORDER BY f1 USING <<;
SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1)
ORDER BY f1 USING <<;
SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon;
SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle;
SET enable_seqscan = OFF;
SET enable_indexscan = ON;
SET enable_bitmapscan = ON;
-- there's no easy way to check that these commands actually use
-- the index, unfortunately. (EXPLAIN would work, but its output -- the index, unfortunately. (EXPLAIN would work, but its output
-- changes too often for me to want to put an EXPLAIN in the test...) -- changes too often for me to want to put an EXPLAIN in the test...)
SELECT * FROM fast_emp4000 SELECT * FROM fast_emp4000
WHERE home_base @ '(200,200),(2000,1000)'::box WHERE home_base @ '(200,200),(2000,1000)'::box
ORDER BY home_base USING <<; ORDER BY home_base USING <<;
SELECT count(*) FROM fast_emp4000 WHERE home_base && '(1000,1000,0,0)'::box;
SELECT * FROM polygon_tbl WHERE f1 ~ '((1,1),(2,2),(2,1))'::polygon
ORDER BY f1 USING <<;
SELECT * FROM circle_tbl WHERE f1 && circle(point(1,-2), 1)
ORDER BY f1 USING <<;
SELECT count(*) FROM gpolygon_tbl WHERE f1 && '(1000,1000,0,0)'::polygon;
SELECT count(*) FROM gcircle_tbl WHERE f1 && '<(500,500),500>'::circle;
RESET enable_seqscan;
RESET enable_indexscan;
RESET enable_bitmapscan;
-- --
-- HASH -- HASH
-- --
......
...@@ -631,10 +631,13 @@ WHERE p1.amopclaid = p3.oid AND p3.opcamid = p2.oid AND ...@@ -631,10 +631,13 @@ WHERE p1.amopclaid = p3.oid AND p3.opcamid = p2.oid AND
-- Detect missing pg_amop entries: should have as many strategy operators -- Detect missing pg_amop entries: should have as many strategy operators
-- as AM expects for each opclass for the AM. When nondefault subtypes are -- as AM expects for each opclass for the AM. When nondefault subtypes are
-- present, enforce condition separately for each subtype. -- present, enforce condition separately for each subtype.
-- We have to exclude GiST, unfortunately, since it hasn't got any fixed
-- requirements about strategy operators.
SELECT p1.oid, p1.amname, p2.oid, p2.opcname, p3.amopsubtype SELECT p1.oid, p1.amname, p2.oid, p2.opcname, p3.amopsubtype
FROM pg_am AS p1, pg_opclass AS p2, pg_amop AS p3 FROM pg_am AS p1, pg_opclass AS p2, pg_amop AS p3
WHERE p2.opcamid = p1.oid AND p3.amopclaid = p2.oid AND WHERE p2.opcamid = p1.oid AND p3.amopclaid = p2.oid AND
p1.amname != 'gist' AND
p1.amstrategies != (SELECT count(*) FROM pg_amop AS p4 p1.amstrategies != (SELECT count(*) FROM pg_amop AS p4
WHERE p4.amopclaid = p2.oid AND WHERE p4.amopclaid = p2.oid AND
p4.amopsubtype = p3.amopsubtype); p4.amopsubtype = p3.amopsubtype);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment