Uses proper postalcode functions and tests
This commit is contained in:
parent
50d1f502f7
commit
91fab99084
@ -6,10 +6,10 @@ BEGIN
|
||||
RETURN NULL;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_postalcode_polygon(user_id name, tx_id bigint, postal_code integer, country_name text)
|
||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_postalcode_point(user_id name, tx_id bigint, postal_code text, country_name text)
|
||||
RETURNS Geometry AS $$
|
||||
BEGIN
|
||||
RAISE NOTICE 'cbd_geocoder_server.geocode_postalcode_polygon invoked with params (%, %, %, %)', user_id, 'some_transaction_id', postal_code, country_name;
|
||||
RAISE NOTICE 'cbd_geocoder_server.geocode_postalcode_point invoked with params (%, %, %, %)', user_id, 'some_transaction_id', postal_code, country_name;
|
||||
RETURN NULL;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
@ -23,12 +23,12 @@ PL/pgSQL function cdb_geocoder_client.geocode_postalcode_polygon(text,text) line
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT cdb_geocoder_client.geocode_postalcode_polygon(3204, 'Spain');
|
||||
NOTICE: cdb_geocoder_client._geocode_postalcode_polygon(4): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_postalcode_polygon invoked with params (postgres, some_transaction_id, 3204, Spain)
|
||||
CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_postalcode_polygon(session_user, txid_current(), postal_code, country_name)"
|
||||
PL/pgSQL function cdb_geocoder_client.geocode_postalcode_polygon(integer,text) line 5 at SQL statement
|
||||
geocode_postalcode_polygon
|
||||
----------------------------
|
||||
SELECT cdb_geocoder_client.geocode_postalcode_point('03204', 'Spain');
|
||||
NOTICE: cdb_geocoder_client._geocode_postalcode_point(4): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_postalcode_polygon invoked with params (postgres, some_transaction_id, 03204, Spain)
|
||||
CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_postalcode_point(session_user, txid_current(), postal_code, country_name)"
|
||||
PL/pgSQL function cdb_geocoder_client.geocode_postalcode_point(text,text) line 5 at SQL statement
|
||||
geocode_postalcode_point
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -65,12 +65,12 @@ PL/pgSQL function cdb_geocoder_client.geocode_postalcode_polygon(text,text) line
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT cdb_geocoder_client.geocode_postalcode_polygon(3204, 'Spain');
|
||||
NOTICE: cdb_geocoder_client._geocode_postalcode_polygon(4): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_postalcode_polygon invoked with params (postgres, some_transaction_id, 3204, Spain)
|
||||
CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_postalcode_polygon(session_user, txid_current(), postal_code, country_name)"
|
||||
PL/pgSQL function cdb_geocoder_client.geocode_postalcode_polygon(integer,text) line 5 at SQL statement
|
||||
geocode_postalcode_polygon
|
||||
----------------------------
|
||||
SELECT cdb_geocoder_client.geocode_postalcode_point('03204', 'Spain');
|
||||
NOTICE: cdb_geocoder_client._geocode_postalcode_point(4): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_postalcode_polygon invoked with params (postgres, some_transaction_id, 03204, Spain)
|
||||
CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_postalcode_point(session_user, txid_current(), postal_code, country_name)"
|
||||
PL/pgSQL function cdb_geocoder_client.geocode_postalcode_point(text,text) line 5 at SQL statement
|
||||
geocode_postalcode_point
|
||||
--------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
@ -98,8 +98,8 @@ SELECT cdb_geocoder_client._geocode_namedplace_point('evil_user', 666, 'Sheol',
|
||||
ERROR: permission denied for function _geocode_namedplace_point
|
||||
SELECT cdb_geocoder_client._geocode_postalcode_polygon('evil_user', 666, '66666', 'Hell');
|
||||
ERROR: permission denied for function _geocode_postalcode_polygon
|
||||
SELECT cdb_geocoder_client._geocode_postalcode_polygon('evil_user', 666, 66666, 'Hell');
|
||||
ERROR: permission denied for function _geocode_postalcode_polygon
|
||||
SELECT cdb_geocoder_client._geocode_postalcode_point('evil_user', 666, '66666', 'Hell');
|
||||
ERROR: permission denied for function _geocode_postalcode_point
|
||||
SELECT cdb_geocoder_client._geocode_ip('evil_user', 666, '8.8.8.8');
|
||||
ERROR: permission denied for function _geocode_ip
|
||||
-- Check the regular user cannot look into config table
|
||||
|
@ -16,12 +16,12 @@ END;
|
||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||
|
||||
---- geocode_postalcode_polygon(postal_code integer, country_name text)
|
||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_postalcode_polygon(postal_code integer, country_name text)
|
||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_postalcode_point(postal_code text, country_name text)
|
||||
RETURNS Geometry AS $$
|
||||
DECLARE
|
||||
ret Geometry;
|
||||
BEGIN
|
||||
SELECT cdb_geocoder_client._geocode_postalcode_polygon(session_user, txid_current(), postal_code, country_name) INTO ret;
|
||||
SELECT cdb_geocoder_client._geocode_postalcode_point(session_user, txid_current(), postal_code, country_name) INTO ret;
|
||||
RETURN ret;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||
@ -37,8 +37,8 @@ RETURNS Geometry AS $$
|
||||
SELECT cdb_geocoder_server.geocode_postalcode_polygon(user_id, tx_id, postal_code, country_name);
|
||||
$$ LANGUAGE plproxy;
|
||||
|
||||
---- geocode_postalcode_polygon(postal_code integer, country_name text)
|
||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_postalcode_polygon(user_id name, tx_id bigint, postal_code integer, country_name text)
|
||||
---- geocode_postalcode_polygon(postal_code text, country_name text)
|
||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_postalcode_point(user_id name, tx_id bigint, postal_code text, country_name text)
|
||||
RETURNS Geometry AS $$
|
||||
CONNECT cdb_geocoder_client._server_conn_str();
|
||||
SELECT cdb_geocoder_server.geocode_postalcode_polygon(user_id, tx_id, postal_code, country_name);
|
||||
|
@ -19,5 +19,5 @@ GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_namedplace_point(city_name
|
||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_namedplace_point(city_name text, country_name text) TO publicuser;
|
||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_namedplace_point(city_name text, admin1_name text, country_name text) TO publicuser;
|
||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_postalcode_polygon(postal_code text, country_name text) TO publicuser;
|
||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_postalcode_polygon(postal_code integer, country_name text) TO publicuser;
|
||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_postalcode_point(postal_code text, country_name text) TO publicuser;
|
||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_ip(ip_address text) TO publicuser;
|
||||
|
@ -7,14 +7,14 @@ BEGIN
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_postalcode_polygon(user_id name, tx_id bigint, postal_code integer, country_name text)
|
||||
CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_postalcode_point(user_id name, tx_id bigint, postal_code text, country_name text)
|
||||
RETURNS Geometry AS $$
|
||||
BEGIN
|
||||
RAISE NOTICE 'cbd_geocoder_server.geocode_postalcode_polygon invoked with params (%, %, %, %)', user_id, 'some_transaction_id', postal_code, country_name;
|
||||
RAISE NOTICE 'cbd_geocoder_server.geocode_postalcode_point invoked with params (%, %, %, %)', user_id, 'some_transaction_id', postal_code, country_name;
|
||||
RETURN NULL;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
||||
|
||||
-- Exercise the public and the proxied function
|
||||
SELECT cdb_geocoder_client.geocode_postalcode_polygon('03204', 'Spain');
|
||||
SELECT cdb_geocoder_client.geocode_postalcode_polygon(3204, 'Spain');
|
||||
SELECT cdb_geocoder_client.geocode_postalcode_point('03204', 'Spain');
|
||||
|
@ -10,7 +10,7 @@ SELECT cdb_geocoder_client.geocode_namedplace_point('Elx');
|
||||
SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Valencia');
|
||||
SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Valencia', 'Spain');
|
||||
SELECT cdb_geocoder_client.geocode_postalcode_polygon('03204', 'Spain');
|
||||
SELECT cdb_geocoder_client.geocode_postalcode_polygon(3204, 'Spain');
|
||||
SELECT cdb_geocoder_client.geocode_postalcode_point('03204', 'Spain');
|
||||
SELECT cdb_geocoder_client.geocode_ip('8.8.8.8');
|
||||
|
||||
-- Check the regular user has no permissions on private functions
|
||||
@ -21,7 +21,7 @@ SELECT cdb_geocoder_client._geocode_namedplace_point('evil_user', 666, 'Sheol');
|
||||
SELECT cdb_geocoder_client._geocode_namedplace_point('evil_user', 666, 'Sheol', 'Hell');
|
||||
SELECT cdb_geocoder_client._geocode_namedplace_point('evil_user', 666, 'Sheol', 'Hell', 'Ugly world');
|
||||
SELECT cdb_geocoder_client._geocode_postalcode_polygon('evil_user', 666, '66666', 'Hell');
|
||||
SELECT cdb_geocoder_client._geocode_postalcode_polygon('evil_user', 666, 66666, 'Hell');
|
||||
SELECT cdb_geocoder_client._geocode_postalcode_point('evil_user', 666, '66666', 'Hell');
|
||||
SELECT cdb_geocoder_client._geocode_ip('evil_user', 666, '8.8.8.8');
|
||||
|
||||
-- Check the regular user cannot look into config table
|
||||
|
Loading…
Reference in New Issue
Block a user