From 2a2f70ec9de38812fa67889e00a5e29f3e46c02f Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Mon, 2 Oct 2023 17:16:11 +0200 Subject: [PATCH 1/2] Bump version to 1.3.2 --- Makefile | 6 +++++- Makefile.common.mk | 2 +- expected/init.out | 2 +- pg_sphere--1.3.1.sql.in => pg_sphere--1.3.2.sql.in | 0 pg_sphere.control | 2 +- upgrade_scripts/pg_sphere--1.3.1--1.3.2.sql.in | 1 + 6 files changed, 9 insertions(+), 4 deletions(-) rename pg_sphere--1.3.1.sql.in => pg_sphere--1.3.2.sql.in (100%) create mode 100644 upgrade_scripts/pg_sphere--1.3.1--1.3.2.sql.in diff --git a/Makefile b/Makefile index db9cf59..2d33da4 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,8 @@ DATA_built = $(RELEASE_SQL) \ pg_sphere--1.2.1--1.2.2.sql \ pg_sphere--1.2.2--1.2.3.sql \ pg_sphere--1.2.3--1.3.0.sql \ - pg_sphere--1.3.0--1.3.1.sql + pg_sphere--1.3.0--1.3.1.sql \ + pg_sphere--1.3.1--1.3.2.sql DOCS = README.pg_sphere COPYRIGHT.pg_sphere REGRESS = init tables points euler circle line ellipse poly path box index \ @@ -258,6 +259,9 @@ pg_sphere--1.2.3--1.3.0.sql: pgs_brin.sql.in pg_sphere--1.3.0--1.3.1.sql: cat upgrade_scripts/$@.in > $@ +pg_sphere--1.3.1--1.3.2.sql: + cat upgrade_scripts/$@.in > $@ + # end of local stuff src/sscan.o : src/sparse.c diff --git a/Makefile.common.mk b/Makefile.common.mk index f3893a9..6387bea 100644 --- a/Makefile.common.mk +++ b/Makefile.common.mk @@ -5,4 +5,4 @@ #---------------------------------------------------------------------------- EXTENSION := pg_sphere -PGSPHERE_VERSION := 1.3.1 +PGSPHERE_VERSION := 1.3.2 diff --git a/expected/init.out b/expected/init.out index fb86488..f5e092b 100644 --- a/expected/init.out +++ b/expected/init.out @@ -6,6 +6,6 @@ CREATE EXTENSION pg_sphere; select pg_sphere_version(); pg_sphere_version ------------------- - 1.3.1 + 1.3.2 (1 row) diff --git a/pg_sphere--1.3.1.sql.in b/pg_sphere--1.3.2.sql.in similarity index 100% rename from pg_sphere--1.3.1.sql.in rename to pg_sphere--1.3.2.sql.in diff --git a/pg_sphere.control b/pg_sphere.control index e2b8ad3..d9f2ccc 100644 --- a/pg_sphere.control +++ b/pg_sphere.control @@ -1,5 +1,5 @@ # pg_sphere extension comment = 'spherical objects with useful functions, operators and index support' -default_version = '1.3.1' +default_version = '1.3.2' module_pathname = '$libdir/pg_sphere' relocatable = true diff --git a/upgrade_scripts/pg_sphere--1.3.1--1.3.2.sql.in b/upgrade_scripts/pg_sphere--1.3.1--1.3.2.sql.in new file mode 100644 index 0000000..8ea3baa --- /dev/null +++ b/upgrade_scripts/pg_sphere--1.3.1--1.3.2.sql.in @@ -0,0 +1 @@ +-- Nothing to upgrade in the schema From c2a235160db76f9ae050a5eb1f1a7a9135787f58 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Mon, 2 Oct 2023 17:24:45 +0200 Subject: [PATCH 2/2] Merge index fetch support for spoint3 into main files So far, the function backing index only fetches on spoint3 gist indexes was already always compiled, but only added to the operator class for PG9.5+, and only when special code in the Makefile was uncommented. We are well past 9.5, and the feature works just fine, so load it unconditionally (assuming no one used it in production yet, ADD FUNCTION will fail when executed twice). Version bumped since we add a new function to the opclass. --- Makefile | 13 ---- expected/index.out | 61 ++++++++++++++++++ expected/index_9.5.out | 62 ------------------- expected/init_test_healpix.out.in | 4 +- index_9.5 | 0 pgs_9.5.sql.in | 7 --- pgs_gist_spoint3.sql.in | 1 + sql/index.sql | 17 +++++ sql/index_9.5.sql | 18 ------ .../pg_sphere--1.3.1--1.3.2.sql.in | 5 +- 10 files changed, 85 insertions(+), 103 deletions(-) delete mode 100644 expected/index_9.5.out delete mode 100644 index_9.5 delete mode 100644 pgs_9.5.sql.in delete mode 100644 sql/index_9.5.sql diff --git a/Makefile b/Makefile index 2d33da4..a016313 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,6 @@ ifneq ($(USE_HEALPIX),0) REGRESS += healpix moc mocautocast endif -REGRESS_9_5 = index_9.5 # experimental for spoint3 - TESTS = init_test tables points euler circle line ellipse poly path box \ index contains_ops contains_ops_compat bounding_box_gist gnomo \ epochprop contains overlaps spoint_brin sbox_brin @@ -84,8 +82,6 @@ endif PGS_SQL += pgs_epochprop.sql -PGS_SQL_9_5 = pgs_9.5.sql # experimental for spoint3 - ifdef USE_PGXS ifndef PG_CONFIG PG_CONFIG = pg_config @@ -112,18 +108,9 @@ endif healpix_bare/healpix_bare.o : healpix_bare/healpix_bare.c $(COMPILE.c) -Wno-declaration-after-statement -o $@ $^ -# experimental for spoint3 pg_version := $(word 2,$(shell $(PG_CONFIG) --version)) -pg_version_9_5_plus = $(if $(filter-out 9.1% 9.2% 9.3% 9.4%,$(pg_version)),y,n) has_explain_summary = $(if $(filter-out 9.%,$(pg_version)),y,n) -## the use of spoint 3 is too experimental and preliminary: -#ifeq ($(pg_version_9_5_plus),y) -# REGRESS += $(REGRESS_9_5) -# TESTS += $(REGRESS_9_5) -# PGS_SQL += $(PGS_SQL_9_5) -#endif - crushtest: REGRESS += $(CRUSH_TESTS) crushtest: installcheck diff --git a/expected/index.out b/expected/index.out index a639dab..8c67155 100644 --- a/expected/index.out +++ b/expected/index.out @@ -134,3 +134,64 @@ SELECT count(*) FROM spheretmp4 WHERE l && scircle '<(1,1),0.3>' ; 40 (1 row) +-- test spoint3 operator class with and without index-only scan +SET enable_bitmapscan = OFF; +SET enable_indexonlyscan = ON; +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + QUERY PLAN +-------------------------------------------------------- + Aggregate + -> Index Only Scan using spoint3_idx on spheretmp1b + Index Cond: (p <@ '<(1 , 1) , 0.3>'::scircle) +(3 rows) + + SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + count +------- + 32 +(1 row) + +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + QUERY PLAN +-------------------------------------------------------- + Aggregate + -> Index Only Scan using spoint3_idx on spheretmp1b + Index Cond: (p = '(3.09 , 1.25)'::spoint) +(3 rows) + + SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + count +------- + 4 +(1 row) + +SET enable_bitmapscan = ON; +SET enable_indexonlyscan = OFF; +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + QUERY PLAN +------------------------------------------------------- + Aggregate + -> Index Scan using spoint3_idx on spheretmp1b + Index Cond: (p <@ '<(1 , 1) , 0.3>'::scircle) +(3 rows) + + SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + count +------- + 32 +(1 row) + +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + QUERY PLAN +--------------------------------------------------- + Aggregate + -> Index Scan using spoint3_idx on spheretmp1b + Index Cond: (p = '(3.09 , 1.25)'::spoint) +(3 rows) + + SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + count +------- + 4 +(1 row) + diff --git a/expected/index_9.5.out b/expected/index_9.5.out deleted file mode 100644 index 99995f0..0000000 --- a/expected/index_9.5.out +++ /dev/null @@ -1,62 +0,0 @@ --- test spoint3 operator class with and without index-only scan -SET enable_seqscan = OFF; -SET enable_bitmapscan = OFF; -SET enable_indexonlyscan = ON; -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - QUERY PLAN --------------------------------------------------------- - Aggregate - -> Index Only Scan using spoint3_idx on spheretmp1b - Index Cond: (p <@ '<(1 , 1) , 0.3>'::scircle) -(3 rows) - - SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - count -------- - 32 -(1 row) - -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - QUERY PLAN --------------------------------------------------------- - Aggregate - -> Index Only Scan using spoint3_idx on spheretmp1b - Index Cond: (p = '(3.09 , 1.25)'::spoint) -(3 rows) - - SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - count -------- - 4 -(1 row) - -SET enable_bitmapscan = ON; -SET enable_indexonlyscan = OFF; -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - QUERY PLAN -------------------------------------------------------- - Aggregate - -> Index Scan using spoint3_idx on spheretmp1b - Index Cond: (p <@ '<(1 , 1) , 0.3>'::scircle) -(3 rows) - - SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - count -------- - 32 -(1 row) - -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - QUERY PLAN ---------------------------------------------------- - Aggregate - -> Index Scan using spoint3_idx on spheretmp1b - Index Cond: (p = '(3.09 , 1.25)'::spoint) -(3 rows) - - SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - count -------- - 4 -(1 row) - diff --git a/expected/init_test_healpix.out.in b/expected/init_test_healpix.out.in index b87a70d..95de0db 100644 --- a/expected/init_test_healpix.out.in +++ b/expected/init_test_healpix.out.in @@ -1,2 +1,2 @@ -psql:pg_sphere.test.sql:9684: NOTICE: return type smoc is only a shell -psql:pg_sphere.test.sql:9690: NOTICE: argument type smoc is only a shell +psql:pg_sphere.test.sql:9685: NOTICE: return type smoc is only a shell +psql:pg_sphere.test.sql:9691: NOTICE: argument type smoc is only a shell diff --git a/index_9.5 b/index_9.5 deleted file mode 100644 index e69de29..0000000 diff --git a/pgs_9.5.sql.in b/pgs_9.5.sql.in deleted file mode 100644 index e3b806d..0000000 --- a/pgs_9.5.sql.in +++ /dev/null @@ -1,7 +0,0 @@ --- add functionality that is only available for PostgreSQL 9.5+ - - --- add "fetch" support function to enable index-only scans for spoint3 - -ALTER OPERATOR FAMILY spoint3 USING gist ADD - FUNCTION 9 (spoint, spoint) g_spoint3_fetch (internal); diff --git a/pgs_gist_spoint3.sql.in b/pgs_gist_spoint3.sql.in index 0382dad..580a12f 100644 --- a/pgs_gist_spoint3.sql.in +++ b/pgs_gist_spoint3.sql.in @@ -66,4 +66,5 @@ CREATE OPERATOR CLASS spoint3 FUNCTION 6 g_spoint3_picksplit (internal, internal), FUNCTION 7 g_spoint3_same (bytea, bytea, internal), FUNCTION 8 g_spoint3_distance (internal, internal, int4, oid), + FUNCTION 9 (spoint, spoint) g_spoint3_fetch (internal), STORAGE pointkey; diff --git a/sql/index.sql b/sql/index.sql index 7273728..fb3730a 100644 --- a/sql/index.sql +++ b/sql/index.sql @@ -59,3 +59,20 @@ SELECT count(*) FROM spheretmp4 WHERE l @ scircle '<(1,1),0.3>' ; SELECT count(*) FROM spheretmp4 WHERE l && scircle '<(1,1),0.3>' ; +-- test spoint3 operator class with and without index-only scan + +SET enable_bitmapscan = OFF; +SET enable_indexonlyscan = ON; + +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + +SET enable_bitmapscan = ON; +SET enable_indexonlyscan = OFF; + +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; + SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; +EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; + SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; diff --git a/sql/index_9.5.sql b/sql/index_9.5.sql deleted file mode 100644 index fe00bcc..0000000 --- a/sql/index_9.5.sql +++ /dev/null @@ -1,18 +0,0 @@ --- test spoint3 operator class with and without index-only scan - -SET enable_seqscan = OFF; -SET enable_bitmapscan = OFF; -SET enable_indexonlyscan = ON; - -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - -SET enable_bitmapscan = ON; -SET enable_indexonlyscan = OFF; - -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; - SELECT count(*) FROM spheretmp1b WHERE p <@ scircle '<(1,1),0.3>'; -EXPLAIN (COSTS OFF) SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; - SELECT count(*) FROM spheretmp1b WHERE p = spoint '(3.09 , 1.25)'; diff --git a/upgrade_scripts/pg_sphere--1.3.1--1.3.2.sql.in b/upgrade_scripts/pg_sphere--1.3.1--1.3.2.sql.in index 8ea3baa..4077cd6 100644 --- a/upgrade_scripts/pg_sphere--1.3.1--1.3.2.sql.in +++ b/upgrade_scripts/pg_sphere--1.3.1--1.3.2.sql.in @@ -1 +1,4 @@ --- Nothing to upgrade in the schema +-- add "fetch" support function to enable index-only scans for spoint3 + +ALTER OPERATOR FAMILY spoint3 USING gist ADD + FUNCTION 9 (spoint, spoint) g_spoint3_fetch (internal);