Generate files in Makefile (WIP)
This commit is contained in:
parent
68dba7136b
commit
c82359f7d7
@ -12,14 +12,29 @@ PG_CONFIG = pg_config
|
|||||||
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
||||||
include $(PGXS)
|
include $(PGXS)
|
||||||
|
|
||||||
|
SOURCES_DATA_DIR = sql/$(EXTVERSION)
|
||||||
|
|
||||||
SOURCES_DATA = $(wildcard sql/$(EXTVERSION)/*.sql)
|
# The interface definition is used along with some templates to automatically generate code
|
||||||
|
RENDERER = ../sql-template-renderer
|
||||||
|
INTERFACE_FILE = ../interface.csv
|
||||||
|
TEMPLATE_DIR = templates
|
||||||
|
TEMPLATE_FILES = $(wildcard $(TEMPLATE_DIR)/*.erb)
|
||||||
|
GENERATED_SQL_FILES = $(patsubst $(TEMPLATE_DIR)/%.erb, $(SOURCES_DATA_DIR)/%.sql, $(TEMPLATE_FILES))
|
||||||
|
|
||||||
|
$(GENERATED_SQL_FILES): $(SOURCES_DATA_DIR)/%.sql: $(TEMPLATE_DIR)/%.erb $(INTERFACE_FILE) $(RENDERER)
|
||||||
|
$(RENDERER) $(INTERFACE_FILE) $< > $@
|
||||||
|
|
||||||
|
all: $(GENERATED_SQL_FILES)
|
||||||
|
@echo $(GENERATED_SQL_FILES)
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES_DATA = $(wildcard $(SOURCES_DATA_DIR)/*.sql)
|
||||||
|
|
||||||
$(DATA): $(SOURCES_DATA)
|
$(DATA): $(SOURCES_DATA)
|
||||||
rm -f $@
|
rm -f $@
|
||||||
cat $(SOURCES_DATA) >> $@
|
cat $(SOURCES_DATA) >> $@
|
||||||
|
|
||||||
all: $(DATA)
|
#all: $(DATA)
|
||||||
|
|
||||||
# Only meant for development time, do not use once a version is released
|
# Only meant for development time, do not use once a version is released
|
||||||
devclean:
|
devclean:
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
--
|
|
||||||
-- 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 cdb_geocoder_client.geocode_admin0_polygon(country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
DECLARE
|
|
||||||
ret Geometry;
|
|
||||||
BEGIN
|
|
||||||
SELECT cdb_geocoder_client._geocode_admin0_polygon(session_user, txid_current(), country_name) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
||||||
|
|
||||||
|
|
||||||
-- TODO: review all permissions stuff [I'd explicitly grant permissions to the public functions]
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_admin0_polygon(user_id name, tx_id bigint, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
CONNECT cdb_geocoder_client._server_conn_str();
|
|
||||||
SELECT cdb_geocoder_server.geocode_admin0_polygon(user_id, tx_id, country_name);
|
|
||||||
$$ LANGUAGE plproxy;
|
|
@ -1,45 +0,0 @@
|
|||||||
--
|
|
||||||
-- Public geocoder API function
|
|
||||||
--
|
|
||||||
-- These are the only ones with permissions to publicuser role
|
|
||||||
-- and should also be the only ones with SECURITY DEFINER
|
|
||||||
|
|
||||||
---- geocode_admin1_polygon(admin1_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_admin1_polygon(admin1_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
DECLARE
|
|
||||||
ret Geometry;
|
|
||||||
BEGIN
|
|
||||||
SELECT cdb_geocoder_client._geocode_admin1_polygon(session_user, txid_current(), admin1_name) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
||||||
|
|
||||||
---- geocode_admin1_polygon(admin1_name text, country_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_admin1_polygon(admin1_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
DECLARE
|
|
||||||
ret Geometry;
|
|
||||||
BEGIN
|
|
||||||
SELECT cdb_geocoder_client._geocode_admin1_polygon(session_user, txid_current(), admin1_name, country_name) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
||||||
|
|
||||||
-- TODO: review all permissions stuff [I'd explicitly grant permissions to the public functions]
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
---- geocode_admin1_polygon(admin1_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_admin1_polygon(user_id name, tx_id bigint, admin1_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
CONNECT cdb_geocoder_client._server_conn_str();
|
|
||||||
SELECT cdb_geocoder_server.geocode_admin1_polygon(user_id, tx_id, admin1_name);
|
|
||||||
$$ LANGUAGE plproxy;
|
|
||||||
|
|
||||||
---- geocode_admin1_polygon(admin1_name text, country_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_admin1_polygon(user_id name, tx_id bigint, admin1_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
CONNECT cdb_geocoder_client._server_conn_str();
|
|
||||||
SELECT cdb_geocoder_server.geocode_admin1_polygon(user_id, tx_id, admin1_name, country_name);
|
|
||||||
$$ LANGUAGE plproxy;
|
|
@ -1,62 +0,0 @@
|
|||||||
--
|
|
||||||
-- Public geocoder API function
|
|
||||||
--
|
|
||||||
-- These are the only ones with permissions to publicuser role
|
|
||||||
-- and should also be the only ones with SECURITY DEFINER
|
|
||||||
|
|
||||||
---- geocode_namedplace_point(city_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_namedplace_point(city_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
DECLARE
|
|
||||||
ret Geometry;
|
|
||||||
BEGIN
|
|
||||||
SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, txid_current(), city_name) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
||||||
|
|
||||||
---- geocode_namedplace_point(city_name text, country_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_namedplace_point(city_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
DECLARE
|
|
||||||
ret Geometry;
|
|
||||||
BEGIN
|
|
||||||
SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, txid_current(), city_name, country_name) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
||||||
|
|
||||||
---- geocode_namedplace_point(city_name text, admin1_name text, country_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_namedplace_point(city_name text, admin1_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
DECLARE
|
|
||||||
ret Geometry;
|
|
||||||
BEGIN
|
|
||||||
SELECT cdb_geocoder_client._geocode_namedplace_point(session_user, txid_current(), city_name, admin1_name, country_name) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
||||||
-- TODO: review all permissions stuff [I'd explicitly grant permissions to the public functions]
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
---- geocode_namedplace_point(city_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_namedplace_point(user_id name, tx_id bigint, city_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
CONNECT cdb_geocoder_client._server_conn_str();
|
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace_point(user_id, tx_id, city_name);
|
|
||||||
$$ LANGUAGE plproxy;
|
|
||||||
|
|
||||||
---- geocode_namedplace_point(city_name text, country_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_namedplace_point(user_id name, tx_id bigint, city_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
CONNECT cdb_geocoder_client._server_conn_str();
|
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace_point(user_id, tx_id, city_name, country_name);
|
|
||||||
$$ LANGUAGE plproxy;
|
|
||||||
|
|
||||||
---- geocode_namedplace_point(city_name text, admin1_name text, country_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_namedplace_point(user_id name, tx_id bigint, city_name text, admin1_name text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
CONNECT cdb_geocoder_client._server_conn_str();
|
|
||||||
SELECT cdb_geocoder_server.geocode_namedplace_point(user_id, tx_id, city_name, admin1_name, country_name);
|
|
||||||
$$ LANGUAGE plproxy;
|
|
@ -1,45 +0,0 @@
|
|||||||
--
|
|
||||||
-- Public geocoder API function
|
|
||||||
--
|
|
||||||
-- These are the only ones with permissions to publicuser role
|
|
||||||
-- and should also be the only ones with SECURITY DEFINER
|
|
||||||
|
|
||||||
---- geocode_postalcode_polygon(postal_code text, country_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_postalcode_polygon(postal_code text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
DECLARE
|
|
||||||
ret Geometry;
|
|
||||||
BEGIN
|
|
||||||
SELECT cdb_geocoder_client._geocode_postalcode_polygon(session_user, txid_current(), postal_code, country_name) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
||||||
|
|
||||||
---- geocode_postalcode_polygon(postal_code integer, country_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_postalcode_point(postal_code text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
DECLARE
|
|
||||||
ret Geometry;
|
|
||||||
BEGIN
|
|
||||||
SELECT cdb_geocoder_client._geocode_postalcode_point(session_user, txid_current(), postal_code, country_name) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
||||||
|
|
||||||
-- TODO: review all permissions stuff [I'd explicitly grant permissions to the public functions]
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
---- geocode_postalcode_polygon(postal_code text, country_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_postalcode_polygon(user_id name, tx_id bigint, postal_code text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
CONNECT cdb_geocoder_client._server_conn_str();
|
|
||||||
SELECT cdb_geocoder_server.geocode_postalcode_polygon(user_id, tx_id, postal_code, country_name);
|
|
||||||
$$ LANGUAGE plproxy;
|
|
||||||
|
|
||||||
---- geocode_postalcode_polygon(postal_code text, country_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_postalcode_point(user_id name, tx_id bigint, postal_code text, country_name text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
CONNECT cdb_geocoder_client._server_conn_str();
|
|
||||||
SELECT cdb_geocoder_server.geocode_postalcode_polygon(user_id, tx_id, postal_code, country_name);
|
|
||||||
$$ LANGUAGE plproxy;
|
|
@ -1,27 +0,0 @@
|
|||||||
--
|
|
||||||
-- Public geocoder API function
|
|
||||||
--
|
|
||||||
-- These are the only ones with permissions to publicuser role
|
|
||||||
-- and should also be the only ones with SECURITY DEFINER
|
|
||||||
|
|
||||||
---- geocode_ipaddress_point(city_name text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_ipaddress_point(ip_address text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
DECLARE
|
|
||||||
ret Geometry;
|
|
||||||
BEGIN
|
|
||||||
SELECT cdb_geocoder_client._geocode_ipaddress_point(session_user, txid_current(), ip_address) INTO ret;
|
|
||||||
RETURN ret;
|
|
||||||
END;
|
|
||||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
||||||
|
|
||||||
-- TODO: review all permissions stuff [I'd explicitly grant permissions to the public functions]
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
---- geocode_ipaddress_point(ip_address text)
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_ipaddress_point(user_id name, tx_id bigint, ip_address text)
|
|
||||||
RETURNS Geometry AS $$
|
|
||||||
CONNECT cdb_geocoder_client._server_conn_str();
|
|
||||||
SELECT cdb_geocoder_server.geocode_ipaddress_point(user_id, tx_id, ip_address);
|
|
||||||
$$ LANGUAGE plproxy;
|
|
9
client/sql/0.0.1/80_permissions.sql
Normal file
9
client/sql/0.0.1/80_permissions.sql
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
-- Make sure by default there are no permissions for publicuser
|
||||||
|
-- NOTE: this happens at extension creation time, as part of an implicit transaction.
|
||||||
|
REVOKE ALL PRIVILEGES ON SCHEMA cdb_geocoder_client FROM PUBLIC, publicuser CASCADE;
|
||||||
|
|
||||||
|
-- Grant permissions on the schema to publicuser (but just the schema)
|
||||||
|
GRANT USAGE ON SCHEMA cdb_geocoder_client TO publicuser;
|
||||||
|
|
||||||
|
-- Revoke execute permissions on all functions in the schema by default
|
||||||
|
REVOKE EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_geocoder_client FROM PUBLIC, publicuser;
|
@ -1,23 +0,0 @@
|
|||||||
-- Make sure by default there are no permissions for publicuser
|
|
||||||
-- NOTE: this happens at extension creation time, as part of an implicit transaction.
|
|
||||||
REVOKE ALL PRIVILEGES ON SCHEMA cdb_geocoder_client FROM PUBLIC, publicuser CASCADE;
|
|
||||||
|
|
||||||
-- Grant permissions on the schema to publicuser (but just the schema)
|
|
||||||
GRANT USAGE ON SCHEMA cdb_geocoder_client TO publicuser;
|
|
||||||
|
|
||||||
-- Revoke execute permissions on all functions in the schema by default
|
|
||||||
REVOKE EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_geocoder_client FROM PUBLIC, publicuser;
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Explicitly grant permissions to public functions
|
|
||||||
-- NOTE: All public functions must be listed below, grating permissions to publicuser
|
|
||||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_admin0_polygon(country_name text) TO publicuser;
|
|
||||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_admin1_polygon(admin1_name text) TO publicuser;
|
|
||||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_admin1_polygon(admin1_name text, country_name text) TO publicuser;
|
|
||||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_namedplace_point(city_name text) TO publicuser;
|
|
||||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_namedplace_point(city_name text, country_name text) TO publicuser;
|
|
||||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_namedplace_point(city_name text, admin1_name text, country_name text) TO publicuser;
|
|
||||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_postalcode_polygon(postal_code text, country_name text) TO publicuser;
|
|
||||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_postalcode_point(postal_code text, country_name text) TO publicuser;
|
|
||||||
GRANT EXECUTE ON FUNCTION cdb_geocoder_client.geocode_ipaddress_point(ip_address text) TO publicuser;
|
|
Loading…
Reference in New Issue
Block a user