mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Update /contrib for "autocommit TO 'on'".
Create objects in public schema. Make spacing/capitalization consistent. Remove transaction block use for object creation. Remove unneeded function GRANTs.
This commit is contained in:
@ -1,24 +1,19 @@
|
||||
begin;
|
||||
-- Adjust this setting to control where the objects get created.
|
||||
SET search_path = public;
|
||||
|
||||
SET autocommit TO 'on';
|
||||
|
||||
--------------- geo_distance
|
||||
|
||||
CREATE OR REPLACE FUNCTION geo_distance (point, point) RETURNS float8
|
||||
LANGUAGE 'c' IMMUTABLE STRICT AS 'MODULE_PATHNAME';
|
||||
CREATE OR REPLACE FUNCTION geo_distance (point, point)
|
||||
RETURNS float8
|
||||
LANGUAGE 'C' IMMUTABLE STRICT AS 'MODULE_PATHNAME';
|
||||
|
||||
--------------- geo_distance as operator <@>
|
||||
|
||||
CREATE OPERATOR <@> (
|
||||
leftarg = point,
|
||||
rightarg = point,
|
||||
procedure = geo_distance,
|
||||
commutator = <@>
|
||||
LEFTARG = point,
|
||||
RIGHTARG = point,
|
||||
PROCEDURE = geo_distance,
|
||||
COMMUTATOR = <@>
|
||||
);
|
||||
|
||||
--
|
||||
-- By default this function is made executable by anyone. To restrict
|
||||
-- access by default, comment out the following grant command.
|
||||
--
|
||||
|
||||
grant execute on function geo_distance(point, point) to public;
|
||||
|
||||
commit;
|
||||
|
@ -9,73 +9,73 @@
|
||||
--
|
||||
-- Test getting the distance between two points using geo_distance.
|
||||
--
|
||||
select geo_distance('(0,0)'::point,'(0,0)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(0,0)'::point)::numeric(20,5);
|
||||
geo_distance
|
||||
--------------
|
||||
0.00000
|
||||
(1 row)
|
||||
|
||||
select geo_distance('(0,0)'::point,'(180,0)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(180,0)'::point)::numeric(20,5);
|
||||
geo_distance
|
||||
--------------
|
||||
12436.77274
|
||||
(1 row)
|
||||
|
||||
select geo_distance('(0,0)'::point,'(0,90)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(0,90)'::point)::numeric(20,5);
|
||||
geo_distance
|
||||
--------------
|
||||
6218.38637
|
||||
(1 row)
|
||||
|
||||
select geo_distance('(0,0)'::point,'(90,0)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(90,0)'::point)::numeric(20,5);
|
||||
geo_distance
|
||||
--------------
|
||||
6218.38637
|
||||
(1 row)
|
||||
|
||||
select geo_distance('(0,0)'::point,'(1,0)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(1,0)'::point)::numeric(20,5);
|
||||
geo_distance
|
||||
--------------
|
||||
69.09318
|
||||
(1 row)
|
||||
|
||||
select geo_distance('(0,0)'::point,'(0,1)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(0,1)'::point)::numeric(20,5);
|
||||
geo_distance
|
||||
--------------
|
||||
69.09318
|
||||
(1 row)
|
||||
|
||||
select geo_distance('(0,30)'::point,'(1,30)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,30)'::point,'(1,30)'::point)::numeric(20,5);
|
||||
geo_distance
|
||||
--------------
|
||||
59.83626
|
||||
(1 row)
|
||||
|
||||
select geo_distance('(0,30)'::point,'(0,31)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,30)'::point,'(0,31)'::point)::numeric(20,5);
|
||||
geo_distance
|
||||
--------------
|
||||
69.09318
|
||||
(1 row)
|
||||
|
||||
select geo_distance('(0,60)'::point,'(1,60)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,60)'::point,'(1,60)'::point)::numeric(20,5);
|
||||
geo_distance
|
||||
--------------
|
||||
34.54626
|
||||
(1 row)
|
||||
|
||||
select geo_distance('(0,60)'::point,'(0,61)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,60)'::point,'(0,61)'::point)::numeric(20,5);
|
||||
geo_distance
|
||||
--------------
|
||||
69.09318
|
||||
(1 row)
|
||||
|
||||
select geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)::numeric(20,5);
|
||||
geo_distance
|
||||
--------------
|
||||
1129.18983
|
||||
(1 row)
|
||||
|
||||
select (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
|
||||
SELECT (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
|
||||
numeric
|
||||
---------------
|
||||
1817254.87730
|
||||
@ -84,73 +84,73 @@ select (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/
|
||||
--
|
||||
-- Test getting the distance between two points using the <@> operator.
|
||||
--
|
||||
select ('(0,0)'::point <@> '(0,0)'::point)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(0,0)'::point)::numeric(20,5);
|
||||
numeric
|
||||
---------
|
||||
0.00000
|
||||
(1 row)
|
||||
|
||||
select ('(0,0)'::point <@> '(180,0)'::point)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(180,0)'::point)::numeric(20,5);
|
||||
numeric
|
||||
-------------
|
||||
12436.77274
|
||||
(1 row)
|
||||
|
||||
select ('(0,0)'::point <@> '(0,90)'::point)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(0,90)'::point)::numeric(20,5);
|
||||
numeric
|
||||
------------
|
||||
6218.38637
|
||||
(1 row)
|
||||
|
||||
select ('(0,0)'::point <@> '(90,0)'::point)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(90,0)'::point)::numeric(20,5);
|
||||
numeric
|
||||
------------
|
||||
6218.38637
|
||||
(1 row)
|
||||
|
||||
select ('(0,0)'::point <@> '(1,0)'::point)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(1,0)'::point)::numeric(20,5);
|
||||
numeric
|
||||
----------
|
||||
69.09318
|
||||
(1 row)
|
||||
|
||||
select ('(0,0)'::point <@> '(0,1)'::point)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(0,1)'::point)::numeric(20,5);
|
||||
numeric
|
||||
----------
|
||||
69.09318
|
||||
(1 row)
|
||||
|
||||
select ('(0,30)'::point <@> '(1,30)'::point)::numeric(20,5);
|
||||
SELECT ('(0,30)'::point <@> '(1,30)'::point)::numeric(20,5);
|
||||
numeric
|
||||
----------
|
||||
59.83626
|
||||
(1 row)
|
||||
|
||||
select ('(0,30)'::point <@> '(0,31)'::point)::numeric(20,5);
|
||||
SELECT ('(0,30)'::point <@> '(0,31)'::point)::numeric(20,5);
|
||||
numeric
|
||||
----------
|
||||
69.09318
|
||||
(1 row)
|
||||
|
||||
select ('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5);
|
||||
SELECT ('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5);
|
||||
numeric
|
||||
----------
|
||||
34.54626
|
||||
(1 row)
|
||||
|
||||
select ('(0,60)'::point <@> '(0,61)'::point)::numeric(20,5);
|
||||
SELECT ('(0,60)'::point <@> '(0,61)'::point)::numeric(20,5);
|
||||
numeric
|
||||
----------
|
||||
69.09318
|
||||
(1 row)
|
||||
|
||||
select ('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)::numeric(20,5);
|
||||
SELECT ('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)::numeric(20,5);
|
||||
numeric
|
||||
------------
|
||||
1129.18983
|
||||
(1 row)
|
||||
|
||||
select (('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
|
||||
SELECT (('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
|
||||
numeric
|
||||
---------------
|
||||
1817254.87730
|
||||
|
@ -7,6 +7,7 @@
|
||||
-- does not depend on contents of earthdistance.sql or cube.sql.
|
||||
--
|
||||
\set ECHO none
|
||||
SET autocommit TO 'on';
|
||||
\i earthdistance.sql
|
||||
\set ECHO all
|
||||
|
||||
@ -14,32 +15,32 @@
|
||||
-- Test getting the distance between two points using geo_distance.
|
||||
--
|
||||
|
||||
select geo_distance('(0,0)'::point,'(0,0)'::point)::numeric(20,5);
|
||||
select geo_distance('(0,0)'::point,'(180,0)'::point)::numeric(20,5);
|
||||
select geo_distance('(0,0)'::point,'(0,90)'::point)::numeric(20,5);
|
||||
select geo_distance('(0,0)'::point,'(90,0)'::point)::numeric(20,5);
|
||||
select geo_distance('(0,0)'::point,'(1,0)'::point)::numeric(20,5);
|
||||
select geo_distance('(0,0)'::point,'(0,1)'::point)::numeric(20,5);
|
||||
select geo_distance('(0,30)'::point,'(1,30)'::point)::numeric(20,5);
|
||||
select geo_distance('(0,30)'::point,'(0,31)'::point)::numeric(20,5);
|
||||
select geo_distance('(0,60)'::point,'(1,60)'::point)::numeric(20,5);
|
||||
select geo_distance('(0,60)'::point,'(0,61)'::point)::numeric(20,5);
|
||||
select geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)::numeric(20,5);
|
||||
select (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(0,0)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(180,0)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(0,90)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(90,0)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(1,0)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,0)'::point,'(0,1)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,30)'::point,'(1,30)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,30)'::point,'(0,31)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,60)'::point,'(1,60)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(0,60)'::point,'(0,61)'::point)::numeric(20,5);
|
||||
SELECT geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)::numeric(20,5);
|
||||
SELECT (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
|
||||
|
||||
--
|
||||
-- Test getting the distance between two points using the <@> operator.
|
||||
--
|
||||
|
||||
select ('(0,0)'::point <@> '(0,0)'::point)::numeric(20,5);
|
||||
select ('(0,0)'::point <@> '(180,0)'::point)::numeric(20,5);
|
||||
select ('(0,0)'::point <@> '(0,90)'::point)::numeric(20,5);
|
||||
select ('(0,0)'::point <@> '(90,0)'::point)::numeric(20,5);
|
||||
select ('(0,0)'::point <@> '(1,0)'::point)::numeric(20,5);
|
||||
select ('(0,0)'::point <@> '(0,1)'::point)::numeric(20,5);
|
||||
select ('(0,30)'::point <@> '(1,30)'::point)::numeric(20,5);
|
||||
select ('(0,30)'::point <@> '(0,31)'::point)::numeric(20,5);
|
||||
select ('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5);
|
||||
select ('(0,60)'::point <@> '(0,61)'::point)::numeric(20,5);
|
||||
select ('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)::numeric(20,5);
|
||||
select (('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(0,0)'::point)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(180,0)'::point)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(0,90)'::point)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(90,0)'::point)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(1,0)'::point)::numeric(20,5);
|
||||
SELECT ('(0,0)'::point <@> '(0,1)'::point)::numeric(20,5);
|
||||
SELECT ('(0,30)'::point <@> '(1,30)'::point)::numeric(20,5);
|
||||
SELECT ('(0,30)'::point <@> '(0,31)'::point)::numeric(20,5);
|
||||
SELECT ('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5);
|
||||
SELECT ('(0,60)'::point <@> '(0,61)'::point)::numeric(20,5);
|
||||
SELECT ('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)::numeric(20,5);
|
||||
SELECT (('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
|
||||
|
Reference in New Issue
Block a user