diff --git a/client/expected/10_admin0_test.out b/client/expected/10_admin0_test.out index 37d99fc..2c4efee 100644 --- a/client/expected/10_admin0_test.out +++ b/client/expected/10_admin0_test.out @@ -1,18 +1,18 @@ -- Mock the server function -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin0_polygons(user_id name, tx_id bigint, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin0_polygon(user_id name, tx_id bigint, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cbd_geocoder_server.geocode_admin0_polygons invoked with params (%, %, %)', user_id, 'some_transaction_id', country_name; + RAISE NOTICE 'cdb_geocoder_server.geocode_admin0_polygon invoked with params (%, %, %)', user_id, 'some_transaction_id', country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -- Exercise the public and the proxied function -SELECT cdb_geocoder_client.geocode_admin0_polygons('Spain'); -NOTICE: cdb_geocoder_client._geocode_admin0_polygons(3): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_admin0_polygons invoked with params (postgres, some_transaction_id, Spain) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin0_polygons(session_user, txid_current(), country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_admin0_polygons(text) line 5 at SQL statement - geocode_admin0_polygons -------------------------- +SELECT cdb_geocoder_client.geocode_admin0_polygon('Spain'); +NOTICE: cdb_geocoder_client._geocode_admin0_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin0_polygon invoked with params (postgres, some_transaction_id, Spain) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin0_polygon(session_user, txid_current(), country_name)" +PL/pgSQL function cdb_geocoder_client.geocode_admin0_polygon(text) line 5 at SQL statement + geocode_admin0_polygon +------------------------ (1 row) diff --git a/client/expected/20_admin1_test.out b/client/expected/20_admin1_test.out index 00ee342..86b3214 100644 --- a/client/expected/20_admin1_test.out +++ b/client/expected/20_admin1_test.out @@ -2,20 +2,20 @@ CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin1_polygon(user_id name, tx_id bigint, admin1_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cbd_geocoder_server.geocode_admin1_polygon invoked with params (%, %, %)', user_id, 'some_transaction_id', admin1_name; + RAISE NOTICE 'cdb_geocoder_server.geocode_admin1_polygon invoked with params (%, %, %)', user_id, 'some_transaction_id', admin1_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin1_polygon(user_id name, tx_id bigint, admin1_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cbd_geocoder_server.geocode_admin1_polygon invoked with params (%, %, %, %)', user_id, 'some_transaction_id', admin1_name, country_name; + RAISE NOTICE 'cdb_geocoder_server.geocode_admin1_polygon invoked with params (%, %, %, %)', user_id, 'some_transaction_id', admin1_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -- Exercise the public and the proxied function SELECT cdb_geocoder_client.geocode_admin1_polygon('California'); -NOTICE: cdb_geocoder_client._geocode_admin1_polygon(3): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_admin1_polygon invoked with params (postgres, some_transaction_id, California) +NOTICE: cdb_geocoder_client._geocode_admin1_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin1_polygon invoked with params (postgres, some_transaction_id, California) CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin1_polygon(session_user, txid_current(), admin1_name)" PL/pgSQL function cdb_geocoder_client.geocode_admin1_polygon(text) line 5 at SQL statement geocode_admin1_polygon @@ -24,7 +24,7 @@ PL/pgSQL function cdb_geocoder_client.geocode_admin1_polygon(text) line 5 at SQL (1 row) SELECT cdb_geocoder_client.geocode_admin1_polygon('California', 'United States'); -NOTICE: cdb_geocoder_client._geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_admin1_polygon invoked with params (postgres, some_transaction_id, California, United States) +NOTICE: cdb_geocoder_client._geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin1_polygon invoked with params (postgres, some_transaction_id, California, United States) CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin1_polygon(session_user, txid_current(), admin1_name, country_name)" PL/pgSQL function cdb_geocoder_client.geocode_admin1_polygon(text,text) line 5 at SQL statement geocode_admin1_polygon diff --git a/client/expected/30_namedplaces_test.out b/client/expected/30_namedplaces_test.out index 7bbd2f8..e476459 100644 --- a/client/expected/30_namedplaces_test.out +++ b/client/expected/30_namedplaces_test.out @@ -2,27 +2,27 @@ CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_namedplace_point(user_id name, tx_id bigint, city_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cbd_geocoder_server.geocode_namedplace_point invoked with params (%, %, %)', user_id, 'some_transaction_id', city_name; + RAISE NOTICE 'cdb_geocoder_server.geocode_namedplace_point invoked with params (%, %, %)', user_id, 'some_transaction_id', city_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_namedplace_point(user_id name, tx_id bigint, city_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cbd_geocoder_server.geocode_namedplace_point invoked with params (%, %, %, %)', user_id, 'some_transaction_id', city_name, country_name; + RAISE NOTICE 'cdb_geocoder_server.geocode_namedplace_point invoked with params (%, %, %, %)', user_id, 'some_transaction_id', city_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_namedplace_point(user_id name, tx_id bigint, city_name text, admin1_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cbd_geocoder_server.geocode_namedplace_point invoked with params (%, %, %, %, %)', user_id, 'some_transaction_id', city_name, admin1_name, country_name; + RAISE NOTICE 'cdb_geocoder_server.geocode_namedplace_point invoked with params (%, %, %, %, %)', user_id, 'some_transaction_id', city_name, admin1_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -- Exercise the public and the proxied function SELECT cdb_geocoder_client.geocode_namedplace_point('Elx'); -NOTICE: cdb_geocoder_client._geocode_namedplace_point(3): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx) +NOTICE: cdb_geocoder_client._geocode_namedplace_point(3): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx) CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, txid_current(), city_name)" PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text) line 5 at SQL statement geocode_namedplace_point @@ -31,7 +31,7 @@ PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text) line 5 at S (1 row) SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Spain'); -NOTICE: cdb_geocoder_client._geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx, Spain) +NOTICE: cdb_geocoder_client._geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx, Spain) CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, txid_current(), city_name, country_name)" PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text,text) line 5 at SQL statement geocode_namedplace_point @@ -40,7 +40,7 @@ PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text,text) line 5 (1 row) SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Valencia', 'Spain'); -NOTICE: cdb_geocoder_client._geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx, Valencia, Spain) +NOTICE: cdb_geocoder_client._geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx, Valencia, Spain) CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, txid_current(), city_name, admin1_name, country_name)" PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text,text,text) line 5 at SQL statement geocode_namedplace_point diff --git a/client/expected/90_permissions_test.out b/client/expected/90_permissions_test.out index 1341c35..3077bd4 100644 --- a/client/expected/90_permissions_test.out +++ b/client/expected/90_permissions_test.out @@ -2,17 +2,17 @@ SET ROLE test_regular_user; -- Exercise the public function -- it is public, it shall work -SELECT cdb_geocoder_client.geocode_admin0_polygons('Spain'); -NOTICE: cdb_geocoder_client._geocode_admin0_polygons(3): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_admin0_polygons invoked with params (postgres, some_transaction_id, Spain) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin0_polygons(session_user, txid_current(), country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_admin0_polygons(text) line 5 at SQL statement - geocode_admin0_polygons -------------------------- +SELECT cdb_geocoder_client.geocode_admin0_polygon('Spain'); +NOTICE: cdb_geocoder_client._geocode_admin0_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin0_polygon invoked with params (postgres, some_transaction_id, Spain) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin0_polygon(session_user, txid_current(), country_name)" +PL/pgSQL function cdb_geocoder_client.geocode_admin0_polygon(text) line 5 at SQL statement + geocode_admin0_polygon +------------------------ (1 row) SELECT cdb_geocoder_client.geocode_admin1_polygon('California'); -NOTICE: cdb_geocoder_client._geocode_admin1_polygon(3): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_admin1_polygon invoked with params (postgres, some_transaction_id, California) +NOTICE: cdb_geocoder_client._geocode_admin1_polygon(3): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin1_polygon invoked with params (postgres, some_transaction_id, California) CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin1_polygon(session_user, txid_current(), admin1_name)" PL/pgSQL function cdb_geocoder_client.geocode_admin1_polygon(text) line 5 at SQL statement geocode_admin1_polygon @@ -21,7 +21,7 @@ PL/pgSQL function cdb_geocoder_client.geocode_admin1_polygon(text) line 5 at SQL (1 row) SELECT cdb_geocoder_client.geocode_admin1_polygon('California', 'United States'); -NOTICE: cdb_geocoder_client._geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_admin1_polygon invoked with params (postgres, some_transaction_id, California, United States) +NOTICE: cdb_geocoder_client._geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin1_polygon invoked with params (postgres, some_transaction_id, California, United States) CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin1_polygon(session_user, txid_current(), admin1_name, country_name)" PL/pgSQL function cdb_geocoder_client.geocode_admin1_polygon(text,text) line 5 at SQL statement geocode_admin1_polygon @@ -30,7 +30,7 @@ PL/pgSQL function cdb_geocoder_client.geocode_admin1_polygon(text,text) line 5 a (1 row) SELECT cdb_geocoder_client.geocode_namedplace_point('Elx'); -NOTICE: cdb_geocoder_client._geocode_namedplace_point(3): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx) +NOTICE: cdb_geocoder_client._geocode_namedplace_point(3): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx) CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, txid_current(), city_name)" PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text) line 5 at SQL statement geocode_namedplace_point @@ -39,7 +39,7 @@ PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text) line 5 at S (1 row) SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Valencia'); -NOTICE: cdb_geocoder_client._geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx, Valencia) +NOTICE: cdb_geocoder_client._geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx, Valencia) CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, txid_current(), city_name, country_name)" PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text,text) line 5 at SQL statement geocode_namedplace_point @@ -48,7 +48,7 @@ PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text,text) line 5 (1 row) SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Valencia', 'Spain'); -NOTICE: cdb_geocoder_client._geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cbd_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx, Valencia, Spain) +NOTICE: cdb_geocoder_client._geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, some_transaction_id, Elx, Valencia, Spain) CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, txid_current(), city_name, admin1_name, country_name)" PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text,text,text) line 5 at SQL statement geocode_namedplace_point @@ -84,8 +84,8 @@ PL/pgSQL function cdb_geocoder_client.geocode_ip(text) line 5 at SQL statement (1 row) -- Check the regular user has no permissions on private functions -SELECT cdb_geocoder_client._geocode_admin0_polygons('evil_user', 666, 'Hell'); -ERROR: permission denied for function _geocode_admin0_polygons +SELECT cdb_geocoder_client._geocode_admin0_polygon('evil_user', 666, 'Hell'); +ERROR: permission denied for function _geocode_admin0_polygon SELECT cdb_geocoder_client._geocode_admin1_polygon('evil_user', 666, 'Hell'); ERROR: permission denied for function _geocode_admin1_polygon SELECT cdb_geocoder_client._geocode_admin1_polygon('evil_user', 666, 'Sheol', 'Hell'); diff --git a/client/sql/0.0.1/10_admin0.sql b/client/sql/0.0.1/10_admin0.sql index db719fd..6337496 100644 --- a/client/sql/0.0.1/10_admin0.sql +++ b/client/sql/0.0.1/10_admin0.sql @@ -4,12 +4,12 @@ -- These are the only ones with permissions to publicuser role -- and should also be the only ones with SECURITY DEFINER -CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_admin0_polygons(country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_admin0_polygon(country_name text) RETURNS Geometry AS $$ DECLARE ret Geometry; BEGIN - SELECT cdb_geocoder_client._geocode_admin0_polygons(session_user, txid_current(), country_name) INTO ret; + SELECT cdb_geocoder_client._geocode_admin0_polygon(session_user, txid_current(), country_name) INTO ret; RETURN ret; END; $$ LANGUAGE 'plpgsql' SECURITY DEFINER; @@ -19,8 +19,8 @@ $$ LANGUAGE 'plpgsql' SECURITY DEFINER; -------------------------------------------------------------------------------- -CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_admin0_polygons(user_id name, tx_id bigint, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_admin0_polygon(user_id name, tx_id bigint, country_name text) RETURNS Geometry AS $$ CONNECT cdb_geocoder_client._server_conn_str(); - SELECT cdb_geocoder_server.geocode_admin0_polygons(user_id, tx_id, country_name); + SELECT cdb_geocoder_server.geocode_admin0_polygon(user_id, tx_id, country_name); $$ LANGUAGE plproxy; diff --git a/client/sql/0.0.1/90_permissions.sql b/client/sql/0.0.1/90_permissions.sql index ec1c0aa..eaeaef0 100644 --- a/client/sql/0.0.1/90_permissions.sql +++ b/client/sql/0.0.1/90_permissions.sql @@ -12,7 +12,7 @@ REVOKE EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_geocoder_client FROM PUBLIC, publi -- Explicitly grant permissions to public functions -- NOTE: All public functions must be listed below, grating permissions to publicuser -GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_admin0_polygons(country_name text) TO publicuser; +GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_admin0_polygon(country_name text) TO publicuser; GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_admin1_polygon(admin1_name text) TO publicuser; GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_admin1_polygon(admin1_name text, country_name text) TO publicuser; GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_namedplace_point(city_name text) TO publicuser; diff --git a/client/sql/10_admin0_test.sql b/client/sql/10_admin0_test.sql index 2658d15..e54a746 100644 --- a/client/sql/10_admin0_test.sql +++ b/client/sql/10_admin0_test.sql @@ -1,12 +1,12 @@ -- Mock the server function -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin0_polygons(user_id name, tx_id bigint, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin0_polygon(user_id name, tx_id bigint, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_admin0_polygons invoked with params (%, %, %)', user_id, 'some_transaction_id', country_name; + RAISE NOTICE 'cdb_geocoder_server.geocode_admin0_polygon invoked with params (%, %, %)', user_id, 'some_transaction_id', country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -- Exercise the public and the proxied function -SELECT cdb_geocoder_client.geocode_admin0_polygons('Spain'); +SELECT cdb_geocoder_client.geocode_admin0_polygon('Spain'); diff --git a/client/sql/90_permissions_test.sql b/client/sql/90_permissions_test.sql index 1a1638b..6f160fa 100644 --- a/client/sql/90_permissions_test.sql +++ b/client/sql/90_permissions_test.sql @@ -3,7 +3,7 @@ SET ROLE test_regular_user; -- Exercise the public function -- it is public, it shall work -SELECT cdb_geocoder_client.geocode_admin0_polygons('Spain'); +SELECT cdb_geocoder_client.geocode_admin0_polygon('Spain'); SELECT cdb_geocoder_client.geocode_admin1_polygon('California'); SELECT cdb_geocoder_client.geocode_admin1_polygon('California', 'United States'); SELECT cdb_geocoder_client.geocode_namedplace_point('Elx'); @@ -14,7 +14,7 @@ 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 -SELECT cdb_geocoder_client._geocode_admin0_polygons('evil_user', 666, 'Hell'); +SELECT cdb_geocoder_client._geocode_admin0_polygon('evil_user', 666, 'Hell'); SELECT cdb_geocoder_client._geocode_admin1_polygon('evil_user', 666, 'Hell'); SELECT cdb_geocoder_client._geocode_admin1_polygon('evil_user', 666, 'Sheol', 'Hell'); SELECT cdb_geocoder_client._geocode_namedplace_point('evil_user', 666, 'Sheol');