From 7cce491a13d52e459e592ce360c407f8cc4786fd Mon Sep 17 00:00:00 2001 From: Mario de Frutos Date: Fri, 22 Jan 2016 10:55:07 +0100 Subject: [PATCH] Dont use the defaults in the grant script --- client/sql/0.1.0/90_grant_execute.sql | 2 +- client/templates/20_public_functions.erb | 2 +- client/templates/30_plproxy_functions.erb | 2 +- sql-template-renderer | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/sql/0.1.0/90_grant_execute.sql b/client/sql/0.1.0/90_grant_execute.sql index 2f9b244..01ce6a4 100644 --- a/client/sql/0.1.0/90_grant_execute.sql +++ b/client/sql/0.1.0/90_grant_execute.sql @@ -7,4 +7,4 @@ GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_namedplace_point(city_ GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_postalcode_polygon(postal_code text, country_name text) TO publicuser; GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_postalcode_point(postal_code text, country_name text) TO publicuser; GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_ipaddress_point(ip_address text) TO publicuser; -GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_street_point(searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) TO publicuser; +GRANT EXECUTE ON FUNCTION cdb_geocoder_client.cdb_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser; diff --git a/client/templates/20_public_functions.erb b/client/templates/20_public_functions.erb index 6ee473d..d213986 100644 --- a/client/templates/20_public_functions.erb +++ b/client/templates/20_public_functions.erb @@ -4,7 +4,7 @@ -- These are the only ones with permissions to publicuser role -- and should also be the only ones with SECURITY DEFINER -CREATE OR REPLACE FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>.<%= name %> (<%= params_with_type %>) +CREATE OR REPLACE FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>.<%= name %> (<%= params_with_type_and_default %>) RETURNS <%= return_type %> AS $$ DECLARE ret <%= return_type %>; diff --git a/client/templates/30_plproxy_functions.erb b/client/templates/30_plproxy_functions.erb index 71ebdc4..906d8a5 100644 --- a/client/templates/30_plproxy_functions.erb +++ b/client/templates/30_plproxy_functions.erb @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text, <%= params_with_type %>) +CREATE OR REPLACE FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>._<%= name %> (username text, organization_name text, <%= params_with_type_and_default %>) RETURNS <%= return_type %> AS $$ CONNECT <%= GEOCODER_CLIENT_SCHEMA %>._server_conn_str(); SELECT cdb_geocoder_server.<%= name %> (username, organization_name, <%= params %>); diff --git a/sql-template-renderer b/sql-template-renderer index 5dff053..8938db8 100755 --- a/sql-template-renderer +++ b/sql-template-renderer @@ -40,6 +40,10 @@ class SqlTemplateRenderer end def params_with_type + @function_signature['params'].map { |p| "#{p['name']} #{p['type']}" }.join(', ') + end + + def params_with_type_and_default parameters = @function_signature['params'].map do |p| if not p['default'].nil? "#{p['name']} #{p['type']} DEFAULT #{p['default']}" @@ -49,7 +53,6 @@ class SqlTemplateRenderer end return parameters.join(', ') end - end