From 6a78bc408b24f812a89341f75bd019e82feeecb1 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Mon, 23 Oct 2023 11:50:17 +0000 Subject: [PATCH 01/21] Testing and fixing Supported and Unsupported CAST for Geospatial Data types Signed-off-by: Anikait Agrawal --- contrib/babelfishpg_common/sql/geography.sql | 161 +++++- contrib/babelfishpg_common/sql/geometry.sql | 135 ++++- .../upgrades/spatial_types--3.2.0--3.3.0.sql | 296 ++++++++-- .../expected/TestSpatialPoint-vu-cleanup.out | 16 + .../expected/TestSpatialPoint-vu-prepare.out | 64 +++ .../expected/TestSpatialPoint-vu-verify.out | 516 +++++++++++++++++- .../datatypes/TestSpatialPoint-vu-cleanup.txt | 16 + .../datatypes/TestSpatialPoint-vu-prepare.txt | 28 + .../datatypes/TestSpatialPoint-vu-verify.sql | 170 ++++++ 9 files changed, 1325 insertions(+), 77 deletions(-) diff --git a/contrib/babelfishpg_common/sql/geography.sql b/contrib/babelfishpg_common/sql/geography.sql index b79eb1493b..8a70ebc2f2 100644 --- a/contrib/babelfishpg_common/sql/geography.sql +++ b/contrib/babelfishpg_common/sql/geography.sql @@ -152,8 +152,16 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(bytea) CREATE OR REPLACE FUNCTION sys.bytea(sys.GEOGRAPHY) RETURNS bytea - AS '$libdir/postgis-3','LWGEOM_to_bytea' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + DECLARE + byte bytea; + BEGIN + byte := (SELECT sys.bytea_helper($1)); + byte := substring(byte from 6); + byte := substring(byte from 1 for 4) || E'\\x010c' || substring(byte from 5); + RETURN byte; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bbf_varbinary) RETURNS sys.GEOGRAPHY @@ -169,27 +177,100 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bbf_varbinary) CREATE OR REPLACE FUNCTION sys.bbf_varbinary(sys.GEOGRAPHY) RETURNS sys.bbf_varbinary - AS '$libdir/postgis-3','LWGEOM_to_bytea' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + DECLARE + byte bytea; + BEGIN + byte := (SELECT CAST ($1 AS bytea)); + RETURN (SELECT CAST (byte AS sys.bbf_varbinary)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE CAST (bytea AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(bytea) AS IMPLICIT; -CREATE CAST (sys.GEOGRAPHY AS bytea) WITH FUNCTION sys.bytea(sys.GEOGRAPHY) AS IMPLICIT; -CREATE CAST (sys.bbf_varbinary AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.bbf_varbinary) AS IMPLICIT; -CREATE CAST (sys.GEOGRAPHY AS sys.bbf_varbinary) WITH FUNCTION sys.bbf_varbinary(sys.GEOGRAPHY) AS IMPLICIT; +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bbf_binary) + RETURNS sys.GEOGRAPHY + AS $$ + DECLARE + varBin sys.bbf_varbinary; + BEGIN + varBin := (SELECT CAST (CAST ($1 AS sys.VARCHAR) AS sys.bbf_varbinary)); + -- Call the underlying function after preprocessing + RETURN (SELECT CAST (varBin AS GEOGRAPHY)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.GEOMETRY) +CREATE OR REPLACE FUNCTION sys.text(sys.GEOGRAPHY) + RETURNS text + AS $$ + BEGIN + RAISE EXCEPTION 'Conversion from data type Geography to Text is not allowed.'; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(text) RETURNS sys.GEOGRAPHY - AS '$libdir/postgis-3','geography_from_geometry' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + BEGIN + RAISE EXCEPTION 'Conversion from data type Text to Geography is not allowed.'; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE CAST (sys.GEOMETRY AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.GEOMETRY) AS ASSIGNMENT; +CREATE OR REPLACE FUNCTION sys.bpchar(sys.GEOGRAPHY) + RETURNS sys.bpchar + AS $$ + BEGIN + -- Call the underlying function after preprocessing + -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) + RETURN CAST ((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1))) AS sys.bpchar); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.GEOGRAPHY) - RETURNS sys.GEOMETRY - AS '$libdir/postgis-3','geometry_from_geography' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bpchar) + RETURNS sys.GEOGRAPHY + AS $$ + DECLARE + geog sys.GEOGRAPHY; + BEGIN + geog := (SELECT sys.bpcharToGeography_helper($1)); + -- Call the underlying function after preprocessing + -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) + RETURN (SELECT sys.Geography__STFlipCoordinates(geog)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.varchar(sys.GEOGRAPHY) + RETURNS sys.varchar + AS $$ + BEGIN + -- Call the underlying function after preprocessing + -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) + RETURN CAST ((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1))) AS sys.varchar); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE CAST (sys.GEOGRAPHY AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.GEOGRAPHY) AS ASSIGNMENT; +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.varchar) + RETURNS sys.GEOGRAPHY + AS $$ + DECLARE + geog sys.GEOGRAPHY; + BEGIN + geog := (SELECT sys.varcharToGeography_helper($1)); + -- Call the underlying function after preprocessing + -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) + RETURN (SELECT sys.Geography__STFlipCoordinates(geog)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE CAST (text AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(text) AS IMPLICIT; +CREATE CAST (sys.GEOGRAPHY AS text) WITH FUNCTION sys.text(sys.GEOGRAPHY); +CREATE CAST (sys.bpchar AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.bpchar) AS IMPLICIT; +CREATE CAST (sys.GEOGRAPHY AS sys.bpchar) WITH FUNCTION sys.bpchar(sys.GEOGRAPHY); +CREATE CAST (sys.varchar AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.varchar) AS IMPLICIT; +CREATE CAST (sys.GEOGRAPHY AS sys.varchar) WITH FUNCTION sys.varchar(sys.GEOGRAPHY); +CREATE CAST (sys.bbf_binary AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.bbf_binary) AS IMPLICIT; +CREATE CAST (bytea AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(bytea) AS IMPLICIT; +CREATE CAST (sys.GEOGRAPHY AS bytea) WITH FUNCTION sys.bytea(sys.GEOGRAPHY); +CREATE CAST (sys.bbf_varbinary AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.bbf_varbinary) AS IMPLICIT; +CREATE CAST (sys.GEOGRAPHY AS sys.bbf_varbinary) WITH FUNCTION sys.bbf_varbinary(sys.GEOGRAPHY); -- This Function Flips the Coordinates of the Point (x, y) -> (y, x) CREATE OR REPLACE FUNCTION sys.Geography__STFlipCoordinates(sys.GEOGRAPHY) @@ -329,6 +410,37 @@ CREATE OR REPLACE FUNCTION sys.ST_zmflag(sys.GEOGRAPHY) AS '$libdir/postgis-3', 'LWGEOM_zmflag' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; +CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) + RETURNS boolean + AS '$libdir/postgis-3', 'ST_Equals' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OPERATOR sys.= ( + LEFTARG = sys.GEOGRAPHY, + RIGHTARG = sys.GEOGRAPHY, + FUNCTION = sys.ST_Equals, + COMMUTATOR = =, + RESTRICT = eqsel +); + +CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) + RETURNS boolean + AS $$ + DECLARE + isEqual boolean; + BEGIN + isEqual := sys.ST_Equals(leftarg, rightarg); + RETURN NOT isEqual; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OPERATOR sys.<> ( + LEFTARG = sys.GEOGRAPHY, + RIGHTARG = sys.GEOGRAPHY, + FUNCTION = sys.ST_NotEquals, + COMMUTATOR = <> +); + -- Minimum distance CREATE OR REPLACE FUNCTION sys.STDistance(geog1 sys.GEOGRAPHY, geog2 sys.GEOGRAPHY) RETURNS float8 @@ -386,3 +498,18 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY_helper(bytea) AS '$libdir/postgis-3','geography_from_binary' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; +CREATE OR REPLACE FUNCTION sys.bpcharToGeography_helper(sys.bpchar) + RETURNS sys.GEOGRAPHY + AS '$libdir/postgis-3','parse_WKT_lwgeom' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.varcharToGeography_helper(sys.varchar) + RETURNS sys.GEOGRAPHY + AS '$libdir/postgis-3','parse_WKT_lwgeom' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.bytea_helper(sys.GEOGRAPHY) + RETURNS bytea + AS '$libdir/postgis-3','LWGEOM_to_bytea' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + diff --git a/contrib/babelfishpg_common/sql/geometry.sql b/contrib/babelfishpg_common/sql/geometry.sql index 1f7772b3ed..bff922ef89 100644 --- a/contrib/babelfishpg_common/sql/geometry.sql +++ b/contrib/babelfishpg_common/sql/geometry.sql @@ -104,7 +104,30 @@ CREATE OR REPLACE FUNCTION sys.STAsText(sys.GEOMETRY) CREATE OR REPLACE FUNCTION sys.text(sys.GEOMETRY) RETURNS text - AS '$libdir/postgis-3','LWGEOM_to_text' + AS $$ + BEGIN + RAISE EXCEPTION 'Conversion from data type Geometry to Text is not allowed.'; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.bpchar(sys.GEOMETRY) + RETURNS sys.bpchar + AS '$libdir/postgis-3','LWGEOM_asText' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bpchar) + RETURNS sys.GEOMETRY + AS '$libdir/postgis-3','parse_WKT_lwgeom' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.varchar(sys.GEOMETRY) + RETURNS sys.varchar + AS '$libdir/postgis-3','LWGEOM_asText' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.varchar) + RETURNS sys.GEOMETRY + AS '$libdir/postgis-3','parse_WKT_lwgeom' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.GEOMETRY(bytea) @@ -155,38 +178,72 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY(bytea) $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.bytea(sys.GEOMETRY) - RETURNS bytea - AS '$libdir/postgis-3','LWGEOM_to_bytea' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + RETURNS bytea + AS $$ + DECLARE + byte bytea; + BEGIN + byte := (SELECT sys.bytea_helper($1)); + byte := substring(byte from 6); + byte := substring(byte from 1 for 4) || E'\\x010c' || substring(byte from 5); + RETURN byte; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bbf_varbinary) - RETURNS sys.GEOMETRY - AS $$ - DECLARE + RETURNS sys.GEOMETRY + AS $$ + DECLARE varBin bytea; - BEGIN - varBin := (SELECT CAST ($1 AS bytea)); - -- Call the underlying function after preprocessing - RETURN (SELECT CAST (varBin AS GEOMETRY)); - END; - $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + BEGIN + varBin := (SELECT CAST ($1 AS bytea)); + -- Call the underlying function after preprocessing + RETURN (SELECT CAST (varBin AS GEOMETRY)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.bbf_varbinary(sys.GEOMETRY) - RETURNS sys.bbf_varbinary - AS '$libdir/postgis-3','LWGEOM_to_bytea' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + RETURNS sys.bbf_varbinary + AS $$ + DECLARE + byte bytea; + BEGIN + byte := (SELECT CAST ($1 AS bytea)); + RETURN (SELECT CAST (byte AS sys.bbf_varbinary)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bbf_binary) + RETURNS sys.GEOMETRY + AS $$ + DECLARE + varBin sys.bbf_varbinary; + BEGIN + varBin := (SELECT CAST (CAST ($1 AS sys.VARCHAR) AS sys.bbf_varbinary)); + -- Call the underlying function after preprocessing + RETURN (SELECT CAST (varBin AS GEOMETRY)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.GEOMETRY(text) RETURNS sys.GEOMETRY - AS '$libdir/postgis-3','parse_WKT_lwgeom' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + BEGIN + RAISE EXCEPTION 'Conversion from data type Text to Geometry is not allowed.'; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE CAST (text AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(text) AS IMPLICIT; -CREATE CAST (sys.GEOMETRY AS text) WITH FUNCTION sys.text(sys.GEOMETRY) AS IMPLICIT; +CREATE CAST (sys.GEOMETRY AS text) WITH FUNCTION sys.text(sys.GEOMETRY); +CREATE CAST (sys.bpchar AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.bpchar) AS IMPLICIT; +CREATE CAST (sys.GEOMETRY AS sys.bpchar) WITH FUNCTION sys.bpchar(sys.GEOMETRY); +CREATE CAST (sys.varchar AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.varchar) AS IMPLICIT; +CREATE CAST (sys.GEOMETRY AS sys.varchar) WITH FUNCTION sys.varchar(sys.GEOMETRY); CREATE CAST (bytea AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(bytea) AS IMPLICIT; -CREATE CAST (sys.GEOMETRY AS bytea) WITH FUNCTION sys.bytea(sys.GEOMETRY) AS IMPLICIT; +CREATE CAST (sys.GEOMETRY AS bytea) WITH FUNCTION sys.bytea(sys.GEOMETRY); CREATE CAST (sys.bbf_varbinary AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.bbf_varbinary) AS IMPLICIT; -CREATE CAST (sys.GEOMETRY AS sys.bbf_varbinary) WITH FUNCTION sys.bbf_varbinary(sys.GEOMETRY) AS IMPLICIT; +CREATE CAST (sys.GEOMETRY AS sys.bbf_varbinary) WITH FUNCTION sys.bbf_varbinary(sys.GEOMETRY); +CREATE CAST (sys.bbf_binary AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.bbf_binary) AS IMPLICIT; -- Availability: 3.2.0 current supported in APG CREATE OR REPLACE FUNCTION sys.Geometry__Point(float8, float8, srid integer) @@ -248,6 +305,37 @@ CREATE OR REPLACE FUNCTION sys.ST_zmflag(sys.GEOMETRY) AS '$libdir/postgis-3', 'LWGEOM_zmflag' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; +CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) + RETURNS boolean + AS '$libdir/postgis-3', 'ST_Equals' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OPERATOR sys.= ( + LEFTARG = sys.GEOMETRY, + RIGHTARG = sys.GEOMETRY, + FUNCTION = sys.ST_Equals, + COMMUTATOR = =, + RESTRICT = eqsel +); + +CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) + RETURNS boolean + AS $$ + DECLARE + isEqual boolean; + BEGIN + isEqual := sys.ST_Equals(leftarg, rightarg); + RETURN NOT isEqual; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OPERATOR sys.<> ( + LEFTARG = sys.GEOMETRY, + RIGHTARG = sys.GEOMETRY, + FUNCTION = sys.ST_NotEquals, + COMMUTATOR = <> +); + -- Minimum distance. 2D only. CREATE OR REPLACE FUNCTION sys.STDistance(geom1 sys.GEOMETRY, geom2 sys.GEOMETRY) RETURNS float8 @@ -280,3 +368,8 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY_helper(bytea) AS '$libdir/postgis-3','LWGEOM_from_bytea' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; +CREATE OR REPLACE FUNCTION sys.bytea_helper(sys.GEOMETRY) + RETURNS bytea + AS '$libdir/postgis-3','LWGEOM_to_bytea' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + diff --git a/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql b/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql index d50f098ab9..e09e67b350 100644 --- a/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql +++ b/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql @@ -108,7 +108,30 @@ CREATE OR REPLACE FUNCTION sys.STAsText(sys.GEOMETRY) CREATE OR REPLACE FUNCTION sys.text(sys.GEOMETRY) RETURNS text - AS '$libdir/postgis-3','LWGEOM_to_text' + AS $$ + BEGIN + RAISE EXCEPTION 'Conversion from data type Geometry to Text is not allowed.'; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.bpchar(sys.GEOMETRY) + RETURNS sys.bpchar + AS '$libdir/postgis-3','LWGEOM_asText' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bpchar) + RETURNS sys.GEOMETRY + AS '$libdir/postgis-3','parse_WKT_lwgeom' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.varchar(sys.GEOMETRY) + RETURNS sys.varchar + AS '$libdir/postgis-3','LWGEOM_asText' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.varchar) + RETURNS sys.GEOMETRY + AS '$libdir/postgis-3','parse_WKT_lwgeom' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.GEOMETRY(bytea) @@ -159,38 +182,72 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY(bytea) $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.bytea(sys.GEOMETRY) - RETURNS bytea - AS '$libdir/postgis-3','LWGEOM_to_bytea' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + RETURNS bytea + AS $$ + DECLARE + byte bytea; + BEGIN + byte := (SELECT sys.bytea_helper($1)); + byte := substring(byte from 6); + byte := substring(byte from 1 for 4) || E'\\x010c' || substring(byte from 5); + RETURN byte; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bbf_varbinary) - RETURNS sys.GEOMETRY - AS $$ - DECLARE + RETURNS sys.GEOMETRY + AS $$ + DECLARE varBin bytea; - BEGIN - varBin := (SELECT CAST ($1 AS bytea)); - -- Call the underlying function after preprocessing - RETURN (SELECT CAST (varBin AS GEOMETRY)); - END; - $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + BEGIN + varBin := (SELECT CAST ($1 AS bytea)); + -- Call the underlying function after preprocessing + RETURN (SELECT CAST (varBin AS GEOMETRY)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.bbf_varbinary(sys.GEOMETRY) - RETURNS sys.bbf_varbinary - AS '$libdir/postgis-3','LWGEOM_to_bytea' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + RETURNS sys.bbf_varbinary + AS $$ + DECLARE + byte bytea; + BEGIN + byte := (SELECT CAST ($1 AS bytea)); + RETURN (SELECT CAST (byte AS sys.bbf_varbinary)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bbf_binary) + RETURNS sys.GEOMETRY + AS $$ + DECLARE + varBin sys.bbf_varbinary; + BEGIN + varBin := (SELECT CAST (CAST ($1 AS sys.VARCHAR) AS sys.bbf_varbinary)); + -- Call the underlying function after preprocessing + RETURN (SELECT CAST (varBin AS GEOMETRY)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.GEOMETRY(text) RETURNS sys.GEOMETRY - AS '$libdir/postgis-3','parse_WKT_lwgeom' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + BEGIN + RAISE EXCEPTION 'Conversion from data type Text to Geometry is not allowed.'; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE CAST (text AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(text) AS IMPLICIT; -CREATE CAST (sys.GEOMETRY AS text) WITH FUNCTION sys.text(sys.GEOMETRY) AS IMPLICIT; +CREATE CAST (sys.GEOMETRY AS text) WITH FUNCTION sys.text(sys.GEOMETRY); +CREATE CAST (sys.bpchar AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.bpchar) AS IMPLICIT; +CREATE CAST (sys.GEOMETRY AS sys.bpchar) WITH FUNCTION sys.bpchar(sys.GEOMETRY); +CREATE CAST (sys.varchar AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.varchar) AS IMPLICIT; +CREATE CAST (sys.GEOMETRY AS sys.varchar) WITH FUNCTION sys.varchar(sys.GEOMETRY); CREATE CAST (bytea AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(bytea) AS IMPLICIT; -CREATE CAST (sys.GEOMETRY AS bytea) WITH FUNCTION sys.bytea(sys.GEOMETRY) AS IMPLICIT; +CREATE CAST (sys.GEOMETRY AS bytea) WITH FUNCTION sys.bytea(sys.GEOMETRY); CREATE CAST (sys.bbf_varbinary AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.bbf_varbinary) AS IMPLICIT; -CREATE CAST (sys.GEOMETRY AS sys.bbf_varbinary) WITH FUNCTION sys.bbf_varbinary(sys.GEOMETRY) AS IMPLICIT; +CREATE CAST (sys.GEOMETRY AS sys.bbf_varbinary) WITH FUNCTION sys.bbf_varbinary(sys.GEOMETRY); +CREATE CAST (sys.bbf_binary AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.bbf_binary) AS IMPLICIT; -- Availability: 3.2.0 current supported in APG CREATE OR REPLACE FUNCTION sys.Geometry__Point(float8, float8, srid integer) @@ -252,6 +309,37 @@ CREATE OR REPLACE FUNCTION sys.ST_zmflag(sys.GEOMETRY) AS '$libdir/postgis-3', 'LWGEOM_zmflag' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; +CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) + RETURNS boolean + AS '$libdir/postgis-3', 'ST_Equals' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OPERATOR sys.= ( + LEFTARG = sys.GEOMETRY, + RIGHTARG = sys.GEOMETRY, + FUNCTION = sys.ST_Equals, + COMMUTATOR = =, + RESTRICT = eqsel +); + +CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) + RETURNS boolean + AS $$ + DECLARE + isEqual boolean; + BEGIN + isEqual := sys.ST_Equals(leftarg, rightarg); + RETURN NOT isEqual; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OPERATOR sys.<> ( + LEFTARG = sys.GEOMETRY, + RIGHTARG = sys.GEOMETRY, + FUNCTION = sys.ST_NotEquals, + COMMUTATOR = <> +); + -- Minimum distance. 2D only. CREATE OR REPLACE FUNCTION sys.STDistance(geom1 sys.GEOMETRY, geom2 sys.GEOMETRY) RETURNS float8 @@ -284,6 +372,11 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY_helper(bytea) AS '$libdir/postgis-3','LWGEOM_from_bytea' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; +CREATE OR REPLACE FUNCTION sys.bytea_helper(sys.GEOMETRY) + RETURNS bytea + AS '$libdir/postgis-3','LWGEOM_to_bytea' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + CREATE OR REPLACE FUNCTION sys.geographyin(cstring, oid, integer) RETURNS sys.GEOGRAPHY AS '$libdir/postgis-3','geography_in' @@ -438,8 +531,16 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(bytea) CREATE OR REPLACE FUNCTION sys.bytea(sys.GEOGRAPHY) RETURNS bytea - AS '$libdir/postgis-3','LWGEOM_to_bytea' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + DECLARE + byte bytea; + BEGIN + byte := (SELECT sys.bytea_helper($1)); + byte := substring(byte from 6); + byte := substring(byte from 1 for 4) || E'\\x010c' || substring(byte from 5); + RETURN byte; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bbf_varbinary) RETURNS sys.GEOGRAPHY @@ -455,27 +556,100 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bbf_varbinary) CREATE OR REPLACE FUNCTION sys.bbf_varbinary(sys.GEOGRAPHY) RETURNS sys.bbf_varbinary - AS '$libdir/postgis-3','LWGEOM_to_bytea' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + DECLARE + byte bytea; + BEGIN + byte := (SELECT CAST ($1 AS bytea)); + RETURN (SELECT CAST (byte AS sys.bbf_varbinary)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE CAST (bytea AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(bytea) AS IMPLICIT; -CREATE CAST (sys.GEOGRAPHY AS bytea) WITH FUNCTION sys.bytea(sys.GEOGRAPHY) AS IMPLICIT; -CREATE CAST (sys.bbf_varbinary AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.bbf_varbinary) AS IMPLICIT; -CREATE CAST (sys.GEOGRAPHY AS sys.bbf_varbinary) WITH FUNCTION sys.bbf_varbinary(sys.GEOGRAPHY) AS IMPLICIT; +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bbf_binary) + RETURNS sys.GEOGRAPHY + AS $$ + DECLARE + varBin sys.bbf_varbinary; + BEGIN + varBin := (SELECT CAST (CAST ($1 AS sys.VARCHAR) AS sys.bbf_varbinary)); + -- Call the underlying function after preprocessing + RETURN (SELECT CAST (varBin AS GEOGRAPHY)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.text(sys.GEOGRAPHY) + RETURNS text + AS $$ + BEGIN + RAISE EXCEPTION 'Conversion from data type Geography to Text is not allowed.'; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.GEOMETRY) +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(text) RETURNS sys.GEOGRAPHY - AS '$libdir/postgis-3','geography_from_geometry' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + BEGIN + RAISE EXCEPTION 'Conversion from data type Text to Geography is not allowed.'; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE CAST (sys.GEOMETRY AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.GEOMETRY) AS ASSIGNMENT; +CREATE OR REPLACE FUNCTION sys.bpchar(sys.GEOGRAPHY) + RETURNS sys.bpchar + AS $$ + BEGIN + -- Call the underlying function after preprocessing + -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) + RETURN CAST ((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1))) AS sys.bpchar); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.GEOGRAPHY) - RETURNS sys.GEOMETRY - AS '$libdir/postgis-3','geometry_from_geography' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bpchar) + RETURNS sys.GEOGRAPHY + AS $$ + DECLARE + geog sys.GEOGRAPHY; + BEGIN + geog := (SELECT sys.bpcharToGeography_helper($1)); + -- Call the underlying function after preprocessing + -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) + RETURN (SELECT sys.Geography__STFlipCoordinates(geog)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE CAST (sys.GEOGRAPHY AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.GEOGRAPHY) AS ASSIGNMENT; +CREATE OR REPLACE FUNCTION sys.varchar(sys.GEOGRAPHY) + RETURNS sys.varchar + AS $$ + BEGIN + -- Call the underlying function after preprocessing + -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) + RETURN CAST ((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1))) AS sys.varchar); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.varchar) + RETURNS sys.GEOGRAPHY + AS $$ + DECLARE + geog sys.GEOGRAPHY; + BEGIN + geog := (SELECT sys.varcharToGeography_helper($1)); + -- Call the underlying function after preprocessing + -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) + RETURN (SELECT sys.Geography__STFlipCoordinates(geog)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE CAST (text AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(text) AS IMPLICIT; +CREATE CAST (sys.GEOGRAPHY AS text) WITH FUNCTION sys.text(sys.GEOGRAPHY); +CREATE CAST (sys.bpchar AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.bpchar) AS IMPLICIT; +CREATE CAST (sys.GEOGRAPHY AS sys.bpchar) WITH FUNCTION sys.bpchar(sys.GEOGRAPHY); +CREATE CAST (sys.varchar AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.varchar) AS IMPLICIT; +CREATE CAST (sys.GEOGRAPHY AS sys.varchar) WITH FUNCTION sys.varchar(sys.GEOGRAPHY); +CREATE CAST (sys.bbf_binary AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.bbf_binary) AS IMPLICIT; +CREATE CAST (bytea AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(bytea) AS IMPLICIT; +CREATE CAST (sys.GEOGRAPHY AS bytea) WITH FUNCTION sys.bytea(sys.GEOGRAPHY); +CREATE CAST (sys.bbf_varbinary AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.bbf_varbinary) AS IMPLICIT; +CREATE CAST (sys.GEOGRAPHY AS sys.bbf_varbinary) WITH FUNCTION sys.bbf_varbinary(sys.GEOGRAPHY); -- This Function Flips the Coordinates of the Point (x, y) -> (y, x) CREATE OR REPLACE FUNCTION sys.Geography__STFlipCoordinates(sys.GEOGRAPHY) @@ -615,6 +789,37 @@ CREATE OR REPLACE FUNCTION sys.ST_zmflag(sys.GEOGRAPHY) AS '$libdir/postgis-3', 'LWGEOM_zmflag' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; +CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) + RETURNS boolean + AS '$libdir/postgis-3', 'ST_Equals' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OPERATOR sys.= ( + LEFTARG = sys.GEOGRAPHY, + RIGHTARG = sys.GEOGRAPHY, + FUNCTION = sys.ST_Equals, + COMMUTATOR = =, + RESTRICT = eqsel +); + +CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) + RETURNS boolean + AS $$ + DECLARE + isEqual boolean; + BEGIN + isEqual := sys.ST_Equals(leftarg, rightarg); + RETURN NOT isEqual; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OPERATOR sys.<> ( + LEFTARG = sys.GEOGRAPHY, + RIGHTARG = sys.GEOGRAPHY, + FUNCTION = sys.ST_NotEquals, + COMMUTATOR = <> +); + -- Minimum distance CREATE OR REPLACE FUNCTION sys.STDistance(geog1 sys.GEOGRAPHY, geog2 sys.GEOGRAPHY) RETURNS float8 @@ -671,3 +876,18 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY_helper(bytea) RETURNS sys.GEOGRAPHY AS '$libdir/postgis-3','geography_from_binary' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.bpcharToGeography_helper(sys.bpchar) + RETURNS sys.GEOGRAPHY + AS '$libdir/postgis-3','parse_WKT_lwgeom' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.varcharToGeography_helper(sys.varchar) + RETURNS sys.GEOGRAPHY + AS '$libdir/postgis-3','parse_WKT_lwgeom' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.bytea_helper(sys.GEOGRAPHY) + RETURNS bytea + AS '$libdir/postgis-3','LWGEOM_to_bytea' + LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; diff --git a/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out b/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out index 5ad69e2c46..3dc766ef14 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out @@ -18,10 +18,26 @@ DROP VIEW IF EXISTS point_distances_geog DROP TABLE IF EXISTS SPATIALPOINTGEOM_dt +DROP TABLE IF EXISTS GeomToVarbinary + +DROP TABLE IF EXISTS GeomTochar + +DROP TABLE IF EXISTS GeomToVarchar + +DROP TABLE IF EXISTS TypeToGeom + DROP TABLE IF EXISTS TypeTable DROP TYPE IF EXISTS geom DROP TABLE IF EXISTS SPATIALPOINTGEOG_dt +DROP TABLE IF EXISTS GeogToVarbinary + +DROP TABLE IF EXISTS GeogTochar + +DROP TABLE IF EXISTS GeogToVarchar + +DROP TABLE IF EXISTS TypeToGeog + DROP TABLE IF EXISTS SPATIALPOINT_dt diff --git a/test/JDBC/expected/TestSpatialPoint-vu-prepare.out b/test/JDBC/expected/TestSpatialPoint-vu-prepare.out index d3c1cda6a0..2d3737573e 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-prepare.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-prepare.out @@ -162,6 +162,38 @@ INSERT INTO TypeTable(ID, Shape) VALUES(1, geometry::Point(1, 2, 4326)); ~~ROW COUNT: 1~~ +#Testing Implicit CASTs to and from Geometry data type for supported Explicit CASTs +#UnSupported CASTs to and from Geometry data type +CREATE TABLE GeomToVarbinary(p varbinary) +INSERT INTO GeomToVarbinary(p) VALUES(geometry::Point(1, 2, 4326)); +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: column "p" is of type varbinary but expression is of type geometry)~~ + +CREATE TABLE GeomTochar(p char) +INSERT INTO GeomTochar(p) VALUES(geometry::Point(1, 2, 4326)); +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: column "p" is of type bpchar but expression is of type geometry)~~ + +CREATE TABLE GeomToVarchar(p varchar) +INSERT INTO GeomToVarchar(p) VALUES(geometry::Point(1, 2, 4326)); +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: column "p" is of type "varchar" but expression is of type geometry)~~ + +#Supported CASTs to and from Geometry data type +CREATE TABLE TypeToGeom(p geometry) +INSERT INTO TypeToGeom(p) VALUES(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS varbinary(MAX))); +~~ROW COUNT: 1~~ + +INSERT INTO TypeToGeom(p) VALUES(CAST ('POINT(1 2)' AS char)); +~~ROW COUNT: 1~~ + +INSERT INTO TypeToGeom(p) VALUES(CAST ('POINT(1 2)' AS varchar)); +~~ROW COUNT: 1~~ + + #Geography Test Cases #Positive Test for STGeomFromText with SRID 4326 @@ -351,6 +383,38 @@ CREATE VIEW TransformFromGeog AS SELECT ST_Transform(location, 4326) AS Modified CREATE VIEW point_distances_geog AS SELECT p1.location AS point1, p2.location AS point2, STDistance( p1.location, p2.location ) AS distance FROM SPATIALPOINTGEOG_dt p1 CROSS JOIN SPATIALPOINTGEOG_dt p2 WHERE p1.location <> p2.location; +#Testing Implicit CASTs to and from Geography data type for supported Explicit CASTs +#UnSupported CASTs to and from Geography data type +CREATE TABLE GeogToVarbinary(p varbinary) +INSERT INTO GeogToVarbinary(p) VALUES(geography::Point(1, 2, 4326)); +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: column "p" is of type varbinary but expression is of type geography)~~ + +CREATE TABLE GeogTochar(p char) +INSERT INTO GeogTochar(p) VALUES(geography::Point(1, 2, 4326)); +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: column "p" is of type bpchar but expression is of type geography)~~ + +CREATE TABLE GeogToVarchar(p varchar) +INSERT INTO GeogToVarchar(p) VALUES(geography::Point(1, 2, 4326)); +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: column "p" is of type "varchar" but expression is of type geography)~~ + +#Supported CASTs to and from Geography data type +CREATE TABLE TypeToGeog(p geography) +INSERT INTO TypeToGeog(p) VALUES(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS varbinary(MAX))); +~~ROW COUNT: 1~~ + +INSERT INTO TypeToGeog(p) VALUES(CAST ('POINT(1 2)' AS char)); +~~ROW COUNT: 1~~ + +INSERT INTO TypeToGeog(p) VALUES(CAST ('POINT(1 2)' AS varchar)); +~~ROW COUNT: 1~~ + + CREATE TABLE SPATIALPOINT_dt (PrimaryKey int, GeomColumn geometry, GeogColumn geography) INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeomColumn) VALUES ( 1, geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) diff --git a/test/JDBC/expected/TestSpatialPoint-vu-verify.out b/test/JDBC/expected/TestSpatialPoint-vu-verify.out index effe3902e8..e0fdd6eeda 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-verify.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-verify.out @@ -119,7 +119,7 @@ geometry#!#geometry#!#float E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C000000000000F03F0000000000000040#!#52.62309000809436 ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: ST_Distance: Operation on mixed SRID geometries (Point, 4326) != (Point, 0))~~ +~~ERROR (Message: ST_Equals: Operation on mixed SRID geometries (Point, 4326) != (Point, 0))~~ SELECT location FROM SPATIALPOINTGEOM_dt; @@ -149,6 +149,265 @@ int#!#geometry ~~END~~ +SELECT * FROM GeomToVarbinary; +GO +~~START~~ +varbinary +~~END~~ + +SELECT * FROM GeomTochar; +GO +~~START~~ +char +~~END~~ + +SELECT * FROM GeomToVarchar; +GO +~~START~~ +varchar +~~END~~ + +SELECT * FROM TypeToGeom; +GO +~~START~~ +geometry +E6100000010C17D9CEF753D34740D34D6210585936C0 +00000000010C000000000000F03F0000000000000040 +00000000010C000000000000F03F0000000000000040 +~~END~~ + + +-- Testing Explicit CASTs to and from Geometry data type +-- Supported CASTs to and from Geometry data type +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS binary) as geometry) +GO +~~START~~ +geometry +E6100000010C17D9CEF753D34740D34D6210585936C0 +~~END~~ + +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS varbinary(MAX)) as geometry) +GO +~~START~~ +geometry +E6100000010C17D9CEF753D34740D34D6210585936C0 +~~END~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS varbinary(MAX)) +GO +~~START~~ +varbinary +E6100000010C000000000000F03F0000000000000040 +~~END~~ + +Select CAST(CAST ('POINT(1 2)' AS char) as geometry) +GO +~~START~~ +geometry +00000000010C000000000000F03F0000000000000040 +~~END~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS char) +GO +~~START~~ +char +POINT(1 2) +~~END~~ + +Select CAST(CAST ('POINT(1 2)' AS nchar) as geometry) +GO +~~START~~ +geometry +00000000010C000000000000F03F0000000000000040 +~~END~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS nchar) +GO +~~START~~ +nchar +POINT(1 2) +~~END~~ + +Select CAST(CAST ('POINT(1 2)' AS varchar) as geometry) +GO +~~START~~ +geometry +00000000010C000000000000F03F0000000000000040 +~~END~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS varchar) +GO +~~START~~ +varchar +POINT(1 2) +~~END~~ + +Select CAST(CAST ('POINT(1 2)' AS nvarchar) as geometry) +GO +~~START~~ +geometry +00000000010C000000000000F03F0000000000000040 +~~END~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS nvarchar) +GO +~~START~~ +nvarchar +POINT(1 2) +~~END~~ + + +-- UnSupported CASTs to and from Geometry data type +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS datetime) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geometry to datetime)~~ + +Select CAST(CAST (0001-01-01 AS datetime) as geometry) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type datetime to geometry)~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS decimal) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geometry to "decimal")~~ + +Select CAST(CAST (20.0 AS decimal) as geometry) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type "decimal" to geometry)~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS bigInt) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geometry to bigint)~~ + +Select CAST(CAST (20 AS bigInt) as geometry) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type bigint to geometry)~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS bigInt) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geometry to bigint)~~ + +Select CAST(CAST (20 AS bigInt) as geometry) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type bigint to geometry)~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS money) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geometry to money)~~ + +Select CAST(CAST ($1 AS money) as geometry) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type money to geometry)~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS bit) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geometry to "bit")~~ + +Select CAST(CAST (1 AS bit) as geometry) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type "bit" to geometry)~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS uniqueidentifier) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geometry to uniqueidentifier)~~ + +Select CAST(CAST ('6F9619FF-8B86-D011-B42D-00C04FC964FF' AS uniqueidentifier) as geometry) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type uniqueidentifier to geometry)~~ + +Select CAST(CAST ('POINT(1 2)' AS text) as geometry) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Conversion from data type Text to Geometry is not allowed.)~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS text) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Conversion from data type Geometry to Text is not allowed.)~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS sql_variant) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geometry to sql_variant)~~ + +Select CAST(CAST ('POINT(1 2)' AS sql_variant) as geometry) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type sql_variant to geometry)~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS xml) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geometry to xml)~~ + +Select CAST(CAST ('point(1 2)' AS xml) as geometry) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type xml to geometry)~~ + +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS geography) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geometry to geography)~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS geometry) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geography to geometry)~~ + + +-- UnSupported CASTs which are currently supported for geometry +-- This is because we have created -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS image) +GO +~~START~~ +image +E6100000010C000000000000F03F0000000000000040 +~~END~~ + +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS image) as geometry) +GO +~~START~~ +geometry +E6100000010C17D9CEF753D34740D34D6210585936C0 +~~END~~ + + DECLARE @point geography; SET @point = geography::STGeomFromText('POINT(-122.34900 47.65100)', 4326); SELECT STAsText(@point); @@ -279,31 +538,39 @@ geography#!#geography#!#float E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#0.0 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#5535965.307328846 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 +E6100000010C0000000000000040000000000000F03F#!#E6100000010C0000000000000040000000000000F03F#!#0.0 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#0.0 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#5535965.307328846 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 +E6100000010C0000000000000040000000000000F03F#!#E6100000010C0000000000000040000000000000F03F#!#0.0 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#0.0 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#0.0 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 +E6100000010C0000000000000040000000000000F03F#!#E6100000010C0000000000000040000000000000F03F#!#0.0 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 +E6100000010C0000000000000040000000000000F03F#!#E6100000010C0000000000000040000000000000F03F#!#0.0 E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#5535965.307328846 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 ~~END~~ @@ -324,6 +591,253 @@ E6100000010C0000000000000040000000000000F03F ~~END~~ +SELECT * FROM GeogToVarbinary; +GO +~~START~~ +varbinary +~~END~~ + +SELECT * FROM GeogTochar; +GO +~~START~~ +char +~~END~~ + +SELECT * FROM GeogToVarchar; +GO +~~START~~ +varchar +~~END~~ + +SELECT * FROM TypeToGeog; +GO +~~START~~ +geography +E6100000010C17D9CEF753D34740D34D6210585936C0 +00000000010C0000000000000040000000000000F03F +00000000010C0000000000000040000000000000F03F +~~END~~ + + +-- Testing Explicit CASTs to and from Geography data type +-- Supported CASTs to and from Geography data type +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS binary) as geography) +GO +~~START~~ +geography +E6100000010C17D9CEF753D34740D34D6210585936C0 +~~END~~ + +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS varbinary(MAX)) as geography) +GO +~~START~~ +geography +E6100000010C17D9CEF753D34740D34D6210585936C0 +~~END~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS varbinary(MAX)) +GO +~~START~~ +varbinary +E6100000010C0000000000000040000000000000F03F +~~END~~ + +Select CAST(CAST ('POINT(1 2)' AS char) as geography) +GO +~~START~~ +geography +00000000010C0000000000000040000000000000F03F +~~END~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS char) +GO +~~START~~ +char +POINT(1 2) +~~END~~ + +Select CAST(CAST ('POINT(1 2)' AS nchar) as geography) +GO +~~START~~ +geography +00000000010C0000000000000040000000000000F03F +~~END~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS nchar) +GO +~~START~~ +nchar +POINT(1 2) +~~END~~ + +Select CAST(CAST ('POINT(1 2)' AS varchar) as geography) +GO +~~START~~ +geography +00000000010C0000000000000040000000000000F03F +~~END~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS varchar) +GO +~~START~~ +varchar +POINT(1 2) +~~END~~ + +Select CAST(CAST ('POINT(1 2)' AS nvarchar) as geography) +GO +~~START~~ +geography +00000000010C0000000000000040000000000000F03F +~~END~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS nvarchar) +GO +~~START~~ +nvarchar +POINT(1 2) +~~END~~ + + +-- UnSupported CASTs to and from Geography data type +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS datetime) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geography to datetime)~~ + +Select CAST(CAST (0001-01-01 AS datetime) as geography) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type datetime to geography)~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS decimal) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geography to "decimal")~~ + +Select CAST(CAST (20.0 AS decimal) as geography) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type "decimal" to geography)~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS bigInt) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geography to bigint)~~ + +Select CAST(CAST (20 AS bigInt) as geography) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type bigint to geography)~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS bigInt) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geography to bigint)~~ + +Select CAST(CAST (20 AS bigInt) as geography) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type bigint to geography)~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS money) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geography to money)~~ + +Select CAST(CAST ($1 AS money) as geography) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type money to geography)~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS bit) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geography to "bit")~~ + +Select CAST(CAST (1 AS bit) as geography) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type "bit" to geography)~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS uniqueidentifier) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geography to uniqueidentifier)~~ + +Select CAST(CAST ('6F9619FF-8B86-D011-B42D-00C04FC964FF' AS uniqueidentifier) as geography) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type uniqueidentifier to geography)~~ + +Select CAST(CAST ('POINT(1 2)' AS text) as geography) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Conversion from data type Text to Geography is not allowed.)~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS text) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Conversion from data type Geography to Text is not allowed.)~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS sql_variant) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geography to sql_variant)~~ + +Select CAST(CAST ('POINT(1 2)' AS sql_variant) as geography) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type sql_variant to geography)~~ + +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS xml) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type geography to xml)~~ + +Select CAST(CAST ('point(1 2)' AS xml) as geography) +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: cannot cast type xml to geography)~~ + + +-- UnSupported CASTs which are currently supported for geography +-- This is because we have created -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS image) +GO +~~START~~ +image +E6100000010C0000000000000040000000000000F03F +~~END~~ + +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS image) as geography) +GO +~~START~~ +geography +E6100000010C17D9CEF753D34740D34D6210585936C0 +~~END~~ + + SELECT * FROM SPATIALPOINT_dt; GO ~~START~~ diff --git a/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.txt b/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.txt index 5ad69e2c46..3dc766ef14 100644 --- a/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.txt +++ b/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.txt @@ -18,10 +18,26 @@ DROP VIEW IF EXISTS point_distances_geog DROP TABLE IF EXISTS SPATIALPOINTGEOM_dt +DROP TABLE IF EXISTS GeomToVarbinary + +DROP TABLE IF EXISTS GeomTochar + +DROP TABLE IF EXISTS GeomToVarchar + +DROP TABLE IF EXISTS TypeToGeom + DROP TABLE IF EXISTS TypeTable DROP TYPE IF EXISTS geom DROP TABLE IF EXISTS SPATIALPOINTGEOG_dt +DROP TABLE IF EXISTS GeogToVarbinary + +DROP TABLE IF EXISTS GeogTochar + +DROP TABLE IF EXISTS GeogToVarchar + +DROP TABLE IF EXISTS TypeToGeog + DROP TABLE IF EXISTS SPATIALPOINT_dt diff --git a/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt b/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt index 2f21076b80..07418a5488 100644 --- a/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt +++ b/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt @@ -80,6 +80,20 @@ CREATE TABLE TypeTable(ID INT PRIMARY KEY, Shape geom) INSERT INTO TypeTable(ID, Shape) VALUES(1, geometry::Point(1, 2, 4326)); +#Testing Implicit CASTs to and from Geometry data type for supported Explicit CASTs +#UnSupported CASTs to and from Geometry data type +CREATE TABLE GeomToVarbinary(p varbinary) +INSERT INTO GeomToVarbinary(p) VALUES(geometry::Point(1, 2, 4326)); +CREATE TABLE GeomTochar(p char) +INSERT INTO GeomTochar(p) VALUES(geometry::Point(1, 2, 4326)); +CREATE TABLE GeomToVarchar(p varchar) +INSERT INTO GeomToVarchar(p) VALUES(geometry::Point(1, 2, 4326)); +#Supported CASTs to and from Geometry data type +CREATE TABLE TypeToGeom(p geometry) +INSERT INTO TypeToGeom(p) VALUES(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS varbinary(MAX))); +INSERT INTO TypeToGeom(p) VALUES(CAST ('POINT(1 2)' AS char)); +INSERT INTO TypeToGeom(p) VALUES(CAST ('POINT(1 2)' AS varchar)); + #Geography Test Cases #Positive Test for STGeomFromText with SRID 4326 @@ -165,6 +179,20 @@ CREATE VIEW TransformFromGeog AS SELECT ST_Transform(location, 4326) AS Modified CREATE VIEW point_distances_geog AS SELECT p1.location AS point1, p2.location AS point2, STDistance( p1.location, p2.location ) AS distance FROM SPATIALPOINTGEOG_dt p1 CROSS JOIN SPATIALPOINTGEOG_dt p2 WHERE p1.location <> p2.location; +#Testing Implicit CASTs to and from Geography data type for supported Explicit CASTs +#UnSupported CASTs to and from Geography data type +CREATE TABLE GeogToVarbinary(p varbinary) +INSERT INTO GeogToVarbinary(p) VALUES(geography::Point(1, 2, 4326)); +CREATE TABLE GeogTochar(p char) +INSERT INTO GeogTochar(p) VALUES(geography::Point(1, 2, 4326)); +CREATE TABLE GeogToVarchar(p varchar) +INSERT INTO GeogToVarchar(p) VALUES(geography::Point(1, 2, 4326)); +#Supported CASTs to and from Geography data type +CREATE TABLE TypeToGeog(p geography) +INSERT INTO TypeToGeog(p) VALUES(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS varbinary(MAX))); +INSERT INTO TypeToGeog(p) VALUES(CAST ('POINT(1 2)' AS char)); +INSERT INTO TypeToGeog(p) VALUES(CAST ('POINT(1 2)' AS varchar)); + CREATE TABLE SPATIALPOINT_dt (PrimaryKey int, GeomColumn geometry, GeogColumn geography) INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeomColumn) VALUES ( 1, geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) diff --git a/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql b/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql index e40ec893fd..5258e5735a 100644 --- a/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql +++ b/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql @@ -46,6 +46,93 @@ GO SELECT * FROM TypeTable; GO +SELECT * FROM GeomToVarbinary; +GO +SELECT * FROM GeomTochar; +GO +SELECT * FROM GeomToVarchar; +GO +SELECT * FROM TypeToGeom; +GO + +-- Testing Explicit CASTs to and from Geometry data type +-- Supported CASTs to and from Geometry data type +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS binary) as geometry) +GO +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS varbinary(MAX)) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS varbinary(MAX)) +GO +Select CAST(CAST ('POINT(1 2)' AS char) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS char) +GO +Select CAST(CAST ('POINT(1 2)' AS nchar) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS nchar) +GO +Select CAST(CAST ('POINT(1 2)' AS varchar) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS varchar) +GO +Select CAST(CAST ('POINT(1 2)' AS nvarchar) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS nvarchar) +GO + +-- UnSupported CASTs to and from Geometry data type +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS datetime) +GO +Select CAST(CAST (0001-01-01 AS datetime) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS decimal) +GO +Select CAST(CAST (20.0 AS decimal) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS bigInt) +GO +Select CAST(CAST (20 AS bigInt) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS bigInt) +GO +Select CAST(CAST (20 AS bigInt) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS money) +GO +Select CAST(CAST ($1 AS money) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS bit) +GO +Select CAST(CAST (1 AS bit) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS uniqueidentifier) +GO +Select CAST(CAST ('6F9619FF-8B86-D011-B42D-00C04FC964FF' AS uniqueidentifier) as geometry) +GO +Select CAST(CAST ('POINT(1 2)' AS text) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS text) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS sql_variant) +GO +Select CAST(CAST ('POINT(1 2)' AS sql_variant) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS xml) +GO +Select CAST(CAST ('point(1 2)' AS xml) as geometry) +GO +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS geometry) +GO + +-- UnSupported CASTs which are currently supported for geometry +-- This is because we have created -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; +Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS image) +GO +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS image) as geometry) +GO + DECLARE @point geography; SET @point = geography::STGeomFromText('POINT(-122.34900 47.65100)', 4326); SELECT STAsText(@point); @@ -92,5 +179,88 @@ GO SELECT location FROM SPATIALPOINTGEOG_dt; GO +SELECT * FROM GeogToVarbinary; +GO +SELECT * FROM GeogTochar; +GO +SELECT * FROM GeogToVarchar; +GO +SELECT * FROM TypeToGeog; +GO + +-- Testing Explicit CASTs to and from Geography data type +-- Supported CASTs to and from Geography data type +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS binary) as geography) +GO +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS varbinary(MAX)) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS varbinary(MAX)) +GO +Select CAST(CAST ('POINT(1 2)' AS char) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS char) +GO +Select CAST(CAST ('POINT(1 2)' AS nchar) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS nchar) +GO +Select CAST(CAST ('POINT(1 2)' AS varchar) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS varchar) +GO +Select CAST(CAST ('POINT(1 2)' AS nvarchar) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS nvarchar) +GO + +-- UnSupported CASTs to and from Geography data type +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS datetime) +GO +Select CAST(CAST (0001-01-01 AS datetime) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS decimal) +GO +Select CAST(CAST (20.0 AS decimal) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS bigInt) +GO +Select CAST(CAST (20 AS bigInt) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS bigInt) +GO +Select CAST(CAST (20 AS bigInt) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS money) +GO +Select CAST(CAST ($1 AS money) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS bit) +GO +Select CAST(CAST (1 AS bit) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS uniqueidentifier) +GO +Select CAST(CAST ('6F9619FF-8B86-D011-B42D-00C04FC964FF' AS uniqueidentifier) as geography) +GO +Select CAST(CAST ('POINT(1 2)' AS text) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS text) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS sql_variant) +GO +Select CAST(CAST ('POINT(1 2)' AS sql_variant) as geography) +GO +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS xml) +GO +Select CAST(CAST ('point(1 2)' AS xml) as geography) +GO + +-- UnSupported CASTs which are currently supported for geography +-- This is because we have created -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; +Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS image) +GO +Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS image) as geography) +GO + SELECT * FROM SPATIALPOINT_dt; GO From 29f90509f08a332dd7de5e4acca7cd8427b52ddd Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Mon, 23 Oct 2023 17:34:15 +0000 Subject: [PATCH 02/21] Fixed JDBC test cases Signed-off-by: Anikait Agrawal --- contrib/babelfishpg_common/sql/geography.sql | 32 ++++++---- contrib/babelfishpg_common/sql/geometry.sql | 28 ++++++--- .../upgrades/spatial_types--3.2.0--3.3.0.sql | 60 ++++++++++++------- .../expected/TestSpatialPoint-vu-verify.out | 26 +++----- .../datatypes/TestSpatialPoint-vu-verify.sql | 4 +- .../expected_dependency.out | 23 ++++++- 6 files changed, 112 insertions(+), 61 deletions(-) diff --git a/contrib/babelfishpg_common/sql/geography.sql b/contrib/babelfishpg_common/sql/geography.sql index 8a70ebc2f2..2c54fe0831 100644 --- a/contrib/babelfishpg_common/sql/geography.sql +++ b/contrib/babelfishpg_common/sql/geography.sql @@ -412,8 +412,16 @@ CREATE OR REPLACE FUNCTION sys.ST_zmflag(sys.GEOGRAPHY) CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) RETURNS boolean - AS '$libdir/postgis-3', 'ST_Equals' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + DECLARE + leftvarBin sys.bbf_varbinary; + rightvarBin sys.bbf_varbinary; + BEGIN + leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); + rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + RETURN (SELECT sys.varbinary_eq(leftvarBin, rightvarBin)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OPERATOR sys.= ( LEFTARG = sys.GEOGRAPHY, @@ -426,13 +434,15 @@ CREATE OPERATOR sys.= ( CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) RETURNS boolean AS $$ - DECLARE - isEqual boolean; - BEGIN - isEqual := sys.ST_Equals(leftarg, rightarg); - RETURN NOT isEqual; - END; - $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + DECLARE + leftvarBin sys.bbf_varbinary; + rightvarBin sys.bbf_varbinary; + BEGIN + leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); + rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + RETURN (SELECT sys.varbinary_neq(leftvarBin, rightvarBin)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OPERATOR sys.<> ( LEFTARG = sys.GEOGRAPHY, @@ -500,12 +510,12 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY_helper(bytea) CREATE OR REPLACE FUNCTION sys.bpcharToGeography_helper(sys.bpchar) RETURNS sys.GEOGRAPHY - AS '$libdir/postgis-3','parse_WKT_lwgeom' + AS '$libdir/postgis-3','geography_from_text' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.varcharToGeography_helper(sys.varchar) RETURNS sys.GEOGRAPHY - AS '$libdir/postgis-3','parse_WKT_lwgeom' + AS '$libdir/postgis-3','geography_from_text' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.bytea_helper(sys.GEOGRAPHY) diff --git a/contrib/babelfishpg_common/sql/geometry.sql b/contrib/babelfishpg_common/sql/geometry.sql index bff922ef89..d162eb0fba 100644 --- a/contrib/babelfishpg_common/sql/geometry.sql +++ b/contrib/babelfishpg_common/sql/geometry.sql @@ -307,8 +307,16 @@ CREATE OR REPLACE FUNCTION sys.ST_zmflag(sys.GEOMETRY) CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) RETURNS boolean - AS '$libdir/postgis-3', 'ST_Equals' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + DECLARE + leftvarBin sys.bbf_varbinary; + rightvarBin sys.bbf_varbinary; + BEGIN + leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); + rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + RETURN (SELECT sys.varbinary_eq(leftvarBin, rightvarBin)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OPERATOR sys.= ( LEFTARG = sys.GEOMETRY, @@ -321,13 +329,15 @@ CREATE OPERATOR sys.= ( CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) RETURNS boolean AS $$ - DECLARE - isEqual boolean; - BEGIN - isEqual := sys.ST_Equals(leftarg, rightarg); - RETURN NOT isEqual; - END; - $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + DECLARE + leftvarBin sys.bbf_varbinary; + rightvarBin sys.bbf_varbinary; + BEGIN + leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); + rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + RETURN (SELECT sys.varbinary_neq(leftvarBin, rightvarBin)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OPERATOR sys.<> ( LEFTARG = sys.GEOMETRY, diff --git a/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql b/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql index e09e67b350..748ab39351 100644 --- a/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql +++ b/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql @@ -311,8 +311,16 @@ CREATE OR REPLACE FUNCTION sys.ST_zmflag(sys.GEOMETRY) CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) RETURNS boolean - AS '$libdir/postgis-3', 'ST_Equals' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + DECLARE + leftvarBin sys.bbf_varbinary; + rightvarBin sys.bbf_varbinary; + BEGIN + leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); + rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + RETURN (SELECT sys.varbinary_eq(leftvarBin, rightvarBin)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OPERATOR sys.= ( LEFTARG = sys.GEOMETRY, @@ -325,13 +333,15 @@ CREATE OPERATOR sys.= ( CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) RETURNS boolean AS $$ - DECLARE - isEqual boolean; - BEGIN - isEqual := sys.ST_Equals(leftarg, rightarg); - RETURN NOT isEqual; - END; - $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + DECLARE + leftvarBin sys.bbf_varbinary; + rightvarBin sys.bbf_varbinary; + BEGIN + leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); + rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + RETURN (SELECT sys.varbinary_neq(leftvarBin, rightvarBin)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OPERATOR sys.<> ( LEFTARG = sys.GEOMETRY, @@ -791,8 +801,16 @@ CREATE OR REPLACE FUNCTION sys.ST_zmflag(sys.GEOGRAPHY) CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) RETURNS boolean - AS '$libdir/postgis-3', 'ST_Equals' - LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; + AS $$ + DECLARE + leftvarBin sys.bbf_varbinary; + rightvarBin sys.bbf_varbinary; + BEGIN + leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); + rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + RETURN (SELECT sys.varbinary_eq(leftvarBin, rightvarBin)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OPERATOR sys.= ( LEFTARG = sys.GEOGRAPHY, @@ -805,13 +823,15 @@ CREATE OPERATOR sys.= ( CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) RETURNS boolean AS $$ - DECLARE - isEqual boolean; - BEGIN - isEqual := sys.ST_Equals(leftarg, rightarg); - RETURN NOT isEqual; - END; - $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + DECLARE + leftvarBin sys.bbf_varbinary; + rightvarBin sys.bbf_varbinary; + BEGIN + leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); + rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + RETURN (SELECT sys.varbinary_neq(leftvarBin, rightvarBin)); + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; CREATE OPERATOR sys.<> ( LEFTARG = sys.GEOGRAPHY, @@ -879,12 +899,12 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY_helper(bytea) CREATE OR REPLACE FUNCTION sys.bpcharToGeography_helper(sys.bpchar) RETURNS sys.GEOGRAPHY - AS '$libdir/postgis-3','parse_WKT_lwgeom' + AS '$libdir/postgis-3','geography_from_text' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.varcharToGeography_helper(sys.varchar) RETURNS sys.GEOGRAPHY - AS '$libdir/postgis-3','parse_WKT_lwgeom' + AS '$libdir/postgis-3','geography_from_text' LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; CREATE OR REPLACE FUNCTION sys.bytea_helper(sys.GEOGRAPHY) diff --git a/test/JDBC/expected/TestSpatialPoint-vu-verify.out b/test/JDBC/expected/TestSpatialPoint-vu-verify.out index e0fdd6eeda..7e756bea17 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-verify.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-verify.out @@ -119,7 +119,7 @@ geometry#!#geometry#!#float E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C000000000000F03F0000000000000040#!#52.62309000809436 ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: ST_Equals: Operation on mixed SRID geometries (Point, 4326) != (Point, 0))~~ +~~ERROR (Message: ST_Distance: Operation on mixed SRID geometries (Point, 4326) != (Point, 0))~~ SELECT location FROM SPATIALPOINTGEOM_dt; @@ -392,7 +392,7 @@ GO -- UnSupported CASTs which are currently supported for geometry --- This is because we have created -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; +-- This is because Image type is created as -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; so it is always converted to it's baseType i.e. varbinary Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS image) GO ~~START~~ @@ -538,39 +538,31 @@ geography#!#geography#!#float E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#0.0 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#5535965.307328846 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 -E6100000010C0000000000000040000000000000F03F#!#E6100000010C0000000000000040000000000000F03F#!#0.0 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#0.0 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#5535965.307328846 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 -E6100000010C0000000000000040000000000000F03F#!#E6100000010C0000000000000040000000000000F03F#!#0.0 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#0.0 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#0.0 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 -E6100000010C0000000000000040000000000000F03F#!#E6100000010C0000000000000040000000000000F03F#!#0.0 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 -E6100000010C0000000000000040000000000000F03F#!#E6100000010C0000000000000040000000000000F03F#!#0.0 E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#5535965.307328846 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 ~~END~~ @@ -614,8 +606,8 @@ GO ~~START~~ geography E6100000010C17D9CEF753D34740D34D6210585936C0 -00000000010C0000000000000040000000000000F03F -00000000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F ~~END~~ @@ -646,7 +638,7 @@ Select CAST(CAST ('POINT(1 2)' AS char) as geography) GO ~~START~~ geography -00000000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F ~~END~~ Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS char) @@ -660,7 +652,7 @@ Select CAST(CAST ('POINT(1 2)' AS nchar) as geography) GO ~~START~~ geography -00000000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F ~~END~~ Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS nchar) @@ -674,7 +666,7 @@ Select CAST(CAST ('POINT(1 2)' AS varchar) as geography) GO ~~START~~ geography -00000000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F ~~END~~ Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS varchar) @@ -688,7 +680,7 @@ Select CAST(CAST ('POINT(1 2)' AS nvarchar) as geography) GO ~~START~~ geography -00000000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F ~~END~~ Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS nvarchar) @@ -822,7 +814,7 @@ GO -- UnSupported CASTs which are currently supported for geography --- This is because we have created -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; +-- This is because Image type is created as -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; so it is always converted to it's baseType i.e. varbinary Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS image) GO ~~START~~ diff --git a/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql b/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql index 5258e5735a..75083433af 100644 --- a/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql +++ b/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql @@ -127,7 +127,7 @@ Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS geometry) GO -- UnSupported CASTs which are currently supported for geometry --- This is because we have created -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; +-- This is because Image type is created as -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; so it is always converted to it's baseType i.e. varbinary Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS image) GO Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS image) as geometry) @@ -256,7 +256,7 @@ Select CAST(CAST ('point(1 2)' AS xml) as geography) GO -- UnSupported CASTs which are currently supported for geography --- This is because we have created -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; +-- This is because Image type is created as -> CREATE DOMAIN sys.IMAGE AS sys.BBF_VARBINARY; so it is always converted to it's baseType i.e. varbinary Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS image) GO Select CAST(CAST (0xE6100000010C17D9CEF753D34740D34D6210585936C0 AS image) as geography) diff --git a/test/python/expected/upgrade_validation/expected_dependency.out b/test/python/expected/upgrade_validation/expected_dependency.out index e9cd5b635f..33f6b60956 100644 --- a/test/python/expected/upgrade_validation/expected_dependency.out +++ b/test/python/expected/upgrade_validation/expected_dependency.out @@ -90,6 +90,8 @@ Function sys."nchar"(sys.varbinary) Function sys."session_user"() Function sys."substring"(sys."nchar",integer,integer) Function sys."substring"(text,integer,integer) +Function sys."varchar"(sys.geography) +Function sys."varchar"(sys.geometry) Function sys.abs(sys.fixeddecimal) Function sys.applock_mode(character varying,character varying,character varying) Function sys.applock_test(character varying,character varying,character varying,character varying) @@ -221,6 +223,7 @@ Function sys.bbf_binary_varbinary_cmp(sys.bbf_binary,sys.bbf_varbinary) Function sys.bbf_get_context_info() Function sys.bbf_get_current_physical_schema_name(text) Function sys.bbf_is_shared_schema(text) +Function sys.bbf_varbinary(sys.geography) Function sys.bbf_varbinary(sys.geometry) Function sys.bbf_varbinary_binary_cmp(sys.bbf_varbinary,sys.bbf_binary) Function sys.bbf_varbinary_cmp(sys.bbf_varbinary,sys.bbf_varbinary) @@ -251,6 +254,8 @@ Function sys.bit_unsupported_max(sys."bit",sys."bit") Function sys.bit_unsupported_min(sys."bit",sys."bit") Function sys.bit_unsupported_sum(sys."bit",sys."bit") Function sys.bitxor(bit,bit) +Function sys.bpchar(sys.geography) +Function sys.bpchar(sys.geometry) Function sys.bpchar2datetime2(sys.bpchar) Function sys.bpchar2float4(sys.bpchar) Function sys.bpchar2int2(sys.bpchar) @@ -264,10 +269,13 @@ Function sys.bpcharbinary(sys.bpchar,integer,boolean) Function sys.bpcharcmp(sys.bpchar,sys.bpchar) Function sys.bpcharrowversion(character,integer,boolean) Function sys.bpcharrowversion(sys.bpchar,integer,boolean) +Function sys.bpchartogeography_helper(sys.bpchar) Function sys.bpcharvarbinary(character,integer,boolean) Function sys.bpcharvarbinary(sys.bpchar,integer,boolean) Function sys.bytea(sys.geography) Function sys.bytea(sys.geometry) +Function sys.bytea_helper(sys.geography) +Function sys.bytea_helper(sys.geometry) Function sys.byteavarbinary(bytea,integer,boolean) Function sys.ceiling(bigint) Function sys.ceiling(integer) @@ -421,9 +429,12 @@ Function sys.ftrunci8(real) Function sys.fulltextserviceproperty(text) Function sys.geogpoint_helper(double precision,double precision,integer) Function sys.geography(bytea) +Function sys.geography(sys."varchar") +Function sys.geography(sys.bbf_binary) Function sys.geography(sys.bbf_varbinary) +Function sys.geography(sys.bpchar) Function sys.geography(sys.geography,integer,boolean) -Function sys.geography(sys.geometry) +Function sys.geography(text) Function sys.geography__point(double precision,double precision,integer) Function sys.geography__stflipcoordinates(sys.geography) Function sys.geography__stgeomfromtext(text,integer) @@ -431,8 +442,10 @@ Function sys.geography__stpointfromtext(text,integer) Function sys.geography_helper(bytea) Function sys.geometry(bytea) Function sys.geometry(point) +Function sys.geometry(sys."varchar") +Function sys.geometry(sys.bbf_binary) Function sys.geometry(sys.bbf_varbinary) -Function sys.geometry(sys.geography) +Function sys.geometry(sys.bpchar) Function sys.geometry(sys.geometry,integer,boolean) Function sys.geometry(text) Function sys.geometry__point(double precision,double precision,integer) @@ -651,6 +664,8 @@ Function sys.sysdatetimeoffset() Function sys.system_user() Function sys.systypes_precision_helper(text,smallint) Function sys.sysutcdatetime() +Function sys.text(sys.geography) +Function sys.text(sys.geometry) Function sys.text_to_name(text) Function sys.time2datetime(time without time zone) Function sys.time2datetime2(time without time zone) @@ -729,6 +744,7 @@ Function sys.varcharbinary(sys."varchar",integer,boolean) Function sys.varcharcmp(sys."varchar",sys."varchar") Function sys.varcharrowversion(character varying,integer,boolean) Function sys.varcharrowversion(sys."varchar",integer,boolean) +Function sys.varchartogeography_helper(sys."varchar") Function sys.varcharvarbinary(character varying,integer,boolean) Function sys.varcharvarbinary(sys."varchar",integer,boolean) Function sys.version() @@ -881,6 +897,7 @@ Operator sys.<>(smallint,sys.fixeddecimal) Operator sys.<>(sys."bit",integer) Operator sys.<>(sys."bit",sys."bit") Operator sys.<>(sys.bbf_binary,sys.bbf_binary) +Operator sys.<>(sys.bbf_varbinary,sys.bbf_varbinary) Operator sys.<>(sys.datetime,sys.datetime) Operator sys.<>(sys.datetime2,sys.datetime2) Operator sys.<>(sys.datetimeoffset,sys.datetimeoffset) @@ -909,6 +926,8 @@ Operator sys.=(sys.fixeddecimal,bigint) Operator sys.=(sys.fixeddecimal,integer) Operator sys.=(sys.fixeddecimal,numeric) Operator sys.=(sys.fixeddecimal,smallint) +Operator sys.=(sys.geography,sys.geography) +Operator sys.=(sys.geometry,sys.geometry) Operator sys.=(sys.rowversion,sys.rowversion) Operator sys.=(sys.smalldatetime,date) Operator sys.=(sys.smalldatetime,sys.smalldatetime) From 0b5ac5aa0bd8d3bc05e250f09c4f8fdc4e7dbc74 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Tue, 24 Oct 2023 06:29:45 +0000 Subject: [PATCH 03/21] Resolved Comments Signed-off-by: Anikait Agrawal --- contrib/babelfishpg_common/sql/geography.sql | 22 ++++++++---- contrib/babelfishpg_common/sql/geometry.sql | 12 ++++--- .../upgrades/spatial_types--3.2.0--3.3.0.sql | 34 +++++++++++++------ .../expected/TestSpatialPoint-vu-verify.out | 8 ++--- 4 files changed, 52 insertions(+), 24 deletions(-) diff --git a/contrib/babelfishpg_common/sql/geography.sql b/contrib/babelfishpg_common/sql/geography.sql index 2c54fe0831..144032e1db 100644 --- a/contrib/babelfishpg_common/sql/geography.sql +++ b/contrib/babelfishpg_common/sql/geography.sql @@ -156,9 +156,15 @@ CREATE OR REPLACE FUNCTION sys.bytea(sys.GEOGRAPHY) DECLARE byte bytea; BEGIN + -- Here the received bytes are -> 1 byte (endianness) + 4 bytes (type) + 4 bytes (SRID) + 16 bytes * npoints byte := (SELECT sys.bytea_helper($1)); - byte := substring(byte from 6); - byte := substring(byte from 1 for 4) || E'\\x010c' || substring(byte from 5); + -- Checking the Geometry type currently we support only POINT type -> type = 1 (01000020 [here last byte represents presence of SRID]) + IF encode(substring(byte from 2 for 4), 'hex') = encode(E'\\x01000020', 'hex') THEN + -- Here we are taking bytes from SRID only for driver expected format -> 4 bytes (SRID) + 16 bytes * npoints + byte := substring(byte from 6); + -- The drivers expected format is 4 bytes (SRID) + 2 bytes (type -> 010C for point) + 16 bytes * npoints + byte := substring(byte from 1 for 4) || E'\\x010c' || substring(byte from 5); + END IF; RETURN byte; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -202,15 +208,19 @@ CREATE OR REPLACE FUNCTION sys.text(sys.GEOGRAPHY) RETURNS text AS $$ BEGIN - RAISE EXCEPTION 'Conversion from data type Geography to Text is not allowed.'; + RAISE EXCEPTION 'Explicit Conversion from data type sys.Geography to Text is not allowed.'; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(text) +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(text, integer, boolean) RETURNS sys.GEOGRAPHY AS $$ BEGIN - RAISE EXCEPTION 'Conversion from data type Text to Geography is not allowed.'; + IF $3 = true THEN + RAISE EXCEPTION 'Explicit Conversion from data type Text to sys.Geography is not allowed.'; + ELSE + RAISE EXCEPTION 'Implicit Conversion from data type Text to sys.Geography is not allowed.'; + END IF; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -260,7 +270,7 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.varchar) END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE CAST (text AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(text) AS IMPLICIT; +CREATE CAST (text AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(text, integer, boolean) AS IMPLICIT; CREATE CAST (sys.GEOGRAPHY AS text) WITH FUNCTION sys.text(sys.GEOGRAPHY); CREATE CAST (sys.bpchar AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.bpchar) AS IMPLICIT; CREATE CAST (sys.GEOGRAPHY AS sys.bpchar) WITH FUNCTION sys.bpchar(sys.GEOGRAPHY); diff --git a/contrib/babelfishpg_common/sql/geometry.sql b/contrib/babelfishpg_common/sql/geometry.sql index d162eb0fba..283ebfa0f2 100644 --- a/contrib/babelfishpg_common/sql/geometry.sql +++ b/contrib/babelfishpg_common/sql/geometry.sql @@ -106,7 +106,7 @@ CREATE OR REPLACE FUNCTION sys.text(sys.GEOMETRY) RETURNS text AS $$ BEGIN - RAISE EXCEPTION 'Conversion from data type Geometry to Text is not allowed.'; + RAISE EXCEPTION 'Explicit Conversion from data type sys.Geometry to Text is not allowed.'; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -225,15 +225,19 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bbf_binary) END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE OR REPLACE FUNCTION sys.GEOMETRY(text) +CREATE OR REPLACE FUNCTION sys.GEOMETRY(text, integer, boolean) RETURNS sys.GEOMETRY AS $$ BEGIN - RAISE EXCEPTION 'Conversion from data type Text to Geometry is not allowed.'; + IF $3 = true THEN + RAISE EXCEPTION 'Explicit Conversion from data type Text to sys.Geometry is not allowed.'; + ELSE + RAISE EXCEPTION 'Implicit Conversion from data type Text to sys.Geometry is not allowed.'; + END IF; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE CAST (text AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(text) AS IMPLICIT; +CREATE CAST (text AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(text, integer, boolean) AS IMPLICIT; CREATE CAST (sys.GEOMETRY AS text) WITH FUNCTION sys.text(sys.GEOMETRY); CREATE CAST (sys.bpchar AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.bpchar) AS IMPLICIT; CREATE CAST (sys.GEOMETRY AS sys.bpchar) WITH FUNCTION sys.bpchar(sys.GEOMETRY); diff --git a/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql b/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql index 748ab39351..539d8f7eba 100644 --- a/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql +++ b/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql @@ -110,7 +110,7 @@ CREATE OR REPLACE FUNCTION sys.text(sys.GEOMETRY) RETURNS text AS $$ BEGIN - RAISE EXCEPTION 'Conversion from data type Geometry to Text is not allowed.'; + RAISE EXCEPTION 'Explicit Conversion from data type sys.Geometry to Text is not allowed.'; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -229,15 +229,19 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bbf_binary) END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE OR REPLACE FUNCTION sys.GEOMETRY(text) +CREATE OR REPLACE FUNCTION sys.GEOMETRY(text, integer, boolean) RETURNS sys.GEOMETRY AS $$ BEGIN - RAISE EXCEPTION 'Conversion from data type Text to Geometry is not allowed.'; + IF $3 = true THEN + RAISE EXCEPTION 'Explicit Conversion from data type Text to sys.Geometry is not allowed.'; + ELSE + RAISE EXCEPTION 'Implicit Conversion from data type Text to sys.Geometry is not allowed.'; + END IF; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE CAST (text AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(text) AS IMPLICIT; +CREATE CAST (text AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(text, integer, boolean) AS IMPLICIT; CREATE CAST (sys.GEOMETRY AS text) WITH FUNCTION sys.text(sys.GEOMETRY); CREATE CAST (sys.bpchar AS sys.GEOMETRY) WITH FUNCTION sys.GEOMETRY(sys.bpchar) AS IMPLICIT; CREATE CAST (sys.GEOMETRY AS sys.bpchar) WITH FUNCTION sys.bpchar(sys.GEOMETRY); @@ -545,9 +549,15 @@ CREATE OR REPLACE FUNCTION sys.bytea(sys.GEOGRAPHY) DECLARE byte bytea; BEGIN + -- Here the received bytes are -> 1 byte (endianness) + 4 bytes (type) + 4 bytes (SRID) + 16 bytes * npoints byte := (SELECT sys.bytea_helper($1)); - byte := substring(byte from 6); - byte := substring(byte from 1 for 4) || E'\\x010c' || substring(byte from 5); + -- Checking the Geometry type currently we support only POINT type -> type = 1 (01000020 [here last byte represents presence of SRID]) + IF encode(substring(byte from 2 for 4), 'hex') = encode(E'\\x01000020', 'hex') THEN + -- Here we are taking bytes from SRID only for driver expected format -> 4 bytes (SRID) + 16 bytes * npoints + byte := substring(byte from 6); + -- The drivers expected format is 4 bytes (SRID) + 2 bytes (type -> 010C for point) + 16 bytes * npoints + byte := substring(byte from 1 for 4) || E'\\x010c' || substring(byte from 5); + END IF; RETURN byte; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -591,15 +601,19 @@ CREATE OR REPLACE FUNCTION sys.text(sys.GEOGRAPHY) RETURNS text AS $$ BEGIN - RAISE EXCEPTION 'Conversion from data type Geography to Text is not allowed.'; + RAISE EXCEPTION 'Explicit Conversion from data type sys.Geography to Text is not allowed.'; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(text) +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(text, integer, boolean) RETURNS sys.GEOGRAPHY AS $$ BEGIN - RAISE EXCEPTION 'Conversion from data type Text to Geography is not allowed.'; + IF $3 = true THEN + RAISE EXCEPTION 'Explicit Conversion from data type Text to sys.Geography is not allowed.'; + ELSE + RAISE EXCEPTION 'Implicit Conversion from data type Text to sys.Geography is not allowed.'; + END IF; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -649,7 +663,7 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.varchar) END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; -CREATE CAST (text AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(text) AS IMPLICIT; +CREATE CAST (text AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(text, integer, boolean) AS IMPLICIT; CREATE CAST (sys.GEOGRAPHY AS text) WITH FUNCTION sys.text(sys.GEOGRAPHY); CREATE CAST (sys.bpchar AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.bpchar) AS IMPLICIT; CREATE CAST (sys.GEOGRAPHY AS sys.bpchar) WITH FUNCTION sys.bpchar(sys.GEOGRAPHY); diff --git a/test/JDBC/expected/TestSpatialPoint-vu-verify.out b/test/JDBC/expected/TestSpatialPoint-vu-verify.out index 7e756bea17..bf6970c320 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-verify.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-verify.out @@ -346,13 +346,13 @@ Select CAST(CAST ('POINT(1 2)' AS text) as geometry) GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: Conversion from data type Text to Geometry is not allowed.)~~ +~~ERROR (Message: Explicit Conversion from data type Text to sys.Geometry is not allowed.)~~ Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS text) GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: Conversion from data type Geometry to Text is not allowed.)~~ +~~ERROR (Message: Explicit Conversion from data type sys.Geometry to Text is not allowed.)~~ Select CAST (geometry::STGeomFromText('POINT(1.0 2.0)', 4326) AS sql_variant) GO @@ -780,13 +780,13 @@ Select CAST(CAST ('POINT(1 2)' AS text) as geography) GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: Conversion from data type Text to Geography is not allowed.)~~ +~~ERROR (Message: Explicit Conversion from data type Text to sys.Geography is not allowed.)~~ Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS text) GO ~~ERROR (Code: 33557097)~~ -~~ERROR (Message: Conversion from data type Geography to Text is not allowed.)~~ +~~ERROR (Message: Explicit Conversion from data type sys.Geography to Text is not allowed.)~~ Select CAST (geography::STGeomFromText('POINT(1.0 2.0)', 4326) AS sql_variant) GO From d3a049a9eb8a368445e68ac280284671501245c5 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Tue, 24 Oct 2023 07:34:48 +0000 Subject: [PATCH 04/21] Updated Expected_Dependencies Signed-off-by: Anikait Agrawal --- .../expected/upgrade_validation/expected_dependency.out | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/python/expected/upgrade_validation/expected_dependency.out b/test/python/expected/upgrade_validation/expected_dependency.out index 33f6b60956..cd2ff12404 100644 --- a/test/python/expected/upgrade_validation/expected_dependency.out +++ b/test/python/expected/upgrade_validation/expected_dependency.out @@ -434,7 +434,7 @@ Function sys.geography(sys.bbf_binary) Function sys.geography(sys.bbf_varbinary) Function sys.geography(sys.bpchar) Function sys.geography(sys.geography,integer,boolean) -Function sys.geography(text) +Function sys.geography(text,integer,boolean) Function sys.geography__point(double precision,double precision,integer) Function sys.geography__stflipcoordinates(sys.geography) Function sys.geography__stgeomfromtext(text,integer) @@ -447,7 +447,7 @@ Function sys.geometry(sys.bbf_binary) Function sys.geometry(sys.bbf_varbinary) Function sys.geometry(sys.bpchar) Function sys.geometry(sys.geometry,integer,boolean) -Function sys.geometry(text) +Function sys.geometry(text,integer,boolean) Function sys.geometry__point(double precision,double precision,integer) Function sys.geometry__stgeomfromtext(text,integer) Function sys.geometry__stpointfromtext(text,integer) From 4a6b80836305e16ef06930e51386e79622876c73 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Tue, 24 Oct 2023 08:54:52 +0000 Subject: [PATCH 05/21] Retrigger test Signed-off-by: Anikait Agrawal From 4a49b46ff956b33e19fd6fa8cf12e5ba03c3eb48 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Tue, 24 Oct 2023 15:09:21 +0000 Subject: [PATCH 06/21] Fixed PostGIS and PROJ versions according to GitFarm Signed-off-by: Anikait Agrawal --- .../build-postgis-extension/action.yml | 12 ++++++------ .../composite-actions/setup-base-version/action.yml | 12 ++++++------ .github/workflows/major-version-upgrade.yml | 12 ++++++------ .github/workflows/minor-version-upgrade.yml | 12 ++++++------ .github/workflows/tap-tests.yml | 12 ++++++------ test/JDBC/expected/TestSpatialPoint-vu-verify.out | 12 ++++++------ 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index e242936b75..fec954f6a7 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -13,11 +13,11 @@ runs: run: | cd .. sudo apt-get install wget - wget http://postgis.net/stuff/postgis-3.3.3dev.tar.gz - tar -xvzf postgis-3.3.3dev.tar.gz - wget https://download.osgeo.org/proj/proj-4.9.1.tar.gz - tar -xvzf proj-4.9.1.tar.gz - cd proj-4.9.1 + wget http://postgis.net/stuff/postgis-3.4.0.tar.gz + tar -xvzf postgis-3.4.0.tar.gz + wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz + tar -xvzf proj-9.1.0.tar.gz + cd proj-9.1.0 if [ ! -d "build" ]; then mkdir build fi @@ -25,7 +25,7 @@ runs: cmake .. cmake --build . sudo cmake --build . --target install - cd ../../postgis-3.3.3dev + cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config install diff --git a/.github/composite-actions/setup-base-version/action.yml b/.github/composite-actions/setup-base-version/action.yml index c8b4a48844..e119184d4c 100644 --- a/.github/composite-actions/setup-base-version/action.yml +++ b/.github/composite-actions/setup-base-version/action.yml @@ -63,11 +63,11 @@ runs: run: | cd .. sudo apt-get install wget - wget http://postgis.net/stuff/postgis-3.3.3dev.tar.gz - tar -xvzf postgis-3.3.3dev.tar.gz - wget https://download.osgeo.org/proj/proj-4.9.1.tar.gz - tar -xvzf proj-4.9.1.tar.gz - cd proj-4.9.1 + wget http://postgis.net/stuff/postgis-3.4.0.tar.gz + tar -xvzf postgis-3.4.0.tar.gz + wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz + tar -xvzf proj-9.1.0.tar.gz + cd proj-9.1.0 if [ ! -d "build" ]; then mkdir build fi @@ -75,7 +75,7 @@ runs: cmake .. cmake --build . sudo cmake --build . --target install - cd ../../postgis-3.3.3dev + cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config install diff --git a/.github/workflows/major-version-upgrade.yml b/.github/workflows/major-version-upgrade.yml index 67a6cc8ef0..31cdc02ca3 100644 --- a/.github/workflows/major-version-upgrade.yml +++ b/.github/workflows/major-version-upgrade.yml @@ -51,11 +51,11 @@ jobs: run: | cd .. sudo apt-get install wget - wget http://postgis.net/stuff/postgis-3.3.3dev.tar.gz - tar -xvzf postgis-3.3.3dev.tar.gz - wget https://download.osgeo.org/proj/proj-4.9.1.tar.gz - tar -xvzf proj-4.9.1.tar.gz - cd proj-4.9.1 + wget http://postgis.net/stuff/postgis-3.4.0.tar.gz + tar -xvzf postgis-3.4.0.tar.gz + wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz + tar -xvzf proj-9.1.0.tar.gz + cd proj-9.1.0 if [ ! -d "build" ]; then mkdir build fi @@ -63,7 +63,7 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install - cd ../../postgis-3.3.3dev + cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config install diff --git a/.github/workflows/minor-version-upgrade.yml b/.github/workflows/minor-version-upgrade.yml index ed893b103d..133ae24e32 100644 --- a/.github/workflows/minor-version-upgrade.yml +++ b/.github/workflows/minor-version-upgrade.yml @@ -41,11 +41,11 @@ jobs: run: | cd .. sudo apt-get install wget - wget http://postgis.net/stuff/postgis-3.3.3dev.tar.gz - tar -xvzf postgis-3.3.3dev.tar.gz - wget https://download.osgeo.org/proj/proj-4.9.1.tar.gz - tar -xvzf proj-4.9.1.tar.gz - cd proj-4.9.1 + wget http://postgis.net/stuff/postgis-3.4.0.tar.gz + tar -xvzf postgis-3.4.0.tar.gz + wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz + tar -xvzf proj-9.1.0.tar.gz + cd proj-9.1.0 if [ ! -d "build" ]; then mkdir build fi @@ -53,7 +53,7 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install - cd ../../postgis-3.3.3dev + cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config install diff --git a/.github/workflows/tap-tests.yml b/.github/workflows/tap-tests.yml index ae78c001d2..2bf27eca56 100644 --- a/.github/workflows/tap-tests.yml +++ b/.github/workflows/tap-tests.yml @@ -57,11 +57,11 @@ jobs: run: | cd .. sudo apt-get install wget - wget http://postgis.net/stuff/postgis-3.3.3dev.tar.gz - tar -xvzf postgis-3.3.3dev.tar.gz - wget https://download.osgeo.org/proj/proj-4.9.1.tar.gz - tar -xvzf proj-4.9.1.tar.gz - cd proj-4.9.1 + wget http://postgis.net/stuff/postgis-3.4.0.tar.gz + tar -xvzf postgis-3.4.0.tar.gz + wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz + tar -xvzf proj-9.1.0.tar.gz + cd proj-9.1.0 if [ ! -d "build" ]; then mkdir build fi @@ -69,7 +69,7 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install - cd ../../postgis-3.3.3dev + cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config install diff --git a/test/JDBC/expected/TestSpatialPoint-vu-verify.out b/test/JDBC/expected/TestSpatialPoint-vu-verify.out index bf6970c320..1e30839b69 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-verify.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-verify.out @@ -537,7 +537,7 @@ GO geography#!#geography#!#float E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.04243622548279E7 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 @@ -545,21 +545,21 @@ E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.04243622548279E7 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#5535965.307328846 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 -E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 +E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.04243622548279E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 -E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 +E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.04243622548279E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 -E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 +E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.04243622548279E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.04243622548279E7 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 From 9099dd60724509e9ae66ddc75914976260a993d8 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Tue, 24 Oct 2023 18:46:19 +0000 Subject: [PATCH 07/21] changed proj version Signed-off-by: Anikait Agrawal --- .../composite-actions/build-postgis-extension/action.yml | 6 +++--- .github/composite-actions/setup-base-version/action.yml | 6 +++--- .github/workflows/major-version-upgrade.yml | 6 +++--- .github/workflows/minor-version-upgrade.yml | 6 +++--- .github/workflows/tap-tests.yml | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index fec954f6a7..4b90183890 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -15,9 +15,9 @@ runs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz - tar -xvzf proj-9.1.0.tar.gz - cd proj-9.1.0 + wget https://download.osgeo.org/proj/proj-6.1.0.tar.gz + tar -xvzf proj-6.1.0.tar.gz + cd proj-6.1.0 if [ ! -d "build" ]; then mkdir build fi diff --git a/.github/composite-actions/setup-base-version/action.yml b/.github/composite-actions/setup-base-version/action.yml index e119184d4c..8d6896e39e 100644 --- a/.github/composite-actions/setup-base-version/action.yml +++ b/.github/composite-actions/setup-base-version/action.yml @@ -65,9 +65,9 @@ runs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz - tar -xvzf proj-9.1.0.tar.gz - cd proj-9.1.0 + wget https://download.osgeo.org/proj/proj-6.1.0.tar.gz + tar -xvzf proj-6.1.0.tar.gz + cd proj-6.1.0 if [ ! -d "build" ]; then mkdir build fi diff --git a/.github/workflows/major-version-upgrade.yml b/.github/workflows/major-version-upgrade.yml index 31cdc02ca3..600b9c0c26 100644 --- a/.github/workflows/major-version-upgrade.yml +++ b/.github/workflows/major-version-upgrade.yml @@ -53,9 +53,9 @@ jobs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz - tar -xvzf proj-9.1.0.tar.gz - cd proj-9.1.0 + wget https://download.osgeo.org/proj/proj-6.1.0.tar.gz + tar -xvzf proj-6.1.0.tar.gz + cd proj-6.1.0 if [ ! -d "build" ]; then mkdir build fi diff --git a/.github/workflows/minor-version-upgrade.yml b/.github/workflows/minor-version-upgrade.yml index 133ae24e32..c7140a1783 100644 --- a/.github/workflows/minor-version-upgrade.yml +++ b/.github/workflows/minor-version-upgrade.yml @@ -43,9 +43,9 @@ jobs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz - tar -xvzf proj-9.1.0.tar.gz - cd proj-9.1.0 + wget https://download.osgeo.org/proj/proj-6.1.0.tar.gz + tar -xvzf proj-6.1.0.tar.gz + cd proj-6.1.0 if [ ! -d "build" ]; then mkdir build fi diff --git a/.github/workflows/tap-tests.yml b/.github/workflows/tap-tests.yml index 2bf27eca56..6e3846dafe 100644 --- a/.github/workflows/tap-tests.yml +++ b/.github/workflows/tap-tests.yml @@ -59,9 +59,9 @@ jobs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz - tar -xvzf proj-9.1.0.tar.gz - cd proj-9.1.0 + wget https://download.osgeo.org/proj/proj-6.1.0.tar.gz + tar -xvzf proj-6.1.0.tar.gz + cd proj-6.1.0 if [ ! -d "build" ]; then mkdir build fi From 40c98e79feef0c23422f1f9b39104ed7de024ab5 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Tue, 24 Oct 2023 20:15:33 +0000 Subject: [PATCH 08/21] Fixed Expected Output File Signed-off-by: Anikait Agrawal --- test/JDBC/expected/TestSpatialPoint-vu-verify.out | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/JDBC/expected/TestSpatialPoint-vu-verify.out b/test/JDBC/expected/TestSpatialPoint-vu-verify.out index 1e30839b69..bf6970c320 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-verify.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-verify.out @@ -537,7 +537,7 @@ GO geography#!#geography#!#float E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.04243622548279E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 @@ -545,21 +545,21 @@ E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.04243622548279E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#5535965.307328846 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 -E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.04243622548279E7 +E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 -E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.04243622548279E7 +E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 -E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.04243622548279E7 +E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.04243622548279E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 From a09903de33be40aaa9923f1b8737acf0f9f81991 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Wed, 25 Oct 2023 13:10:04 +0000 Subject: [PATCH 09/21] Changed PROJ version to 9.1.0 Signed-off-by: Anikait Agrawal --- .../build-postgis-extension/action.yml | 7 ++++--- .../composite-actions/setup-base-version/action.yml | 7 ++++--- .github/workflows/major-version-upgrade.yml | 7 ++++--- .github/workflows/minor-version-upgrade.yml | 7 ++++--- .github/workflows/tap-tests.yml | 7 ++++--- test/JDBC/expected/TestSpatialPoint-vu-verify.out | 12 ++++++------ 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index 4b90183890..500e1b1dd1 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -15,9 +15,9 @@ runs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-6.1.0.tar.gz - tar -xvzf proj-6.1.0.tar.gz - cd proj-6.1.0 + wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz + tar -xvzf proj-9.1.0.tar.gz + cd proj-9.1.0 if [ ! -d "build" ]; then mkdir build fi @@ -25,6 +25,7 @@ runs: cmake .. cmake --build . sudo cmake --build . --target install + sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib64/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config diff --git a/.github/composite-actions/setup-base-version/action.yml b/.github/composite-actions/setup-base-version/action.yml index 8d6896e39e..b50ed09e14 100644 --- a/.github/composite-actions/setup-base-version/action.yml +++ b/.github/composite-actions/setup-base-version/action.yml @@ -65,9 +65,9 @@ runs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-6.1.0.tar.gz - tar -xvzf proj-6.1.0.tar.gz - cd proj-6.1.0 + wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz + tar -xvzf proj-9.1.0.tar.gz + cd proj-9.1.0 if [ ! -d "build" ]; then mkdir build fi @@ -75,6 +75,7 @@ runs: cmake .. cmake --build . sudo cmake --build . --target install + sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib64/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config diff --git a/.github/workflows/major-version-upgrade.yml b/.github/workflows/major-version-upgrade.yml index 600b9c0c26..b99577d557 100644 --- a/.github/workflows/major-version-upgrade.yml +++ b/.github/workflows/major-version-upgrade.yml @@ -53,9 +53,9 @@ jobs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-6.1.0.tar.gz - tar -xvzf proj-6.1.0.tar.gz - cd proj-6.1.0 + wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz + tar -xvzf proj-9.1.0.tar.gz + cd proj-9.1.0 if [ ! -d "build" ]; then mkdir build fi @@ -63,6 +63,7 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install + sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib64/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config diff --git a/.github/workflows/minor-version-upgrade.yml b/.github/workflows/minor-version-upgrade.yml index c7140a1783..ed488c0fa3 100644 --- a/.github/workflows/minor-version-upgrade.yml +++ b/.github/workflows/minor-version-upgrade.yml @@ -43,9 +43,9 @@ jobs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-6.1.0.tar.gz - tar -xvzf proj-6.1.0.tar.gz - cd proj-6.1.0 + wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz + tar -xvzf proj-9.1.0.tar.gz + cd proj-9.1.0 if [ ! -d "build" ]; then mkdir build fi @@ -53,6 +53,7 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install + sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib64/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config diff --git a/.github/workflows/tap-tests.yml b/.github/workflows/tap-tests.yml index 6e3846dafe..05c638b2d4 100644 --- a/.github/workflows/tap-tests.yml +++ b/.github/workflows/tap-tests.yml @@ -59,9 +59,9 @@ jobs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-6.1.0.tar.gz - tar -xvzf proj-6.1.0.tar.gz - cd proj-6.1.0 + wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz + tar -xvzf proj-9.1.0.tar.gz + cd proj-9.1.0 if [ ! -d "build" ]; then mkdir build fi @@ -69,6 +69,7 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install + sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib64/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config diff --git a/test/JDBC/expected/TestSpatialPoint-vu-verify.out b/test/JDBC/expected/TestSpatialPoint-vu-verify.out index bf6970c320..1e30839b69 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-verify.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-verify.out @@ -537,7 +537,7 @@ GO geography#!#geography#!#float E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.04243622548279E7 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 @@ -545,21 +545,21 @@ E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.04243622548279E7 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#5535965.307328846 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 -E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 +E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.04243622548279E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 -E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 +E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.04243622548279E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 -E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 +E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.04243622548279E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 -E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.04243622548279E7 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 From a5339545ad2ffed49da5ad874ee0a64ef49b03bc Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Wed, 25 Oct 2023 13:58:27 +0000 Subject: [PATCH 10/21] Changed lib path Signed-off-by: Anikait Agrawal --- .github/composite-actions/build-postgis-extension/action.yml | 2 +- .github/composite-actions/setup-base-version/action.yml | 2 +- .github/workflows/major-version-upgrade.yml | 2 +- .github/workflows/minor-version-upgrade.yml | 2 +- .github/workflows/tap-tests.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index 500e1b1dd1..ce4a915412 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -25,7 +25,7 @@ runs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib64/ + sudo cp ~/workplace/babel/proj-4.9.1/build/lib/* /usr/lib/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config diff --git a/.github/composite-actions/setup-base-version/action.yml b/.github/composite-actions/setup-base-version/action.yml index b50ed09e14..1ac58d63c1 100644 --- a/.github/composite-actions/setup-base-version/action.yml +++ b/.github/composite-actions/setup-base-version/action.yml @@ -75,7 +75,7 @@ runs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib64/ + sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config diff --git a/.github/workflows/major-version-upgrade.yml b/.github/workflows/major-version-upgrade.yml index b99577d557..ed65cabcf3 100644 --- a/.github/workflows/major-version-upgrade.yml +++ b/.github/workflows/major-version-upgrade.yml @@ -63,7 +63,7 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib64/ + sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config diff --git a/.github/workflows/minor-version-upgrade.yml b/.github/workflows/minor-version-upgrade.yml index ed488c0fa3..f133286ce2 100644 --- a/.github/workflows/minor-version-upgrade.yml +++ b/.github/workflows/minor-version-upgrade.yml @@ -53,7 +53,7 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib64/ + sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config diff --git a/.github/workflows/tap-tests.yml b/.github/workflows/tap-tests.yml index 05c638b2d4..0c9ca063b5 100644 --- a/.github/workflows/tap-tests.yml +++ b/.github/workflows/tap-tests.yml @@ -69,7 +69,7 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib64/ + sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config From b65b7005453d2e90646973220a4b9ad317e00223 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Wed, 25 Oct 2023 14:00:26 +0000 Subject: [PATCH 11/21] Corrected lib copy path Signed-off-by: Anikait Agrawal --- .github/composite-actions/build-postgis-extension/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index ce4a915412..2a83f1a761 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -25,7 +25,7 @@ runs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp ~/workplace/babel/proj-4.9.1/build/lib/* /usr/lib/ + sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config From 23d2abca9e590234a90fdc1079401aebddb65cfc Mon Sep 17 00:00:00 2001 From: Anikait Agrawal <54908236+Anikait143@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:08:34 +0530 Subject: [PATCH 12/21] Add proj to postgresql's lib directory --- .github/composite-actions/build-postgis-extension/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index 2a83f1a761..2eee5796d8 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -25,7 +25,7 @@ runs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib/ + sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* ~/${{ inputs.install_dir }}/lib cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config From 6851d5383e4a3ba8d8fa4e602a259d331559051f Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Sat, 28 Oct 2023 19:11:39 +0000 Subject: [PATCH 13/21] fixed test cases and proj version Signed-off-by: Anikait Agrawal --- .../build-postgis-extension/action.yml | 9 ++--- .../setup-base-version/action.yml | 7 ++-- .github/workflows/major-version-upgrade.yml | 7 ++-- .github/workflows/minor-version-upgrade.yml | 7 ++-- .github/workflows/tap-tests.yml | 7 ++-- .../expected/TestSpatialPoint-vu-prepare.out | 40 ------------------- .../datatypes/TestSpatialPoint-vu-prepare.txt | 8 ---- 7 files changed, 15 insertions(+), 70 deletions(-) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index a0f7772316..c959a72443 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -15,9 +15,9 @@ runs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz - tar -xvzf proj-9.1.0.tar.gz - cd proj-9.1.0 + wget https://download.osgeo.org/proj/proj-9.2.1.tar.gz + tar -xvzf proj-9.2.1.tar.gz + cd proj-9.2.1 if [ ! -d "build" ]; then mkdir build fi @@ -25,11 +25,8 @@ runs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* ~/${{ inputs.install_dir }}/lib cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config install - ldd /home/runner/psql/lib/postgresql/postgis-3.so - export LD_LIBRARY_PATH=/home/runner/psql/lib/postgresql:$LD_LIBRARY_PATH shell: bash diff --git a/.github/composite-actions/setup-base-version/action.yml b/.github/composite-actions/setup-base-version/action.yml index 1ac58d63c1..1416cce320 100644 --- a/.github/composite-actions/setup-base-version/action.yml +++ b/.github/composite-actions/setup-base-version/action.yml @@ -65,9 +65,9 @@ runs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz - tar -xvzf proj-9.1.0.tar.gz - cd proj-9.1.0 + wget https://download.osgeo.org/proj/proj-9.2.1.tar.gz + tar -xvzf proj-9.2.1.tar.gz + cd proj-9.2.1 if [ ! -d "build" ]; then mkdir build fi @@ -75,7 +75,6 @@ runs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config diff --git a/.github/workflows/major-version-upgrade.yml b/.github/workflows/major-version-upgrade.yml index ed65cabcf3..e51fbce3ba 100644 --- a/.github/workflows/major-version-upgrade.yml +++ b/.github/workflows/major-version-upgrade.yml @@ -53,9 +53,9 @@ jobs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz - tar -xvzf proj-9.1.0.tar.gz - cd proj-9.1.0 + wget https://download.osgeo.org/proj/proj-9.2.1.tar.gz + tar -xvzf proj-9.2.1.tar.gz + cd proj-9.2.1 if [ ! -d "build" ]; then mkdir build fi @@ -63,7 +63,6 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config diff --git a/.github/workflows/minor-version-upgrade.yml b/.github/workflows/minor-version-upgrade.yml index f133286ce2..4e083a39a7 100644 --- a/.github/workflows/minor-version-upgrade.yml +++ b/.github/workflows/minor-version-upgrade.yml @@ -43,9 +43,9 @@ jobs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz - tar -xvzf proj-9.1.0.tar.gz - cd proj-9.1.0 + wget https://download.osgeo.org/proj/proj-9.2.1.tar.gz + tar -xvzf proj-9.2.1.tar.gz + cd proj-9.2.1 if [ ! -d "build" ]; then mkdir build fi @@ -53,7 +53,6 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config diff --git a/.github/workflows/tap-tests.yml b/.github/workflows/tap-tests.yml index 0c9ca063b5..2ba915fca0 100644 --- a/.github/workflows/tap-tests.yml +++ b/.github/workflows/tap-tests.yml @@ -59,9 +59,9 @@ jobs: sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz - wget https://download.osgeo.org/proj/proj-9.1.0.tar.gz - tar -xvzf proj-9.1.0.tar.gz - cd proj-9.1.0 + wget https://download.osgeo.org/proj/proj-9.2.1.tar.gz + tar -xvzf proj-9.2.1.tar.gz + cd proj-9.2.1 if [ ! -d "build" ]; then mkdir build fi @@ -69,7 +69,6 @@ jobs: cmake .. cmake --build . sudo cmake --build . --target install - sudo cp /home/runner/work/babelfish_extensions/proj-9.1.0/build/lib/* /usr/lib/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config diff --git a/test/JDBC/expected/TestSpatialPoint-vu-prepare.out b/test/JDBC/expected/TestSpatialPoint-vu-prepare.out index 2d3737573e..e827d23487 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-prepare.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-prepare.out @@ -121,26 +121,6 @@ prepst#!#exec#!#GEOMETRY|-|location|-|LINESTRING(1 2, 3 4):4326 ~~ERROR (Message: Unsupported geometry type)~~ -#Negative Test for STGeomFromText when invalid type is provided -prepst#!#exec#!#GEOMETRY|-|location|-|Pnt:4326 -~~ERROR (Code: 0)~~ - -~~ERROR (Message: Illegal character in Well-Known text at position 3.)~~ - -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Unsupported geometry type)~~ - -#Negative Test for STGeomFromText when Null geometry is provided -prepst#!#exec#!#GEOMETRY|-|location|-|:4326 -~~ERROR (Code: 0)~~ - -~~ERROR (Message: Illegal character in Well-Known text at position 0.)~~ - -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Unsupported geometry type)~~ - CREATE VIEW TextFromGeom AS SELECT STAsText(location) AS TextRepresentation FROM SPATIALPOINTGEOM_dt; @@ -351,26 +331,6 @@ prepst#!#exec#!#GEOGRAPHY|-|location|-|LINESTRING(1 2, 3 4):4326 ~~ERROR (Message: Unsupported geometry type)~~ -#Negative Test for STGeomFromText when invalid type is provided -prepst#!#exec#!#GEOGRAPHY|-|location|-|Pnt:4326 -~~ERROR (Code: 0)~~ - -~~ERROR (Message: Illegal character in Well-Known text at position 3.)~~ - -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Unsupported geometry type)~~ - -#Negative Test for STGeomFromText when Null geography is provided -prepst#!#exec#!#GEOGRAPHY|-|location|-|:4326 -~~ERROR (Code: 0)~~ - -~~ERROR (Message: Illegal character in Well-Known text at position 0.)~~ - -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Unsupported geometry type)~~ - CREATE VIEW TextFromGeog AS SELECT STAsText(location) AS TextRepresentation FROM SPATIALPOINTGEOG_dt; diff --git a/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt b/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt index 07418a5488..a069d52482 100644 --- a/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt +++ b/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt @@ -57,10 +57,6 @@ prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 ):4326 #Negative Test when an unsupported feature in queried prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 prepst#!#exec#!#GEOMETRY|-|location|-|LINESTRING(1 2, 3 4):4326 -#Negative Test for STGeomFromText when invalid type is provided -prepst#!#exec#!#GEOMETRY|-|location|-|Pnt:4326 -#Negative Test for STGeomFromText when Null geometry is provided -prepst#!#exec#!#GEOMETRY|-|location|-|:4326 CREATE VIEW TextFromGeom AS SELECT STAsText(location) AS TextRepresentation FROM SPATIALPOINTGEOM_dt; @@ -163,10 +159,6 @@ prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 ):4326 #Negative Test when an unsupported feature in queried prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 prepst#!#exec#!#GEOGRAPHY|-|location|-|LINESTRING(1 2, 3 4):4326 -#Negative Test for STGeomFromText when invalid type is provided -prepst#!#exec#!#GEOGRAPHY|-|location|-|Pnt:4326 -#Negative Test for STGeomFromText when Null geography is provided -prepst#!#exec#!#GEOGRAPHY|-|location|-|:4326 CREATE VIEW TextFromGeog AS SELECT STAsText(location) AS TextRepresentation FROM SPATIALPOINTGEOG_dt; From 22267cdf1384298895352cf4410dee1d8f6fb42a Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Mon, 30 Oct 2023 17:53:33 +0000 Subject: [PATCH 14/21] Modified configure flags for PostGIS installation Signed-off-by: Anikait Agrawal --- .github/composite-actions/build-postgis-extension/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index c959a72443..5e8d1a9e4d 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -26,7 +26,7 @@ runs: cmake --build . sudo cmake --build . --target install cd ../../postgis-3.4.0 - ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config + ./configure --without-protobuf --without-raster --with-projdir=$HOME/work/babelfish_extensions --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config install shell: bash From 3402dafbff000ab4a98db97651b07b8169d96fc4 Mon Sep 17 00:00:00 2001 From: Rishabh Tanwar <33982749+rishabhtanwar29@users.noreply.github.com> Date: Thu, 2 Nov 2023 13:09:45 +0530 Subject: [PATCH 15/21] Correct proj install directory --- .github/composite-actions/build-postgis-extension/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index 5e8d1a9e4d..b39ff97f56 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -22,11 +22,11 @@ runs: mkdir build fi cd build - cmake .. + cmake -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_PREFIX="/usr" .. cmake --build . sudo cmake --build . --target install cd ../../postgis-3.4.0 - ./configure --without-protobuf --without-raster --with-projdir=$HOME/work/babelfish_extensions --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config + ./configure --without-protobuf --without-raster --with-projdir=/usr --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config install shell: bash From 969bd584ffef5de7d045ba5f69c668ef090850e3 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Thu, 2 Nov 2023 08:24:03 +0000 Subject: [PATCH 16/21] Debugging using SSH access to github actions Signed-off-by: Anikait Agrawal --- .github/workflows/jdbc-tests.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/jdbc-tests.yml b/.github/workflows/jdbc-tests.yml index cb5a85de38..137fe85f5e 100644 --- a/.github/workflows/jdbc-tests.yml +++ b/.github/workflows/jdbc-tests.yml @@ -45,6 +45,13 @@ jobs: if: always() && steps.build-postgis-extension.outcome == 'success' uses: ./.github/composite-actions/install-extensions + - name: Setup upterm session + if: always() && steps.install-extensions.outcome == 'failure' + uses: lhotari/action-upterm@v1 + timeout-minutes: 60 + with: + limit-access-to-actor: true + - name: Run JDBC Tests id: jdbc if: always() && steps.install-extensions.outcome == 'success' From 3edd7ce7d5c8da65a446421a031a577522c410c0 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Thu, 2 Nov 2023 09:10:32 +0000 Subject: [PATCH 17/21] Retrigger actions From 7acd2cf3c0df049711d26a9f7d7fd13b03020a1b Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Thu, 2 Nov 2023 09:32:02 +0000 Subject: [PATCH 18/21] Added CCache export statements Signed-off-by: Anikait Agrawal --- .github/composite-actions/build-postgis-extension/action.yml | 3 +++ .github/composite-actions/setup-base-version/action.yml | 3 +++ .github/workflows/major-version-upgrade.yml | 3 +++ .github/workflows/minor-version-upgrade.yml | 3 +++ .github/workflows/tap-tests.yml | 3 +++ 5 files changed, 15 insertions(+) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index b39ff97f56..95ff3b47f3 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -12,6 +12,9 @@ runs: - name: Build PostGIS Extension run: | cd .. + export CC='ccache gcc' + export CMAKE_C_COMPILER_LAUNCHER=ccache + export CMAKE_CXX_COMPILER_LAUNCHER=ccache sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz diff --git a/.github/composite-actions/setup-base-version/action.yml b/.github/composite-actions/setup-base-version/action.yml index 1416cce320..3aa6ebb2db 100644 --- a/.github/composite-actions/setup-base-version/action.yml +++ b/.github/composite-actions/setup-base-version/action.yml @@ -62,6 +62,9 @@ runs: - name: Build PostGIS Extension run: | cd .. + export CC='ccache gcc' + export CMAKE_C_COMPILER_LAUNCHER=ccache + export CMAKE_CXX_COMPILER_LAUNCHER=ccache sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz diff --git a/.github/workflows/major-version-upgrade.yml b/.github/workflows/major-version-upgrade.yml index e51fbce3ba..248cbc3e7b 100644 --- a/.github/workflows/major-version-upgrade.yml +++ b/.github/workflows/major-version-upgrade.yml @@ -50,6 +50,9 @@ jobs: if: always() && steps.compile-antlr.outcome == 'success' run: | cd .. + export CC='ccache gcc' + export CMAKE_C_COMPILER_LAUNCHER=ccache + export CMAKE_CXX_COMPILER_LAUNCHER=ccache sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz diff --git a/.github/workflows/minor-version-upgrade.yml b/.github/workflows/minor-version-upgrade.yml index 4e083a39a7..d878677642 100644 --- a/.github/workflows/minor-version-upgrade.yml +++ b/.github/workflows/minor-version-upgrade.yml @@ -40,6 +40,9 @@ jobs: if: always() && steps.compile-antlr.outcome == 'success' run: | cd .. + export CC='ccache gcc' + export CMAKE_C_COMPILER_LAUNCHER=ccache + export CMAKE_CXX_COMPILER_LAUNCHER=ccache sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz diff --git a/.github/workflows/tap-tests.yml b/.github/workflows/tap-tests.yml index 2ba915fca0..90dd8aa264 100644 --- a/.github/workflows/tap-tests.yml +++ b/.github/workflows/tap-tests.yml @@ -56,6 +56,9 @@ jobs: if: always() && steps.compile-antlr.outcome == 'success' run: | cd .. + export CC='ccache gcc' + export CMAKE_C_COMPILER_LAUNCHER=ccache + export CMAKE_CXX_COMPILER_LAUNCHER=ccache sudo apt-get install wget wget http://postgis.net/stuff/postgis-3.4.0.tar.gz tar -xvzf postgis-3.4.0.tar.gz From fe10f33803d02072cf97e8320f709f71c922f431 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Thu, 2 Nov 2023 12:23:42 +0000 Subject: [PATCH 19/21] Corrected proj files path Signed-off-by: Anikait Agrawal --- .../composite-actions/build-postgis-extension/action.yml | 1 + .github/composite-actions/setup-base-version/action.yml | 5 +++-- .github/workflows/jdbc-tests.yml | 7 ------- .github/workflows/major-version-upgrade.yml | 5 +++-- .github/workflows/minor-version-upgrade.yml | 5 +++-- .github/workflows/tap-tests.yml | 5 +++-- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index 95ff3b47f3..695a4e389c 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -28,6 +28,7 @@ runs: cmake -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_PREFIX="/usr" .. cmake --build . sudo cmake --build . --target install + sudo cp /usr/lib/libproj* /usr/lib/x86_64-linux-gnu/ cd ../../postgis-3.4.0 ./configure --without-protobuf --without-raster --with-projdir=/usr --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config diff --git a/.github/composite-actions/setup-base-version/action.yml b/.github/composite-actions/setup-base-version/action.yml index 3aa6ebb2db..ebe312e726 100644 --- a/.github/composite-actions/setup-base-version/action.yml +++ b/.github/composite-actions/setup-base-version/action.yml @@ -75,11 +75,12 @@ runs: mkdir build fi cd build - cmake .. + cmake -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_PREFIX="/usr" .. cmake --build . sudo cmake --build . --target install + sudo cp /usr/lib/libproj* /usr/lib/x86_64-linux-gnu/ cd ../../postgis-3.4.0 - ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config + ./configure --without-protobuf --without-raster --with-projdir=/usr --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config install shell: bash diff --git a/.github/workflows/jdbc-tests.yml b/.github/workflows/jdbc-tests.yml index 137fe85f5e..cb5a85de38 100644 --- a/.github/workflows/jdbc-tests.yml +++ b/.github/workflows/jdbc-tests.yml @@ -45,13 +45,6 @@ jobs: if: always() && steps.build-postgis-extension.outcome == 'success' uses: ./.github/composite-actions/install-extensions - - name: Setup upterm session - if: always() && steps.install-extensions.outcome == 'failure' - uses: lhotari/action-upterm@v1 - timeout-minutes: 60 - with: - limit-access-to-actor: true - - name: Run JDBC Tests id: jdbc if: always() && steps.install-extensions.outcome == 'success' diff --git a/.github/workflows/major-version-upgrade.yml b/.github/workflows/major-version-upgrade.yml index 248cbc3e7b..0f978ade90 100644 --- a/.github/workflows/major-version-upgrade.yml +++ b/.github/workflows/major-version-upgrade.yml @@ -63,11 +63,12 @@ jobs: mkdir build fi cd build - cmake .. + cmake -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_PREFIX="/usr" .. cmake --build . sudo cmake --build . --target install + sudo cp /usr/lib/libproj* /usr/lib/x86_64-linux-gnu/ cd ../../postgis-3.4.0 - ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config + ./configure --without-protobuf --without-raster --with-projdir=/usr --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config install shell: bash diff --git a/.github/workflows/minor-version-upgrade.yml b/.github/workflows/minor-version-upgrade.yml index d878677642..253b92cf34 100644 --- a/.github/workflows/minor-version-upgrade.yml +++ b/.github/workflows/minor-version-upgrade.yml @@ -53,11 +53,12 @@ jobs: mkdir build fi cd build - cmake .. + cmake -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_PREFIX="/usr" .. cmake --build . sudo cmake --build . --target install + sudo cp /usr/lib/libproj* /usr/lib/x86_64-linux-gnu/ cd ../../postgis-3.4.0 - ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql/bin/pg_config + ./configure --without-protobuf --without-raster --with-projdir=/usr --with-pgconfig=$HOME/psql/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config install shell: bash diff --git a/.github/workflows/tap-tests.yml b/.github/workflows/tap-tests.yml index 90dd8aa264..7583853b5f 100644 --- a/.github/workflows/tap-tests.yml +++ b/.github/workflows/tap-tests.yml @@ -69,11 +69,12 @@ jobs: mkdir build fi cd build - cmake .. + cmake -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_PREFIX="/usr" .. cmake --build . sudo cmake --build . --target install + sudo cp /usr/lib/libproj* /usr/lib/x86_64-linux-gnu/ cd ../../postgis-3.4.0 - ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config + ./configure --without-protobuf --without-raster --with-projdir=/usr --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config install shell: bash From fa17f409cd4eeb71e421e4aa11f14cfb9ef21c07 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Mon, 6 Nov 2023 16:02:37 +0000 Subject: [PATCH 20/21] Resolved Comments Signed-off-by: Anikait Agrawal --- .../build-postgis-extension/action.yml | 5 +- .../setup-base-version/action.yml | 5 +- .github/workflows/major-version-upgrade.yml | 5 +- .github/workflows/minor-version-upgrade.yml | 5 +- .github/workflows/tap-tests.yml | 5 +- contrib/babelfishpg_common/sql/geography.sql | 22 +++---- contrib/babelfishpg_common/sql/geometry.sql | 14 ++--- .../upgrades/spatial_types--3.2.0--3.3.0.sql | 36 +++++------ .../expected/TestSpatialPoint-vu-cleanup.out | 4 ++ .../expected/TestSpatialPoint-vu-prepare.out | 4 ++ .../expected/TestSpatialPoint-vu-verify.out | 62 +++++++++++++++++++ .../datatypes/TestSpatialPoint-vu-cleanup.txt | 4 ++ .../datatypes/TestSpatialPoint-vu-prepare.txt | 4 ++ .../datatypes/TestSpatialPoint-vu-verify.sql | 6 ++ 14 files changed, 130 insertions(+), 51 deletions(-) diff --git a/.github/composite-actions/build-postgis-extension/action.yml b/.github/composite-actions/build-postgis-extension/action.yml index 695a4e389c..1277685c40 100644 --- a/.github/composite-actions/build-postgis-extension/action.yml +++ b/.github/composite-actions/build-postgis-extension/action.yml @@ -25,12 +25,11 @@ runs: mkdir build fi cd build - cmake -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_PREFIX="/usr" .. + cmake -DCMAKE_INSTALL_LIBDIR="lib/x86_64-linux-gnu" -DCMAKE_INSTALL_PREFIX="/usr" .. cmake --build . sudo cmake --build . --target install - sudo cp /usr/lib/libproj* /usr/lib/x86_64-linux-gnu/ cd ../../postgis-3.4.0 - ./configure --without-protobuf --without-raster --with-projdir=/usr --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config + ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config install shell: bash diff --git a/.github/composite-actions/setup-base-version/action.yml b/.github/composite-actions/setup-base-version/action.yml index ebe312e726..b8eddf5918 100644 --- a/.github/composite-actions/setup-base-version/action.yml +++ b/.github/composite-actions/setup-base-version/action.yml @@ -75,12 +75,11 @@ runs: mkdir build fi cd build - cmake -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_PREFIX="/usr" .. + cmake -DCMAKE_INSTALL_LIBDIR="lib/x86_64-linux-gnu" -DCMAKE_INSTALL_PREFIX="/usr" .. cmake --build . sudo cmake --build . --target install - sudo cp /usr/lib/libproj* /usr/lib/x86_64-linux-gnu/ cd ../../postgis-3.4.0 - ./configure --without-protobuf --without-raster --with-projdir=/usr --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config + ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/${{ inputs.install_dir }}/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/${{ inputs.install_dir }}/bin/pg_config install shell: bash diff --git a/.github/workflows/major-version-upgrade.yml b/.github/workflows/major-version-upgrade.yml index 0f978ade90..ed3deb3eaf 100644 --- a/.github/workflows/major-version-upgrade.yml +++ b/.github/workflows/major-version-upgrade.yml @@ -63,12 +63,11 @@ jobs: mkdir build fi cd build - cmake -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_PREFIX="/usr" .. + cmake -DCMAKE_INSTALL_LIBDIR="lib/x86_64-linux-gnu" -DCMAKE_INSTALL_PREFIX="/usr" .. cmake --build . sudo cmake --build . --target install - sudo cp /usr/lib/libproj* /usr/lib/x86_64-linux-gnu/ cd ../../postgis-3.4.0 - ./configure --without-protobuf --without-raster --with-projdir=/usr --with-pgconfig=$HOME/psql_source/bin/pg_config + ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config install shell: bash diff --git a/.github/workflows/minor-version-upgrade.yml b/.github/workflows/minor-version-upgrade.yml index 253b92cf34..7a5fe74e9d 100644 --- a/.github/workflows/minor-version-upgrade.yml +++ b/.github/workflows/minor-version-upgrade.yml @@ -53,12 +53,11 @@ jobs: mkdir build fi cd build - cmake -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_PREFIX="/usr" .. + cmake -DCMAKE_INSTALL_LIBDIR="lib/x86_64-linux-gnu" -DCMAKE_INSTALL_PREFIX="/usr" .. cmake --build . sudo cmake --build . --target install - sudo cp /usr/lib/libproj* /usr/lib/x86_64-linux-gnu/ cd ../../postgis-3.4.0 - ./configure --without-protobuf --without-raster --with-projdir=/usr --with-pgconfig=$HOME/psql/bin/pg_config + ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config install shell: bash diff --git a/.github/workflows/tap-tests.yml b/.github/workflows/tap-tests.yml index 7583853b5f..ce5148305a 100644 --- a/.github/workflows/tap-tests.yml +++ b/.github/workflows/tap-tests.yml @@ -69,12 +69,11 @@ jobs: mkdir build fi cd build - cmake -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_PREFIX="/usr" .. + cmake -DCMAKE_INSTALL_LIBDIR="lib/x86_64-linux-gnu" -DCMAKE_INSTALL_PREFIX="/usr" .. cmake --build . sudo cmake --build . --target install - sudo cp /usr/lib/libproj* /usr/lib/x86_64-linux-gnu/ cd ../../postgis-3.4.0 - ./configure --without-protobuf --without-raster --with-projdir=/usr --with-pgconfig=$HOME/psql_source/bin/pg_config + ./configure --without-protobuf --without-raster --with-pgconfig=$HOME/psql_source/bin/pg_config make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config sudo make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config install shell: bash diff --git a/contrib/babelfishpg_common/sql/geography.sql b/contrib/babelfishpg_common/sql/geography.sql index 144032e1db..1da875688e 100644 --- a/contrib/babelfishpg_common/sql/geography.sql +++ b/contrib/babelfishpg_common/sql/geography.sql @@ -177,7 +177,7 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bbf_varbinary) BEGIN varBin := (SELECT CAST ($1 AS bytea)); -- Call the underlying function after preprocessing - RETURN (SELECT CAST (varBin AS GEOGRAPHY)); + RETURN (SELECT sys.GEOGRAPHY(varBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -187,7 +187,7 @@ CREATE OR REPLACE FUNCTION sys.bbf_varbinary(sys.GEOGRAPHY) DECLARE byte bytea; BEGIN - byte := (SELECT CAST ($1 AS bytea)); + byte := (SELECT sys.bytea($1)); RETURN (SELECT CAST (byte AS sys.bbf_varbinary)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -200,7 +200,7 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bbf_binary) BEGIN varBin := (SELECT CAST (CAST ($1 AS sys.VARCHAR) AS sys.bbf_varbinary)); -- Call the underlying function after preprocessing - RETURN (SELECT CAST (varBin AS GEOGRAPHY)); + RETURN (SELECT sys.GEOGRAPHY(varBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -230,7 +230,7 @@ CREATE OR REPLACE FUNCTION sys.bpchar(sys.GEOGRAPHY) BEGIN -- Call the underlying function after preprocessing -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) - RETURN CAST ((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1))) AS sys.bpchar); + RETURN sys.bpchar((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1)))); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -253,7 +253,7 @@ CREATE OR REPLACE FUNCTION sys.varchar(sys.GEOGRAPHY) BEGIN -- Call the underlying function after preprocessing -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) - RETURN CAST ((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1))) AS sys.varchar); + RETURN sys.varchar((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1)))); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -421,14 +421,14 @@ CREATE OR REPLACE FUNCTION sys.ST_zmflag(sys.GEOGRAPHY) LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) - RETURNS boolean + RETURNS boolean AS $$ DECLARE leftvarBin sys.bbf_varbinary; - rightvarBin sys.bbf_varbinary; + rightvarBin sys.bbf_varbinary; BEGIN - leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); - rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + leftvarBin := (SELECT sys.bbf_varbinary($1)); + rightvarBin := (SELECT sys.bbf_varbinary($2)); RETURN (SELECT sys.varbinary_eq(leftvarBin, rightvarBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -448,8 +448,8 @@ CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) leftvarBin sys.bbf_varbinary; rightvarBin sys.bbf_varbinary; BEGIN - leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); - rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + leftvarBin := (SELECT sys.bbf_varbinary($1)); + rightvarBin := (SELECT sys.bbf_varbinary($2)); RETURN (SELECT sys.varbinary_neq(leftvarBin, rightvarBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; diff --git a/contrib/babelfishpg_common/sql/geometry.sql b/contrib/babelfishpg_common/sql/geometry.sql index 283ebfa0f2..f87fe16744 100644 --- a/contrib/babelfishpg_common/sql/geometry.sql +++ b/contrib/babelfishpg_common/sql/geometry.sql @@ -198,7 +198,7 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bbf_varbinary) BEGIN varBin := (SELECT CAST ($1 AS bytea)); -- Call the underlying function after preprocessing - RETURN (SELECT CAST (varBin AS GEOMETRY)); + RETURN (SELECT sys.GEOMETRY(varBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -208,7 +208,7 @@ CREATE OR REPLACE FUNCTION sys.bbf_varbinary(sys.GEOMETRY) DECLARE byte bytea; BEGIN - byte := (SELECT CAST ($1 AS bytea)); + byte := (SELECT sys.bytea($1)); RETURN (SELECT CAST (byte AS sys.bbf_varbinary)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -221,7 +221,7 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bbf_binary) BEGIN varBin := (SELECT CAST (CAST ($1 AS sys.VARCHAR) AS sys.bbf_varbinary)); -- Call the underlying function after preprocessing - RETURN (SELECT CAST (varBin AS GEOMETRY)); + RETURN (SELECT sys.GEOMETRY(varBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -316,8 +316,8 @@ CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) leftvarBin sys.bbf_varbinary; rightvarBin sys.bbf_varbinary; BEGIN - leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); - rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + leftvarBin := (SELECT sys.bbf_varbinary($1)); + rightvarBin := (SELECT sys.bbf_varbinary($2)); RETURN (SELECT sys.varbinary_eq(leftvarBin, rightvarBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -337,8 +337,8 @@ CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) leftvarBin sys.bbf_varbinary; rightvarBin sys.bbf_varbinary; BEGIN - leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); - rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + leftvarBin := (SELECT sys.bbf_varbinary($1)); + rightvarBin := (SELECT sys.bbf_varbinary($2)); RETURN (SELECT sys.varbinary_neq(leftvarBin, rightvarBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; diff --git a/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql b/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql index 539d8f7eba..f4b1fdcfec 100644 --- a/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql +++ b/contrib/babelfishpg_common/sql/upgrades/spatial_types--3.2.0--3.3.0.sql @@ -202,7 +202,7 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bbf_varbinary) BEGIN varBin := (SELECT CAST ($1 AS bytea)); -- Call the underlying function after preprocessing - RETURN (SELECT CAST (varBin AS GEOMETRY)); + RETURN (SELECT sys.GEOMETRY(varBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -212,7 +212,7 @@ CREATE OR REPLACE FUNCTION sys.bbf_varbinary(sys.GEOMETRY) DECLARE byte bytea; BEGIN - byte := (SELECT CAST ($1 AS bytea)); + byte := (SELECT sys.bytea($1)); RETURN (SELECT CAST (byte AS sys.bbf_varbinary)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -225,7 +225,7 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY(sys.bbf_binary) BEGIN varBin := (SELECT CAST (CAST ($1 AS sys.VARCHAR) AS sys.bbf_varbinary)); -- Call the underlying function after preprocessing - RETURN (SELECT CAST (varBin AS GEOMETRY)); + RETURN (SELECT sys.GEOMETRY(varBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -320,8 +320,8 @@ CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) leftvarBin sys.bbf_varbinary; rightvarBin sys.bbf_varbinary; BEGIN - leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); - rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + leftvarBin := (SELECT sys.bbf_varbinary($1)); + rightvarBin := (SELECT sys.bbf_varbinary($2)); RETURN (SELECT sys.varbinary_eq(leftvarBin, rightvarBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -341,8 +341,8 @@ CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOMETRY, rightarg sys.GEOMETRY) leftvarBin sys.bbf_varbinary; rightvarBin sys.bbf_varbinary; BEGIN - leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); - rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + leftvarBin := (SELECT sys.bbf_varbinary($1)); + rightvarBin := (SELECT sys.bbf_varbinary($2)); RETURN (SELECT sys.varbinary_neq(leftvarBin, rightvarBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -570,7 +570,7 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bbf_varbinary) BEGIN varBin := (SELECT CAST ($1 AS bytea)); -- Call the underlying function after preprocessing - RETURN (SELECT CAST (varBin AS GEOGRAPHY)); + RETURN (SELECT sys.GEOGRAPHY(varBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -580,7 +580,7 @@ CREATE OR REPLACE FUNCTION sys.bbf_varbinary(sys.GEOGRAPHY) DECLARE byte bytea; BEGIN - byte := (SELECT CAST ($1 AS bytea)); + byte := (SELECT sys.bytea($1)); RETURN (SELECT CAST (byte AS sys.bbf_varbinary)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -593,7 +593,7 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.bbf_binary) BEGIN varBin := (SELECT CAST (CAST ($1 AS sys.VARCHAR) AS sys.bbf_varbinary)); -- Call the underlying function after preprocessing - RETURN (SELECT CAST (varBin AS GEOGRAPHY)); + RETURN (SELECT sys.GEOGRAPHY(varBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -623,7 +623,7 @@ CREATE OR REPLACE FUNCTION sys.bpchar(sys.GEOGRAPHY) BEGIN -- Call the underlying function after preprocessing -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) - RETURN CAST ((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1))) AS sys.bpchar); + RETURN sys.bpchar((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1)))); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -646,7 +646,7 @@ CREATE OR REPLACE FUNCTION sys.varchar(sys.GEOGRAPHY) BEGIN -- Call the underlying function after preprocessing -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) - RETURN CAST ((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1))) AS sys.varchar); + RETURN sys.varchar((SELECT sys.STAsText_helper(sys.Geography__STFlipCoordinates($1)))); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -814,14 +814,14 @@ CREATE OR REPLACE FUNCTION sys.ST_zmflag(sys.GEOGRAPHY) LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE; CREATE FUNCTION sys.ST_Equals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) - RETURNS boolean + RETURNS boolean AS $$ DECLARE leftvarBin sys.bbf_varbinary; - rightvarBin sys.bbf_varbinary; + rightvarBin sys.bbf_varbinary; BEGIN - leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); - rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + leftvarBin := (SELECT sys.bbf_varbinary($1)); + rightvarBin := (SELECT sys.bbf_varbinary($2)); RETURN (SELECT sys.varbinary_eq(leftvarBin, rightvarBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -841,8 +841,8 @@ CREATE FUNCTION sys.ST_NotEquals(leftarg sys.GEOGRAPHY, rightarg sys.GEOGRAPHY) leftvarBin sys.bbf_varbinary; rightvarBin sys.bbf_varbinary; BEGIN - leftvarBin := (SELECT CAST ($1 AS sys.bbf_varbinary)); - rightvarBin := (SELECT CAST ($2 AS sys.bbf_varbinary)); + leftvarBin := (SELECT sys.bbf_varbinary($1)); + rightvarBin := (SELECT sys.bbf_varbinary($2)); RETURN (SELECT sys.varbinary_neq(leftvarBin, rightvarBin)); END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; diff --git a/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out b/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out index 3dc766ef14..cfd1c8615f 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out @@ -4,6 +4,8 @@ DROP VIEW IF EXISTS BinaryFromGeom DROP VIEW IF EXISTS CoordsFromGeom +DROP VIEW IF EXISTS equal_geom + DROP VIEW IF EXISTS point_distances_geom DROP VIEW IF EXISTS TextFromGeog @@ -14,6 +16,8 @@ DROP VIEW IF EXISTS CoordsFromGeog DROP VIEW IF EXISTS TransformFromGeog +DROP VIEW IF EXISTS equal_geog + DROP VIEW IF EXISTS point_distances_geog DROP TABLE IF EXISTS SPATIALPOINTGEOM_dt diff --git a/test/JDBC/expected/TestSpatialPoint-vu-prepare.out b/test/JDBC/expected/TestSpatialPoint-vu-prepare.out index e827d23487..e644e6d4de 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-prepare.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-prepare.out @@ -128,6 +128,8 @@ CREATE VIEW BinaryFromGeom AS SELECT STAsBinary(location) AS BinaryRepresentatio CREATE VIEW CoordsFromGeom AS SELECT STX(location), STY(location) AS Coordinates FROM SPATIALPOINTGEOM_dt; +CREATE VIEW equal_geom AS SELECT p1.location AS point FROM SPATIALPOINTGEOM_dt p1 CROSS JOIN SPATIALPOINTGEOM_dt p2 WHERE p1.location = p2.location; + CREATE VIEW point_distances_geom AS SELECT p1.location AS point1, p2.location AS point2, STDistance( p1.location, p2.location ) AS distance FROM SPATIALPOINTGEOM_dt p1 CROSS JOIN SPATIALPOINTGEOM_dt p2 WHERE p1.location <> p2.location; CREATE TABLE SPATIALPOINTGEOG_dt (location geography) @@ -341,6 +343,8 @@ CREATE VIEW CoordsFromGeog AS SELECT long(location), lat(location) AS Coordinat CREATE VIEW TransformFromGeog AS SELECT ST_Transform(location, 4326) AS Modified_points FROM SPATIALPOINTGEOG_dt; +CREATE VIEW equal_geog AS SELECT p1.location AS point FROM SPATIALPOINTGEOG_dt p1 CROSS JOIN SPATIALPOINTGEOG_dt p2 WHERE p1.location = p2.location; + CREATE VIEW point_distances_geog AS SELECT p1.location AS point1, p2.location AS point2, STDistance( p1.location, p2.location ) AS distance FROM SPATIALPOINTGEOG_dt p1 CROSS JOIN SPATIALPOINTGEOG_dt p2 WHERE p1.location <> p2.location; #Testing Implicit CASTs to and from Geography data type for supported Explicit CASTs diff --git a/test/JDBC/expected/TestSpatialPoint-vu-verify.out b/test/JDBC/expected/TestSpatialPoint-vu-verify.out index 1e30839b69..9521a1164e 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-verify.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-verify.out @@ -112,6 +112,42 @@ float#!#float ~~END~~ +SELECT * FROM equal_geom; +GO +~~START~~ +geometry +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C000000000000F03F0000000000000040 +E6100000010C000000000000F03F0000000000000040 +E6100000010C000000000000F03F0000000000000040 +00000000010C17D9CEF753D34740D34D6210585936C0 +00000000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C000000000000F03F0000000000000040 +E6100000010C000000000000F03F0000000000000040 +E6100000010C000000000000F03F0000000000000040 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C000000000000F03F0000000000000040 +E6100000010C000000000000F03F0000000000000040 +E6100000010C000000000000F03F0000000000000040 +00000000010C17D9CEF753D34740D34D6210585936C0 +00000000010C17D9CEF753D34740D34D6210585936C0 +~~END~~ + + SELECT * FROM point_distances_geom; GO ~~START~~ @@ -531,6 +567,32 @@ E6100000010C0000000000000040000000000000F03F ~~END~~ +SELECT * FROM equal_geog; +GO +~~START~~ +geography +E6100000010CD34D6210585936C017D9CEF753D34740 +E6100000010CD34D6210585936C017D9CEF753D34740 +E6100000010CD34D6210585936C017D9CEF753D34740 +E6100000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F +E6100000010CD34D6210585936C017D9CEF753D34740 +E6100000010CD34D6210585936C017D9CEF753D34740 +E6100000010CD34D6210585936C017D9CEF753D34740 +E6100000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010CD34D6210585936C017D9CEF753D34740 +E6100000010CD34D6210585936C017D9CEF753D34740 +E6100000010CD34D6210585936C017D9CEF753D34740 +E6100000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F +E6100000010C0000000000000040000000000000F03F +~~END~~ + + SELECT * FROM point_distances_geog; GO ~~START~~ diff --git a/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.txt b/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.txt index 3dc766ef14..cfd1c8615f 100644 --- a/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.txt +++ b/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.txt @@ -4,6 +4,8 @@ DROP VIEW IF EXISTS BinaryFromGeom DROP VIEW IF EXISTS CoordsFromGeom +DROP VIEW IF EXISTS equal_geom + DROP VIEW IF EXISTS point_distances_geom DROP VIEW IF EXISTS TextFromGeog @@ -14,6 +16,8 @@ DROP VIEW IF EXISTS CoordsFromGeog DROP VIEW IF EXISTS TransformFromGeog +DROP VIEW IF EXISTS equal_geog + DROP VIEW IF EXISTS point_distances_geog DROP TABLE IF EXISTS SPATIALPOINTGEOM_dt diff --git a/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt b/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt index a069d52482..67f3e3419f 100644 --- a/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt +++ b/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt @@ -64,6 +64,8 @@ CREATE VIEW BinaryFromGeom AS SELECT STAsBinary(location) AS BinaryRepresentatio CREATE VIEW CoordsFromGeom AS SELECT STX(location), STY(location) AS Coordinates FROM SPATIALPOINTGEOM_dt; +CREATE VIEW equal_geom AS SELECT p1.location AS point FROM SPATIALPOINTGEOM_dt p1 CROSS JOIN SPATIALPOINTGEOM_dt p2 WHERE p1.location = p2.location; + CREATE VIEW point_distances_geom AS SELECT p1.location AS point1, p2.location AS point2, STDistance( p1.location, p2.location ) AS distance FROM SPATIALPOINTGEOM_dt p1 CROSS JOIN SPATIALPOINTGEOM_dt p2 WHERE p1.location <> p2.location; CREATE TABLE SPATIALPOINTGEOG_dt (location geography) @@ -169,6 +171,8 @@ CREATE VIEW CoordsFromGeog AS SELECT long(location), lat(location) AS Coordinat CREATE VIEW TransformFromGeog AS SELECT ST_Transform(location, 4326) AS Modified_points FROM SPATIALPOINTGEOG_dt; +CREATE VIEW equal_geog AS SELECT p1.location AS point FROM SPATIALPOINTGEOG_dt p1 CROSS JOIN SPATIALPOINTGEOG_dt p2 WHERE p1.location = p2.location; + CREATE VIEW point_distances_geog AS SELECT p1.location AS point1, p2.location AS point2, STDistance( p1.location, p2.location ) AS distance FROM SPATIALPOINTGEOG_dt p1 CROSS JOIN SPATIALPOINTGEOG_dt p2 WHERE p1.location <> p2.location; #Testing Implicit CASTs to and from Geography data type for supported Explicit CASTs diff --git a/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql b/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql index 75083433af..239f4e93ad 100644 --- a/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql +++ b/test/JDBC/input/datatypes/TestSpatialPoint-vu-verify.sql @@ -35,6 +35,9 @@ GO SELECT * FROM CoordsFromGeom; GO +SELECT * FROM equal_geom; +GO + SELECT * FROM point_distances_geom; GO @@ -173,6 +176,9 @@ GO SELECT * FROM TransformFromGeog; GO +SELECT * FROM equal_geog; +GO + SELECT * FROM point_distances_geog; GO From b66f67712966616008c4b2807d3b11ebcfe6fdb8 Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Mon, 6 Nov 2023 16:22:37 +0000 Subject: [PATCH 21/21] Fixed expected_dependency file Signed-off-by: Anikait Agrawal --- test/python/expected/upgrade_validation/expected_dependency.out | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/python/expected/upgrade_validation/expected_dependency.out b/test/python/expected/upgrade_validation/expected_dependency.out index ac1a1b1dec..8f9713bff5 100644 --- a/test/python/expected/upgrade_validation/expected_dependency.out +++ b/test/python/expected/upgrade_validation/expected_dependency.out @@ -942,8 +942,6 @@ Operator sys.=(sys.fixeddecimal,bigint) Operator sys.=(sys.fixeddecimal,integer) Operator sys.=(sys.fixeddecimal,numeric) Operator sys.=(sys.fixeddecimal,smallint) -Operator sys.=(sys.geography,sys.geography) -Operator sys.=(sys.geometry,sys.geometry) Operator sys.=(sys.rowversion,sys.rowversion) Operator sys.=(sys.smalldatetime,date) Operator sys.=(sys.smalldatetime,sys.smalldatetime)