-- -- Public geocoder API function -- -- 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 %>) RETURNS <%= return_type %> AS $$ DECLARE ret <%= return_type %>; username text; BEGIN IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN RAISE EXCEPTION 'The api_key must be provided'; END IF; SELECT _CDB_username() INTO username; SELECT <%= GEOCODER_CLIENT_SCHEMA %>._<%= name %>(username, <%= params %>) INTO ret; RETURN ret; END; $$ LANGUAGE 'plpgsql' SECURITY DEFINER;