diff --git a/client/expected/00_installation_test.out b/client/expected/00_installation_test.out index 1f08763..50028dd 100644 --- a/client/expected/00_installation_test.out +++ b/client/expected/00_installation_test.out @@ -33,3 +33,4 @@ CREATE SCHEMA cdb_geocoder_server; DROP ROLE IF EXISTS test_regular_user; CREATE ROLE test_regular_user; GRANT publicuser TO test_regular_user; +ALTER ROLE test_regular_user SET search_path TO "$user",public,cartodb,cdb_geocoder_client; diff --git a/client/expected/10_admin0_test.out b/client/expected/10_admin0_test.out index dc191eb..13c532f 100644 --- a/client/expected/10_admin0_test.out +++ b/client/expected/10_admin0_test.out @@ -1,18 +1,20 @@ +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; -- Mock the server function -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin0_polygon(user_id name, user_config JSON, geocoder_config JSON, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin0_polygon(user_id name, user_config JSON, geocoder_config JSON, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_admin0_polygon invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}' , country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_admin0_polygon invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}' , country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -- Exercise the public and the proxied function -SELECT cdb_geocoder_client.geocode_admin0_polygon('Spain'); -NOTICE: cdb_geocoder_client._geocode_admin0_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin0_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Spain) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin0_polygon(session_user, user_config, geocoder_config, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_admin0_polygon(text) line 12 at SQL statement - geocode_admin0_polygon ------------------------- +SELECT cdb_geocode_admin0_polygon('Spain'); +NOTICE: cdb_geocoder_client._cdb_geocode_admin0_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_admin0_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Spain) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_admin0_polygon(session_user, user_config, geocoder_config, country_name)" +PL/pgSQL function cdb_geocode_admin0_polygon(text) line 12 at SQL statement + cdb_geocode_admin0_polygon +---------------------------- (1 row) diff --git a/client/expected/20_admin1_test.out b/client/expected/20_admin1_test.out index a8de7fd..7428868 100644 --- a/client/expected/20_admin1_test.out +++ b/client/expected/20_admin1_test.out @@ -1,34 +1,36 @@ +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_admin1_polygon invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', admin1_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', admin1_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_admin1_polygon invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', admin1_name, country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 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(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin1_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, California) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin1_polygon(session_user, user_config, geocoder_config, admin1_name)" -PL/pgSQL function cdb_geocoder_client.geocode_admin1_polygon(text) line 12 at SQL statement - geocode_admin1_polygon ------------------------- +SELECT cdb_geocode_admin1_polygon('California'); +NOTICE: cdb_geocoder_client._cdb_geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_admin1_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, California) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_admin1_polygon(session_user, user_config, geocoder_config, admin1_name)" +PL/pgSQL function cdb_geocode_admin1_polygon(text) line 12 at SQL statement + cdb_geocode_admin1_polygon +---------------------------- (1 row) -SELECT cdb_geocoder_client.geocode_admin1_polygon('California', 'United States'); -NOTICE: cdb_geocoder_client._geocode_admin1_polygon(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin1_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, California, United States) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin1_polygon(session_user, user_config, geocoder_config, admin1_name, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_admin1_polygon(text,text) line 12 at SQL statement - geocode_admin1_polygon ------------------------- +SELECT cdb_geocode_admin1_polygon('California', 'United States'); +NOTICE: cdb_geocoder_client._cdb_geocode_admin1_polygon(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_admin1_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, California, United States) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_admin1_polygon(session_user, user_config, geocoder_config, admin1_name, country_name)" +PL/pgSQL function cdb_geocode_admin1_polygon(text,text) line 12 at SQL statement + cdb_geocode_admin1_polygon +---------------------------- (1 row) diff --git a/client/expected/30_namedplaces_test.out b/client/expected/30_namedplaces_test.out index fea70ad..8470520 100644 --- a/client/expected/30_namedplaces_test.out +++ b/client/expected/30_namedplaces_test.out @@ -1,50 +1,52 @@ +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_namedplace_point invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', city_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', city_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_namedplace_point invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', city_name, country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', city_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text, admin1_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_namedplace_point invoked with params (%, %, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', city_name, admin1_name, country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 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(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, user_config, geocoder_config, city_name)" -PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text) line 12 at SQL statement - geocode_namedplace_point --------------------------- +SELECT cdb_geocode_namedplace_point('Elx'); +NOTICE: cdb_geocoder_client._cdb_geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_namedplace_point(session_user, user_config, geocoder_config, city_name)" +PL/pgSQL function cdb_geocode_namedplace_point(text) line 12 at SQL statement + cdb_geocode_namedplace_point +------------------------------ (1 row) -SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Spain'); -NOTICE: cdb_geocoder_client._geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx, Spain) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, user_config, geocoder_config, city_name, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text,text) line 12 at SQL statement - geocode_namedplace_point --------------------------- +SELECT cdb_geocode_namedplace_point('Elx', 'Spain'); +NOTICE: cdb_geocoder_client._cdb_geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx, Spain) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_namedplace_point(session_user, user_config, geocoder_config, city_name, country_name)" +PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 12 at SQL statement + cdb_geocode_namedplace_point +------------------------------ (1 row) -SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Valencia', 'Spain'); -NOTICE: cdb_geocoder_client._geocode_namedplace_point(6): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx, Valencia, Spain) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, user_config, geocoder_config, city_name, admin1_name, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text,text,text) line 12 at SQL statement - geocode_namedplace_point --------------------------- +SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain'); +NOTICE: cdb_geocoder_client._cdb_geocode_namedplace_point(6): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx, Valencia, Spain) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_namedplace_point(session_user, user_config, geocoder_config, city_name, admin1_name, country_name)" +PL/pgSQL function cdb_geocode_namedplace_point(text,text,text) line 12 at SQL statement + cdb_geocode_namedplace_point +------------------------------ (1 row) diff --git a/client/expected/40_postalcodes_test.out b/client/expected/40_postalcodes_test.out index 30137a8..00d052b 100644 --- a/client/expected/40_postalcodes_test.out +++ b/client/expected/40_postalcodes_test.out @@ -1,34 +1,36 @@ +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_postalcode_polygon(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_polygon(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_postalcode_polygon invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', postal_code, country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_postalcode_polygon invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', postal_code, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_postalcode_point(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_point(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_postalcode_point invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', postal_code, country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_postalcode_point invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 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'); -NOTICE: cdb_geocoder_client._geocode_postalcode_polygon(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_postalcode_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 03204, Spain) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_postalcode_polygon(session_user, user_config, geocoder_config, postal_code, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_postalcode_polygon(text,text) line 12 at SQL statement - geocode_postalcode_polygon ----------------------------- +SELECT cdb_geocode_postalcode_polygon('03204', 'Spain'); +NOTICE: cdb_geocoder_client._cdb_geocode_postalcode_polygon(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_postalcode_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 03204, Spain) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_postalcode_polygon(session_user, user_config, geocoder_config, postal_code, country_name)" +PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 12 at SQL statement + cdb_geocode_postalcode_polygon +-------------------------------- (1 row) -SELECT cdb_geocoder_client.geocode_postalcode_point('03204', 'Spain'); -NOTICE: cdb_geocoder_client._geocode_postalcode_point(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_postalcode_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 03204, Spain) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_postalcode_point(session_user, user_config, geocoder_config, postal_code, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_postalcode_point(text,text) line 12 at SQL statement - geocode_postalcode_point --------------------------- +SELECT cdb_geocode_postalcode_point('03204', 'Spain'); +NOTICE: cdb_geocoder_client._cdb_geocode_postalcode_point(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_postalcode_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 03204, Spain) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_postalcode_point(session_user, user_config, geocoder_config, postal_code, country_name)" +PL/pgSQL function cdb_geocode_postalcode_point(text,text) line 12 at SQL statement + cdb_geocode_postalcode_point +------------------------------ (1 row) diff --git a/client/expected/50_ipaddresses_test.out b/client/expected/50_ipaddresses_test.out index e4f417a..a8cbbfd 100644 --- a/client/expected/50_ipaddresses_test.out +++ b/client/expected/50_ipaddresses_test.out @@ -1,18 +1,20 @@ +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_ipaddress_point(user_id name, user_config JSON, geocoder_config JSON, ip_address text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_ipaddress_point(user_id name, user_config JSON, geocoder_config JSON, ip_address text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_ipaddress_point invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', ip_address; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_ipaddress_point invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', ip_address; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -- Exercise the public and the proxied function -SELECT cdb_geocoder_client.geocode_ipaddress_point('8.8.8.8'); -NOTICE: cdb_geocoder_client._geocode_ipaddress_point(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_ipaddress_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 8.8.8.8) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_ipaddress_point(session_user, user_config, geocoder_config, ip_address)" -PL/pgSQL function cdb_geocoder_client.geocode_ipaddress_point(text) line 12 at SQL statement - geocode_ipaddress_point -------------------------- +SELECT cdb_geocode_ipaddress_point('8.8.8.8'); +NOTICE: cdb_geocoder_client._cdb_geocode_ipaddress_point(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_ipaddress_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 8.8.8.8) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_ipaddress_point(session_user, user_config, geocoder_config, ip_address)" +PL/pgSQL function cdb_geocode_ipaddress_point(text) line 12 at SQL statement + cdb_geocode_ipaddress_point +----------------------------- (1 row) diff --git a/client/expected/90_permissions_test.out b/client/expected/90_permissions_test.out index 2dfafb8..8b70706 100644 --- a/client/expected/90_permissions_test.out +++ b/client/expected/90_permissions_test.out @@ -1,104 +1,106 @@ -- Use regular user role SET ROLE test_regular_user; +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; -- Exercise the public function -- it is public, it shall work -SELECT cdb_geocoder_client.geocode_admin0_polygon('Spain'); -NOTICE: cdb_geocoder_client._geocode_admin0_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin0_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Spain) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin0_polygon(session_user, user_config, geocoder_config, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_admin0_polygon(text) line 12 at SQL statement - geocode_admin0_polygon ------------------------- - -(1 row) - -SELECT cdb_geocoder_client.geocode_admin1_polygon('California'); -NOTICE: cdb_geocoder_client._geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin1_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, California) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin1_polygon(session_user, user_config, geocoder_config, admin1_name)" -PL/pgSQL function cdb_geocoder_client.geocode_admin1_polygon(text) line 12 at SQL statement - geocode_admin1_polygon ------------------------- - -(1 row) - -SELECT cdb_geocoder_client.geocode_admin1_polygon('California', 'United States'); -NOTICE: cdb_geocoder_client._geocode_admin1_polygon(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_admin1_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, California, United States) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_admin1_polygon(session_user, user_config, geocoder_config, admin1_name, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_admin1_polygon(text,text) line 12 at SQL statement - geocode_admin1_polygon ------------------------- - -(1 row) - -SELECT cdb_geocoder_client.geocode_namedplace_point('Elx'); -NOTICE: cdb_geocoder_client._geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, user_config, geocoder_config, city_name)" -PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text) line 12 at SQL statement - geocode_namedplace_point --------------------------- - -(1 row) - -SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Valencia'); -NOTICE: cdb_geocoder_client._geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx, Valencia) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, user_config, geocoder_config, city_name, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text,text) line 12 at SQL statement - geocode_namedplace_point --------------------------- - -(1 row) - -SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Valencia', 'Spain'); -NOTICE: cdb_geocoder_client._geocode_namedplace_point(6): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx, Valencia, Spain) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, user_config, geocoder_config, city_name, admin1_name, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_namedplace_point(text,text,text) line 12 at SQL statement - geocode_namedplace_point --------------------------- - -(1 row) - -SELECT cdb_geocoder_client.geocode_postalcode_polygon('03204', 'Spain'); -NOTICE: cdb_geocoder_client._geocode_postalcode_polygon(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_postalcode_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 03204, Spain) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_postalcode_polygon(session_user, user_config, geocoder_config, postal_code, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_postalcode_polygon(text,text) line 12 at SQL statement - geocode_postalcode_polygon +SELECT cdb_geocode_admin0_polygon('Spain'); +NOTICE: cdb_geocoder_client._cdb_geocode_admin0_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_admin0_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Spain) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_admin0_polygon(session_user, user_config, geocoder_config, country_name)" +PL/pgSQL function cdb_geocode_admin0_polygon(text) line 12 at SQL statement + cdb_geocode_admin0_polygon ---------------------------- (1 row) -SELECT cdb_geocoder_client.geocode_postalcode_point('03204', 'Spain'); -NOTICE: cdb_geocoder_client._geocode_postalcode_point(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_postalcode_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 03204, Spain) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_postalcode_point(session_user, user_config, geocoder_config, postal_code, country_name)" -PL/pgSQL function cdb_geocoder_client.geocode_postalcode_point(text,text) line 12 at SQL statement - geocode_postalcode_point --------------------------- +SELECT cdb_geocode_admin1_polygon('California'); +NOTICE: cdb_geocoder_client._cdb_geocode_admin1_polygon(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_admin1_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, California) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_admin1_polygon(session_user, user_config, geocoder_config, admin1_name)" +PL/pgSQL function cdb_geocode_admin1_polygon(text) line 12 at SQL statement + cdb_geocode_admin1_polygon +---------------------------- (1 row) -SELECT cdb_geocoder_client.geocode_ipaddress_point('8.8.8.8'); -NOTICE: cdb_geocoder_client._geocode_ipaddress_point(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.geocode_ipaddress_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 8.8.8.8) -CONTEXT: SQL statement "SELECT cdb_geocoder_client._geocode_ipaddress_point(session_user, user_config, geocoder_config, ip_address)" -PL/pgSQL function cdb_geocoder_client.geocode_ipaddress_point(text) line 12 at SQL statement - geocode_ipaddress_point -------------------------- +SELECT cdb_geocode_admin1_polygon('California', 'United States'); +NOTICE: cdb_geocoder_client._cdb_geocode_admin1_polygon(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_admin1_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, California, United States) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_admin1_polygon(session_user, user_config, geocoder_config, admin1_name, country_name)" +PL/pgSQL function cdb_geocode_admin1_polygon(text,text) line 12 at SQL statement + cdb_geocode_admin1_polygon +---------------------------- + +(1 row) + +SELECT cdb_geocode_namedplace_point('Elx'); +NOTICE: cdb_geocoder_client._cdb_geocode_namedplace_point(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_namedplace_point(session_user, user_config, geocoder_config, city_name)" +PL/pgSQL function cdb_geocode_namedplace_point(text) line 12 at SQL statement + cdb_geocode_namedplace_point +------------------------------ + +(1 row) + +SELECT cdb_geocode_namedplace_point('Elx', 'Valencia'); +NOTICE: cdb_geocoder_client._cdb_geocode_namedplace_point(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx, Valencia) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_namedplace_point(session_user, user_config, geocoder_config, city_name, country_name)" +PL/pgSQL function cdb_geocode_namedplace_point(text,text) line 12 at SQL statement + cdb_geocode_namedplace_point +------------------------------ + +(1 row) + +SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain'); +NOTICE: cdb_geocoder_client._cdb_geocode_namedplace_point(6): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, Elx, Valencia, Spain) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_namedplace_point(session_user, user_config, geocoder_config, city_name, admin1_name, country_name)" +PL/pgSQL function cdb_geocode_namedplace_point(text,text,text) line 12 at SQL statement + cdb_geocode_namedplace_point +------------------------------ + +(1 row) + +SELECT cdb_geocode_postalcode_polygon('03204', 'Spain'); +NOTICE: cdb_geocoder_client._cdb_geocode_postalcode_polygon(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_postalcode_polygon invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 03204, Spain) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_postalcode_polygon(session_user, user_config, geocoder_config, postal_code, country_name)" +PL/pgSQL function cdb_geocode_postalcode_polygon(text,text) line 12 at SQL statement + cdb_geocode_postalcode_polygon +-------------------------------- + +(1 row) + +SELECT cdb_geocode_postalcode_point('03204', 'Spain'); +NOTICE: cdb_geocoder_client._cdb_geocode_postalcode_point(5): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_postalcode_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 03204, Spain) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_postalcode_point(session_user, user_config, geocoder_config, postal_code, country_name)" +PL/pgSQL function cdb_geocode_postalcode_point(text,text) line 12 at SQL statement + cdb_geocode_postalcode_point +------------------------------ + +(1 row) + +SELECT cdb_geocode_ipaddress_point('8.8.8.8'); +NOTICE: cdb_geocoder_client._cdb_geocode_ipaddress_point(4): [contrib_regression] REMOTE NOTICE: cdb_geocoder_server.cdb_geocode_ipaddress_point invoked with params (postgres, {"is_organization": false, "entity_name": "test_user"}, {"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}, 8.8.8.8) +CONTEXT: SQL statement "SELECT cdb_geocoder_client._cdb_geocode_ipaddress_point(session_user, user_config, geocoder_config, ip_address)" +PL/pgSQL function cdb_geocode_ipaddress_point(text) line 12 at SQL statement + cdb_geocode_ipaddress_point +----------------------------- (1 row) -- Check the regular user has no permissions on private functions -SELECT cdb_geocoder_client._geocode_admin0_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Hell'); -ERROR: permission denied for function _geocode_admin0_polygon -SELECT cdb_geocoder_client._geocode_admin1_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Hell'); -ERROR: permission denied for function _geocode_admin1_polygon -SELECT cdb_geocoder_client._geocode_admin1_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell'); -ERROR: permission denied for function _geocode_admin1_polygon -SELECT cdb_geocoder_client._geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol'); -ERROR: permission denied for function _geocode_namedplace_point -SELECT cdb_geocoder_client._geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell'); -ERROR: permission denied for function _geocode_namedplace_point -SELECT cdb_geocoder_client._geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell', 'Ugly world'); -ERROR: permission denied for function _geocode_namedplace_point -SELECT cdb_geocoder_client._geocode_postalcode_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '66666', 'Hell'); -ERROR: permission denied for function _geocode_postalcode_polygon -SELECT cdb_geocoder_client._geocode_postalcode_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '66666', 'Hell'); -ERROR: permission denied for function _geocode_postalcode_point -SELECT cdb_geocoder_client._geocode_ipaddress_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '8.8.8.8'); -ERROR: permission denied for function _geocode_ipaddress_point +SELECT _cdb_geocode_admin0_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Hell'); +ERROR: permission denied for function _cdb_geocode_admin0_polygon +SELECT _cdb_geocode_admin1_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Hell'); +ERROR: permission denied for function _cdb_geocode_admin1_polygon +SELECT _cdb_geocode_admin1_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell'); +ERROR: permission denied for function _cdb_geocode_admin1_polygon +SELECT _cdb_geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol'); +ERROR: permission denied for function _cdb_geocode_namedplace_point +SELECT _cdb_geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell'); +ERROR: permission denied for function _cdb_geocode_namedplace_point +SELECT _cdb_geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell', 'Ugly world'); +ERROR: permission denied for function _cdb_geocode_namedplace_point +SELECT _cdb_geocode_postalcode_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '66666', 'Hell'); +ERROR: permission denied for function _cdb_geocode_postalcode_polygon +SELECT _cdb_geocode_postalcode_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '66666', 'Hell'); +ERROR: permission denied for function _cdb_geocode_postalcode_point +SELECT _cdb_geocode_ipaddress_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '8.8.8.8'); +ERROR: permission denied for function _cdb_geocode_ipaddress_point diff --git a/client/sql/00_installation_test.sql b/client/sql/00_installation_test.sql index 49c85c4..29dbdcc 100644 --- a/client/sql/00_installation_test.sql +++ b/client/sql/00_installation_test.sql @@ -22,3 +22,4 @@ CREATE SCHEMA cdb_geocoder_server; DROP ROLE IF EXISTS test_regular_user; CREATE ROLE test_regular_user; GRANT publicuser TO test_regular_user; +ALTER ROLE test_regular_user SET search_path TO "$user",public,cartodb,cdb_geocoder_client; \ No newline at end of file diff --git a/client/sql/10_admin0_test.sql b/client/sql/10_admin0_test.sql index 42f51e8..f1ac039 100644 --- a/client/sql/10_admin0_test.sql +++ b/client/sql/10_admin0_test.sql @@ -1,12 +1,15 @@ +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; + -- Mock the server function -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin0_polygon(user_id name, user_config JSON, geocoder_config JSON, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin0_polygon(user_id name, user_config JSON, geocoder_config JSON, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_admin0_polygon invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}' , country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_admin0_polygon invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}' , country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -- Exercise the public and the proxied function -SELECT cdb_geocoder_client.geocode_admin0_polygon('Spain'); +SELECT cdb_geocode_admin0_polygon('Spain'); diff --git a/client/sql/20_admin1_test.sql b/client/sql/20_admin1_test.sql index 9867d8e..fb130fc 100644 --- a/client/sql/20_admin1_test.sql +++ b/client/sql/20_admin1_test.sql @@ -1,21 +1,24 @@ +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; + -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_admin1_polygon invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', admin1_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', admin1_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config JSON, geocoder_config JSON, admin1_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_admin1_polygon invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', admin1_name, country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', admin1_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -- Exercise the public and the proxied function -SELECT cdb_geocoder_client.geocode_admin1_polygon('California'); -SELECT cdb_geocoder_client.geocode_admin1_polygon('California', 'United States'); +SELECT cdb_geocode_admin1_polygon('California'); +SELECT cdb_geocode_admin1_polygon('California', 'United States'); diff --git a/client/sql/30_namedplaces_test.sql b/client/sql/30_namedplaces_test.sql index a32d562..491acc6 100644 --- a/client/sql/30_namedplaces_test.sql +++ b/client/sql/30_namedplaces_test.sql @@ -1,30 +1,33 @@ +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; + -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_namedplace_point invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', city_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', city_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_namedplace_point invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', city_name, country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', city_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config JSON, geocoder_config JSON, city_name text, admin1_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_namedplace_point invoked with params (%, %, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', city_name, admin1_name, country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 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'); -SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Spain'); -SELECT cdb_geocoder_client.geocode_namedplace_point('Elx', 'Valencia', 'Spain'); +SELECT cdb_geocode_namedplace_point('Elx'); +SELECT cdb_geocode_namedplace_point('Elx', 'Spain'); +SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain'); diff --git a/client/sql/40_postalcodes_test.sql b/client/sql/40_postalcodes_test.sql index 6236d20..4c4a47d 100644 --- a/client/sql/40_postalcodes_test.sql +++ b/client/sql/40_postalcodes_test.sql @@ -1,20 +1,23 @@ +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; + -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_postalcode_polygon(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_polygon(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_postalcode_polygon invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', postal_code, country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_postalcode_polygon invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', postal_code, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_postalcode_point(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_point(user_id name, user_config JSON, geocoder_config JSON, postal_code text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_postalcode_point invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', postal_code, country_name; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_postalcode_point invoked with params (%, %, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 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_point('03204', 'Spain'); +SELECT cdb_geocode_postalcode_polygon('03204', 'Spain'); +SELECT cdb_geocode_postalcode_point('03204', 'Spain'); diff --git a/client/sql/50_ipaddresses_test.sql b/client/sql/50_ipaddresses_test.sql index bfbf126..c4117df 100644 --- a/client/sql/50_ipaddresses_test.sql +++ b/client/sql/50_ipaddresses_test.sql @@ -1,12 +1,15 @@ +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; + -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_ipaddress_point(user_id name, user_config JSON, geocoder_config JSON, ip_address text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_ipaddress_point(user_id name, user_config JSON, geocoder_config JSON, ip_address text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_geocoder_server.geocode_ipaddress_point invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', ip_address; + RAISE NOTICE 'cdb_geocoder_server.cdb_geocode_ipaddress_point invoked with params (%, %, %, %)', user_id, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', ip_address; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -- Exercise the public and the proxied function -SELECT cdb_geocoder_client.geocode_ipaddress_point('8.8.8.8'); +SELECT cdb_geocode_ipaddress_point('8.8.8.8'); diff --git a/client/sql/90_permissions_test.sql b/client/sql/90_permissions_test.sql index 1973f8b..3b05b79 100644 --- a/client/sql/90_permissions_test.sql +++ b/client/sql/90_permissions_test.sql @@ -1,25 +1,28 @@ -- Use regular user role SET ROLE test_regular_user; +-- Add to the search path the schema +SET search_path TO "$user",public,cartodb,cdb_geocoder_client; + -- Exercise the public function -- it is public, it shall work -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'); -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_point('03204', 'Spain'); -SELECT cdb_geocoder_client.geocode_ipaddress_point('8.8.8.8'); +SELECT cdb_geocode_admin0_polygon('Spain'); +SELECT cdb_geocode_admin1_polygon('California'); +SELECT cdb_geocode_admin1_polygon('California', 'United States'); +SELECT cdb_geocode_namedplace_point('Elx'); +SELECT cdb_geocode_namedplace_point('Elx', 'Valencia'); +SELECT cdb_geocode_namedplace_point('Elx', 'Valencia', 'Spain'); +SELECT cdb_geocode_postalcode_polygon('03204', 'Spain'); +SELECT cdb_geocode_postalcode_point('03204', 'Spain'); +SELECT cdb_geocode_ipaddress_point('8.8.8.8'); -- Check the regular user has no permissions on private functions -SELECT cdb_geocoder_client._geocode_admin0_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Hell'); -SELECT cdb_geocoder_client._geocode_admin1_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Hell'); -SELECT cdb_geocoder_client._geocode_admin1_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell'); -SELECT cdb_geocoder_client._geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol'); -SELECT cdb_geocoder_client._geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell'); -SELECT cdb_geocoder_client._geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell', 'Ugly world'); -SELECT cdb_geocoder_client._geocode_postalcode_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '66666', 'Hell'); -SELECT cdb_geocoder_client._geocode_postalcode_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '66666', 'Hell'); -SELECT cdb_geocoder_client._geocode_ipaddress_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '8.8.8.8'); +SELECT _cdb_geocode_admin0_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Hell'); +SELECT _cdb_geocode_admin1_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Hell'); +SELECT _cdb_geocode_admin1_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell'); +SELECT _cdb_geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol'); +SELECT _cdb_geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell'); +SELECT _cdb_geocode_namedplace_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Sheol', 'Hell', 'Ugly world'); +SELECT _cdb_geocode_postalcode_polygon('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '66666', 'Hell'); +SELECT _cdb_geocode_postalcode_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '66666', 'Hell'); +SELECT _cdb_geocode_ipaddress_point('evil_user', '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '8.8.8.8'); diff --git a/interface.yaml b/interface.yaml index 01b1cc0..535c02d 100644 --- a/interface.yaml +++ b/interface.yaml @@ -1,19 +1,19 @@ --- -- name: geocode_admin0_polygon +- name: cdb_geocode_admin0_polygon return_type: Geometry user_config_key: user_config geocoder_config_key: geocoder_config params: - { name: country_name, type: text } -- name: geocode_admin1_polygon +- name: cdb_geocode_admin1_polygon return_type: Geometry user_config_key: user_config geocoder_config_key: geocoder_config params: - { name: admin1_name, type: text } -- name: geocode_admin1_polygon +- name: cdb_geocode_admin1_polygon return_type: Geometry user_config_key: user_config geocoder_config_key: geocoder_config @@ -21,14 +21,14 @@ - { name: admin1_name, type: text } - { name: country_name, type: text } -- name: geocode_namedplace_point +- name: cdb_geocode_namedplace_point return_type: Geometry user_config_key: user_config geocoder_config_key: geocoder_config params: - { name: city_name, type: text} -- name: geocode_namedplace_point +- name: cdb_geocode_namedplace_point return_type: Geometry user_config_key: user_config geocoder_config_key: geocoder_config @@ -36,7 +36,7 @@ - { name: city_name, type: text} - { name: country_name, type: text} -- name: geocode_namedplace_point +- name: cdb_geocode_namedplace_point return_type: Geometry user_config_key: user_config geocoder_config_key: geocoder_config @@ -46,7 +46,7 @@ - { name: country_name, type: text} -- name: geocode_postalcode_polygon +- name: cdb_geocode_postalcode_polygon return_type: Geometry user_config_key: user_config geocoder_config_key: geocoder_config @@ -54,7 +54,7 @@ - { name: postal_code, type: text} - { name: country_name, type: text} -- name: geocode_postalcode_point +- name: cdb_geocode_postalcode_point return_type: Geometry user_config_key: user_config geocoder_config_key: geocoder_config @@ -62,7 +62,7 @@ - { name: postal_code, type: text} - { name: country_name, type: text} -- name: geocode_ipaddress_point +- name: cdb_geocode_ipaddress_point return_type: Geometry user_config_key: user_config geocoder_config_key: geocoder_config diff --git a/server/extension/expected/30_admin0_test.out b/server/extension/expected/30_admin0_test.out index 2ce7cff..d4aa801 100644 --- a/server/extension/expected/30_admin0_test.out +++ b/server/extension/expected/30_admin0_test.out @@ -1,8 +1,8 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_geocoder_server.geocode_admin0_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'Spain'); - geocode_admin0_polygon ------------------------- +SELECT cdb_geocoder_server.cdb_geocode_admin0_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'Spain'); + cdb_geocode_admin0_polygon +---------------------------- (1 row) @@ -16,8 +16,8 @@ INSERT INTO ne_admin0_v3 (adm0_a3, the_geom) VALUES('ESP', ST_GeomFromText( -71.1031880899493 42.3152774590236))',4326) ); -- This should return the polygon inserted above -SELECT cdb_geocoder_server.geocode_admin0_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'Spain'); - geocode_admin0_polygon +SELECT cdb_geocoder_server.cdb_geocode_admin0_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'Spain'); + cdb_geocode_admin0_polygon -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540 (1 row) @@ -27,7 +27,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_admin0_polygon' + AND proname = 'cdb_geocode_admin0_polygon' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); exists -------- @@ -38,7 +38,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_admin0_polygon' + AND proname = '_cdb_geocode_admin0_polygon' AND oidvectortypes(p.proargtypes) = 'text'); exists -------- diff --git a/server/extension/expected/40_admin1_test.out b/server/extension/expected/40_admin1_test.out index 1967425..0b130bc 100644 --- a/server/extension/expected/40_admin1_test.out +++ b/server/extension/expected/40_admin1_test.out @@ -1,14 +1,14 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'California'); - geocode_admin1_polygon ------------------------- +SELECT cdb_geocoder_server.cdb_geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'California'); + cdb_geocode_admin1_polygon +---------------------------- (1 row) -SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'California', 'United States'); - geocode_admin1_polygon ------------------------- +SELECT cdb_geocoder_server.cdb_geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'California', 'United States'); + cdb_geocode_admin1_polygon +---------------------------- (1 row) @@ -22,14 +22,14 @@ INSERT INTO global_province_polygons (synonyms, iso3, the_geom) VALUES (Array['c -71.1031880899493 42.3152774590236))',4326) ); -- This should return the polygon inserted above -SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'California'); - geocode_admin1_polygon +SELECT cdb_geocoder_server.cdb_geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'California'); + cdb_geocode_admin1_polygon -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540 (1 row) -SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'California', 'United States'); - geocode_admin1_polygon +SELECT cdb_geocoder_server.cdb_geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'California', 'United States'); + cdb_geocode_admin1_polygon -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540 (1 row) @@ -39,7 +39,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_admin1_polygon' + AND proname = 'cdb_geocode_admin1_polygon' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); exists -------- @@ -50,7 +50,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_admin1_polygon' + AND proname = 'cdb_geocode_admin1_polygon' AND oidvectortypes(p.proargtypes) = 'name, json, json, text, text'); exists -------- @@ -61,7 +61,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_admin1_polygon' + AND proname = '_cdb_geocode_admin1_polygon' AND oidvectortypes(p.proargtypes) = 'text'); exists -------- @@ -72,7 +72,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_admin1_polygon' + AND proname = '_cdb_geocode_admin1_polygon' AND oidvectortypes(p.proargtypes) = 'text, text'); exists -------- diff --git a/server/extension/expected/50_namedplaces_test.out b/server/extension/expected/50_namedplaces_test.out index 75ec79a..86f9e80 100644 --- a/server/extension/expected/50_namedplaces_test.out +++ b/server/extension/expected/50_namedplaces_test.out @@ -1,20 +1,20 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx'); - geocode_namedplace_point --------------------------- +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx'); + cdb_geocode_namedplace_point +------------------------------ (1 row) -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Spain'); - geocode_namedplace_point --------------------------- +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Spain'); + cdb_geocode_namedplace_point +------------------------------ (1 row) -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Valencia', 'Spain'); - geocode_namedplace_point --------------------------- +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Valencia', 'Spain'); + cdb_geocode_namedplace_point +------------------------------ (1 row) @@ -31,38 +31,38 @@ INSERT INTO country_decoder (synonyms, iso2) VALUES (Array['spain'], 'ES'); -- Insert dummy data into admin1 decoder table INSERT INTO admin1_decoder (admin1, synonyms, iso2) VALUES ('Valencia', Array['valencia', 'Valencia'], 'ES'); -- This should return the point inserted above -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx'); - geocode_namedplace_point +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx'); + cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche'); - geocode_namedplace_point +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche'); + cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Spain'); - geocode_namedplace_point +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Spain'); + cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche', 'Spain'); - geocode_namedplace_point +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche', 'Spain'); + cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Valencia', 'Spain'); - geocode_namedplace_point +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Valencia', 'Spain'); + cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche', 'valencia', 'Spain'); - geocode_namedplace_point +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche', 'valencia', 'Spain'); + cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) @@ -72,7 +72,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_namedplace_point' + AND proname = 'cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); exists -------- @@ -83,7 +83,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_namedplace_point' + AND proname = 'cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text, text'); exists -------- @@ -94,7 +94,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_namedplace_point' + AND proname = 'cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text, text'); exists -------- @@ -105,7 +105,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_namedplace_point' + AND proname = '_cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'text'); exists -------- @@ -116,7 +116,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_namedplace_point' + AND proname = '_cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'text, text'); exists -------- @@ -127,7 +127,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_namedplace_point' + AND proname = '_cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'text, text, text'); exists -------- diff --git a/server/extension/expected/60_postalcodes_test.out b/server/extension/expected/60_postalcodes_test.out index b9c3bf9..3c012bf 100644 --- a/server/extension/expected/60_postalcodes_test.out +++ b/server/extension/expected/60_postalcodes_test.out @@ -6,9 +6,9 @@ DELETE FROM available_services; DELETE FROM admin0_synonyms; -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_geocoder_server.geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); - geocode_postalcode_point --------------------------- +SELECT cdb_geocoder_server.cdb_geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); + cdb_geocode_postalcode_point +------------------------------ (1 row) @@ -42,26 +42,26 @@ INSERT INTO admin0_synonyms (adm0_a3, name, name_, rank) VALUES ( 3 ); -- This should return the polygon inserted above -SELECT cdb_geocoder_server.geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); - geocode_postalcode_point +SELECT cdb_geocoder_server.cdb_geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); + cdb_geocode_postalcode_point ---------------------------------------------------- 0101000020E61000000000000000E040408036B47414764840 (1 row) -SELECT cdb_geocoder_server.geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204', 'spain'); - geocode_postalcode_point +SELECT cdb_geocoder_server.cdb_geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204', 'spain'); + cdb_geocode_postalcode_point ---------------------------------------------------- 0101000020E61000000000000000E040408036B47414764840 (1 row) -SELECT cdb_geocoder_server.geocode_postalcode_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); - geocode_postalcode_polygon +SELECT cdb_geocoder_server.cdb_geocode_postalcode_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); + cdb_geocode_postalcode_polygon -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0106000020E610000001000000010300000001000000040000000000000000E000C01F383D7839B740400000000000E000C0AA3C0EDE220F3B4000000000004812404FB7FCCD04893D400000000000E000C01F383D7839B74040 (1 row) -SELECT cdb_geocoder_server.geocode_postalcode_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204', 'spain'); - geocode_postalcode_polygon +SELECT cdb_geocoder_server.cdb_geocode_postalcode_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204', 'spain'); + cdb_geocode_postalcode_polygon -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0106000020E610000001000000010300000001000000040000000000000000E000C01F383D7839B740400000000000E000C0AA3C0EDE220F3B4000000000004812404FB7FCCD04893D400000000000E000C01F383D7839B74040 (1 row) @@ -77,7 +77,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_postalcode_point' + AND proname = 'cdb_geocode_postalcode_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); exists -------- @@ -88,7 +88,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_postalcode_point' + AND proname = 'cdb_geocode_postalcode_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text, text'); exists -------- @@ -99,7 +99,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_postalcode_polygon' + AND proname = 'cdb_geocode_postalcode_polygon' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); exists -------- @@ -110,7 +110,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_postalcode_polygon' + AND proname = 'cdb_geocode_postalcode_polygon' AND oidvectortypes(p.proargtypes) = 'name, json, json, text, text'); exists -------- @@ -121,7 +121,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_postalcode_point' + AND proname = '_cdb_geocode_postalcode_point' AND oidvectortypes(p.proargtypes) = 'text'); exists -------- @@ -132,7 +132,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_postalcode_point' + AND proname = '_cdb_geocode_postalcode_point' AND oidvectortypes(p.proargtypes) = 'text, text'); exists -------- @@ -143,7 +143,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_postalcode_polygon' + AND proname = '_cdb_geocode_postalcode_polygon' AND oidvectortypes(p.proargtypes) = 'text'); exists -------- @@ -154,7 +154,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_postalcode_polygon' + AND proname = '_cdb_geocode_postalcode_polygon' AND oidvectortypes(p.proargtypes) = 'text, text'); exists -------- diff --git a/server/extension/expected/70_ips_test.out b/server/extension/expected/70_ips_test.out index 9dd9f81..8548e14 100644 --- a/server/extension/expected/70_ips_test.out +++ b/server/extension/expected/70_ips_test.out @@ -1,16 +1,16 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_geocoder_server.geocode_ipaddress_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '0.0.0.0'); - geocode_ipaddress_point -------------------------- +SELECT cdb_geocoder_server.cdb_geocode_ipaddress_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '0.0.0.0'); + cdb_geocode_ipaddress_point +----------------------------- (1 row) -- Insert dummy data into ip_address_locations INSERT INTO ip_address_locations VALUES ('::ffff:0.0.0.0'::inet, (ST_SetSRID(ST_MakePoint('40.40', '3.71'), 4326))); -- This should return the polygon inserted above -SELECT cdb_geocoder_server.geocode_ipaddress_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '0.0.0.0'); - geocode_ipaddress_point +SELECT cdb_geocoder_server.cdb_geocode_ipaddress_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '0.0.0.0'); + cdb_geocode_ipaddress_point ---------------------------------------------------- 0101000020E61000003333333333334440AE47E17A14AE0D40 (1 row) @@ -20,7 +20,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_ipaddress_point' + AND proname = 'cdb_geocode_ipaddress_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); exists -------- @@ -31,7 +31,7 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_ipaddress_point' + AND proname = '_cdb_geocode_ipaddress_point' AND oidvectortypes(p.proargtypes) = 'text'); exists -------- diff --git a/server/extension/sql/0.0.1/20_geocode_street.sql b/server/extension/sql/0.0.1/20_geocode_street.sql index 73ce23c..2d9e96a 100644 --- a/server/extension/sql/0.0.1/20_geocode_street.sql +++ b/server/extension/sql/0.0.1/20_geocode_street.sql @@ -1,5 +1,5 @@ -- Geocodes a street address given a searchtext and a state and/or country -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_street_point(searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_street_point(searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) RETURNS Geometry AS $$ import json diff --git a/server/extension/sql/0.0.1/30_admin0.sql b/server/extension/sql/0.0.1/30_admin0.sql index 4bd10c4..1a1b7a1 100644 --- a/server/extension/sql/0.0.1/30_admin0.sql +++ b/server/extension/sql/0.0.1/30_admin0.sql @@ -1,18 +1,18 @@ -- Interface of the server extension -CREATE OR REPLACE FUNCTION cdb_geocoder_server.geocode_admin0_polygon(user_id name, user_config_data JSON, geocoder_config_data JSON, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin0_polygon(user_id name, user_config_data JSON, geocoder_config_data JSON, country_name text) RETURNS Geometry AS $$ - plpy.debug('Entering geocode_admin0_polygons') + plpy.debug('Entering cdb_geocode_admin0_polygons') plpy.debug('user_id = %s' % user_id) #--TODO: rate limiting check #--TODO: quota check #-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html - plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_admin0_polygon($1) AS mypolygon", ["text"]) + plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_admin0_polygon($1) AS mypolygon", ["text"]) rv = plpy.execute(plan, [country_name], 1) - plpy.debug('Returning from Returning from geocode_admin0_polygons') + plpy.debug('Returning from Returning from cdb_geocode_admin0_polygons') return rv[0]["mypolygon"] $$ LANGUAGE plpythonu; @@ -21,7 +21,7 @@ $$ LANGUAGE plpythonu; -- Implementation of the server extension -- Note: these functions depend on the cdb_geocoder extension -CREATE OR REPLACE FUNCTION cdb_geocoder_server._geocode_admin0_polygon(country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_admin0_polygon(country_name text) RETURNS Geometry AS $$ DECLARE ret Geometry; diff --git a/server/extension/sql/0.0.1/40_admin1.sql b/server/extension/sql/0.0.1/40_admin1.sql index f7c63c5..ccb9846 100644 --- a/server/extension/sql/0.0.1/40_admin1.sql +++ b/server/extension/sql/0.0.1/40_admin1.sql @@ -1,36 +1,36 @@ -- Interfacess of the server extension ----- geocode_admin1_polygon(admin1_name text) -CREATE OR REPLACE FUNCTION geocode_admin1_polygon(user_id name, user_config json, geocoder_config json, admin1_name text) +---- cdb_geocode_admin1_polygon(admin1_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config json, geocoder_config json, admin1_name text) RETURNS Geometry AS $$ - plpy.debug('Entering geocode_admin1_polygon(admin1_name text)') + plpy.debug('Entering cdb_geocode_admin1_polygon(admin1_name text)') plpy.debug('user_id = %s' % user_id) #--TODO: rate limiting check #--TODO: quota check #-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html - plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_admin1_polygon($1) AS mypolygon", ["text"]) + plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_admin1_polygon($1) AS mypolygon", ["text"]) rv = plpy.execute(plan, [admin1_name], 1) - plpy.debug('Returning from Returning from geocode_admin1_polygons') + plpy.debug('Returning from Returning from cdb_geocode_admin1_polygons') return rv[0]["mypolygon"] $$ LANGUAGE plpythonu; ----- geocode_admin1_polygon(admin1_name text, country_name text) -CREATE OR REPLACE FUNCTION geocode_admin1_polygon(user_id name, user_config json, geocoder_config json, admin1_name text, country_name text) +---- cdb_geocode_admin1_polygon(admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_admin1_polygon(user_id name, user_config json, geocoder_config json, admin1_name text, country_name text) RETURNS Geometry AS $$ - plpy.debug('Entering geocode_admin1_polygon(admin1_name text, country_name text)') + plpy.debug('Entering cdb_geocode_admin1_polygon(admin1_name text, country_name text)') plpy.debug('user_id = %s' % user_id) #--TODO: rate limiting check #--TODO: quota check #-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html - plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_admin1_polygon($1, $2) AS mypolygon", ["text", "text"]) + plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_admin1_polygon($1, $2) AS mypolygon", ["text", "text"]) rv = plpy.execute(plan, [admin1_name, country_name], 1) - plpy.debug('Returning from Returning from geocode_admin1_polygon(admin1_name text, country_name text)') + plpy.debug('Returning from Returning from cdb_geocode_admin1_polygon(admin1_name text, country_name text)') return rv[0]["mypolygon"] $$ LANGUAGE plpythonu; @@ -39,8 +39,8 @@ $$ LANGUAGE plpythonu; -- Implementation of the server extension -- Note: these functions depend on the cdb_geocoder extension ----- geocode_admin1_polygon(admin1_name text) -CREATE OR REPLACE FUNCTION _geocode_admin1_polygon(admin1_name text) +---- cdb_geocode_admin1_polygon(admin1_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_admin1_polygon(admin1_name text) RETURNS Geometry AS $$ DECLARE ret Geometry; @@ -63,8 +63,8 @@ RETURNS Geometry AS $$ END $$ LANGUAGE plpgsql; ----- geocode_admin1_polygon(admin1_name text, country_name text) -CREATE OR REPLACE FUNCTION _geocode_admin1_polygon(admin1_name text, country_name text) +---- cdb_geocode_admin1_polygon(admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_admin1_polygon(admin1_name text, country_name text) RETURNS Geometry AS $$ DECLARE ret Geometry; diff --git a/server/extension/sql/0.0.1/50_namedplaces.sql b/server/extension/sql/0.0.1/50_namedplaces.sql index 46b0315..b355ca7 100644 --- a/server/extension/sql/0.0.1/50_namedplaces.sql +++ b/server/extension/sql/0.0.1/50_namedplaces.sql @@ -1,50 +1,50 @@ -- Interfacess of the server extension ----- geocode_namedplace_point(city_name text) -CREATE OR REPLACE FUNCTION geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text) +---- cdb_geocode_namedplace_point(city_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text) RETURNS Geometry AS $$ - plpy.debug('Entering geocode_namedplace_point(city_name text)') + plpy.debug('Entering cdb_geocode_namedplace_point(city_name text)') plpy.debug('user_id = %s' % user_id) #--TODO: rate limiting check #--TODO: quota check #-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html - plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_namedplace_point($1) AS mypoint", ["text"]) + plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_namedplace_point($1) AS mypoint", ["text"]) rv = plpy.execute(plan, [city_name], 1) plpy.debug('Returning from Returning from geocode_namedplace') return rv[0]["mypoint"] $$ LANGUAGE plpythonu; ----- geocode_namedplace_point(city_name text, country_name text) -CREATE OR REPLACE FUNCTION geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text, country_name text) +---- cdb_geocode_namedplace_point(city_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text, country_name text) RETURNS Geometry AS $$ - plpy.debug('Entering geocode_namedplace_point(city_name text, country_name text)') + plpy.debug('Entering cdb_geocode_namedplace_point(city_name text, country_name text)') plpy.debug('user_id = %s' % user_id) #--TODO: rate limiting check #--TODO: quota check #-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html - plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_namedplace_point($1, $2) AS mypoint", ["text", "text"]) + plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_namedplace_point($1, $2) AS mypoint", ["text", "text"]) rv = plpy.execute(plan, [city_name, country_name], 1) plpy.debug('Returning from Returning from geocode_namedplace') return rv[0]["mypoint"] $$ LANGUAGE plpythonu; ----- geocode_namedplace_point(city_name text, admin1_name text, country_name text) -CREATE OR REPLACE FUNCTION geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text, admin1_name text, country_name text) +---- cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_namedplace_point(user_id name, user_config json, geocoder_config json, city_name text, admin1_name text, country_name text) RETURNS Geometry AS $$ - plpy.debug('Entering geocode_namedplace_point(city_name text, admin1_name text, country_name text)') + plpy.debug('Entering cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text)') plpy.debug('user_id = %s' % user_id) #--TODO: rate limiting check #--TODO: quota check #-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html - plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_namedplace_point($1, $2, $3) AS mypoint", ["text", "text", "text"]) + plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_namedplace_point($1, $2, $3) AS mypoint", ["text", "text", "text"]) rv = plpy.execute(plan, [city_name, admin1_name, country_name], 1) plpy.debug('Returning from Returning from geocode_namedplace') @@ -56,8 +56,8 @@ $$ LANGUAGE plpythonu; -- Implementation of the server extension -- Note: these functions depend on the cdb_geocoder extension ----- geocode_namedplace_point(city_name text) -CREATE OR REPLACE FUNCTION _geocode_namedplace_point(city_name text) +---- cdb_geocode_namedplace_point(city_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_namedplace_point(city_name text) RETURNS Geometry AS $$ DECLARE ret Geometry; @@ -75,8 +75,8 @@ RETURNS Geometry AS $$ END $$ LANGUAGE plpgsql; ----- geocode_namedplace_point(city_name text, country_name text) -CREATE OR REPLACE FUNCTION _geocode_namedplace_point(city_name text, country_name text) +---- cdb_geocode_namedplace_point(city_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_namedplace_point(city_name text, country_name text) RETURNS Geometry AS $$ DECLARE ret Geometry; @@ -95,8 +95,8 @@ RETURNS Geometry AS $$ END $$ LANGUAGE plpgsql; ----- geocode_namedplace_point(city_name text, admin1_name text, country_name text) -CREATE OR REPLACE FUNCTION _geocode_namedplace_point(city_name text, admin1_name text, country_name text) +---- cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text) RETURNS Geometry AS $$ DECLARE ret Geometry; diff --git a/server/extension/sql/0.0.1/60_postalcodes.sql b/server/extension/sql/0.0.1/60_postalcodes.sql index 8abda9f..1f817d5 100644 --- a/server/extension/sql/0.0.1/60_postalcodes.sql +++ b/server/extension/sql/0.0.1/60_postalcodes.sql @@ -1,68 +1,66 @@ --- TODO geocode_postalcode_polygon(code text, country text) - -- Interface of the server extension -CREATE OR REPLACE FUNCTION geocode_postalcode_point(user_id name, user_config json, geocoder_config json, code text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_point(user_id name, user_config json, geocoder_config json, code text) RETURNS Geometry AS $$ - plpy.debug('Entering _geocode_postalcode_point') + plpy.debug('Entering _cdb_geocode_postalcode_point') plpy.debug('user_id = %s' % user_id) #--TODO: rate limiting check #--TODO: quota check #-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html - plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_postalcode_point($1) AS point", ["text"]) + plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_postalcode_point($1) AS point", ["text"]) rv = plpy.execute(plan, [code], 1) - plpy.debug('Returning from _geocode_postalcode_point') + plpy.debug('Returning from _cdb_geocode_postalcode_point') return rv[0]["point"] $$ LANGUAGE plpythonu; -CREATE OR REPLACE FUNCTION geocode_postalcode_point(user_id name, user_config json, geocoder_config json, code text, country text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_point(user_id name, user_config json, geocoder_config json, code text, country text) RETURNS Geometry AS $$ - plpy.debug('Entering _geocode_postalcode_point') + plpy.debug('Entering _cdb_geocode_postalcode_point') plpy.debug('user_id = %s' % user_id) #--TODO: rate limiting check #--TODO: quota check #-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html - plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_postalcode_point($1, $2) AS point", ["TEXT", "TEXT"]) + plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_postalcode_point($1, $2) AS point", ["TEXT", "TEXT"]) rv = plpy.execute(plan, [code, country], 1) - plpy.debug('Returning from _geocode_postalcode_point') + plpy.debug('Returning from _cdb_geocode_postalcode_point') return rv[0]["point"] $$ LANGUAGE plpythonu; -CREATE OR REPLACE FUNCTION geocode_postalcode_polygon(user_id name, user_config json, geocoder_config json, code text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_polygon(user_id name, user_config json, geocoder_config json, code text) RETURNS Geometry AS $$ - plpy.debug('Entering _geocode_postalcode_polygon') + plpy.debug('Entering _cdb_geocode_postalcode_polygon') plpy.debug('user_id = %s' % user_id) #--TODO: rate limiting check #--TODO: quota check #-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html - plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_postalcode_polygon($1) AS polygon", ["text"]) + plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_postalcode_polygon($1) AS polygon", ["text"]) rv = plpy.execute(plan, [code], 1) - plpy.debug('Returning from _geocode_postalcode_polygon') + plpy.debug('Returning from _cdb_geocode_postalcode_polygon') return rv[0]["polygon"] $$ LANGUAGE plpythonu; -CREATE OR REPLACE FUNCTION geocode_postalcode_polygon(user_id name, user_config json, geocoder_config json, code text, country text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_postalcode_polygon(user_id name, user_config json, geocoder_config json, code text, country text) RETURNS Geometry AS $$ - plpy.debug('Entering _geocode_postalcode_point') + plpy.debug('Entering _cdb_geocode_postalcode_point') plpy.debug('user_id = %s' % user_id) #--TODO: rate limiting check #--TODO: quota check #-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html - plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_postalcode_polygon($1, $2) AS polygon", ["TEXT", "TEXT"]) + plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_postalcode_polygon($1, $2) AS polygon", ["TEXT", "TEXT"]) rv = plpy.execute(plan, [code, country], 1) - plpy.debug('Returning from _geocode_postalcode_point') + plpy.debug('Returning from _cdb_geocode_postalcode_point') return rv[0]["polygon"] $$ LANGUAGE plpythonu; @@ -71,7 +69,7 @@ $$ LANGUAGE plpythonu; -- Implementation of the server extension -- Note: these functions depend on the cdb_geocoder extension -CREATE OR REPLACE FUNCTION _geocode_postalcode_point(code text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_postalcode_point(code text) RETURNS Geometry AS $$ DECLARE ret Geometry; @@ -92,7 +90,7 @@ RETURNS Geometry AS $$ END $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION _geocode_postalcode_point(code text, country text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_postalcode_point(code text, country text) RETURNS Geometry AS $$ DECLARE ret Geometry; @@ -117,7 +115,7 @@ RETURNS Geometry AS $$ END $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION _geocode_postalcode_polygon(code text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_postalcode_polygon(code text) RETURNS Geometry AS $$ DECLARE ret Geometry; @@ -138,7 +136,7 @@ RETURNS Geometry AS $$ END $$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION _geocode_postalcode_polygon(code text, country text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_postalcode_polygon(code text, country text) RETURNS Geometry AS $$ DECLARE ret Geometry; diff --git a/server/extension/sql/0.0.1/70_ips.sql b/server/extension/sql/0.0.1/70_ips.sql index 5a7e660..ae69d1d 100644 --- a/server/extension/sql/0.0.1/70_ips.sql +++ b/server/extension/sql/0.0.1/70_ips.sql @@ -1,18 +1,18 @@ -- Interface of the server extension -CREATE OR REPLACE FUNCTION geocode_ipaddress_point(user_id name, user_config json, geocoder_config json, ip text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server.cdb_geocode_ipaddress_point(user_id name, user_config json, geocoder_config json, ip text) RETURNS Geometry AS $$ - plpy.debug('Entering _geocode_ipaddress_point') + plpy.debug('Entering _cdb_geocode_ipaddress_point') plpy.debug('user_id = %s' % user_id) #--TODO: rate limiting check #--TODO: quota check #-- Copied from the doc, see http://www.postgresql.org/docs/9.4/static/plpython-database.html - plan = plpy.prepare("SELECT cdb_geocoder_server._geocode_ipaddress_point($1) AS point", ["TEXT"]) + plan = plpy.prepare("SELECT cdb_geocoder_server._cdb_geocode_ipaddress_point($1) AS point", ["TEXT"]) rv = plpy.execute(plan, [ip], 1) - plpy.debug('Returning from _geocode_ipaddress_point') + plpy.debug('Returning from _cdb_geocode_ipaddress_point') return rv[0]["point"] $$ LANGUAGE plpythonu; @@ -21,7 +21,7 @@ $$ LANGUAGE plpythonu; -- Implementation of the server extension -- Note: these functions depend on the cdb_geocoder extension -CREATE OR REPLACE FUNCTION _geocode_ipaddress_point(ip text) +CREATE OR REPLACE FUNCTION cdb_geocoder_server._cdb_geocode_ipaddress_point(ip text) RETURNS Geometry AS $$ DECLARE ret Geometry; diff --git a/server/extension/sql/30_admin0_test.sql b/server/extension/sql/30_admin0_test.sql index 7a00717..df9fbaa 100644 --- a/server/extension/sql/30_admin0_test.sql +++ b/server/extension/sql/30_admin0_test.sql @@ -1,6 +1,6 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_geocoder_server.geocode_admin0_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'Spain'); +SELECT cdb_geocoder_server.cdb_geocode_admin0_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'Spain'); -- Insert some dummy synonym INSERT INTO admin0_synonyms (name, adm0_a3) VALUES ('Spain', 'ESP'); @@ -14,19 +14,19 @@ INSERT INTO ne_admin0_v3 (adm0_a3, the_geom) VALUES('ESP', ST_GeomFromText( ); -- This should return the polygon inserted above -SELECT cdb_geocoder_server.geocode_admin0_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'Spain'); +SELECT cdb_geocoder_server.cdb_geocode_admin0_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'Spain'); -- Check for admin0 signatures SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_admin0_polygon' + AND proname = 'cdb_geocode_admin0_polygon' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_admin0_polygon' + AND proname = '_cdb_geocode_admin0_polygon' AND oidvectortypes(p.proargtypes) = 'text'); \ No newline at end of file diff --git a/server/extension/sql/40_admin1_test.sql b/server/extension/sql/40_admin1_test.sql index 8ed4acb..f637b87 100644 --- a/server/extension/sql/40_admin1_test.sql +++ b/server/extension/sql/40_admin1_test.sql @@ -1,7 +1,7 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'California'); -SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'California', 'United States'); +SELECT cdb_geocoder_server.cdb_geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'California'); +SELECT cdb_geocoder_server.cdb_geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'California', 'United States'); -- Insert dummy data into country decoder table INSERT INTO country_decoder (synonyms, iso3) VALUES (Array['united states'], 'USA'); @@ -15,34 +15,34 @@ INSERT INTO global_province_polygons (synonyms, iso3, the_geom) VALUES (Array['c ); -- This should return the polygon inserted above -SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'California'); -SELECT cdb_geocoder_server.geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'California', 'United States'); +SELECT cdb_geocoder_server.cdb_geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'California'); +SELECT cdb_geocoder_server.cdb_geocode_admin1_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 0, "nokia_soft_geocoder_limit": false}', 'California', 'United States'); -- Check for admin1 signatures SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_admin1_polygon' + AND proname = 'cdb_geocode_admin1_polygon' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_admin1_polygon' + AND proname = 'cdb_geocode_admin1_polygon' AND oidvectortypes(p.proargtypes) = 'name, json, json, text, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_admin1_polygon' + AND proname = '_cdb_geocode_admin1_polygon' AND oidvectortypes(p.proargtypes) = 'text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_admin1_polygon' + AND proname = '_cdb_geocode_admin1_polygon' AND oidvectortypes(p.proargtypes) = 'text, text'); \ No newline at end of file diff --git a/server/extension/sql/50_namedplaces_test.sql b/server/extension/sql/50_namedplaces_test.sql index 8dadee5..6574ef0 100644 --- a/server/extension/sql/50_namedplaces_test.sql +++ b/server/extension/sql/50_namedplaces_test.sql @@ -1,8 +1,8 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx'); -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Spain'); -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Valencia', 'Spain'); +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx'); +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Spain'); +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Valencia', 'Spain'); -- Insert dummy data into points table INSERT INTO global_cities_points_limited (geoname_id, name, iso2, admin1, admin2, population, lowername, the_geom) VALUES (3128760, 'Elche', 'ES', 'Valencia', 'AL', 34534, 'elche', ST_GeomFromText( @@ -21,52 +21,52 @@ INSERT INTO country_decoder (synonyms, iso2) VALUES (Array['spain'], 'ES'); INSERT INTO admin1_decoder (admin1, synonyms, iso2) VALUES ('Valencia', Array['valencia', 'Valencia'], 'ES'); -- This should return the point inserted above -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx'); -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche'); -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Spain'); -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche', 'Spain'); -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Valencia', 'Spain'); -SELECT cdb_geocoder_server.geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche', 'valencia', 'Spain'); +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx'); +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche'); +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Spain'); +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche', 'Spain'); +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elx', 'Valencia', 'Spain'); +SELECT cdb_geocoder_server.cdb_geocode_namedplace_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', 'Elche', 'valencia', 'Spain'); -- Check for namedplaces signatures SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_namedplace_point' + AND proname = 'cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_namedplace_point' + AND proname = 'cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_namedplace_point' + AND proname = 'cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_namedplace_point' + AND proname = '_cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_namedplace_point' + AND proname = '_cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'text, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_namedplace_point' + AND proname = '_cdb_geocode_namedplace_point' AND oidvectortypes(p.proargtypes) = 'text, text, text'); \ No newline at end of file diff --git a/server/extension/sql/60_postalcodes_test.sql b/server/extension/sql/60_postalcodes_test.sql index a5ba28c..65e33c6 100644 --- a/server/extension/sql/60_postalcodes_test.sql +++ b/server/extension/sql/60_postalcodes_test.sql @@ -7,7 +7,7 @@ DELETE FROM admin0_synonyms; -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_geocoder_server.geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); +SELECT cdb_geocoder_server.cdb_geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); -- Insert dummy data into ip_address_locations INSERT INTO global_postal_code_points (the_geom, iso3, postal_code, postal_code_num) VALUES ( @@ -44,13 +44,13 @@ INSERT INTO admin0_synonyms (adm0_a3, name, name_, rank) VALUES ( ); -- This should return the polygon inserted above -SELECT cdb_geocoder_server.geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); +SELECT cdb_geocoder_server.cdb_geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); -SELECT cdb_geocoder_server.geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204', 'spain'); +SELECT cdb_geocoder_server.cdb_geocode_postalcode_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204', 'spain'); -SELECT cdb_geocoder_server.geocode_postalcode_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); +SELECT cdb_geocoder_server.cdb_geocode_postalcode_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204'); -SELECT cdb_geocoder_server.geocode_postalcode_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204', 'spain'); +SELECT cdb_geocoder_server.cdb_geocode_postalcode_polygon(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '03204', 'spain'); -- Clean dbs DELETE FROM global_postal_code_points; @@ -64,54 +64,54 @@ SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_postalcode_point' + AND proname = 'cdb_geocode_postalcode_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_postalcode_point' + AND proname = 'cdb_geocode_postalcode_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_postalcode_polygon' + AND proname = 'cdb_geocode_postalcode_polygon' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_postalcode_polygon' + AND proname = 'cdb_geocode_postalcode_polygon' AND oidvectortypes(p.proargtypes) = 'name, json, json, text, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_postalcode_point' + AND proname = '_cdb_geocode_postalcode_point' AND oidvectortypes(p.proargtypes) = 'text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_postalcode_point' + AND proname = '_cdb_geocode_postalcode_point' AND oidvectortypes(p.proargtypes) = 'text, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_postalcode_polygon' + AND proname = '_cdb_geocode_postalcode_polygon' AND oidvectortypes(p.proargtypes) = 'text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_postalcode_polygon' + AND proname = '_cdb_geocode_postalcode_polygon' AND oidvectortypes(p.proargtypes) = 'text, text'); \ No newline at end of file diff --git a/server/extension/sql/70_ips_test.sql b/server/extension/sql/70_ips_test.sql index cc7d09b..143d8c3 100644 --- a/server/extension/sql/70_ips_test.sql +++ b/server/extension/sql/70_ips_test.sql @@ -1,24 +1,24 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_geocoder_server.geocode_ipaddress_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '0.0.0.0'); +SELECT cdb_geocoder_server.cdb_geocode_ipaddress_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '0.0.0.0'); -- Insert dummy data into ip_address_locations INSERT INTO ip_address_locations VALUES ('::ffff:0.0.0.0'::inet, (ST_SetSRID(ST_MakePoint('40.40', '3.71'), 4326))); -- This should return the polygon inserted above -SELECT cdb_geocoder_server.geocode_ipaddress_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '0.0.0.0'); +SELECT cdb_geocoder_server.cdb_geocode_ipaddress_point(session_user, '{"is_organization": false, "entity_name": "test_user"}', '{"street_geocoder_provider": "nokia","nokia_monthly_quota": 100, "nokia_soft_geocoder_limit": false}', '0.0.0.0'); -- Check for namedplaces signatures (point and polygon) SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = 'geocode_ipaddress_point' + AND proname = 'cdb_geocode_ipaddress_point' AND oidvectortypes(p.proargtypes) = 'name, json, json, text'); SELECT exists(SELECT * FROM pg_proc p INNER JOIN pg_namespace ns ON (p.pronamespace = ns.oid) WHERE ns.nspname = 'cdb_geocoder_server' - AND proname = '_geocode_ipaddress_point' + AND proname = '_cdb_geocode_ipaddress_point' AND oidvectortypes(p.proargtypes) = 'text'); \ No newline at end of file