Skip to content

[ISSUE #19] Make HEALPix/MOC support optional #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 11, 2023
97 changes: 75 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
PGSPHERE_VERSION = 1.2.2
EXTENSION = pg_sphere
RELEASE_SQL = $(EXTENSION)--$(PGSPHERE_VERSION).sql
USE_PGXS = 1
USE_HEALPIX =? 1

# the base dir name may be changed depending on git clone command
SRC_DIR = $(shell basename $(shell pwd))
Expand All @@ -7,11 +11,13 @@ MODULE_big = pg_sphere
OBJS = src/sscan.o src/sparse.o src/sbuffer.o src/vector3d.o src/point.o \
src/euler.o src/circle.o src/line.o src/ellipse.o src/polygon.o \
src/path.o src/box.o src/output.o src/gq_cache.o src/gist.o \
src/key.o src/gnomo.o src/healpix.o src/moc.o src/process_moc.o \
healpix_bare/healpix_bare.o src/epochprop.o
src/key.o src/gnomo.o src/epochprop.o

ifneq ($(USE_HEALPIX),0)
OBJS += src/healpix.o src/moc.o src/process_moc.o \
healpix_bare/healpix_bare.o
endif

EXTENSION = pg_sphere
RELEASE_SQL = $(EXTENSION)--$(PGSPHERE_VERSION).sql
DATA_built = $(RELEASE_SQL) \
pg_sphere--unpackaged--1.1.5beta0gavo.sql \
pg_sphere--1.0--1.0_gavo.sql \
Expand All @@ -24,14 +30,24 @@ DATA_built = $(RELEASE_SQL) \

DOCS = README.pg_sphere COPYRIGHT.pg_sphere
REGRESS = init tables points euler circle line ellipse poly path box index \
contains_ops contains_ops_compat bounding_box_gist gnomo healpix \
moc mocautocast epochprop
contains_ops contains_ops_compat bounding_box_gist gnomo

ifneq ($(USE_HEALPIX),0)
REGRESS += healpix moc mocautocast
endif

REGRESS += epochprop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose not to separate epochprop into a new line. It is already included unconditionally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to change the order of the tests, as I thought that might affect something. I think I saw a comment somewhere saying that "the order matters" and not to change it, but maybe that doesn't apply to REGRESS. If it's ok to change the order of the tests, it would certainly simplify things if I could add it unconditionally above this line and I will update the PR.

Copy link
Contributor

@vitcpp vitcpp Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may guess that epochprop independent on other tests. I tried to move epochprop back and forth and I haven't seen any problems with it. I got your point. It is up to you to keep PR unchanged. Furthermore, we are planning to cleanup and improve Makefile in the future. I do not see any problems with your PR at the moment.


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 healpix \
moc mocautocast epochprop
TESTS = init_test tables points euler circle line ellipse poly path box \
index contains_ops contains_ops_compat bounding_box_gist gnomo

ifneq ($(USE_HEALPIX),0)
TESTS += healpix moc mocautocast
endif

TESTS += epochprop

PG_CFLAGS += -DPGSPHERE_VERSION=$(PGSPHERE_VERSION)
PG_CPPFLAGS += -DPGSPHERE_VERSION=$(PGSPHERE_VERSION)
Expand All @@ -48,14 +64,25 @@ CRUSH_TESTS = init_extended circle_extended

# order of sql files is important
PGS_SQL = pgs_types.sql pgs_point.sql pgs_euler.sql pgs_circle.sql \
pgs_line.sql pgs_ellipse.sql pgs_polygon.sql pgs_path.sql \
pgs_box.sql pgs_contains_ops.sql pgs_contains_ops_compat.sql \
pgs_gist.sql gnomo.sql \
healpix.sql pgs_gist_spoint3.sql pgs_moc_type.sql pgs_moc_compat.sql pgs_moc_ops.sql \
pgs_moc_geo_casts.sql pgs_epochprop.sql
pgs_line.sql pgs_ellipse.sql pgs_polygon.sql pgs_path.sql \
pgs_box.sql pgs_contains_ops.sql pgs_contains_ops_compat.sql \
pgs_gist.sql gnomo.sql

ifneq ($(USE_HEALPIX),0)
PGS_SQL += healpix.sql
endif

PGS_SQL += pgs_gist_spoint3.sql

ifneq ($(USE_HEALPIX),0)
PGS_SQL += pgs_moc_type.sql pgs_moc_compat.sql pgs_moc_ops.sql \
pgs_moc_geo_casts.sql
endif

PGS_SQL += pgs_epochprop.sql

PGS_SQL_9_5 = pgs_9.5.sql # experimental for spoint3

USE_PGXS = 1
ifdef USE_PGXS
ifndef PG_CONFIG
PG_CONFIG := pg_config
Expand All @@ -70,11 +97,13 @@ else
include $(top_srcdir)/contrib/contrib-global.mk
endif

ifneq ($(USE_HEALPIX),0)
# compiler settings
PKG_CONFIG = pkg-config
override CPPFLAGS += $(shell $(PKG_CONFIG) --cflags healpix_cxx)
SHLIB_LINK += $(shell $(PKG_CONFIG) --libs healpix_cxx)
LINK.shared = g++ -shared
endif

# healpix_bare.c isn't ours so we refrain from fixing the warnings in there
healpix_bare/healpix_bare.o : healpix_bare/healpix_bare.c
Expand All @@ -96,9 +125,11 @@ has_explain_summary = $(if $(filter-out 9.%,$(pg_version)),y,n)
crushtest: REGRESS += $(CRUSH_TESTS)
crushtest: installcheck

ifneq ($(USE_HEALPIX),0)
ifeq ($(has_explain_summary),y)
REGRESS += moc1 moc100
endif
endif

ifeq ($(pg_version_9_5_plus),y)
PGS_TMP_DIR = --temp-instance=tmp_check
Expand Down Expand Up @@ -159,12 +190,17 @@ else
endif

# local stuff follows here

AUGMENT_GAVO_111 = $(AUGMENT_UNP_111) healpix.sql # for vanilla 1.1.1 users
AUGMENT_GAVO_111 = $(AUGMENT_UNP_111) # for vanilla 1.1.1 users
ifneq ($(USE_HEALPIX),0)
AUGMENT_GAVO_111 += healpix.sql
endif
UPGRADE_GAVO_111 = $(UPGRADE_UNP_COMMON)

# add new Healpix functions and experimental spoint3
AUGMENT_FROM_GAVO = healpix.sql pgs_gist_spoint3.sql
# add new HEALPix functions and experimental spoint3
ifneq ($(USE_HEALPIX),0)
AUGMENT_FROM_GAVO = healpix.sql
endif
AUGMENT_FROM_GAVO += pgs_gist_spoint3.sql

AUGMENT_UNP_115B0G = $(AUGMENT_UNP_111) $(AUGMENT_FROM_GAVO)
UPGRADE_UNP_115B0G = $(UPGRADE_UNP_COMMON)
Expand All @@ -188,20 +224,37 @@ pg_sphere--1.0_gavo--1.1.5beta0gavo.sql: $(addsuffix .in, \
$(addprefix upgrade_scripts/, $(UPGRADE_1_0_115B0G)))
cat upgrade_scripts/$@.in $^ > $@

ifneq ($(USE_HEALPIX),0)
pg_sphere--1.1.5beta0gavo--1.1.5beta2gavo.sql: pgs_moc_type.sql.in
cat upgrade_scripts/$@.in $^ > $@

pg_sphere--1.1.5beta2gavo--1.1.5beta4gavo.sql: pgs_moc_compat.sql.in
cat upgrade_scripts/$@.in $^ > $@

pg_sphere--1.1.5beta4gavo--1.2.0.sql: pgs_moc_ops.sql.in
cat $^ > $@
cat upgrade_scripts/$@.in $^ > $@

pg_sphere--1.2.0--1.2.1.sql: pgs_moc_geo_casts.sql.in pgs_epochprop.sql.in
cat $^ > $@

pg_sphere--1.2.1--1.2.2.sql: upgrade_scripts/pg_sphere--1.2.1--1.2.2.sql.in
cat $^ > $@
pg_sphere--1.2.1--1.2.2.sql: upgrade_scripts/pg_sphere--1.2.1--1.2.2-healpix.sql.in
cat upgrade_scripts/$@.in $^ > $@
else
pg_sphere--1.1.5beta0gavo--1.1.5beta2gavo.sql:
cat upgrade_scripts/$@.in > $@

pg_sphere--1.1.5beta2gavo--1.1.5beta4gavo.sql:
cat upgrade_scripts/$@.in > $@

pg_sphere--1.1.5beta4gavo--1.2.0.sql:
cat upgrade_scripts/$@.in > $@

pg_sphere--1.2.0--1.2.1.sql: pgs_epochprop.sql.in
cat upgrade_scripts/$@.in $^ > $@

pg_sphere--1.2.1--1.2.2.sql:
cat upgrade_scripts/$@.in > $@
endif

# end of local stuff

Expand Down
47 changes: 36 additions & 11 deletions README.pg_sphere
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,53 @@ like spherical points and spherical circles with
useful functions and operators.

NOTICE:
This version will work only with postgresql version 9.1 and above.
This version will work only with PostgreSQL version 9.5 and above.

INSTALLATION:

-- build and install
gmake USE_PGXS=1 PG_CONFIG=/usr/bin/pg_config
gmake USE_PGXS=1 PG_CONFIG=/usr/bin/pg_config install
-- load extension
-- Build and install

gmake
gmake install

-- HEALPix/MOC support is included by default. If your platform does not
-- have the required libhealpix_cxx dependency, you can optionally build
-- pgSphere without HEALPix/MOC support, like so:

gmake USE_HEALPIX=0
gmake USE_HEALPIX=0 install

-- Load extension

psql -c "CREATE EXTENSION pg_sphere;" <database>

REGRESSION TEST (as the same user as the currently running postgresql server):
UPDATING AN EXISTING INSTALLATION:

-- If you are updating from a previous version of pgSphere, perform the
-- same make and make install steps as above, but, instead of the CREATE
-- EXTENSION step, you need to do:

make USE_PGXS=1 installcheck
psql -c "ALTER EXTENSION q3c UPDATE TO 'A.B.C';" <database>

-- where A.B.C is a placeholder for the current version.
-- You also may want to check what version of pgSphere is installed using
either of following commands:

psql -c "select pg_sphere_version();" <database>
psql -c "SELECT * FROM pg_available_extension_versions WHERE name = 'pg_sphere';"

REGRESSION TESTS (as the same user as the currently running PostgreSQL server):

make installcheck
make test

LONG REGRESSION TEST:

make USE_PGXS=1 crushtest
make crushtest

The 'make' program must be compatible with GNU make.

For more information, have a look at http://pgsphere.projects.postgresql.org
and https://github.com/akorotkov/pgsphere
For more information or to report issues or to help with development, please
refer to https://github.com/postgrespro/pgsphere/

Have a lot of fun!

2 changes: 2 additions & 0 deletions upgrade_scripts/pg_sphere--1.1.5beta4gavo--1.2.0.sql.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- complain if this upgrade script is run via psql
\echo Use "ALTER EXTENSION pg_sphere UPDATE TO '1.2.0'" to load this file. \quit
2 changes: 2 additions & 0 deletions upgrade_scripts/pg_sphere--1.2.0--1.2.1.sql.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- complain if this upgrade script is run via psql
\echo Use "ALTER EXTENSION pg_sphere UPDATE TO '1.2.1'" to load this file. \quit
30 changes: 30 additions & 0 deletions upgrade_scripts/pg_sphere--1.2.1--1.2.2-healpix.sql.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- healpix
ALTER FUNCTION nest2ring(integer, bigint) PARALLEL SAFE;
ALTER FUNCTION ring2nest(integer, bigint) PARALLEL SAFE;
ALTER FUNCTION healpix_convert_nest(integer, integer, bigint) PARALLEL SAFE;
ALTER FUNCTION healpix_convert_ring(integer, integer, bigint) PARALLEL SAFE;
ALTER FUNCTION nside2order(bigint) PARALLEL SAFE;
ALTER FUNCTION order2nside(integer) PARALLEL SAFE;
ALTER FUNCTION nside2npix(bigint) PARALLEL SAFE;
ALTER FUNCTION npix2nside(bigint) PARALLEL SAFE;
ALTER FUNCTION healpix_nest(integer, spoint) PARALLEL SAFE;
ALTER FUNCTION healpix_ring(integer, spoint) PARALLEL SAFE;
ALTER FUNCTION centre_of_healpix_nest(integer, bigint) PARALLEL SAFE;
ALTER FUNCTION centre_of_healpix_ring(integer, bigint) PARALLEL SAFE;
ALTER FUNCTION center_of_healpix_nest(integer, bigint) PARALLEL SAFE;
ALTER FUNCTION center_of_healpix_ring(integer, bigint) PARALLEL SAFE;

-- moc_type
ALTER FUNCTION smoc_in(cstring) PARALLEL SAFE;
ALTER FUNCTION smoc_out(smoc) PARALLEL SAFE;
ALTER FUNCTION moc_debug() PARALLEL SAFE;
ALTER FUNCTION set_smoc_output_type(integer) PARALLEL SAFE;
ALTER FUNCTION max_order(smoc) PARALLEL SAFE;
ALTER FUNCTION healpix_subset_smoc(bigint, smoc) PARALLEL SAFE;
ALTER FUNCTION healpix_not_subset_smoc(bigint, smoc) PARALLEL SAFE;
ALTER FUNCTION smoc_superset_healpix(smoc, bigint) PARALLEL SAFE;
ALTER FUNCTION smoc_not_superset_healpix(smoc, bigint) PARALLEL SAFE;
ALTER FUNCTION spoint_subset_smoc(spoint, smoc) PARALLEL SAFE;
ALTER FUNCTION spoint_not_subset_smoc(spoint, smoc) PARALLEL SAFE;
ALTER FUNCTION smoc_superset_spoint(smoc, spoint) PARALLEL SAFE;
ALTER FUNCTION smoc_not_superset_spoint(smoc, spoint) PARALLEL SAFE;
34 changes: 2 additions & 32 deletions upgrade_scripts/pg_sphere--1.2.1--1.2.2.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@
ALTER FUNCTION gnomonic_proj(spoint, spoint) PARALLEL SAFE;
ALTER FUNCTION gnomonic_inv(point, spoint) PARALLEL SAFE;

-- healpix
ALTER FUNCTION nest2ring(integer, bigint) PARALLEL SAFE;
ALTER FUNCTION ring2nest(integer, bigint) PARALLEL SAFE;
ALTER FUNCTION healpix_convert_nest(integer, integer, bigint) PARALLEL SAFE;
ALTER FUNCTION healpix_convert_ring(integer, integer, bigint) PARALLEL SAFE;
ALTER FUNCTION nside2order(bigint) PARALLEL SAFE;
ALTER FUNCTION order2nside(integer) PARALLEL SAFE;
ALTER FUNCTION nside2npix(bigint) PARALLEL SAFE;
ALTER FUNCTION npix2nside(bigint) PARALLEL SAFE;
ALTER FUNCTION healpix_nest(integer, spoint) PARALLEL SAFE;
ALTER FUNCTION healpix_ring(integer, spoint) PARALLEL SAFE;
ALTER FUNCTION centre_of_healpix_nest(integer, bigint) PARALLEL SAFE;
ALTER FUNCTION centre_of_healpix_ring(integer, bigint) PARALLEL SAFE;
ALTER FUNCTION center_of_healpix_nest(integer, bigint) PARALLEL SAFE;
ALTER FUNCTION center_of_healpix_ring(integer, bigint) PARALLEL SAFE;

-- sbox
ALTER FUNCTION sbox(spoint, spoint) PARALLEL SAFE;
ALTER FUNCTION sw(sbox) PARALLEL SAFE;
Expand Down Expand Up @@ -215,21 +199,6 @@ ALTER FUNCTION scircle_contains_line_com(sline, scircle) PARALLEL SAFE;
ALTER FUNCTION scircle_contains_line_neg(scircle, sline) PARALLEL SAFE;
ALTER FUNCTION scircle_contains_line_com_neg(sline, scircle) PARALLEL SAFE;

-- moc_type
ALTER FUNCTION smoc_in(cstring) PARALLEL SAFE;
ALTER FUNCTION smoc_out(smoc) PARALLEL SAFE;
ALTER FUNCTION moc_debug() PARALLEL SAFE;
ALTER FUNCTION set_smoc_output_type(integer) PARALLEL SAFE;
ALTER FUNCTION max_order(smoc) PARALLEL SAFE;
ALTER FUNCTION healpix_subset_smoc(bigint, smoc) PARALLEL SAFE;
ALTER FUNCTION healpix_not_subset_smoc(bigint, smoc) PARALLEL SAFE;
ALTER FUNCTION smoc_superset_healpix(smoc, bigint) PARALLEL SAFE;
ALTER FUNCTION smoc_not_superset_healpix(smoc, bigint) PARALLEL SAFE;
ALTER FUNCTION spoint_subset_smoc(spoint, smoc) PARALLEL SAFE;
ALTER FUNCTION spoint_not_subset_smoc(spoint, smoc) PARALLEL SAFE;
ALTER FUNCTION smoc_superset_spoint(smoc, spoint) PARALLEL SAFE;
ALTER FUNCTION smoc_not_superset_spoint(smoc, spoint) PARALLEL SAFE;

-- spath
ALTER FUNCTION npoints(spath) PARALLEL SAFE;
ALTER FUNCTION spoint(spath, int4) PARALLEL SAFE;
Expand Down Expand Up @@ -344,4 +313,5 @@ ALTER FUNCTION spoly_add_points_fin_aggr(spoly) PARALLEL SAFE;

-- gist_spoint3
ALTER FUNCTION g_spoint3_penalty(internal, internal, internal) PARALLEL SAFE;
ALTER FUNCTION g_spoint3_fetch(internal, internal, internal) PARALLEL SAFE;
ALTER FUNCTION g_spoint3_fetch(internal) PARALLEL SAFE;