From 75d586023cef2a6e9933511c6d85cf3b05635638 Mon Sep 17 00:00:00 2001 From: Zacharias Knudsen Date: Tue, 20 Sep 2022 16:30:28 +0200 Subject: [PATCH] Fix upgrade path to not require postgis, at this point we should probably consider removing some of the oldest upgrades --- .github/docker/entrypoint.sh | 1 - h3/sql/updates/h3--0.2.0--0.3.0.sql | 70 ++++++++++++++--------------- h3/sql/updates/h3--0.3.0--0.3.1.sql | 8 ++-- h3/sql/updates/h3--0.4.0--1.0.0.sql | 18 ++++---- h3/sql/updates/h3--3.6.4--3.6.5.sql | 34 +++++++------- h3/sql/updates/h3--3.6.5--3.7.0.sql | 8 ++-- h3/sql/updates/h3--3.7.2--4.0.0.sql | 4 +- 7 files changed, 71 insertions(+), 72 deletions(-) diff --git a/.github/docker/entrypoint.sh b/.github/docker/entrypoint.sh index 2ecba776..c4169f26 100755 --- a/.github/docker/entrypoint.sh +++ b/.github/docker/entrypoint.sh @@ -25,6 +25,5 @@ elif [ "$CMD" = "pgxn-v3" ]; then else ARGS="$@" make install - su postgres -p -c "psql -c 'CREATE EXTENSION postgis'" su postgres -p -c "$ARGS" fi diff --git a/h3/sql/updates/h3--0.2.0--0.3.0.sql b/h3/sql/updates/h3--0.2.0--0.3.0.sql index d7dc6d69..85433bb4 100644 --- a/h3/sql/updates/h3--0.2.0--0.3.0.sql +++ b/h3/sql/updates/h3--0.2.0--0.3.0.sql @@ -53,47 +53,47 @@ CREATE OR REPLACE FUNCTION h3_h3_to_children_slow(index h3index, resolution inte 'Slower version of H3ToChildren but allocates less memory'; -- PostGIS -CREATE OR REPLACE FUNCTION h3_geo_to_h3(geometry, resolution integer) RETURNS h3index - AS $$ SELECT h3_geo_to_h3($1::point, $2); $$ LANGUAGE SQL; -CREATE OR REPLACE FUNCTION h3_geo_to_h3(geography, resolution integer) RETURNS h3index - AS $$ SELECT h3_geo_to_h3($1::geometry, $2); $$ LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_geo_to_h3(geometry, resolution integer) RETURNS h3index +-- AS $$ SELECT h3_geo_to_h3($1::point, $2); $$ LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_geo_to_h3(geography, resolution integer) RETURNS h3index +-- AS $$ SELECT h3_geo_to_h3($1::geometry, $2); $$ LANGUAGE SQL; -CREATE OR REPLACE FUNCTION h3_h3_to_geometry(h3index) RETURNS geometry - AS $$ SELECT ST_SetSRID(h3_h3_to_geo($1)::geometry, 4326) $$ LANGUAGE SQL; -CREATE OR REPLACE FUNCTION h3_h3_to_geography(h3index) RETURNS geography - AS $$ SELECT h3_h3_to_geometry($1)::geography $$ LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_h3_to_geometry(h3index) RETURNS geometry +-- AS $$ SELECT ST_SetSRID(h3_h3_to_geo($1)::geometry, 4326) $$ LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_h3_to_geography(h3index) RETURNS geography +-- AS $$ SELECT h3_h3_to_geometry($1)::geography $$ LANGUAGE SQL; -CREATE OR REPLACE FUNCTION h3_h3_to_geo_boundary_geometry(h3index) RETURNS geometry - AS $$ SELECT ST_SetSRID(h3_h3_to_geo_boundary($1)::geometry, 4326) $$ LANGUAGE SQL; -CREATE OR REPLACE FUNCTION h3_h3_to_geo_boundary_geography(h3index) RETURNS geography - AS $$ SELECT h3_h3_to_geo_boundary_geometry($1)::geography $$ LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_h3_to_geo_boundary_geometry(h3index) RETURNS geometry +-- AS $$ SELECT ST_SetSRID(h3_h3_to_geo_boundary($1)::geometry, 4326) $$ LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_h3_to_geo_boundary_geography(h3index) RETURNS geography +-- AS $$ SELECT h3_h3_to_geo_boundary_geometry($1)::geography $$ LANGUAGE SQL; -CREATE OR REPLACE FUNCTION h3_polyfill(multi geometry, resolution integer) RETURNS SETOF h3index - AS $$ SELECT h3_polyfill(exterior, holes, resolution) FROM ( - SELECT - -- extract exterior ring of each polygon - ST_MakePolygon(ST_ExteriorRing(poly))::polygon exterior, - -- extract holes of each polygon - (SELECT array_agg(hole) - FROM ( - SELECT ST_MakePolygon(ST_InteriorRingN( - poly, - generate_series(1, ST_NumInteriorRings(poly)) - ))::polygon AS hole - ) q_hole - ) holes - -- extract single polygons from multipolygon - FROM ( - select (st_dump(multi)).geom as poly - ) q_poly GROUP BY poly - ) h3_polyfill; $$ LANGUAGE SQL IMMUTABLE STRICT; -CREATE OR REPLACE FUNCTION h3_polyfill(multi geography, resolution integer) RETURNS SETOF h3index -AS $$ SELECT h3_polyfill($1::geometry, $2) $$ LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_polyfill(multi geometry, resolution integer) RETURNS SETOF h3index +-- AS $$ SELECT h3_polyfill(exterior, holes, resolution) FROM ( +-- SELECT +-- -- extract exterior ring of each polygon +-- ST_MakePolygon(ST_ExteriorRing(poly))::polygon exterior, +-- -- extract holes of each polygon +-- (SELECT array_agg(hole) +-- FROM ( +-- SELECT ST_MakePolygon(ST_InteriorRingN( +-- poly, +-- generate_series(1, ST_NumInteriorRings(poly)) +-- ))::polygon AS hole +-- ) q_hole +-- ) holes +-- -- extract single polygons from multipolygon +-- FROM ( +-- select (st_dump(multi)).geom as poly +-- ) q_poly GROUP BY poly +-- ) h3_polyfill; $$ LANGUAGE SQL IMMUTABLE STRICT; +--CREATE OR REPLACE FUNCTION h3_polyfill(multi geography, resolution integer) RETURNS SETOF h3index +--AS $$ SELECT h3_polyfill($1::geometry, $2) $$ LANGUAGE SQL; -- Type casts CREATE CAST (h3index AS point) WITH FUNCTION h3_h3_to_geo(h3index); -CREATE CAST (h3index AS geometry) WITH FUNCTION h3_h3_to_geometry(h3index); -CREATE CAST (h3index AS geography) WITH FUNCTION h3_h3_to_geography(h3index); +--CREATE CAST (h3index AS geometry) WITH FUNCTION h3_h3_to_geometry(h3index); +--CREATE CAST (h3index AS geography) WITH FUNCTION h3_h3_to_geography(h3index); -- DEPRECATED in v1.0.0 CREATE OR REPLACE FUNCTION h3_haversine_distance(h3index, h3index) RETURNS double precision diff --git a/h3/sql/updates/h3--0.3.0--0.3.1.sql b/h3/sql/updates/h3--0.3.0--0.3.1.sql index 28745e8a..b8ebad8d 100644 --- a/h3/sql/updates/h3--0.3.0--0.3.1.sql +++ b/h3/sql/updates/h3--0.3.0--0.3.1.sql @@ -25,7 +25,7 @@ CREATE OR REPLACE FUNCTION h3_h3_to_geo_boundary(h3index, extend_at_meridian BOO AS 'h3', 'h3_cell_to_boundary' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; COMMENT ON FUNCTION h3_h3_to_geo_boundary(h3index, boolean) IS 'Finds the boundary of the index, second argument extends coordinates when crossing 180th meridian to help visualization'; -CREATE OR REPLACE FUNCTION h3_h3_to_geo_boundary_geometry(h3index, extend BOOLEAN DEFAULT FALSE) RETURNS geometry - AS $$ SELECT ST_SetSRID(h3_h3_to_geo_boundary($1, $2)::geometry, 4326) $$ LANGUAGE SQL; -CREATE OR REPLACE FUNCTION h3_h3_to_geo_boundary_geography(h3index, extend BOOLEAN DEFAULT FALSE) RETURNS geography - AS $$ SELECT h3_h3_to_geo_boundary_geometry($1, $2)::geography $$ LANGUAGE SQL; \ No newline at end of file +--CREATE OR REPLACE FUNCTION h3_h3_to_geo_boundary_geometry(h3index, extend BOOLEAN DEFAULT FALSE) RETURNS geometry +-- AS $$ SELECT ST_SetSRID(h3_h3_to_geo_boundary($1, $2)::geometry, 4326) $$ LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_h3_to_geo_boundary_geography(h3index, extend BOOLEAN DEFAULT FALSE) RETURNS geography +-- AS $$ SELECT h3_h3_to_geo_boundary_geometry($1, $2)::geography $$ LANGUAGE SQL; \ No newline at end of file diff --git a/h3/sql/updates/h3--0.4.0--1.0.0.sql b/h3/sql/updates/h3--0.4.0--1.0.0.sql index c7c45f32..01031cdf 100644 --- a/h3/sql/updates/h3--0.4.0--1.0.0.sql +++ b/h3/sql/updates/h3--0.4.0--1.0.0.sql @@ -1,5 +1,5 @@ /* - * Copyright 2018 Bytes & Brains + * Copyright 2018-2022 Bytes & Brains * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,20 +34,20 @@ ALTER FUNCTION h3_h3_set_to_linked_geo(h3index[]) RENAME TO h3_set_to_linked_geo ALTER FUNCTION __h3_h3_to_children_aux(h3index,integer,integer) RENAME TO __h3_to_children_aux; ALTER FUNCTION h3_h3_to_children(h3index,integer) RENAME TO h3_to_children; ALTER FUNCTION h3_h3_to_children_slow(h3index,integer) RENAME TO h3_to_children_slow; -ALTER FUNCTION h3_h3_to_geo_boundary_geography(h3index,boolean) RENAME TO h3_to_geo_boundary_geography; -ALTER FUNCTION h3_h3_to_geo_boundary_geometry(h3index,boolean) RENAME TO h3_to_geo_boundary_geometry; +--ALTER FUNCTION h3_h3_to_geo_boundary_geography(h3index,boolean) RENAME TO h3_to_geo_boundary_geography; +--ALTER FUNCTION h3_h3_to_geo_boundary_geometry(h3index,boolean) RENAME TO h3_to_geo_boundary_geometry; ALTER FUNCTION h3_h3_to_geo_boundary(h3index,boolean) RENAME TO h3_to_geo_boundary; -ALTER FUNCTION h3_h3_to_geography(h3index) RENAME TO h3_to_geography; +--ALTER FUNCTION h3_h3_to_geography(h3index) RENAME TO h3_to_geography; ALTER FUNCTION h3_h3_to_geo(h3index) RENAME TO h3_to_geo; -ALTER FUNCTION h3_h3_to_geometry(h3index) RENAME TO h3_to_geometry; +--ALTER FUNCTION h3_h3_to_geometry(h3index) RENAME TO h3_to_geometry; ALTER FUNCTION h3_h3_to_parent(h3index,integer) RENAME TO h3_to_parent; ALTER FUNCTION h3_h3_to_string(h3index) RENAME TO h3_to_string; ALTER FUNCTION h3_h3_unidirectional_edge_is_valid(h3index) RENAME TO h3_unidirectional_edge_is_valid; -CREATE OR REPLACE FUNCTION h3_to_geo_boundary_geometry(h3index, extend BOOLEAN DEFAULT FALSE) RETURNS geometry - AS $$ SELECT ST_SetSRID(h3_to_geo_boundary($1, $2)::geometry, 4326) $$ LANGUAGE SQL; -CREATE OR REPLACE FUNCTION h3_to_geo_boundary_geography(h3index, extend BOOLEAN DEFAULT FALSE) RETURNS geography - AS $$ SELECT h3_to_geo_boundary_geometry($1, $2)::geography $$ LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_to_geo_boundary_geometry(h3index, extend BOOLEAN DEFAULT FALSE) RETURNS geometry +-- AS $$ SELECT ST_SetSRID(h3_to_geo_boundary($1, $2)::geometry, 4326) $$ LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_to_geo_boundary_geography(h3index, extend BOOLEAN DEFAULT FALSE) RETURNS geography +-- AS $$ SELECT h3_to_geo_boundary_geometry($1, $2)::geography $$ LANGUAGE SQL; CREATE OR REPLACE FUNCTION h3_to_children_slow(index h3index, resolution integer DEFAULT -1) RETURNS SETOF h3index AS $$ SELECT __h3_to_children_aux($1, $2, -1) $$ LANGUAGE SQL; diff --git a/h3/sql/updates/h3--3.6.4--3.6.5.sql b/h3/sql/updates/h3--3.6.4--3.6.5.sql index 4e6a9ee7..cece42e9 100644 --- a/h3/sql/updates/h3--3.6.4--3.6.5.sql +++ b/h3/sql/updates/h3--3.6.4--3.6.5.sql @@ -1,5 +1,5 @@ /* - * Copyright 2020 Bytes & Brains + * Copyright 2020-2022 Bytes & Brains * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,22 +20,22 @@ -- Fix function flags which were previously only changed in install files ALTER FUNCTION h3_get_h3_unidirectional_edge_boundary(h3index) IMMUTABLE STRICT PARALLEL SAFE; -ALTER FUNCTION h3_geo_to_h3(geometry, integer) - IMMUTABLE STRICT PARALLEL SAFE; -ALTER FUNCTION h3_geo_to_h3(geography, integer) - IMMUTABLE STRICT PARALLEL SAFE; -ALTER FUNCTION h3_to_geometry(h3index) - IMMUTABLE STRICT PARALLEL SAFE; -ALTER FUNCTION h3_to_geography(h3index) - IMMUTABLE STRICT PARALLEL SAFE; -ALTER FUNCTION h3_to_geo_boundary_geometry(h3index, boolean) - IMMUTABLE STRICT PARALLEL SAFE; -ALTER FUNCTION h3_to_geo_boundary_geography(h3index, boolean) - IMMUTABLE STRICT PARALLEL SAFE; -ALTER FUNCTION h3_polyfill(geometry, integer) - IMMUTABLE PARALLEL SAFE CALLED ON NULL INPUT; -- NOT STRICT -ALTER FUNCTION h3_polyfill(geography, integer) - IMMUTABLE PARALLEL SAFE CALLED ON NULL INPUT; -- NOT STRICT +--ALTER FUNCTION h3_geo_to_h3(geometry, integer) +-- IMMUTABLE STRICT PARALLEL SAFE; +--ALTER FUNCTION h3_geo_to_h3(geography, integer) +-- IMMUTABLE STRICT PARALLEL SAFE; +--ALTER FUNCTION h3_to_geometry(h3index) +-- IMMUTABLE STRICT PARALLEL SAFE; +--ALTER FUNCTION h3_to_geography(h3index) +-- IMMUTABLE STRICT PARALLEL SAFE; +--ALTER FUNCTION h3_to_geo_boundary_geometry(h3index, boolean) +-- IMMUTABLE STRICT PARALLEL SAFE; +--ALTER FUNCTION h3_to_geo_boundary_geography(h3index, boolean) +-- IMMUTABLE STRICT PARALLEL SAFE; +--ALTER FUNCTION h3_polyfill(geometry, integer) +-- IMMUTABLE PARALLEL SAFE CALLED ON NULL INPUT; -- NOT STRICT +--ALTER FUNCTION h3_polyfill(geography, integer) +-- IMMUTABLE PARALLEL SAFE CALLED ON NULL INPUT; -- NOT STRICT -- Add second support function for hash opclass CREATE OR REPLACE FUNCTION h3index_hash_extended(h3index, int8) RETURNS int8 diff --git a/h3/sql/updates/h3--3.6.5--3.7.0.sql b/h3/sql/updates/h3--3.6.5--3.7.0.sql index 19e4d902..aa6898f8 100644 --- a/h3/sql/updates/h3--3.6.5--3.7.0.sql +++ b/h3/sql/updates/h3--3.6.5--3.7.0.sql @@ -25,10 +25,10 @@ CREATE OPERATOR <-> ( ); -- Broken since 1.0.0 on update path -CREATE OR REPLACE FUNCTION h3_to_geometry(h3index) RETURNS geometry - AS $$ SELECT ST_SetSRID(h3_to_geo($1)::geometry, 4326) $$ IMMUTABLE STRICT PARALLEL SAFE LANGUAGE SQL; -CREATE OR REPLACE FUNCTION h3_to_geography(h3index) RETURNS geography - AS $$ SELECT h3_to_geometry($1)::geography $$ IMMUTABLE STRICT PARALLEL SAFE LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_to_geometry(h3index) RETURNS geometry +-- AS $$ SELECT ST_SetSRID(h3_to_geo($1)::geometry, 4326) $$ IMMUTABLE STRICT PARALLEL SAFE LANGUAGE SQL; +--CREATE OR REPLACE FUNCTION h3_to_geography(h3index) RETURNS geography +-- AS $$ SELECT h3_to_geometry($1)::geography $$ IMMUTABLE STRICT PARALLEL SAFE LANGUAGE SQL; -- New functions in core v3.7.0 CREATE OR REPLACE FUNCTION h3_point_dist(a point, b point, unit text DEFAULT 'km') RETURNS float diff --git a/h3/sql/updates/h3--3.7.2--4.0.0.sql b/h3/sql/updates/h3--3.7.2--4.0.0.sql index 03b36c43..e8836929 100644 --- a/h3/sql/updates/h3--3.7.2--4.0.0.sql +++ b/h3/sql/updates/h3--3.7.2--4.0.0.sql @@ -26,8 +26,8 @@ DROP FUNCTION IF EXISTS h3_to_geo_boundary_geometry(h3index, extend boolean); DROP FUNCTION IF EXISTS h3_to_geo_boundary_geography(h3index, extend boolean); DROP FUNCTION IF EXISTS h3_polyfill(multi geometry, resolution integer); DROP FUNCTION IF EXISTS h3_polyfill(multi geography, resolution integer); -DROP CAST (h3index AS geometry); -DROP CAST (h3index AS geography); +DROP CAST IF EXISTS (h3index AS geometry); +DROP CAST IF EXISTS (h3index AS geography); DROP FUNCTION IF EXISTS h3_to_geometry(h3index); DROP FUNCTION IF EXISTS h3_to_geography(h3index);