From acb1f450af63f64a35e56719f61db821adb0c5be Mon Sep 17 00:00:00 2001 From: Anikait Agrawal Date: Wed, 18 Oct 2023 15:50:56 +0000 Subject: [PATCH] Resolved Comments Signed-off-by: Anikait Agrawal --- contrib/babelfishpg_common/Makefile | 4 +- contrib/babelfishpg_common/sql/geography.sql | 143 ++---- contrib/babelfishpg_common/sql/geometry.sql | 10 +- .../upgrades/spatial_types--3.2.0--3.3.0.sql | 153 +++--- .../babelfishpg_tds/src/backend/tds/tdsrpc.c | 16 +- .../src/backend/tds/tdstypeio.c | 66 +-- .../src/include/tds_iofuncmap.h | 6 +- test/JDBC/expected/TestPoint-vu-cleanup.out | 5 - test/JDBC/expected/TestPoint-vu-prepare.out | 133 ------ test/JDBC/expected/TestPoint-vu-verify.out | 25 - test/JDBC/expected/TestPoint.out | 161 ------- .../expected/TestSpatialPoint-vu-cleanup.out | 14 - .../expected/TestSpatialPoint-vu-prepare.out | 446 ++++++++++-------- .../expected/TestSpatialPoint-vu-verify.out | 39 ++ .../input/datatypes/TestPoint-vu-cleanup.txt | 5 - .../input/datatypes/TestPoint-vu-prepare.txt | 29 -- .../input/datatypes/TestPoint-vu-verify.txt | 5 - test/JDBC/input/datatypes/TestPoint.txt | 37 -- ...up.sql => TestSpatialPoint-vu-cleanup.txt} | 14 - .../datatypes/TestSpatialPoint-vu-prepare.sql | 240 ---------- .../datatypes/TestSpatialPoint-vu-prepare.txt | 180 +++++++ test/JDBC/upgrade/latest/schedule | 1 - test/JDBC/upgrade/master/schedule | 1 - 23 files changed, 630 insertions(+), 1103 deletions(-) delete mode 100644 test/JDBC/expected/TestPoint-vu-cleanup.out delete mode 100644 test/JDBC/expected/TestPoint-vu-prepare.out delete mode 100644 test/JDBC/expected/TestPoint-vu-verify.out delete mode 100644 test/JDBC/expected/TestPoint.out delete mode 100644 test/JDBC/input/datatypes/TestPoint-vu-cleanup.txt delete mode 100644 test/JDBC/input/datatypes/TestPoint-vu-prepare.txt delete mode 100644 test/JDBC/input/datatypes/TestPoint-vu-verify.txt delete mode 100644 test/JDBC/input/datatypes/TestPoint.txt rename test/JDBC/input/datatypes/{TestSpatialPoint-vu-cleanup.sql => TestSpatialPoint-vu-cleanup.txt} (92%) delete mode 100644 test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.sql create mode 100644 test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt diff --git a/contrib/babelfishpg_common/Makefile b/contrib/babelfishpg_common/Makefile index e0bd9a0c57..21c47f2e59 100644 --- a/contrib/babelfishpg_common/Makefile +++ b/contrib/babelfishpg_common/Makefile @@ -61,8 +61,8 @@ endif DATA_built = \ $(EXTENSION).control \ - sql/$(EXTENSION)--$(EXTVERSION).sql $(UPGRADES) \ - $(GENERATED_UPGRADES) + sql/$(EXTENSION)--$(EXTVERSION).sql $(UPGRADES) \ + $(GENERATED_UPGRADES) #include ../Makefile.common diff --git a/contrib/babelfishpg_common/sql/geography.sql b/contrib/babelfishpg_common/sql/geography.sql index 2d7cf3e8ca..d2a2fd7fa9 100644 --- a/contrib/babelfishpg_common/sql/geography.sql +++ b/contrib/babelfishpg_common/sql/geography.sql @@ -55,20 +55,10 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.GEOGRAPHY, integer, boolean) CREATE CAST (sys.GEOGRAPHY AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.GEOGRAPHY, integer, boolean) AS IMPLICIT; -CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(bytea) - RETURNS sys.GEOGRAPHY - AS $$ - DECLARE - len integer; - varBin bytea; - geomType bytea; - srid integer; - newVarBin bytea; - lat float8; - byte_position integer := 6; - coord_NaN bytea := E'\\x000000000000f87f'; - input_coord bytea; - isNaN integer = 0; +CREATE OR REPLACE FUNCTION sys.get_valid_srids() + RETURNS integer[] + AS $$ + DECLARE valid_srids integer[] := ARRAY[ 4120, 4121, 4122, 4123, 4124, 4127, 4128, 4129, 4130, 4131, 4132, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4141, 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160, @@ -92,14 +82,43 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(bytea) 4941, 4943, 4945, 4947, 4949, 4951, 4953, 4955, 4957, 4959, 4961, 4963, 4965, 4967, 4971, 4973, 4975, 4977, 4979, 4981, 4983, 4985, 4987, 4989, 4991, 4993, 4995, 4997, 4999, 7843, 7844, 104001 ]; + BEGIN + RETURN valid_srids; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(bytea) + RETURNS sys.GEOGRAPHY + AS $$ + DECLARE + len integer; + varBin bytea; + geomType bytea; + srid integer; + newVarBin bytea; + lat float8; + byte_position integer := 6; + coord_NaN bytea := E'\\x000000000000f87f'; + input_coord bytea; + reversed_bytea bytea := E'\\x'; + i integer := 14; + isNaN integer = 0; + valid_srids integer[]; BEGIN + -- Call the function to retrieve the valid SRIDs + SELECT sys.get_valid_srids() INTO valid_srids; varBin := $1; len := LENGTH(varBin); IF len >= 22 THEN - -- We are preprocessing it by removing 2 constant Geometry Type bytes -> 01 0c (currently for Point Type) - -- Then adding 5 Bytes -> 01 (little endianess) + 4 Bytes (Geography Type) + -- General Logic: We are preprocessing it by removing 2 constant Geometry Type bytes -> 01 0c (currently for Point Type) Then adding 5 Bytes -> 01 (little endianess) + 4 Bytes (Geography Type). It is expected by the driver + -- Here we are calculating SRID which is initially in little endian order srid := (get_byte(varBin, 3) << 24) | (get_byte(varBin, 2) << 16) | (get_byte(varBin, 1) << 8) | get_byte(varBin, 0); - lat := varbinaryfloat8(CAST ((substring(varBin from 14 for 1) || substring(varBin from 13 for 1) || substring(varBin from 12 for 1) || substring(varBin from 11 for 1) || substring(varBin from 10 for 1) || substring(varBin from 9 for 1) || substring(varBin from 8 for 1) || substring(varBin from 7 for 1)) AS bbf_varbinary)); + -- Here we are calculating value of latitude which is initially in little endian order to check if it lies in the range [-90, 90] + WHILE i > 6 LOOP + reversed_bytea := reversed_bytea || substring(varBin from i for 1); + i = i - 1; + END LOOP; + lat := varbinaryfloat8(CAST (reversed_bytea AS bbf_varbinary)); WHILE byte_position < len LOOP -- Get the coordinate to check if it is NaN input_coord := substring(varBin from byte_position + 1 for 8); @@ -118,7 +137,7 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(bytea) RAISE EXCEPTION 'Error converting data type varbinary to geography.'; END IF; ELSE - RAISE EXCEPTION 'Currently only Point Type(without Z and M flags) is Supported in Babelfish'; + RAISE EXCEPTION 'Currently only Point Type(without Z and M flags) is Supported'; END IF; ELSE RAISE EXCEPTION 'Error converting data type varbinary to geography.'; @@ -185,31 +204,11 @@ CREATE OR REPLACE FUNCTION sys.Geography__stgeomfromtext(text, integer) srid integer; Geomtype text; geom sys.GEOGRAPHY; - valid_srids integer[] := ARRAY[ - 4120, 4121, 4122, 4123, 4124, 4127, 4128, 4129, 4130, 4131, 4132, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4141, - 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160, - 4161, 4162, 4163, 4164, 4165, 4166, 4167, 4168, 4169, 4170, 4171, 4173, 4174, 4175, 4176, 4178, 4179, 4180, 4181, - 4182, 4183, 4184, 4188, 4189, 4190, 4191, 4192, 4193, 4194, 4195, 4196, 4197, 4198, 4199, 4200, 4201, 4202, 4203, - 4204, 4205, 4206, 4207, 4208, 4209, 4210, 4211, 4212, 4213, 4214, 4215, 4216, 4218, 4219, 4220, 4221, 4222, 4223, - 4224, 4225, 4227, 4229, 4230, 4231, 4232, 4236, 4237, 4238, 4239, 4240, 4241, 4242, 4243, 4244, 4245, 4246, 4247, - 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, 4256, 4257, 4258, 4259, 4261, 4262, 4263, 4265, 4266, 4267, 4268, - 4269, 4270, 4271, 4272, 4273, 4274, 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4288, - 4289, 4292, 4293, 4295, 4297, 4298, 4299, 4300, 4301, 4302, 4303, 4304, 4306, 4307, 4308, 4309, 4310, 4311, 4312, - 4313, 4314, 4315, 4316, 4317, 4318, 4319, 4322, 4324, 4326, 4600, 4601, 4602, 4603, 4604, 4605, 4606, 4607, 4608, - 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626, 4627, - 4628, 4629, 4630, 4632, 4633, 4636, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4646, 4657, 4658, 4659, 4660, - 4661, 4662, 4663, 4664, 4665, 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4676, 4677, 4678, 4679, - 4680, 4682, 4683, 4684, 4686, 4687, 4688, 4689, 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, - 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716, 4717, 4718, 4719, - 4720, 4721, 4722, 4723, 4724, 4725, 4726, 4727, 4728, 4729, 4730, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, - 4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747, 4748, 4749, 4750, 4751, 4752, 4753, 4754, 4755, 4756, 4757, 4758, - 4801, 4802, 4803, 4804, 4805, 4806, 4807, 4808, 4809, 4810, 4811, 4813, 4814, 4815, 4816, 4817, 4818, 4820, 4821, - 4895, 4898, 4900, 4901, 4902, 4903, 4904, 4907, 4909, 4921, 4923, 4925, 4927, 4929, 4931, 4933, 4935, 4937, 4939, - 4941, 4943, 4945, 4947, 4949, 4951, 4953, 4955, 4957, 4959, 4961, 4963, 4965, 4967, 4971, 4973, 4975, 4977, 4979, - 4981, 4983, 4985, 4987, 4989, 4991, 4993, 4995, 4997, 4999, 7843, 7844, 104001 - ]; + valid_srids integer[]; lat float8; - BEGIN + BEGIN + -- Call the function to retrieve the valid SRIDs + SELECT sys.get_valid_srids() INTO valid_srids; srid := $2; -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) geom = (SELECT sys.stgeogfromtext_helper($1, $2)); @@ -220,7 +219,7 @@ CREATE OR REPLACE FUNCTION sys.Geography__stgeomfromtext(text, integer) -- 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) IF (SELECT sys.ST_Zmflag(geom)) = 1 OR (SELECT sys.ST_Zmflag(geom)) = 2 OR (SELECT sys.ST_Zmflag(geom)) = 3 THEN - RAISE EXCEPTION 'Z and M flags are currently not supported in Babelfish'; + RAISE EXCEPTION 'Z and M flags are currently not supported'; ELSE RETURN (SELECT sys.Geography__STFlipCoordinates(geom)); END IF; @@ -230,7 +229,7 @@ CREATE OR REPLACE FUNCTION sys.Geography__stgeomfromtext(text, integer) RAISE EXCEPTION 'Inavalid SRID'; END IF; ELSE - RAISE EXCEPTION '% is currently not supported in Babelfish', Geomtype; + RAISE EXCEPTION '% is currently not supported', Geomtype; END IF; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -256,30 +255,10 @@ CREATE OR REPLACE FUNCTION sys.Geography__Point(float8, float8, srid integer) DECLARE srid integer; lat float8; - valid_srids integer[] := ARRAY[ - 4120, 4121, 4122, 4123, 4124, 4127, 4128, 4129, 4130, 4131, 4132, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4141, - 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160, - 4161, 4162, 4163, 4164, 4165, 4166, 4167, 4168, 4169, 4170, 4171, 4173, 4174, 4175, 4176, 4178, 4179, 4180, 4181, - 4182, 4183, 4184, 4188, 4189, 4190, 4191, 4192, 4193, 4194, 4195, 4196, 4197, 4198, 4199, 4200, 4201, 4202, 4203, - 4204, 4205, 4206, 4207, 4208, 4209, 4210, 4211, 4212, 4213, 4214, 4215, 4216, 4218, 4219, 4220, 4221, 4222, 4223, - 4224, 4225, 4227, 4229, 4230, 4231, 4232, 4236, 4237, 4238, 4239, 4240, 4241, 4242, 4243, 4244, 4245, 4246, 4247, - 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, 4256, 4257, 4258, 4259, 4261, 4262, 4263, 4265, 4266, 4267, 4268, - 4269, 4270, 4271, 4272, 4273, 4274, 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4288, - 4289, 4292, 4293, 4295, 4297, 4298, 4299, 4300, 4301, 4302, 4303, 4304, 4306, 4307, 4308, 4309, 4310, 4311, 4312, - 4313, 4314, 4315, 4316, 4317, 4318, 4319, 4322, 4324, 4326, 4600, 4601, 4602, 4603, 4604, 4605, 4606, 4607, 4608, - 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626, 4627, - 4628, 4629, 4630, 4632, 4633, 4636, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4646, 4657, 4658, 4659, 4660, - 4661, 4662, 4663, 4664, 4665, 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4676, 4677, 4678, 4679, - 4680, 4682, 4683, 4684, 4686, 4687, 4688, 4689, 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, - 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716, 4717, 4718, 4719, - 4720, 4721, 4722, 4723, 4724, 4725, 4726, 4727, 4728, 4729, 4730, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, - 4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747, 4748, 4749, 4750, 4751, 4752, 4753, 4754, 4755, 4756, 4757, 4758, - 4801, 4802, 4803, 4804, 4805, 4806, 4807, 4808, 4809, 4810, 4811, 4813, 4814, 4815, 4816, 4817, 4818, 4820, 4821, - 4895, 4898, 4900, 4901, 4902, 4903, 4904, 4907, 4909, 4921, 4923, 4925, 4927, 4929, 4931, 4933, 4935, 4937, 4939, - 4941, 4943, 4945, 4947, 4949, 4951, 4953, 4955, 4957, 4959, 4961, 4963, 4965, 4967, 4971, 4973, 4975, 4977, 4979, - 4981, 4983, 4985, 4987, 4989, 4991, 4993, 4995, 4997, 4999, 7843, 7844, 104001 - ]; + valid_srids integer[]; BEGIN + -- Call the function to retrieve the valid SRIDs + SELECT sys.get_valid_srids() INTO valid_srids; srid := $3; lat := $1; IF srid = ANY(valid_srids) AND lat >= -90.0 AND lat <= 90.0 THEN @@ -310,31 +289,11 @@ CREATE OR REPLACE FUNCTION sys.Geography__STPointFromText(text, integer) srid integer; Geomtype text; geom sys.GEOGRAPHY; - valid_srids integer[] := ARRAY[ - 4120, 4121, 4122, 4123, 4124, 4127, 4128, 4129, 4130, 4131, 4132, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4141, - 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160, - 4161, 4162, 4163, 4164, 4165, 4166, 4167, 4168, 4169, 4170, 4171, 4173, 4174, 4175, 4176, 4178, 4179, 4180, 4181, - 4182, 4183, 4184, 4188, 4189, 4190, 4191, 4192, 4193, 4194, 4195, 4196, 4197, 4198, 4199, 4200, 4201, 4202, 4203, - 4204, 4205, 4206, 4207, 4208, 4209, 4210, 4211, 4212, 4213, 4214, 4215, 4216, 4218, 4219, 4220, 4221, 4222, 4223, - 4224, 4225, 4227, 4229, 4230, 4231, 4232, 4236, 4237, 4238, 4239, 4240, 4241, 4242, 4243, 4244, 4245, 4246, 4247, - 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, 4256, 4257, 4258, 4259, 4261, 4262, 4263, 4265, 4266, 4267, 4268, - 4269, 4270, 4271, 4272, 4273, 4274, 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4288, - 4289, 4292, 4293, 4295, 4297, 4298, 4299, 4300, 4301, 4302, 4303, 4304, 4306, 4307, 4308, 4309, 4310, 4311, 4312, - 4313, 4314, 4315, 4316, 4317, 4318, 4319, 4322, 4324, 4326, 4600, 4601, 4602, 4603, 4604, 4605, 4606, 4607, 4608, - 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626, 4627, - 4628, 4629, 4630, 4632, 4633, 4636, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4646, 4657, 4658, 4659, 4660, - 4661, 4662, 4663, 4664, 4665, 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4676, 4677, 4678, 4679, - 4680, 4682, 4683, 4684, 4686, 4687, 4688, 4689, 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, - 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716, 4717, 4718, 4719, - 4720, 4721, 4722, 4723, 4724, 4725, 4726, 4727, 4728, 4729, 4730, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, - 4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747, 4748, 4749, 4750, 4751, 4752, 4753, 4754, 4755, 4756, 4757, 4758, - 4801, 4802, 4803, 4804, 4805, 4806, 4807, 4808, 4809, 4810, 4811, 4813, 4814, 4815, 4816, 4817, 4818, 4820, 4821, - 4895, 4898, 4900, 4901, 4902, 4903, 4904, 4907, 4909, 4921, 4923, 4925, 4927, 4929, 4931, 4933, 4935, 4937, 4939, - 4941, 4943, 4945, 4947, 4949, 4951, 4953, 4955, 4957, 4959, 4961, 4963, 4965, 4967, 4971, 4973, 4975, 4977, 4979, - 4981, 4983, 4985, 4987, 4989, 4991, 4993, 4995, 4997, 4999, 7843, 7844, 104001 - ]; + valid_srids integer[]; lat float8; BEGIN + -- Call the function to retrieve the valid SRIDs + SELECT sys.get_valid_srids() INTO valid_srids; srid := $2; -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) geom = (SELECT sys.stgeogfromtext_helper($1, $2)); @@ -345,7 +304,7 @@ CREATE OR REPLACE FUNCTION sys.Geography__STPointFromText(text, integer) -- 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) IF (SELECT sys.ST_Zmflag(geom)) = 1 OR (SELECT sys.ST_Zmflag(geom)) = 2 OR (SELECT sys.ST_Zmflag(geom)) = 3 THEN - RAISE EXCEPTION 'Z and M flags are currently not supported in Babelfish'; + RAISE EXCEPTION 'Z and M flags are currently not supported'; ELSE RETURN (SELECT sys.Geography__STFlipCoordinates(geom)); END IF; @@ -355,7 +314,7 @@ CREATE OR REPLACE FUNCTION sys.Geography__STPointFromText(text, integer) RAISE EXCEPTION 'Inavalid SRID'; END IF; ELSE - RAISE EXCEPTION '% is currently not supported in Babelfish', Geomtype; + RAISE EXCEPTION '% is currently not supported', Geomtype; END IF; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; diff --git a/contrib/babelfishpg_common/sql/geometry.sql b/contrib/babelfishpg_common/sql/geometry.sql index 30dc9645d1..72492b555e 100644 --- a/contrib/babelfishpg_common/sql/geometry.sql +++ b/contrib/babelfishpg_common/sql/geometry.sql @@ -83,12 +83,12 @@ CREATE OR REPLACE FUNCTION sys.Geometry__stgeomfromtext(text, integer) Geomtype = (SELECT sys.ST_GeometryType(geom)); IF Geomtype = 'ST_Point' THEN IF (SELECT sys.ST_Zmflag(geom)) = 1 OR (SELECT sys.ST_Zmflag(geom)) = 2 OR (SELECT sys.ST_Zmflag(geom)) = 3 THEN - RAISE EXCEPTION 'Z and M flags are currently not supported in Babelfish'; + RAISE EXCEPTION 'Z and M flags are currently not supported'; ELSE RETURN geom; END IF; ELSE - RAISE EXCEPTION '% is currently not supported in Babelfish', Geomtype; + RAISE EXCEPTION '% is currently not supported', Geomtype; END IF; ELSE RAISE EXCEPTION 'SRID value should be between 0 and 999999'; @@ -141,7 +141,7 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY(bytea) IF encode(geomType, 'hex') = encode(E'\\x010c', 'hex') THEN newVarBin := E'\\x0101000020' || varBin; ELSE - RAISE EXCEPTION 'Currently only Point Type(without Z and M flags) is Supported in Babelfish'; + RAISE EXCEPTION 'Currently only Point Type(without Z and M flags) is Supported'; END IF; ELSE RAISE EXCEPTION 'Error converting data type varbinary to geometry.'; @@ -225,12 +225,12 @@ CREATE OR REPLACE FUNCTION sys.Geometry__STPointFromText(text, integer) Geomtype = (SELECT sys.ST_GeometryType(geom)); IF Geomtype = 'ST_Point' THEN IF (SELECT sys.ST_Zmflag(geom)) = 1 OR (SELECT sys.ST_Zmflag(geom)) = 2 OR (SELECT sys.ST_Zmflag(geom)) = 3 THEN - RAISE EXCEPTION 'Z and M flags are currently not supported in Babelfish'; + RAISE EXCEPTION 'Z and M flags are currently not supported'; ELSE RETURN geom; END IF; ELSE - RAISE EXCEPTION '% is currently not supported in Babelfish', Geomtype; + RAISE EXCEPTION '% is currently not supported', Geomtype; END IF; ELSE RAISE EXCEPTION 'SRID value should be between 0 and 999999'; 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 80c155f0a0..3fb36cdc4b 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 @@ -87,12 +87,12 @@ CREATE OR REPLACE FUNCTION sys.Geometry__stgeomfromtext(text, integer) Geomtype = (SELECT sys.ST_GeometryType(geom)); IF Geomtype = 'ST_Point' THEN IF (SELECT sys.ST_Zmflag(geom)) = 1 OR (SELECT sys.ST_Zmflag(geom)) = 2 OR (SELECT sys.ST_Zmflag(geom)) = 3 THEN - RAISE EXCEPTION 'Z and M flags are currently not supported in Babelfish'; + RAISE EXCEPTION 'Z and M flags are currently not supported'; ELSE RETURN geom; END IF; ELSE - RAISE EXCEPTION '% is currently not supported in Babelfish', Geomtype; + RAISE EXCEPTION '% is currently not supported', Geomtype; END IF; ELSE RAISE EXCEPTION 'SRID value should be between 0 and 999999'; @@ -145,7 +145,7 @@ CREATE OR REPLACE FUNCTION sys.GEOMETRY(bytea) IF encode(geomType, 'hex') = encode(E'\\x010c', 'hex') THEN newVarBin := E'\\x0101000020' || varBin; ELSE - RAISE EXCEPTION 'Currently only Point Type(without Z and M flags) is Supported in Babelfish'; + RAISE EXCEPTION 'Currently only Point Type(without Z and M flags) is Supported'; END IF; ELSE RAISE EXCEPTION 'Error converting data type varbinary to geometry.'; @@ -229,12 +229,12 @@ CREATE OR REPLACE FUNCTION sys.Geometry__STPointFromText(text, integer) Geomtype = (SELECT sys.ST_GeometryType(geom)); IF Geomtype = 'ST_Point' THEN IF (SELECT sys.ST_Zmflag(geom)) = 1 OR (SELECT sys.ST_Zmflag(geom)) = 2 OR (SELECT sys.ST_Zmflag(geom)) = 3 THEN - RAISE EXCEPTION 'Z and M flags are currently not supported in Babelfish'; + RAISE EXCEPTION 'Z and M flags are currently not supported'; ELSE RETURN geom; END IF; ELSE - RAISE EXCEPTION '% is currently not supported in Babelfish', Geomtype; + RAISE EXCEPTION '% is currently not supported', Geomtype; END IF; ELSE RAISE EXCEPTION 'SRID value should be between 0 and 999999'; @@ -341,20 +341,10 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(sys.GEOGRAPHY, integer, boolean) CREATE CAST (sys.GEOGRAPHY AS sys.GEOGRAPHY) WITH FUNCTION sys.GEOGRAPHY(sys.GEOGRAPHY, integer, boolean) AS IMPLICIT; -CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(bytea) - RETURNS sys.GEOGRAPHY - AS $$ - DECLARE - len integer; - varBin bytea; - geomType bytea; - srid integer; - newVarBin bytea; - lat float8; - byte_position integer := 6; - coord_NaN bytea := E'\\x000000000000f87f'; - input_coord bytea; - isNaN integer = 0; +CREATE OR REPLACE FUNCTION sys.get_valid_srids() + RETURNS integer[] + AS $$ + DECLARE valid_srids integer[] := ARRAY[ 4120, 4121, 4122, 4123, 4124, 4127, 4128, 4129, 4130, 4131, 4132, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4141, 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160, @@ -378,14 +368,43 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(bytea) 4941, 4943, 4945, 4947, 4949, 4951, 4953, 4955, 4957, 4959, 4961, 4963, 4965, 4967, 4971, 4973, 4975, 4977, 4979, 4981, 4983, 4985, 4987, 4989, 4991, 4993, 4995, 4997, 4999, 7843, 7844, 104001 ]; + BEGIN + RETURN valid_srids; + END; + $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; + +CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(bytea) + RETURNS sys.GEOGRAPHY + AS $$ + DECLARE + len integer; + varBin bytea; + geomType bytea; + srid integer; + newVarBin bytea; + lat float8; + byte_position integer := 6; + coord_NaN bytea := E'\\x000000000000f87f'; + input_coord bytea; + reversed_bytea bytea := E'\\x'; + i integer := 14; + isNaN integer = 0; + valid_srids integer[]; BEGIN + -- Call the function to retrieve the valid SRIDs + SELECT sys.get_valid_srids() INTO valid_srids; varBin := $1; len := LENGTH(varBin); IF len >= 22 THEN - -- We are preprocessing it by removing 2 constant Geometry Type bytes -> 01 0c (currently for Point Type) - -- Then adding 5 Bytes -> 01 (little endianess) + 4 Bytes (Geography Type) + -- General Logic: We are preprocessing it by removing 2 constant Geometry Type bytes -> 01 0c (currently for Point Type) Then adding 5 Bytes -> 01 (little endianess) + 4 Bytes (Geography Type). It is expected by the driver + -- Here we are calculating SRID which is initially in little endian order srid := (get_byte(varBin, 3) << 24) | (get_byte(varBin, 2) << 16) | (get_byte(varBin, 1) << 8) | get_byte(varBin, 0); - lat := varbinaryfloat8(CAST ((substring(varBin from 14 for 1) || substring(varBin from 13 for 1) || substring(varBin from 12 for 1) || substring(varBin from 11 for 1) || substring(varBin from 10 for 1) || substring(varBin from 9 for 1) || substring(varBin from 8 for 1) || substring(varBin from 7 for 1)) AS bbf_varbinary)); + -- Here we are calculating value of latitude which is initially in little endian order to check if it lies in the range [-90, 90] + WHILE i > 6 LOOP + reversed_bytea := reversed_bytea || substring(varBin from i for 1); + i = i - 1; + END LOOP; + lat := varbinaryfloat8(CAST (reversed_bytea AS bbf_varbinary)); WHILE byte_position < len LOOP -- Get the coordinate to check if it is NaN input_coord := substring(varBin from byte_position + 1 for 8); @@ -404,7 +423,7 @@ CREATE OR REPLACE FUNCTION sys.GEOGRAPHY(bytea) RAISE EXCEPTION 'Error converting data type varbinary to geography.'; END IF; ELSE - RAISE EXCEPTION 'Currently only Point Type(without Z and M flags) is Supported in Babelfish'; + RAISE EXCEPTION 'Currently only Point Type(without Z and M flags) is Supported'; END IF; ELSE RAISE EXCEPTION 'Error converting data type varbinary to geography.'; @@ -471,31 +490,11 @@ CREATE OR REPLACE FUNCTION sys.Geography__stgeomfromtext(text, integer) srid integer; Geomtype text; geom sys.GEOGRAPHY; - valid_srids integer[] := ARRAY[ - 4120, 4121, 4122, 4123, 4124, 4127, 4128, 4129, 4130, 4131, 4132, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4141, - 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160, - 4161, 4162, 4163, 4164, 4165, 4166, 4167, 4168, 4169, 4170, 4171, 4173, 4174, 4175, 4176, 4178, 4179, 4180, 4181, - 4182, 4183, 4184, 4188, 4189, 4190, 4191, 4192, 4193, 4194, 4195, 4196, 4197, 4198, 4199, 4200, 4201, 4202, 4203, - 4204, 4205, 4206, 4207, 4208, 4209, 4210, 4211, 4212, 4213, 4214, 4215, 4216, 4218, 4219, 4220, 4221, 4222, 4223, - 4224, 4225, 4227, 4229, 4230, 4231, 4232, 4236, 4237, 4238, 4239, 4240, 4241, 4242, 4243, 4244, 4245, 4246, 4247, - 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, 4256, 4257, 4258, 4259, 4261, 4262, 4263, 4265, 4266, 4267, 4268, - 4269, 4270, 4271, 4272, 4273, 4274, 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4288, - 4289, 4292, 4293, 4295, 4297, 4298, 4299, 4300, 4301, 4302, 4303, 4304, 4306, 4307, 4308, 4309, 4310, 4311, 4312, - 4313, 4314, 4315, 4316, 4317, 4318, 4319, 4322, 4324, 4326, 4600, 4601, 4602, 4603, 4604, 4605, 4606, 4607, 4608, - 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626, 4627, - 4628, 4629, 4630, 4632, 4633, 4636, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4646, 4657, 4658, 4659, 4660, - 4661, 4662, 4663, 4664, 4665, 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4676, 4677, 4678, 4679, - 4680, 4682, 4683, 4684, 4686, 4687, 4688, 4689, 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, - 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716, 4717, 4718, 4719, - 4720, 4721, 4722, 4723, 4724, 4725, 4726, 4727, 4728, 4729, 4730, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, - 4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747, 4748, 4749, 4750, 4751, 4752, 4753, 4754, 4755, 4756, 4757, 4758, - 4801, 4802, 4803, 4804, 4805, 4806, 4807, 4808, 4809, 4810, 4811, 4813, 4814, 4815, 4816, 4817, 4818, 4820, 4821, - 4895, 4898, 4900, 4901, 4902, 4903, 4904, 4907, 4909, 4921, 4923, 4925, 4927, 4929, 4931, 4933, 4935, 4937, 4939, - 4941, 4943, 4945, 4947, 4949, 4951, 4953, 4955, 4957, 4959, 4961, 4963, 4965, 4967, 4971, 4973, 4975, 4977, 4979, - 4981, 4983, 4985, 4987, 4989, 4991, 4993, 4995, 4997, 4999, 7843, 7844, 104001 - ]; + valid_srids integer[]; lat float8; - BEGIN + BEGIN + -- Call the function to retrieve the valid SRIDs + SELECT sys.get_valid_srids() INTO valid_srids; srid := $2; -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) geom = (SELECT sys.stgeogfromtext_helper($1, $2)); @@ -506,7 +505,7 @@ CREATE OR REPLACE FUNCTION sys.Geography__stgeomfromtext(text, integer) -- 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) IF (SELECT sys.ST_Zmflag(geom)) = 1 OR (SELECT sys.ST_Zmflag(geom)) = 2 OR (SELECT sys.ST_Zmflag(geom)) = 3 THEN - RAISE EXCEPTION 'Z and M flags are currently not supported in Babelfish'; + RAISE EXCEPTION 'Z and M flags are currently not supported'; ELSE RETURN (SELECT sys.Geography__STFlipCoordinates(geom)); END IF; @@ -516,7 +515,7 @@ CREATE OR REPLACE FUNCTION sys.Geography__stgeomfromtext(text, integer) RAISE EXCEPTION 'Inavalid SRID'; END IF; ELSE - RAISE EXCEPTION '% is currently not supported in Babelfish', Geomtype; + RAISE EXCEPTION '% is currently not supported', Geomtype; END IF; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; @@ -542,30 +541,10 @@ CREATE OR REPLACE FUNCTION sys.Geography__Point(float8, float8, srid integer) DECLARE srid integer; lat float8; - valid_srids integer[] := ARRAY[ - 4120, 4121, 4122, 4123, 4124, 4127, 4128, 4129, 4130, 4131, 4132, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4141, - 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160, - 4161, 4162, 4163, 4164, 4165, 4166, 4167, 4168, 4169, 4170, 4171, 4173, 4174, 4175, 4176, 4178, 4179, 4180, 4181, - 4182, 4183, 4184, 4188, 4189, 4190, 4191, 4192, 4193, 4194, 4195, 4196, 4197, 4198, 4199, 4200, 4201, 4202, 4203, - 4204, 4205, 4206, 4207, 4208, 4209, 4210, 4211, 4212, 4213, 4214, 4215, 4216, 4218, 4219, 4220, 4221, 4222, 4223, - 4224, 4225, 4227, 4229, 4230, 4231, 4232, 4236, 4237, 4238, 4239, 4240, 4241, 4242, 4243, 4244, 4245, 4246, 4247, - 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, 4256, 4257, 4258, 4259, 4261, 4262, 4263, 4265, 4266, 4267, 4268, - 4269, 4270, 4271, 4272, 4273, 4274, 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4288, - 4289, 4292, 4293, 4295, 4297, 4298, 4299, 4300, 4301, 4302, 4303, 4304, 4306, 4307, 4308, 4309, 4310, 4311, 4312, - 4313, 4314, 4315, 4316, 4317, 4318, 4319, 4322, 4324, 4326, 4600, 4601, 4602, 4603, 4604, 4605, 4606, 4607, 4608, - 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626, 4627, - 4628, 4629, 4630, 4632, 4633, 4636, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4646, 4657, 4658, 4659, 4660, - 4661, 4662, 4663, 4664, 4665, 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4676, 4677, 4678, 4679, - 4680, 4682, 4683, 4684, 4686, 4687, 4688, 4689, 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, - 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716, 4717, 4718, 4719, - 4720, 4721, 4722, 4723, 4724, 4725, 4726, 4727, 4728, 4729, 4730, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, - 4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747, 4748, 4749, 4750, 4751, 4752, 4753, 4754, 4755, 4756, 4757, 4758, - 4801, 4802, 4803, 4804, 4805, 4806, 4807, 4808, 4809, 4810, 4811, 4813, 4814, 4815, 4816, 4817, 4818, 4820, 4821, - 4895, 4898, 4900, 4901, 4902, 4903, 4904, 4907, 4909, 4921, 4923, 4925, 4927, 4929, 4931, 4933, 4935, 4937, 4939, - 4941, 4943, 4945, 4947, 4949, 4951, 4953, 4955, 4957, 4959, 4961, 4963, 4965, 4967, 4971, 4973, 4975, 4977, 4979, - 4981, 4983, 4985, 4987, 4989, 4991, 4993, 4995, 4997, 4999, 7843, 7844, 104001 - ]; + valid_srids integer[]; BEGIN + -- Call the function to retrieve the valid SRIDs + SELECT sys.get_valid_srids() INTO valid_srids; srid := $3; lat := $1; IF srid = ANY(valid_srids) AND lat >= -90.0 AND lat <= 90.0 THEN @@ -596,31 +575,11 @@ CREATE OR REPLACE FUNCTION sys.Geography__STPointFromText(text, integer) srid integer; Geomtype text; geom sys.GEOGRAPHY; - valid_srids integer[] := ARRAY[ - 4120, 4121, 4122, 4123, 4124, 4127, 4128, 4129, 4130, 4131, 4132, 4133, 4134, 4135, 4136, 4137, 4138, 4139, 4141, - 4142, 4143, 4144, 4145, 4146, 4147, 4148, 4149, 4150, 4151, 4152, 4153, 4154, 4155, 4156, 4157, 4158, 4159, 4160, - 4161, 4162, 4163, 4164, 4165, 4166, 4167, 4168, 4169, 4170, 4171, 4173, 4174, 4175, 4176, 4178, 4179, 4180, 4181, - 4182, 4183, 4184, 4188, 4189, 4190, 4191, 4192, 4193, 4194, 4195, 4196, 4197, 4198, 4199, 4200, 4201, 4202, 4203, - 4204, 4205, 4206, 4207, 4208, 4209, 4210, 4211, 4212, 4213, 4214, 4215, 4216, 4218, 4219, 4220, 4221, 4222, 4223, - 4224, 4225, 4227, 4229, 4230, 4231, 4232, 4236, 4237, 4238, 4239, 4240, 4241, 4242, 4243, 4244, 4245, 4246, 4247, - 4248, 4249, 4250, 4251, 4252, 4253, 4254, 4255, 4256, 4257, 4258, 4259, 4261, 4262, 4263, 4265, 4266, 4267, 4268, - 4269, 4270, 4271, 4272, 4273, 4274, 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4288, - 4289, 4292, 4293, 4295, 4297, 4298, 4299, 4300, 4301, 4302, 4303, 4304, 4306, 4307, 4308, 4309, 4310, 4311, 4312, - 4313, 4314, 4315, 4316, 4317, 4318, 4319, 4322, 4324, 4326, 4600, 4601, 4602, 4603, 4604, 4605, 4606, 4607, 4608, - 4609, 4610, 4611, 4612, 4613, 4614, 4615, 4616, 4617, 4618, 4619, 4620, 4621, 4622, 4623, 4624, 4625, 4626, 4627, - 4628, 4629, 4630, 4632, 4633, 4636, 4637, 4638, 4639, 4640, 4641, 4642, 4643, 4644, 4646, 4657, 4658, 4659, 4660, - 4661, 4662, 4663, 4664, 4665, 4666, 4667, 4668, 4669, 4670, 4671, 4672, 4673, 4674, 4675, 4676, 4677, 4678, 4679, - 4680, 4682, 4683, 4684, 4686, 4687, 4688, 4689, 4690, 4691, 4692, 4693, 4694, 4695, 4696, 4697, 4698, 4699, 4700, - 4701, 4702, 4703, 4704, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716, 4717, 4718, 4719, - 4720, 4721, 4722, 4723, 4724, 4725, 4726, 4727, 4728, 4729, 4730, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, - 4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747, 4748, 4749, 4750, 4751, 4752, 4753, 4754, 4755, 4756, 4757, 4758, - 4801, 4802, 4803, 4804, 4805, 4806, 4807, 4808, 4809, 4810, 4811, 4813, 4814, 4815, 4816, 4817, 4818, 4820, 4821, - 4895, 4898, 4900, 4901, 4902, 4903, 4904, 4907, 4909, 4921, 4923, 4925, 4927, 4929, 4931, 4933, 4935, 4937, 4939, - 4941, 4943, 4945, 4947, 4949, 4951, 4953, 4955, 4957, 4959, 4961, 4963, 4965, 4967, 4971, 4973, 4975, 4977, 4979, - 4981, 4983, 4985, 4987, 4989, 4991, 4993, 4995, 4997, 4999, 7843, 7844, 104001 - ]; + valid_srids integer[]; lat float8; BEGIN + -- Call the function to retrieve the valid SRIDs + SELECT sys.get_valid_srids() INTO valid_srids; srid := $2; -- Here we are flipping the coordinates since Geography Datatype stores the point from STGeomFromText and STPointFromText in Reverse Order i.e. (long, lat) geom = (SELECT sys.stgeogfromtext_helper($1, $2)); @@ -631,7 +590,7 @@ CREATE OR REPLACE FUNCTION sys.Geography__STPointFromText(text, integer) -- 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) IF (SELECT sys.ST_Zmflag(geom)) = 1 OR (SELECT sys.ST_Zmflag(geom)) = 2 OR (SELECT sys.ST_Zmflag(geom)) = 3 THEN - RAISE EXCEPTION 'Z and M flags are currently not supported in Babelfish'; + RAISE EXCEPTION 'Z and M flags are currently not supported'; ELSE RETURN (SELECT sys.Geography__STFlipCoordinates(geom)); END IF; @@ -641,7 +600,7 @@ CREATE OR REPLACE FUNCTION sys.Geography__STPointFromText(text, integer) RAISE EXCEPTION 'Inavalid SRID'; END IF; ELSE - RAISE EXCEPTION '% is currently not supported in Babelfish', Geomtype; + RAISE EXCEPTION '% is currently not supported', Geomtype; END IF; END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdsrpc.c b/contrib/babelfishpg_tds/src/backend/tds/tdsrpc.c index fa2918e143..64aeab3797 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdsrpc.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdsrpc.c @@ -1800,26 +1800,30 @@ ReadParameters(TDSRequestSP request, uint64_t offset, StringInfo message, int *p temp->maxLen = len; - /* We are reading the type name for spatial datatypes (geometry or geography) */ + /* Read the type name for the given CLR-UDT */ memcpy(&typenamelen, &message->data[offset], sizeof(typenamelen)); offset += sizeof(typenamelen); TdsUTF16toUTF8StringInfo(&typeName, &(message->data[offset]), 2*typenamelen); offset += 2*typenamelen; - if(!(pg_strcasecmp(typeName.data, "geometry") == 0 || pg_strcasecmp(typeName.data, "geography") == 0)){ + if (!(pg_strcasecmp(typeName.data, "geometry") == 0 || pg_strcasecmp(typeName.data, "geography") == 0)) + { ereport(ERROR, - (errcode(ERRCODE_PROTOCOL_VIOLATION), + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. " "UdtTypeName is incorrect."))); } - /* we set the column metadata for the appropriate types and also set TDS type from CLRUDT type to respective geometry or geography type */ - if(pg_strcasecmp(typeName.data, "geometry") == 0){ + /* Set column metadata for given CLR-UDT type depending upon the underlying typename. */ + if (pg_strcasecmp(typeName.data, "geometry") == 0) + { SetColMetadataForGeometryType(&temp->paramMeta, tdsType, TDS_MAXLEN_POINT, "", "geometry"); temp->type = TDS_TYPE_GEOMETRY; tdsType = TDS_TYPE_GEOMETRY; - }else{ + } + else + { SetColMetadataForGeographyType(&temp->paramMeta, tdsType, TDS_MAXLEN_POINT, "", "geography"); temp->type = TDS_TYPE_GEOGRAPHY; tdsType = TDS_TYPE_GEOGRAPHY; diff --git a/contrib/babelfishpg_tds/src/backend/tds/tdstypeio.c b/contrib/babelfishpg_tds/src/backend/tds/tdstypeio.c index 649e2e6fce..fd1b12276c 100644 --- a/contrib/babelfishpg_tds/src/backend/tds/tdstypeio.c +++ b/contrib/babelfishpg_tds/src/backend/tds/tdstypeio.c @@ -51,6 +51,8 @@ #define TDS_RETURN_DATUM(x) return ((Datum) (x)) #define VARCHAR_MAX 2147483647 +/* TODO: need to add for other geometry types when introduced */ +#define POINTTYPE 1 #define GetPgOid(pgTypeOid, finfo) \ do { \ @@ -1454,42 +1456,48 @@ Datum TdsTypeSpatialToDatum(StringInfo buf) { bytea *result; - int nbytes; - int loopVar; + int nbytes, + npoints; + StringInfoData destBuf; + initStringInfo(&destBuf); /* * Here the incoming buf format is -> 4 Byte SRID + 2 Byte Geometry Type + (16 Bytes)*npoints * But Driver expects -> 4 Byte SRID + 4 Byte Type + 4 Byte npoints + (16 Bytes)*npoints - * so we first shift (16 Bytes)*npoints by 6 Bytes and handle the remaining in between bytes */ - for (loopVar = buf->len - 1; loopVar >= buf->cursor + 6; loopVar--) { - buf->data[loopVar + 6] = buf->data[loopVar]; - } - + /* We are copying first 4 Byte SRID from buf */ + appendBinaryStringInfo(&destBuf, buf->data + buf->cursor, 4); + + npoints = (buf->len - buf->cursor - 6)/16; nbytes = buf->len - buf->cursor + 6; result = (bytea *) palloc0(nbytes + VARHDRSZ); SET_VARSIZE(result, nbytes + VARHDRSZ); /* Here we are handling the 8 bytes (4 Byte Type + 4 Byte npoints) which driver expects for 2-D point */ - if (buf->data[buf->cursor + 4] == 1 && buf->data[buf->cursor + 5] == 12) { - - buf->data[buf->cursor + 4] = 0x01; - buf->data[buf->cursor + 5] = 0x00; - buf->data[buf->cursor + 6] = 0x00; - buf->data[buf->cursor + 7] = 0x00; - - buf->data[buf->cursor + 8] = 0x01; - buf->data[buf->cursor + 9] = 0x00; - buf->data[buf->cursor + 10] = 0x00; - buf->data[buf->cursor + 11] = 0x00; - } else { + if (buf->data[buf->cursor + 4] == 1 && buf->data[buf->cursor + 5] == 12) + { + appendStringInfoChar(&destBuf, POINTTYPE & 0xFF); + appendStringInfoChar(&destBuf, (POINTTYPE >> 8) & 0xFF); + appendStringInfoChar(&destBuf, (POINTTYPE >> 16) & 0xFF); + appendStringInfoChar(&destBuf, (POINTTYPE >> 24) & 0xFF); + + appendStringInfoChar(&destBuf, npoints & 0xFF); + appendStringInfoChar(&destBuf, (npoints >> 8) & 0xFF); + appendStringInfoChar(&destBuf, (npoints >> 16) & 0xFF); + appendStringInfoChar(&destBuf, (npoints >> 24) & 0xFF); + } + else + { ereport(ERROR, - (errcode(ERRCODE_INTERNAL_ERROR), + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("Currently Only 2-D Point Type is Supported in BabelFish!"))); } - memcpy(VARDATA(result), &buf->data[buf->cursor], nbytes); - buf->cursor += nbytes; + /* We are copying the remaining bytes (16 Bytes)*npoints from buf */ + appendBinaryStringInfo(&destBuf, buf->data + buf->cursor + 6, buf->len - 6); + + memcpy(VARDATA(result), &destBuf.data, nbytes); + buf->cursor += nbytes - 6; PG_RETURN_BYTEA_P(result); } @@ -4215,12 +4223,16 @@ TdsSendSpatialHelper(FmgrInfo *finfo, Datum value, void *vMetaData, int TdsInstr /* Driver Expects 01 0C for 2-D Point Type as 2 constant Bytes to identify the Geometry Type */ /* TODO: Will need to introduce for Different Geometry Data Types */ - if(*((uint32_t*)gser->data) == 1) + switch (*((uint32_t*)gser->data)) { - *itr = 1; - itr++; - *itr = 12; - itr++; + case 1: + *itr = 1; + itr++; + *itr = 12; + itr++; + break; + default: + elog(ERROR, "Currently only 2-D point datatype is supported in babelfish!"); } /* Data part of the Row has length 16 * (No. of Points) */ diff --git a/contrib/babelfishpg_tds/src/include/tds_iofuncmap.h b/contrib/babelfishpg_tds/src/include/tds_iofuncmap.h index 93e5355530..5726cddc60 100644 --- a/contrib/babelfishpg_tds/src/include/tds_iofuncmap.h +++ b/contrib/babelfishpg_tds/src/include/tds_iofuncmap.h @@ -117,9 +117,9 @@ #define TDS_TYPE_SQLVARIANT 98 /* 0x62 */ #define TDS_TYPE_DATETIMEOFFSET 43 /* 0x2B */ #define TDS_TYPE_SMALLDATETIME 58 /* 0x3A */ -#define TDS_TYPE_CLRUDT 240 /* 0xF0 */ -#define TDS_TYPE_GEOMETRY 254 /* 0xFE */ -#define TDS_TYPE_GEOGRAPHY 255 /* 0xFF */ +#define TDS_TYPE_CLRUDT 240 /* 0xF0 */ +#define TDS_TYPE_GEOMETRY 254 /* 0xFE */ +#define TDS_TYPE_GEOGRAPHY 255 /* 0xFF */ /* * macros for supporting sqlvariant datatype on TDS side diff --git a/test/JDBC/expected/TestPoint-vu-cleanup.out b/test/JDBC/expected/TestPoint-vu-cleanup.out deleted file mode 100644 index 6ca352cddb..0000000000 --- a/test/JDBC/expected/TestPoint-vu-cleanup.out +++ /dev/null @@ -1,5 +0,0 @@ -DROP TABLE IF EXISTS POINTGEOM_dt; - -DROP TABLE IF EXISTS POINTGEOG_dt; - -DROP TABLE IF EXISTS POINT_dt; diff --git a/test/JDBC/expected/TestPoint-vu-prepare.out b/test/JDBC/expected/TestPoint-vu-prepare.out deleted file mode 100644 index 0ec57772bd..0000000000 --- a/test/JDBC/expected/TestPoint-vu-prepare.out +++ /dev/null @@ -1,133 +0,0 @@ -CREATE TABLE POINTGEOM_dt(location GEOMETRY); -prepst#!#INSERT INTO POINTGEOM_dt(location) values(?) #!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):4326 -~~ROW COUNT: 1~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0):4326 -~~ROW COUNT: 1~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):0 -~~ROW COUNT: 1~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):1000000000 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geometry.)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):-1 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geometry.)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900): -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geometry.)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 ):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geometry.)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|LINESTRING(1 2, 3 4):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -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: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|:4326 -~~ERROR (Code: 0)~~ - -~~ERROR (Message: Illegal character in Well-Known text at position 0.)~~ - -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -CREATE TABLE POINTGEOG_dt(location GEOGRAPHY); -prepst#!#INSERT INTO POINTGEOG_dt(location) values(?) #!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):4326 -~~ROW COUNT: 1~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0):4326 -~~ROW COUNT: 1~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):0 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -122.34900):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):1000000000 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):-1 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900): -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 ):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|LINESTRING(1 2, 3 4):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -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: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|:4326 -~~ERROR (Code: 0)~~ - -~~ERROR (Message: Illegal character in Well-Known text at position 0.)~~ - -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -CREATE TABLE POINT_dt(geom GEOMETRY, geog GEOGRAPHY); -prepst#!#INSERT INTO POINT_dt(geom) values(?) #!#GEOMETRY|-|geom|-|Point(47.65100 -22.34900):4326 -~~ROW COUNT: 1~~ - -prepst#!#INSERT INTO POINT_dt(geog) values(?) #!#GEOGRAPHY|-|geog|-|Point(47.65100 -22.34900):4326 -~~ROW COUNT: 1~~ - -prepst#!#INSERT INTO POINT_dt(geom, geog) values(?, ?) #!#GEOMETRY|-|geom|-|Point(1.0 2.0):4326#!#GEOGRAPHY|-|geog|-|Point(1.0 2.0):4326 -~~ROW COUNT: 1~~ - diff --git a/test/JDBC/expected/TestPoint-vu-verify.out b/test/JDBC/expected/TestPoint-vu-verify.out deleted file mode 100644 index 061a43a54d..0000000000 --- a/test/JDBC/expected/TestPoint-vu-verify.out +++ /dev/null @@ -1,25 +0,0 @@ -SELECT location FROM POINTGEOM_dt; -~~START~~ -geometry -E6100000010C17D9CEF753D34740D34D6210585936C0 -E6100000010C000000000000F03F0000000000000040 -00000000010C17D9CEF753D34740D34D6210585936C0 -~~END~~ - - -SELECT location FROM POINTGEOG_dt; -~~START~~ -geography -E6100000010CD34D6210585936C017D9CEF753D34740 -E6100000010C0000000000000040000000000000F03F -~~END~~ - - -SELECT * FROM POINT_dt; -~~START~~ -geometry#!#geography -E6100000010C17D9CEF753D34740D34D6210585936C0#!# -#!#E6100000010CD34D6210585936C017D9CEF753D34740 -E6100000010C000000000000F03F0000000000000040#!#E6100000010C0000000000000040000000000000F03F -~~END~~ - diff --git a/test/JDBC/expected/TestPoint.out b/test/JDBC/expected/TestPoint.out deleted file mode 100644 index 98a083d44a..0000000000 --- a/test/JDBC/expected/TestPoint.out +++ /dev/null @@ -1,161 +0,0 @@ -CREATE TABLE POINTGEOM_dt(location GEOMETRY); -prepst#!#INSERT INTO POINTGEOM_dt(location) values(?) #!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):4326 -~~ROW COUNT: 1~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0):4326 -~~ROW COUNT: 1~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):0 -~~ROW COUNT: 1~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):1000000000 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geometry.)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):-1 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geometry.)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900): -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geometry.)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 ):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geometry.)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|LINESTRING(1 2, 3 4):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -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: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -prepst#!#exec#!#GEOMETRY|-|location|-|:4326 -~~ERROR (Code: 0)~~ - -~~ERROR (Message: Illegal character in Well-Known text at position 0.)~~ - -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -CREATE TABLE POINTGEOG_dt(location GEOGRAPHY); -prepst#!#INSERT INTO POINTGEOG_dt(location) values(?) #!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):4326 -~~ROW COUNT: 1~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0):4326 -~~ROW COUNT: 1~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):0 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -122.34900):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):1000000000 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):-1 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900): -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 ):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Error converting data type varbinary to geography.)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|LINESTRING(1 2, 3 4):4326 -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -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: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -prepst#!#exec#!#GEOGRAPHY|-|location|-|:4326 -~~ERROR (Code: 0)~~ - -~~ERROR (Message: Illegal character in Well-Known text at position 0.)~~ - -~~ERROR (Code: 33557097)~~ - -~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported in Babelfish)~~ - -CREATE TABLE POINT_dt(geom GEOMETRY, geog GEOGRAPHY); -prepst#!#INSERT INTO POINT_dt(geom) values(?) #!#GEOMETRY|-|geom|-|Point(47.65100 -22.34900):4326 -~~ROW COUNT: 1~~ - -prepst#!#INSERT INTO POINT_dt(geog) values(?) #!#GEOGRAPHY|-|geog|-|Point(47.65100 -22.34900):4326 -~~ROW COUNT: 1~~ - -prepst#!#INSERT INTO POINT_dt(geom, geog) values(?, ?) #!#GEOMETRY|-|geom|-|Point(1.0 2.0):4326#!#GEOGRAPHY|-|geog|-|Point(1.0 2.0):4326 -~~ROW COUNT: 1~~ - - -SELECT location FROM POINTGEOM_dt; -~~START~~ -geometry -E6100000010C17D9CEF753D34740D34D6210585936C0 -E6100000010C000000000000F03F0000000000000040 -00000000010C17D9CEF753D34740D34D6210585936C0 -~~END~~ - -SELECT location FROM POINTGEOG_dt; -~~START~~ -geography -E6100000010CD34D6210585936C017D9CEF753D34740 -E6100000010C0000000000000040000000000000F03F -~~END~~ - -SELECT * FROM POINT_dt; -~~START~~ -geometry#!#geography -E6100000010C17D9CEF753D34740D34D6210585936C0#!# -#!#E6100000010CD34D6210585936C017D9CEF753D34740 -E6100000010C000000000000F03F0000000000000040#!#E6100000010C0000000000000040000000000000F03F -~~END~~ - - -DROP TABLE IF EXISTS POINTGEOM_dt; -DROP TABLE IF EXISTS POINTGEOG_dt; -DROP TABLE IF EXISTS POINT_dt; diff --git a/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out b/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out index d2f24215ac..5ad69e2c46 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-cleanup.out @@ -1,41 +1,27 @@ DROP VIEW IF EXISTS TextFromGeom -GO DROP VIEW IF EXISTS BinaryFromGeom -GO DROP VIEW IF EXISTS CoordsFromGeom -GO DROP VIEW IF EXISTS point_distances_geom -GO DROP VIEW IF EXISTS TextFromGeog -GO DROP VIEW IF EXISTS BinaryFromGeog -GO DROP VIEW IF EXISTS CoordsFromGeog -GO DROP VIEW IF EXISTS TransformFromGeog -GO DROP VIEW IF EXISTS point_distances_geog -GO DROP TABLE IF EXISTS SPATIALPOINTGEOM_dt -GO DROP TABLE IF EXISTS TypeTable -GO DROP TYPE IF EXISTS geom -GO DROP TABLE IF EXISTS SPATIALPOINTGEOG_dt -GO DROP TABLE IF EXISTS SPATIALPOINT_dt -GO diff --git a/test/JDBC/expected/TestSpatialPoint-vu-prepare.out b/test/JDBC/expected/TestSpatialPoint-vu-prepare.out index 57accc8c64..53cd7e0aa0 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-prepare.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-prepare.out @@ -1,334 +1,378 @@ CREATE TABLE SPATIALPOINTGEOM_dt (location geometry) -GO +#Geometry Test Cases --- Geometry Test Cases --- Positive Test for STGeomFromText with SRID 4326 -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) -GO +#Positive Test for STGeomFromText with SRID 4326 +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) ~~ROW COUNT: 1~~ -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(1.0 2.0)', 4326) ) -GO + +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(1.0 2.0)', 4326) ) ~~ROW COUNT: 1~~ --- Positive Test for STGeomFromText with SRID 0 -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 0) ) -GO +#Positive Test for STGeomFromText with SRID 0 +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 0) ) ~~ROW COUNT: 1~~ --- Negative Test for STGeomFromText when SRID is not provided -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)') ) -GO +#Negative Test for STGeomFromText when SRID is not provided +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)') ) ~~ERROR (Code: 8146)~~ ~~ERROR (Message: function geometry__stgeomfromtext has no parameters and arguments were supplied.)~~ --- Negative Test for STGeomFromText when SRID >= 10^6 --- SRID should be between 0 to 999999 -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 1000000000 ) ) -GO +#Negative Test for STGeomFromText when SRID >= 10^6 +#SRID should be between 0 to 999999 +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 1000000000 ) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: SRID value should be between 0 and 999999)~~ --- Negative Test for STGeomFromText with SRID < 0 --- SRID should be between 0 to 999999 -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', -1) ) -GO +#Negative Test for STGeomFromText with SRID < 0 +#SRID should be between 0 to 999999 +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', -1) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: SRID value should be between 0 and 999999)~~ --- Negative Test for STGeomFromText when a coordinate is missing -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(1.0 )', 4326) ) -GO +#Negative Test for STGeomFromText when a coordinate is missing +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(1.0 )', 4326) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: parse error - invalid geometry)~~ --- Negative Test for STGeomFromText when invalid type is provided -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Pnt', 4326) ) -GO +#Negative Test for STGeomFromText when invalid type is provided +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Pnt', 4326) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: parse error - invalid geometry)~~ --- Test for STGeomFromText when null Point is Given -> Returns NBCRow -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText(null, 4326) ) -GO +#Test for STGeomFromText when null Point is Given -> Returns NBCRow +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText(null, 4326) ) ~~ROW COUNT: 1~~ +#Negative Test for STGeomFromText when Incorrect cast is provided +#INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) --- -- Negative Test for STGeomFromText when Incorrect cast is provided --- INSERT INTO SPATIALPOINTGEOM_dt (location) --- VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) --- GO --- Positive Test for STPointFromText with SRID 4326. Rest are same as STGeomFromText -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STPointFromText('Point(47.65100 -22.34900)', 4326) ) -GO +#Positive Test for STPointFromText with SRID 4326. Rest are same as STGeomFromText +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STPointFromText('Point(47.65100 -22.34900)', 4326) ) ~~ROW COUNT: 1~~ -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STPointFromText('Point(1.0 2.0)', 4326) ) -GO + +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STPointFromText('Point(1.0 2.0)', 4326) ) ~~ROW COUNT: 1~~ --- Positive Test for Point with SRID 4326 -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::Point(47.65100, -22.34900, 4326) ) -GO + +#Positive Test for Point with SRID 4326 +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::Point(47.65100, -22.34900, 4326) ) ~~ROW COUNT: 1~~ -CREATE VIEW TextFromGeom AS -SELECT STAsText(location) AS TextRepresentation -FROM SPATIALPOINTGEOM_dt; -GO - -CREATE VIEW BinaryFromGeom AS -SELECT STAsBinary(location) AS BinaryRepresentation -FROM SPATIALPOINTGEOM_dt; -GO - -CREATE VIEW CoordsFromGeom AS -SELECT STX(location), STY(location) AS Coordinates -FROM SPATIALPOINTGEOM_dt; -GO - -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; -GO +#Tests for Geometry type Prepared Statements +prepst#!#INSERT INTO SPATIALPOINTGEOM_dt(location) values(?) #!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):4326 +~~ROW COUNT: 1~~ + +prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0):4326 +~~ROW COUNT: 1~~ + +prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):0 +~~ROW COUNT: 1~~ + +#Negative Test for STGeomFromText when SRID >= 10^6 +prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):1000000000 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Error converting data type varbinary to geometry.)~~ + +#Negative Test for STGeomFromText with SRID < 0 +prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):-1 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Error converting data type varbinary to geometry.)~~ + +#Negative Test for STGeomFromText when SRID is NULL +prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900): +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Error converting data type varbinary to geometry.)~~ + +#Negative Test for STGeomFromText when a coordinate is missing +prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 ):4326 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Error converting data type varbinary to geometry.)~~ + +#Negative Test when an unsupported feature in queried +prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported)~~ + +prepst#!#exec#!#GEOMETRY|-|location|-|LINESTRING(1 2, 3 4):4326 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported)~~ + +#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: Currently only Point Type(without Z and M flags) is Supported)~~ + +#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: Currently only Point Type(without Z and M flags) is Supported)~~ + + +CREATE VIEW TextFromGeom AS SELECT STAsText(location) AS TextRepresentation FROM SPATIALPOINTGEOM_dt; + +CREATE VIEW BinaryFromGeom AS SELECT STAsBinary(location) AS BinaryRepresentation FROM SPATIALPOINTGEOM_dt; + +CREATE VIEW CoordsFromGeom AS SELECT STX(location), STY(location) AS Coordinates FROM SPATIALPOINTGEOM_dt; + +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) -GO --- Create Type Test Case currently Babelfish supports it but TSQL doesn't for spatial Types, Although it doesn't break anything --- TODO: Make it similar to T-SQL -CREATE TYPE geom -FROM geometry NOT NULL ; -GO +#Create Type Test Case currently Babelfish supports it but TSQL doesn't for spatial Types, Although it doesn't break anything +#TODO: Make it similar to T-SQL +CREATE TYPE geom FROM geometry NOT NULL ; CREATE TABLE TypeTable(ID INT PRIMARY KEY, Shape geom) -GO -INSERT INTO TypeTable(ID, Shape) -VALUES(1, geometry::Point(1, 2, 4326)); -GO +INSERT INTO TypeTable(ID, Shape) VALUES(1, geometry::Point(1, 2, 4326)); ~~ROW COUNT: 1~~ +#Geography Test Cases --- Geography Test Cases --- Positive Test for STGeomFromText with SRID 4326 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) -GO +#Positive Test for STGeomFromText with SRID 4326 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) ~~ROW COUNT: 1~~ -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(1.0 2.0)', 4326) ) -GO + +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(1.0 2.0)', 4326) ) ~~ROW COUNT: 1~~ --- Negative Test for STGeomFromText for Geography with SRID 0 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 0) ) -GO +#Negative Test for STGeomFromText for Geography with SRID 0 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 0) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: Inavalid SRID)~~ --- Negative Test for STGeomFromText for Geography when lat > 90 or < -90 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -122.34900)', 4326) ) -GO +#Negative Test for STGeomFromText for Geography when lat > 90 or < -90 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -122.34900)', 4326) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: Latitude values must be between -90 and 90 degrees)~~ --- Negative Test for STGeomFromText when SRID is not provided -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)') ) -GO +#Negative Test for STGeomFromText when SRID is not provided +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)') ) ~~ERROR (Code: 8146)~~ ~~ERROR (Message: function geography__stgeomfromtext has no parameters and arguments were supplied.)~~ --- Negative Test for STGeomFromText when cast is not provided -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( STGeomFromText('Point(47.65100 -22.34900)', 4326) ) -GO +#Negative Test for STGeomFromText when cast is not provided +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( STGeomFromText('Point(47.65100 -22.34900)', 4326) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: function stgeomfromtext(unknown, integer) does not exist)~~ +#Negative Test for STGeomFromText when incorrect cast is provided +#INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) --- -- Negative Test for STGeomFromText when incorrect cast is provided --- INSERT INTO SPATIALPOINTGEOG_dt (location) --- VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) --- GO --- Negative Test for STGeomFromText when SRID >= 10^6 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 1000000000 ) ) -GO +#Negative Test for STGeomFromText when SRID >= 10^6 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 1000000000 ) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: Inavalid SRID)~~ --- Negative Test for STGeomFromText with SRID < 0 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', -1) ) -GO +#Negative Test for STGeomFromText with SRID < 0 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', -1) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: Inavalid SRID)~~ --- Negative Test for STGeomFromText when a coordinate is missing -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(1.0 )', 4326) ) -GO +#Negative Test for STGeomFromText when a coordinate is missing +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(1.0 )', 4326) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: parse error - invalid geometry)~~ --- Negative Test for STGeomFromText when invalid type is provided -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Pnt', 4326) ) -GO +#Negative Test for STGeomFromText when invalid type is provided +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Pnt', 4326) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: parse error - invalid geometry)~~ --- Test for STGeomFromText when null Point is Given -> Returns NBCRow -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText(null, 4326) ) -GO +#Test for STGeomFromText when null Point is Given -> Returns NBCRow +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText(null, 4326) ) ~~ROW COUNT: 1~~ --- Positive Test for STPointFromText with SRID 4326. Rest are same as STGeomFromText -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STPointFromText('Point(47.65100 -22.34900)', 4326) ) -GO +#Positive Test for STPointFromText with SRID 4326. Rest are same as STGeomFromText +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STPointFromText('Point(47.65100 -22.34900)', 4326) ) ~~ROW COUNT: 1~~ -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STPointFromText('Point(1.0 2.0)', 4326) ) -GO + +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STPointFromText('Point(1.0 2.0)', 4326) ) ~~ROW COUNT: 1~~ --- Negative Test for STPointFromText for Geography when lat > 90 or < -90 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STPointFromText('Point(47.65100 122.34900)', 4326) ) -GO +#Negative Test for STPointFromText for Geography when lat > 90 or < -90 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STPointFromText('Point(47.65100 122.34900)', 4326) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: Latitude values must be between -90 and 90 degrees)~~ --- Positive Test for Point with SRID 4326 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::Point(47.65100, -22.34900, 4326) ) -GO +#Positive Test for Point with SRID 4326 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::Point(47.65100, -22.34900, 4326) ) ~~ROW COUNT: 1~~ --- Negative Test for Point for Geography when lat > 90 or < -90 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::Point(147.65100, -22.34900, 4326) ) -GO +#Negative Test for Point for Geography when lat > 90 or < -90 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::Point(147.65100, -22.34900, 4326) ) ~~ERROR (Code: 33557097)~~ ~~ERROR (Message: Latitude values must be between -90 and 90 degrees)~~ -CREATE VIEW TextFromGeog AS -SELECT STAsText(location) AS TextRepresentation -FROM SPATIALPOINTGEOG_dt; -GO - -CREATE VIEW BinaryFromGeog AS -SELECT STAsBinary(location) AS BinaryRepresentation -FROM SPATIALPOINTGEOG_dt; -GO - -CREATE VIEW CoordsFromGeog AS -SELECT long(location), lat(location) AS Coordinates -FROM SPATIALPOINTGEOG_dt; -GO - - -CREATE VIEW TransformFromGeog AS -SELECT ST_Transform(location, 4326) AS Modified_points -FROM SPATIALPOINTGEOG_dt; -GO - -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; -GO +#Tests for Geography type Prepared Statements +prepst#!#INSERT INTO SPATIALPOINTGEOG_dt(location) values(?) #!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):4326 +~~ROW COUNT: 1~~ + +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0):4326 +~~ROW COUNT: 1~~ + +#Negative Test for STGeomFromText for Geography with SRID 0 +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):0 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Error converting data type varbinary to geography.)~~ + +#Negative Test for STGeomFromText for Geography when lat > 90 or < -90 +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -122.34900):4326 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Error converting data type varbinary to geography.)~~ + +#Negative Test for STGeomFromText when SRID >= 10^6 +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):1000000000 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Error converting data type varbinary to geography.)~~ + +#Negative Test for STGeomFromText with SRID < 0 +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):-1 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Error converting data type varbinary to geography.)~~ + +#Negative Test for STGeomFromText with SRID is NULL +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900): +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Error converting data type varbinary to geography.)~~ + +#Negative Test for STGeomFromText when a coordinate is missing +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 ):4326 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Error converting data type varbinary to geography.)~~ + +#Negative Test when an unsupported feature in queried +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported)~~ + +prepst#!#exec#!#GEOGRAPHY|-|location|-|LINESTRING(1 2, 3 4):4326 +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Currently only Point Type(without Z and M flags) is Supported)~~ + +#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: Currently only Point Type(without Z and M flags) is Supported)~~ + +#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: Currently only Point Type(without Z and M flags) is Supported)~~ + + +CREATE VIEW TextFromGeog AS SELECT STAsText(location) AS TextRepresentation FROM SPATIALPOINTGEOG_dt; + +CREATE VIEW BinaryFromGeog AS SELECT STAsBinary(location) AS BinaryRepresentation FROM SPATIALPOINTGEOG_dt; + +CREATE VIEW CoordsFromGeog AS SELECT long(location), lat(location) AS Coordinates FROM SPATIALPOINTGEOG_dt; + + +CREATE VIEW TransformFromGeog AS SELECT ST_Transform(location, 4326) AS Modified_points FROM SPATIALPOINTGEOG_dt; + +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; CREATE TABLE SPATIALPOINT_dt (PrimaryKey int, GeomColumn geometry, GeogColumn geography) -GO -INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeomColumn) -VALUES ( 1, geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) -GO + +INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeomColumn) VALUES ( 1, geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) +~~ROW COUNT: 1~~ + + +INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeogColumn) VALUES ( 2, geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) +~~ROW COUNT: 1~~ + + +INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeomColumn, GeogColumn) VALUES ( 3, geometry::STGeomFromText('Point(1.0 2.0)', 4326), geography::STGeomFromText('Point(1.0 2.0)', 4326) ) +~~ROW COUNT: 1~~ + + + +#Tests for Spatial type Prepared Statements +prepst#!#INSERT INTO SPATIALPOINT_dt(PrimaryKey, GeomColumn) values(?, ?) #!#int|-|PrimaryKey|-|4#!#GEOMETRY|-|GeomColumn|-|Point(47.65100 -22.34900):4326 ~~ROW COUNT: 1~~ -INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeogColumn) -VALUES ( 2, geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) -GO +prepst#!#INSERT INTO SPATIALPOINT_dt(PrimaryKey, GeogColumn) values(?, ?) #!#int|-|PrimaryKey|-|5#!#GEOGRAPHY|-|GeogColumn|-|Point(47.65100 -22.34900):4326 ~~ROW COUNT: 1~~ -INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeomColumn, GeogColumn) -VALUES ( 3, geometry::STGeomFromText('Point(1.0 2.0)', 4326), geography::STGeomFromText('Point(1.0 2.0)', 4326) ) -GO +prepst#!#INSERT INTO SPATIALPOINT_dt(PrimaryKey, GeomColumn, GeogColumn) values(?, ?, ?) #!#int|-|PrimaryKey|-|6#!#GEOMETRY|-|GeomColumn|-|Point(1.0 2.0):4326#!#GEOGRAPHY|-|GeogColumn|-|Point(1.0 2.0):4326 ~~ROW COUNT: 1~~ diff --git a/test/JDBC/expected/TestSpatialPoint-vu-verify.out b/test/JDBC/expected/TestSpatialPoint-vu-verify.out index d1970a1633..effe3902e8 100644 --- a/test/JDBC/expected/TestSpatialPoint-vu-verify.out +++ b/test/JDBC/expected/TestSpatialPoint-vu-verify.out @@ -72,6 +72,9 @@ POINT(47.651 -22.349) POINT(47.651 -22.349) POINT(1 2) POINT(47.651 -22.349) +POINT(47.651 -22.349) +POINT(1 2) +POINT(47.651 -22.349) ~~END~~ @@ -86,6 +89,9 @@ varbinary 010100000017D9CEF753D34740D34D6210585936C0 0101000000000000000000F03F0000000000000040 010100000017D9CEF753D34740D34D6210585936C0 +010100000017D9CEF753D34740D34D6210585936C0 +0101000000000000000000F03F0000000000000040 +010100000017D9CEF753D34740D34D6210585936C0 ~~END~~ @@ -100,6 +106,9 @@ float#!#float 47.651#!#-22.349 1.0#!#2.0 47.651#!#-22.349 +47.651#!#-22.349 +1.0#!#2.0 +47.651#!#-22.349 ~~END~~ @@ -124,6 +133,9 @@ E6100000010C000000000000F03F0000000000000040 E6100000010C17D9CEF753D34740D34D6210585936C0 E6100000010C000000000000F03F0000000000000040 E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010C000000000000F03F0000000000000040 +00000000010C17D9CEF753D34740D34D6210585936C0 ~~END~~ @@ -210,6 +222,8 @@ POINT(1 2) POINT(47.651 -22.349) POINT(1 2) POINT(-22.349 47.651) +POINT(47.651 -22.349) +POINT(1 2) ~~END~~ @@ -223,6 +237,8 @@ varbinary 010100000017D9CEF753D34740D34D6210585936C0 0101000000000000000000F03F0000000000000040 0101000000D34D6210585936C017D9CEF753D34740 +010100000017D9CEF753D34740D34D6210585936C0 +0101000000000000000000F03F0000000000000040 ~~END~~ @@ -236,6 +252,8 @@ float#!#float 47.651#!#-22.349 1.0#!#2.0 -22.349#!#47.651 +47.651#!#-22.349 +1.0#!#2.0 ~~END~~ @@ -249,6 +267,8 @@ E6100000010C0000000000000040000000000000F03F E6100000010CD34D6210585936C017D9CEF753D34740 E6100000010C0000000000000040000000000000F03F E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010CD34D6210585936C017D9CEF753D34740 +E6100000010C0000000000000040000000000000F03F ~~END~~ @@ -259,19 +279,33 @@ geography#!#geography#!#float E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#5535965.307328846 +E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 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.0424362254827898E7 +E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#1.0424362254827898E7 E6100000010C17D9CEF753D34740D34D6210585936C0#!#E6100000010C0000000000000040000000000000F03F#!#5535965.307328846 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#1.0424362254827898E7 +E6100000010CD34D6210585936C017D9CEF753D34740#!#E6100000010C0000000000000040000000000000F03F#!#5736178.674863189 +E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 +E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 +E6100000010C0000000000000040000000000000F03F#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!#5535965.307328846 +E6100000010C0000000000000040000000000000F03F#!#E6100000010CD34D6210585936C017D9CEF753D34740#!#5736178.674863189 ~~END~~ @@ -285,6 +319,8 @@ E6100000010C0000000000000040000000000000F03F E6100000010CD34D6210585936C017D9CEF753D34740 E6100000010C0000000000000040000000000000F03F E6100000010C17D9CEF753D34740D34D6210585936C0 +E6100000010CD34D6210585936C017D9CEF753D34740 +E6100000010C0000000000000040000000000000F03F ~~END~~ @@ -295,5 +331,8 @@ int#!#geometry#!#geography 1#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!# 2#!##!#E6100000010CD34D6210585936C017D9CEF753D34740 3#!#E6100000010C000000000000F03F0000000000000040#!#E6100000010C0000000000000040000000000000F03F +4#!#E6100000010C17D9CEF753D34740D34D6210585936C0#!# +5#!##!#E6100000010CD34D6210585936C017D9CEF753D34740 +6#!#E6100000010C000000000000F03F0000000000000040#!#E6100000010C0000000000000040000000000000F03F ~~END~~ diff --git a/test/JDBC/input/datatypes/TestPoint-vu-cleanup.txt b/test/JDBC/input/datatypes/TestPoint-vu-cleanup.txt deleted file mode 100644 index 6ca352cddb..0000000000 --- a/test/JDBC/input/datatypes/TestPoint-vu-cleanup.txt +++ /dev/null @@ -1,5 +0,0 @@ -DROP TABLE IF EXISTS POINTGEOM_dt; - -DROP TABLE IF EXISTS POINTGEOG_dt; - -DROP TABLE IF EXISTS POINT_dt; diff --git a/test/JDBC/input/datatypes/TestPoint-vu-prepare.txt b/test/JDBC/input/datatypes/TestPoint-vu-prepare.txt deleted file mode 100644 index 5f86dd16f9..0000000000 --- a/test/JDBC/input/datatypes/TestPoint-vu-prepare.txt +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE POINTGEOM_dt(location GEOMETRY); -prepst#!#INSERT INTO POINTGEOM_dt(location) values(@location) #!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):4326 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0):4326 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):0 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):1000000000 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):-1 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900): -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 ):4326 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 -prepst#!#exec#!#GEOMETRY|-|location|-|LINESTRING(1 2, 3 4):4326 -prepst#!#exec#!#GEOMETRY|-|location|-|Pnt:4326 -prepst#!#exec#!#GEOMETRY|-|location|-|:4326 -CREATE TABLE POINTGEOG_dt(location GEOGRAPHY); -prepst#!#INSERT INTO POINTGEOG_dt(location) values(@location) #!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):0 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -122.34900):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):1000000000 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):-1 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900): -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 ):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|LINESTRING(1 2, 3 4):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Pnt:4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|:4326 -CREATE TABLE POINT_dt(geom GEOMETRY, geog GEOGRAPHY); -prepst#!#INSERT INTO POINT_dt(geom) values(@geom) #!#GEOMETRY|-|geom|-|Point(47.65100 -22.34900):4326 -prepst#!#INSERT INTO POINT_dt(geog) values(@geog) #!#GEOGRAPHY|-|geog|-|Point(47.65100 -22.34900):4326 -prepst#!#INSERT INTO POINT_dt(geom, geog) values(@geom, @geog) #!#GEOMETRY|-|geom|-|Point(1.0 2.0):4326#!#GEOGRAPHY|-|geog|-|Point(1.0 2.0):4326 diff --git a/test/JDBC/input/datatypes/TestPoint-vu-verify.txt b/test/JDBC/input/datatypes/TestPoint-vu-verify.txt deleted file mode 100644 index f182565335..0000000000 --- a/test/JDBC/input/datatypes/TestPoint-vu-verify.txt +++ /dev/null @@ -1,5 +0,0 @@ -SELECT location FROM POINTGEOM_dt; - -SELECT location FROM POINTGEOG_dt; - -SELECT * FROM POINT_dt; diff --git a/test/JDBC/input/datatypes/TestPoint.txt b/test/JDBC/input/datatypes/TestPoint.txt deleted file mode 100644 index a4fd004231..0000000000 --- a/test/JDBC/input/datatypes/TestPoint.txt +++ /dev/null @@ -1,37 +0,0 @@ -CREATE TABLE POINTGEOM_dt(location GEOMETRY); -prepst#!#INSERT INTO POINTGEOM_dt(location) values(@location) #!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):4326 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0):4326 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):0 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):1000000000 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):-1 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900): -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 ):4326 -prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 -prepst#!#exec#!#GEOMETRY|-|location|-|LINESTRING(1 2, 3 4):4326 -prepst#!#exec#!#GEOMETRY|-|location|-|Pnt:4326 -prepst#!#exec#!#GEOMETRY|-|location|-|:4326 -CREATE TABLE POINTGEOG_dt(location GEOGRAPHY); -prepst#!#INSERT INTO POINTGEOG_dt(location) values(@location) #!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):0 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -122.34900):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):1000000000 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):-1 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900): -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 ):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0 3.0 4.0):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|LINESTRING(1 2, 3 4):4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|Pnt:4326 -prepst#!#exec#!#GEOGRAPHY|-|location|-|:4326 -CREATE TABLE POINT_dt(geom GEOMETRY, geog GEOGRAPHY); -prepst#!#INSERT INTO POINT_dt(geom) values(@geom) #!#GEOMETRY|-|geom|-|Point(47.65100 -22.34900):4326 -prepst#!#INSERT INTO POINT_dt(geog) values(@geog) #!#GEOGRAPHY|-|geog|-|Point(47.65100 -22.34900):4326 -prepst#!#INSERT INTO POINT_dt(geom, geog) values(@geom, @geog) #!#GEOMETRY|-|geom|-|Point(1.0 2.0):4326#!#GEOGRAPHY|-|geog|-|Point(1.0 2.0):4326 - -SELECT location FROM POINTGEOM_dt; -SELECT location FROM POINTGEOG_dt; -SELECT * FROM POINT_dt; - -DROP TABLE IF EXISTS POINTGEOM_dt; -DROP TABLE IF EXISTS POINTGEOG_dt; -DROP TABLE IF EXISTS POINT_dt; diff --git a/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.sql b/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.txt similarity index 92% rename from test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.sql rename to test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.txt index d2f24215ac..5ad69e2c46 100644 --- a/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.sql +++ b/test/JDBC/input/datatypes/TestSpatialPoint-vu-cleanup.txt @@ -1,41 +1,27 @@ DROP VIEW IF EXISTS TextFromGeom -GO DROP VIEW IF EXISTS BinaryFromGeom -GO DROP VIEW IF EXISTS CoordsFromGeom -GO DROP VIEW IF EXISTS point_distances_geom -GO DROP VIEW IF EXISTS TextFromGeog -GO DROP VIEW IF EXISTS BinaryFromGeog -GO DROP VIEW IF EXISTS CoordsFromGeog -GO DROP VIEW IF EXISTS TransformFromGeog -GO DROP VIEW IF EXISTS point_distances_geog -GO DROP TABLE IF EXISTS SPATIALPOINTGEOM_dt -GO DROP TABLE IF EXISTS TypeTable -GO DROP TYPE IF EXISTS geom -GO DROP TABLE IF EXISTS SPATIALPOINTGEOG_dt -GO DROP TABLE IF EXISTS SPATIALPOINT_dt -GO diff --git a/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.sql b/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.sql deleted file mode 100644 index bf044fe4eb..0000000000 --- a/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.sql +++ /dev/null @@ -1,240 +0,0 @@ -CREATE TABLE SPATIALPOINTGEOM_dt (location geometry) -GO - --- Geometry Test Cases - --- Positive Test for STGeomFromText with SRID 4326 -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) -GO -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(1.0 2.0)', 4326) ) -GO - --- Positive Test for STGeomFromText with SRID 0 -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 0) ) -GO - --- Negative Test for STGeomFromText when SRID is not provided -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)') ) -GO - --- Negative Test for STGeomFromText when SRID >= 10^6 --- SRID should be between 0 to 999999 -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 1000000000 ) ) -GO - --- Negative Test for STGeomFromText with SRID < 0 --- SRID should be between 0 to 999999 -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', -1) ) -GO - --- Negative Test for STGeomFromText when a coordinate is missing -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Point(1.0 )', 4326) ) -GO - --- Negative Test for STGeomFromText when invalid type is provided -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText('Pnt', 4326) ) -GO - --- Test for STGeomFromText when null Point is Given -> Returns NBCRow -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STGeomFromText(null, 4326) ) -GO - --- -- Negative Test for STGeomFromText when Incorrect cast is provided --- INSERT INTO SPATIALPOINTGEOM_dt (location) --- VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) --- GO - --- Positive Test for STPointFromText with SRID 4326. Rest are same as STGeomFromText -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STPointFromText('Point(47.65100 -22.34900)', 4326) ) -GO -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::STPointFromText('Point(1.0 2.0)', 4326) ) -GO - --- Positive Test for Point with SRID 4326 -INSERT INTO SPATIALPOINTGEOM_dt (location) -VALUES ( geometry::Point(47.65100, -22.34900, 4326) ) -GO - -CREATE VIEW TextFromGeom AS -SELECT STAsText(location) AS TextRepresentation -FROM SPATIALPOINTGEOM_dt; -GO - -CREATE VIEW BinaryFromGeom AS -SELECT STAsBinary(location) AS BinaryRepresentation -FROM SPATIALPOINTGEOM_dt; -GO - -CREATE VIEW CoordsFromGeom AS -SELECT STX(location), STY(location) AS Coordinates -FROM SPATIALPOINTGEOM_dt; -GO - -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; -GO - -CREATE TABLE SPATIALPOINTGEOG_dt (location geography) -GO - --- Create Type Test Case currently Babelfish supports it but TSQL doesn't for spatial Types, Although it doesn't break anything --- TODO: Make it similar to T-SQL -CREATE TYPE geom -FROM geometry NOT NULL ; -GO - -CREATE TABLE TypeTable(ID INT PRIMARY KEY, Shape geom) -GO - -INSERT INTO TypeTable(ID, Shape) -VALUES(1, geometry::Point(1, 2, 4326)); -GO - --- Geography Test Cases - --- Positive Test for STGeomFromText with SRID 4326 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) -GO -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(1.0 2.0)', 4326) ) -GO - --- Negative Test for STGeomFromText for Geography with SRID 0 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 0) ) -GO - --- Negative Test for STGeomFromText for Geography when lat > 90 or < -90 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -122.34900)', 4326) ) -GO - --- Negative Test for STGeomFromText when SRID is not provided -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)') ) -GO - --- Negative Test for STGeomFromText when cast is not provided -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( STGeomFromText('Point(47.65100 -22.34900)', 4326) ) -GO - --- -- Negative Test for STGeomFromText when incorrect cast is provided --- INSERT INTO SPATIALPOINTGEOG_dt (location) --- VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) --- GO - --- Negative Test for STGeomFromText when SRID >= 10^6 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 1000000000 ) ) -GO - --- Negative Test for STGeomFromText with SRID < 0 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', -1) ) -GO - --- Negative Test for STGeomFromText when a coordinate is missing -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Point(1.0 )', 4326) ) -GO - --- Negative Test for STGeomFromText when invalid type is provided -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText('Pnt', 4326) ) -GO - --- Test for STGeomFromText when null Point is Given -> Returns NBCRow -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STGeomFromText(null, 4326) ) -GO - --- Positive Test for STPointFromText with SRID 4326. Rest are same as STGeomFromText -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STPointFromText('Point(47.65100 -22.34900)', 4326) ) -GO -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STPointFromText('Point(1.0 2.0)', 4326) ) -GO - --- Negative Test for STPointFromText for Geography when lat > 90 or < -90 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::STPointFromText('Point(47.65100 122.34900)', 4326) ) -GO - --- Positive Test for Point with SRID 4326 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::Point(47.65100, -22.34900, 4326) ) -GO - --- Negative Test for Point for Geography when lat > 90 or < -90 -INSERT INTO SPATIALPOINTGEOG_dt (location) -VALUES ( geography::Point(147.65100, -22.34900, 4326) ) -GO - -CREATE VIEW TextFromGeog AS -SELECT STAsText(location) AS TextRepresentation -FROM SPATIALPOINTGEOG_dt; -GO - -CREATE VIEW BinaryFromGeog AS -SELECT STAsBinary(location) AS BinaryRepresentation -FROM SPATIALPOINTGEOG_dt; -GO - -CREATE VIEW CoordsFromGeog AS -SELECT long(location), lat(location) AS Coordinates -FROM SPATIALPOINTGEOG_dt; -GO - - -CREATE VIEW TransformFromGeog AS -SELECT ST_Transform(location, 4326) AS Modified_points -FROM SPATIALPOINTGEOG_dt; -GO - -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; -GO - -CREATE TABLE SPATIALPOINT_dt (PrimaryKey int, GeomColumn geometry, GeogColumn geography) -GO -INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeomColumn) -VALUES ( 1, geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) -GO -INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeogColumn) -VALUES ( 2, geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) -GO -INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeomColumn, GeogColumn) -VALUES ( 3, geometry::STGeomFromText('Point(1.0 2.0)', 4326), geography::STGeomFromText('Point(1.0 2.0)', 4326) ) -GO diff --git a/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt b/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt new file mode 100644 index 0000000000..2f21076b80 --- /dev/null +++ b/test/JDBC/input/datatypes/TestSpatialPoint-vu-prepare.txt @@ -0,0 +1,180 @@ +CREATE TABLE SPATIALPOINTGEOM_dt (location geometry) + +#Geometry Test Cases + +#Positive Test for STGeomFromText with SRID 4326 +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) + +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(1.0 2.0)', 4326) ) + +#Positive Test for STGeomFromText with SRID 0 +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 0) ) + +#Negative Test for STGeomFromText when SRID is not provided +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)') ) + +#Negative Test for STGeomFromText when SRID >= 10^6 +#SRID should be between 0 to 999999 +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 1000000000 ) ) + +#Negative Test for STGeomFromText with SRID < 0 +#SRID should be between 0 to 999999 +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', -1) ) + +#Negative Test for STGeomFromText when a coordinate is missing +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Point(1.0 )', 4326) ) + +#Negative Test for STGeomFromText when invalid type is provided +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText('Pnt', 4326) ) + +#Test for STGeomFromText when null Point is Given -> Returns NBCRow +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STGeomFromText(null, 4326) ) + +#Negative Test for STGeomFromText when Incorrect cast is provided +#INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) + +#Positive Test for STPointFromText with SRID 4326. Rest are same as STGeomFromText +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STPointFromText('Point(47.65100 -22.34900)', 4326) ) + +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::STPointFromText('Point(1.0 2.0)', 4326) ) + + +#Positive Test for Point with SRID 4326 +INSERT INTO SPATIALPOINTGEOM_dt (location) VALUES ( geometry::Point(47.65100, -22.34900, 4326) ) + +#Tests for Geometry type Prepared Statements +prepst#!#INSERT INTO SPATIALPOINTGEOM_dt(location) values(@location) #!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):4326 +prepst#!#exec#!#GEOMETRY|-|location|-|Point(1.0 2.0):4326 +prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):0 +#Negative Test for STGeomFromText when SRID >= 10^6 +prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):1000000000 +#Negative Test for STGeomFromText with SRID < 0 +prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900):-1 +#Negative Test for STGeomFromText when SRID is NULL +prepst#!#exec#!#GEOMETRY|-|location|-|Point(47.65100 -22.34900): +#Negative Test for STGeomFromText when a coordinate is missing +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; + +CREATE VIEW BinaryFromGeom AS SELECT STAsBinary(location) AS BinaryRepresentation FROM SPATIALPOINTGEOM_dt; + +CREATE VIEW CoordsFromGeom AS SELECT STX(location), STY(location) AS Coordinates FROM SPATIALPOINTGEOM_dt; + +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) + +#Create Type Test Case currently Babelfish supports it but TSQL doesn't for spatial Types, Although it doesn't break anything +#TODO: Make it similar to T-SQL +CREATE TYPE geom FROM geometry NOT NULL ; + +CREATE TABLE TypeTable(ID INT PRIMARY KEY, Shape geom) + +INSERT INTO TypeTable(ID, Shape) VALUES(1, geometry::Point(1, 2, 4326)); + +#Geography Test Cases + +#Positive Test for STGeomFromText with SRID 4326 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) + +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(1.0 2.0)', 4326) ) + +#Negative Test for STGeomFromText for Geography with SRID 0 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 0) ) + +#Negative Test for STGeomFromText for Geography when lat > 90 or < -90 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -122.34900)', 4326) ) + +#Negative Test for STGeomFromText when SRID is not provided +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)') ) + +#Negative Test for STGeomFromText when cast is not provided +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( STGeomFromText('Point(47.65100 -22.34900)', 4326) ) + +#Negative Test for STGeomFromText when incorrect cast is provided +#INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geometry::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) + +#Negative Test for STGeomFromText when SRID >= 10^6 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', 1000000000 ) ) + +#Negative Test for STGeomFromText with SRID < 0 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(47.65100 -22.34900)', -1) ) + +#Negative Test for STGeomFromText when a coordinate is missing +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Point(1.0 )', 4326) ) + +#Negative Test for STGeomFromText when invalid type is provided +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText('Pnt', 4326) ) + +#Test for STGeomFromText when null Point is Given -> Returns NBCRow +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STGeomFromText(null, 4326) ) + +#Positive Test for STPointFromText with SRID 4326. Rest are same as STGeomFromText +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STPointFromText('Point(47.65100 -22.34900)', 4326) ) + +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STPointFromText('Point(1.0 2.0)', 4326) ) + +#Negative Test for STPointFromText for Geography when lat > 90 or < -90 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::STPointFromText('Point(47.65100 122.34900)', 4326) ) + +#Positive Test for Point with SRID 4326 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::Point(47.65100, -22.34900, 4326) ) + +#Negative Test for Point for Geography when lat > 90 or < -90 +INSERT INTO SPATIALPOINTGEOG_dt (location) VALUES ( geography::Point(147.65100, -22.34900, 4326) ) + +#Tests for Geography type Prepared Statements +prepst#!#INSERT INTO SPATIALPOINTGEOG_dt(location) values(@location) #!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):4326 +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(1.0 2.0):4326 +#Negative Test for STGeomFromText for Geography with SRID 0 +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):0 +#Negative Test for STGeomFromText for Geography when lat > 90 or < -90 +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -122.34900):4326 +#Negative Test for STGeomFromText when SRID >= 10^6 +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):1000000000 +#Negative Test for STGeomFromText with SRID < 0 +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900):-1 +#Negative Test for STGeomFromText with SRID is NULL +prepst#!#exec#!#GEOGRAPHY|-|location|-|Point(47.65100 -22.34900): +#Negative Test for STGeomFromText when a coordinate is missing +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; + +CREATE VIEW BinaryFromGeog AS SELECT STAsBinary(location) AS BinaryRepresentation FROM SPATIALPOINTGEOG_dt; + +CREATE VIEW CoordsFromGeog AS SELECT long(location), lat(location) AS Coordinates FROM SPATIALPOINTGEOG_dt; + + +CREATE VIEW TransformFromGeog AS SELECT ST_Transform(location, 4326) AS Modified_points FROM SPATIALPOINTGEOG_dt; + +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; + +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) ) + +INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeogColumn) VALUES ( 2, geography::STGeomFromText('Point(47.65100 -22.34900)', 4326) ) + +INSERT INTO SPATIALPOINT_dt (PrimaryKey, GeomColumn, GeogColumn) VALUES ( 3, geometry::STGeomFromText('Point(1.0 2.0)', 4326), geography::STGeomFromText('Point(1.0 2.0)', 4326) ) + + +#Tests for Spatial type Prepared Statements +prepst#!#INSERT INTO SPATIALPOINT_dt(PrimaryKey, GeomColumn) values(@PrimaryKey, @GeomColumn) #!#int|-|PrimaryKey|-|4#!#GEOMETRY|-|GeomColumn|-|Point(47.65100 -22.34900):4326 +prepst#!#INSERT INTO SPATIALPOINT_dt(PrimaryKey, GeogColumn) values(@PrimaryKey, @GeogColumn) #!#int|-|PrimaryKey|-|5#!#GEOGRAPHY|-|GeogColumn|-|Point(47.65100 -22.34900):4326 +prepst#!#INSERT INTO SPATIALPOINT_dt(PrimaryKey, GeomColumn, GeogColumn) values(@PrimaryKey, @GeomColumn, @GeogColumn) #!#int|-|PrimaryKey|-|6#!#GEOMETRY|-|GeomColumn|-|Point(1.0 2.0):4326#!#GEOGRAPHY|-|GeogColumn|-|Point(1.0 2.0):4326 diff --git a/test/JDBC/upgrade/latest/schedule b/test/JDBC/upgrade/latest/schedule index 83d00b4b60..42143cbd27 100644 --- a/test/JDBC/upgrade/latest/schedule +++ b/test/JDBC/upgrade/latest/schedule @@ -414,7 +414,6 @@ TestInt TestMoney TestNotNull TestNumeric -TestPoint TestReal TestRowVersion TestSmallDatetime diff --git a/test/JDBC/upgrade/master/schedule b/test/JDBC/upgrade/master/schedule index 4695d13a7b..122eb40bb4 100644 --- a/test/JDBC/upgrade/master/schedule +++ b/test/JDBC/upgrade/master/schedule @@ -303,7 +303,6 @@ TestInt TestMoney TestNotNull TestNumeric -TestPoint TestReal TestRowVersion TestSmallDatetime