summaryrefslogtreecommitdiff
path: root/contrib/earthdistance
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-02-13 21:24:14 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2011-02-13 22:54:52 -0500
commit029fac2264101919b65fb6319bb994f941969471 (patch)
treeedb89110508318a04730a7caa42d312e050ef7ce /contrib/earthdistance
parent629b3af27d5c2bc9d6e16b22b943ad651d4ecb56 (diff)
downloadpostgresql-029fac2264101919b65fb6319bb994f941969471.tar.gz
Avoid use of CREATE OR REPLACE FUNCTION in extension installation files.
It was never terribly consistent to use OR REPLACE (because of the lack of comparable functionality for data types, operators, etc), and experimentation shows that it's now positively pernicious in the extension world. We really want a failure to occur if there are any conflicts, else it's unclear what the extension-ownership state of the conflicted object ought to be. Most of the time, CREATE EXTENSION will fail anyway because of conflicts on other object types, but an extension defining only functions can succeed, with bad results.
Diffstat (limited to 'contrib/earthdistance')
-rw-r--r--contrib/earthdistance/earthdistance--1.0.sql20
1 files changed, 10 insertions, 10 deletions
diff --git a/contrib/earthdistance/earthdistance--1.0.sql b/contrib/earthdistance/earthdistance--1.0.sql
index 0a2af648de..71e4025f6f 100644
--- a/contrib/earthdistance/earthdistance--1.0.sql
+++ b/contrib/earthdistance/earthdistance--1.0.sql
@@ -4,7 +4,7 @@
-- place you need to change things for the cube base distance functions
-- in order to use different units (or a better value for the Earth's radius).
-CREATE OR REPLACE FUNCTION earth() RETURNS float8
+CREATE FUNCTION earth() RETURNS float8
LANGUAGE SQL IMMUTABLE
AS 'SELECT ''6378168''::float8';
@@ -13,7 +13,7 @@ AS 'SELECT ''6378168''::float8';
-- uncomment the one below. Note that doing this will break the regression
-- tests.
--
--- CREATE OR REPLACE FUNCTION earth() RETURNS float8
+-- CREATE FUNCTION earth() RETURNS float8
-- LANGUAGE SQL IMMUTABLE
-- AS 'SELECT 180/pi()';
@@ -30,43 +30,43 @@ CREATE DOMAIN earth AS cube
CONSTRAINT on_surface check(abs(cube_distance(value, '(0)'::cube) /
earth() - 1) < '10e-7'::float8);
-CREATE OR REPLACE FUNCTION sec_to_gc(float8)
+CREATE FUNCTION sec_to_gc(float8)
RETURNS float8
LANGUAGE SQL
IMMUTABLE STRICT
AS 'SELECT CASE WHEN $1 < 0 THEN 0::float8 WHEN $1/(2*earth()) > 1 THEN pi()*earth() ELSE 2*earth()*asin($1/(2*earth())) END';
-CREATE OR REPLACE FUNCTION gc_to_sec(float8)
+CREATE FUNCTION gc_to_sec(float8)
RETURNS float8
LANGUAGE SQL
IMMUTABLE STRICT
AS 'SELECT CASE WHEN $1 < 0 THEN 0::float8 WHEN $1/earth() > pi() THEN 2*earth() ELSE 2*earth()*sin($1/(2*earth())) END';
-CREATE OR REPLACE FUNCTION ll_to_earth(float8, float8)
+CREATE FUNCTION ll_to_earth(float8, float8)
RETURNS earth
LANGUAGE SQL
IMMUTABLE STRICT
AS 'SELECT cube(cube(cube(earth()*cos(radians($1))*cos(radians($2))),earth()*cos(radians($1))*sin(radians($2))),earth()*sin(radians($1)))::earth';
-CREATE OR REPLACE FUNCTION latitude(earth)
+CREATE FUNCTION latitude(earth)
RETURNS float8
LANGUAGE SQL
IMMUTABLE STRICT
AS 'SELECT CASE WHEN cube_ll_coord($1, 3)/earth() < -1 THEN -90::float8 WHEN cube_ll_coord($1, 3)/earth() > 1 THEN 90::float8 ELSE degrees(asin(cube_ll_coord($1, 3)/earth())) END';
-CREATE OR REPLACE FUNCTION longitude(earth)
+CREATE FUNCTION longitude(earth)
RETURNS float8
LANGUAGE SQL
IMMUTABLE STRICT
AS 'SELECT degrees(atan2(cube_ll_coord($1, 2), cube_ll_coord($1, 1)))';
-CREATE OR REPLACE FUNCTION earth_distance(earth, earth)
+CREATE FUNCTION earth_distance(earth, earth)
RETURNS float8
LANGUAGE SQL
IMMUTABLE STRICT
AS 'SELECT sec_to_gc(cube_distance($1, $2))';
-CREATE OR REPLACE FUNCTION earth_box(earth, float8)
+CREATE FUNCTION earth_box(earth, float8)
RETURNS cube
LANGUAGE SQL
IMMUTABLE STRICT
@@ -74,7 +74,7 @@ AS 'SELECT cube_enlarge($1, gc_to_sec($2), 3)';
--------------- geo_distance
-CREATE OR REPLACE FUNCTION geo_distance (point, point)
+CREATE FUNCTION geo_distance (point, point)
RETURNS float8
LANGUAGE C IMMUTABLE STRICT AS 'MODULE_PATHNAME';