diff --git a/client/Makefile b/client/Makefile index 895f39f..7c4da43 100644 --- a/client/Makefile +++ b/client/Makefile @@ -8,6 +8,11 @@ SED = sed ERB = erb REPLACEMENTS = -i 's/$(EXTVERSION)/$(NEW_VERSION)/g' NEW_EXTENSION_ARTIFACT = $(EXTENSION)--$(EXTVERSION).sql +AWK = awk + +# Parallel support macros +PG_CONFIG = pg_config +PG_PARALLEL := $(shell $(PG_CONFIG) --version | ($(AWK) '{$$2*=1000; if ($$2 >= 9600) print 1; else print 0;}' 2> /dev/null || echo 0)) # OLD_VERSIONS = $(wildcard old_versions/*.sql) # DATA = $(NEW_EXTENSION_ARTIFACT) \ @@ -50,6 +55,13 @@ SOURCES_DATA = $(wildcard $(SOURCES_DATA_DIR)/*.sql) $(GENERATED_SQL_FILES) $(NEW_EXTENSION_ARTIFACT): $(SOURCES_DATA) rm -f $@ cat $(SOURCES_DATA_DIR)/*.sql >> $@ +ifeq ($(PG_PARALLEL), 0) +# Remove PARALLEL in aggregates and functions + $(eval TMPFILE := $(shell mktemp /tmp/$(basename $0).XXXXXXXX)) + $(SED) -e 's/PARALLEL \= [A-Z]*,/''/g' \ + -e 's/PARALLEL [A-Z]*/''/g' $@ > $(TMPFILE) + mv $(TMPFILE) $@ +endif .PHONY: all all: $(DATA) @@ -61,6 +73,13 @@ release: $(EXTENSION).control $(SOURCES_DATA) $(SED) $(REPLACEMENTS) $(EXTENSION).control git add $(EXTENSION).control cat $(SOURCES_DATA_DIR)/*.sql > $(EXTENSION)--$(NEW_VERSION).sql +ifeq ($(PG_PARALLEL), 0) +# Remove PARALLEL in aggregates and functions + $(eval TMPFILE := $(shell mktemp /tmp/$(basename $0).XXXXXXXX)) + $(SED) -e 's/PARALLEL \= [A-Z]*,/''/g' \ + -e 's/PARALLEL [A-Z]*/''/g' $@ > $(TMPFILE) + mv $(TMPFILE) $@ +endif git add $(EXTENSION)--$(NEW_VERSION).sql $(ERB) version=$(NEW_VERSION) upgrade_downgrade_template.erb > $(EXTENSION)--$(EXTVERSION)--$(NEW_VERSION).sql $(ERB) version=$(EXTVERSION) upgrade_downgrade_template.erb > $(EXTENSION)--$(NEW_VERSION)--$(EXTVERSION).sql diff --git a/client/sql/10_geocoder_server_conn.sql b/client/sql/10_geocoder_server_conn.sql index d180ab6..cf1b2f5 100644 --- a/client/sql/10_geocoder_server_conn.sql +++ b/client/sql/10_geocoder_server_conn.sql @@ -13,4 +13,4 @@ BEGIN SELECT trim(both '"' FROM db_connection_str) INTO db_connection_str; RETURN db_connection_str; END; -$$ LANGUAGE 'plpgsql'; \ No newline at end of file +$$ LANGUAGE 'plpgsql' STABLE PARALLEL SAFE; diff --git a/client/sql/15_config_management.sql b/client/sql/15_config_management.sql index 6a27cf6..16c8188 100644 --- a/client/sql/15_config_management.sql +++ b/client/sql/15_config_management.sql @@ -34,4 +34,4 @@ BEGIN result.organization_name = organization_name; RETURN result; END; -$$ LANGUAGE 'plpgsql' SECURITY DEFINER; \ No newline at end of file +$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL SAFE; diff --git a/client/sql/20_table_augmentation.sql b/client/sql/20_table_augmentation.sql index fb69387..18f0d77 100644 --- a/client/sql/20_table_augmentation.sql +++ b/client/sql/20_table_augmentation.sql @@ -41,7 +41,7 @@ BEGIN RETURN result; END; -$$ LANGUAGE 'plpgsql' SECURITY DEFINER; +$$ LANGUAGE 'plpgsql' SECURITY DEFINER VOLATILE PARALLEL UNSAFE; CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_PopulateTableOBS_GetMeasure( table_name text, @@ -89,7 +89,7 @@ BEGIN RETURN result; END; -$$ LANGUAGE 'plpgsql' SECURITY DEFINER; +$$ LANGUAGE 'plpgsql' SECURITY DEFINER VOLATILE PARALLEL UNSAFE; CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PrepareTableOBS_GetMeasure( @@ -134,7 +134,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PrepareTableOBS_GetMeas ) return True -$$ LANGUAGE plpythonu; +$$ LANGUAGE plpythonu VOLATILE PARALLEL UNSAFE; CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PopulateTableOBS_GetMeasure( username text, @@ -227,7 +227,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client.__DST_PopulateTableOBS_GetMea fdw_server=plpy.quote_literal(server_name))) return True -$$ LANGUAGE plpythonu; +$$ LANGUAGE plpythonu VOLATILE PARALLEL UNSAFE; CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_ConnectUserTable( username text, @@ -239,7 +239,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_ConnectUserTable( )RETURNS cdb_dataservices_client.ds_fdw_metadata AS $$ CONNECT cdb_dataservices_client._server_conn_str(); TARGET cdb_dataservices_server._DST_ConnectUserTable; -$$ LANGUAGE plproxy; +$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE; CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_GetReturnMetadata( username text, @@ -249,7 +249,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_GetReturnMetadata( ) RETURNS cdb_dataservices_client.ds_return_metadata AS $$ CONNECT cdb_dataservices_client._server_conn_str(); TARGET cdb_dataservices_server._DST_GetReturnMetadata; -$$ LANGUAGE plproxy; +$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE; CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_FetchJoinFdwTableData( username text, @@ -261,7 +261,7 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_FetchJoinFdwTableData( ) RETURNS SETOF record AS $$ CONNECT cdb_dataservices_client._server_conn_str(); TARGET cdb_dataservices_server._DST_FetchJoinFdwTableData; -$$ LANGUAGE plproxy; +$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE; CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_DisconnectUserTable( username text, @@ -272,4 +272,4 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_client._DST_DisconnectUserTable( ) RETURNS boolean AS $$ CONNECT cdb_dataservices_client._server_conn_str(); TARGET cdb_dataservices_server._DST_DisconnectUserTable; -$$ LANGUAGE plproxy; +$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE; diff --git a/client/sql/35_precheck_functions.sql b/client/sql/35_precheck_functions.sql index c238a6a..92f4520 100644 --- a/client/sql/35_precheck_functions.sql +++ b/client/sql/35_precheck_functions.sql @@ -51,4 +51,4 @@ BEGIN RETURN TRUE; END; -$$ LANGUAGE 'plpgsql'; +$$ LANGUAGE 'plpgsql' VOLATILE PARALLEL UNSAFE;