From 093e0bcb36ee2c95117aad941333877100cf2a2c Mon Sep 17 00:00:00 2001 From: Raul Marin Date: Thu, 26 Dec 2019 17:48:12 +0100 Subject: [PATCH] Always use @@plpythonu@@ as variable --- Makefile | 6 +++--- cartodb.control.in | 2 +- .../CDB_FederatedServerDiagnostics.sql | 2 +- scripts-available/CDB_GhostTables.sql | 2 +- scripts-available/CDB_Groups_API.sql | 20 +++++++++---------- scripts-available/CDB_QueryStatements.sql | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index d25f86c..1d53d14 100644 --- a/Makefile +++ b/Makefile @@ -150,7 +150,7 @@ $(EXTENSION)--$(EXTVERSION).sql: $(CDBSCRIPTS) cartodb_version.sql Makefile cat $(CDBSCRIPTS) | \ $(SED) -e 's/@extschema@/cartodb/g' \ -e 's/@postgisschema@/public/g' \ - -e 's/plpythonu/$(PLPYTHONU)/g' >> $@ + -e 's/@@plpythonu@@/$(PLPYTHONU)/g' >> $@ echo "GRANT USAGE ON SCHEMA cartodb TO public;" >> $@ cat cartodb_version.sql >> $@ @@ -164,10 +164,10 @@ $(EXTENSION)--$(EXTVERSION)--$(EXTVERSION)next.sql: $(EXTENSION)--$(EXTVERSION). cp $< $@ $(EXTENSION).control: $(EXTENSION).control.in Makefile - $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/g' -e 's/plpythonu/$(PLPYTHONU)/g' $< > $@ + $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/g' -e 's/@@plpythonu@@/$(PLPYTHONU)/g' $< > $@ cartodb_version.sql: cartodb_version.sql.in Makefile $(GITDIR)/index - $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' -e 's/@extschema@/cartodb/g' -e "s/@postgisschema@/public/g" -e 's/plpythonu/$(PLPYTHONU)/g' $< > $@ + $(SED) -e 's/@@VERSION@@/$(EXTVERSION)/' -e 's/@extschema@/cartodb/g' -e "s/@postgisschema@/public/g" -e 's/@@plpythonu@@/$(PLPYTHONU)/g' $< > $@ # Needed for consistent `echo` results with backslashes SHELL = bash diff --git a/cartodb.control.in b/cartodb.control.in index a5dcfa0..d166ac1 100644 --- a/cartodb.control.in +++ b/cartodb.control.in @@ -3,4 +3,4 @@ comment = 'Turn a database into a cartodb user database.' superuser = true relocatable = false schema = cartodb -requires = 'plpythonu, postgis' +requires = '@@plpythonu@@, postgis' diff --git a/scripts-available/CDB_FederatedServerDiagnostics.sql b/scripts-available/CDB_FederatedServerDiagnostics.sql index b1e2e4c..fd55af8 100644 --- a/scripts-available/CDB_FederatedServerDiagnostics.sql +++ b/scripts-available/CDB_FederatedServerDiagnostics.sql @@ -191,7 +191,7 @@ AS $$ }) return json.dumps(stats) $$ -LANGUAGE plpythonu VOLATILE PARALLEL UNSAFE; +LANGUAGE @@plpythonu@@ VOLATILE PARALLEL UNSAFE; -- diff --git a/scripts-available/CDB_GhostTables.sql b/scripts-available/CDB_GhostTables.sql index 3a19242..bb45785 100644 --- a/scripts-available/CDB_GhostTables.sql +++ b/scripts-available/CDB_GhostTables.sql @@ -45,7 +45,7 @@ AS $$ plpy.warning('Error calling Invalidation Service to link Ghost Tables: ' + str(err)) break tis_retry -= 1 # try reconnecting -$$ LANGUAGE 'plpythonu' VOLATILE PARALLEL UNSAFE; +$$ LANGUAGE '@@plpythonu@@' VOLATILE PARALLEL UNSAFE; -- Enqueues a job to run Ghost tables linking process for the current user CREATE OR REPLACE FUNCTION @extschema@.CDB_LinkGhostTables(event_name text DEFAULT 'USER') diff --git a/scripts-available/CDB_Groups_API.sql b/scripts-available/CDB_Groups_API.sql index b29eb77..d4d9669 100644 --- a/scripts-available/CDB_Groups_API.sql +++ b/scripts-available/CDB_Groups_API.sql @@ -21,7 +21,7 @@ $$ body = '{ "name": "%s", "database_role": "%s" }' % (group_name, group_role) query = "select @extschema@._CDB_Group_API_Request('POST', '%s', '%s', '{200, 409}') as response_status" % (url, body) plpy.execute(query) -$$ LANGUAGE 'plpythonu' +$$ LANGUAGE '@@plpythonu@@' VOLATILE PARALLEL UNSAFE SECURITY DEFINER @@ -41,7 +41,7 @@ $$ query = "select @extschema@._CDB_Group_API_Request('DELETE', '%s', '', '{204, 404}') as response_status" % url plpy.execute(query) -$$ LANGUAGE 'plpythonu' +$$ LANGUAGE '@@plpythonu@@' VOLATILE PARALLEL UNSAFE SECURITY DEFINER @@ -61,7 +61,7 @@ $$ body = '{ "name": "%s", "database_role": "%s" }' % (new_group_name, new_group_role) query = "select @extschema@._CDB_Group_API_Request('PUT', '%s', '%s', '{200, 409}') as response_status" % (url, body) plpy.execute(query) -$$ LANGUAGE 'plpythonu' +$$ LANGUAGE '@@plpythonu@@' VOLATILE PARALLEL UNSAFE SECURITY DEFINER @@ -81,7 +81,7 @@ $$ body = "{ \"users\": [\"%s\"] }" % "\",\"".join(usernames) query = "select @extschema@._CDB_Group_API_Request('POST', '%s', '%s', '{200, 409}') as response_status" % (url, body) plpy.execute(query) -$$ LANGUAGE 'plpythonu' +$$ LANGUAGE '@@plpythonu@@' VOLATILE PARALLEL UNSAFE SECURITY DEFINER @@ -101,7 +101,7 @@ $$ body = "{ \"users\": [\"%s\"] }" % "\",\"".join(usernames) query = "select @extschema@._CDB_Group_API_Request('DELETE', '%s', '%s', '{200, 404}') as response_status" % (url, body) plpy.execute(query) -$$ LANGUAGE 'plpythonu' +$$ LANGUAGE '@@plpythonu@@' VOLATILE PARALLEL UNSAFE SECURITY DEFINER @@ -129,7 +129,7 @@ $$ body = '{ "access": "%s" }' % access query = "select @extschema@._CDB_Group_API_Request('PUT', '%s', '%s', '{200, 409}') as response_status" % (url, body) plpy.execute(query) -$$ LANGUAGE 'plpythonu' +$$ LANGUAGE '@@plpythonu@@' VOLATILE PARALLEL UNSAFE SECURITY DEFINER @@ -156,7 +156,7 @@ $$ url = '/api/v1/databases/{0}/groups/%s/permission/%s/tables/%s' % (pathname2url(group_name), username, table_name) query = "select @extschema@._CDB_Group_API_Request('DELETE', '%s', '', '{200, 404}') as response_status" % url plpy.execute(query) -$$ LANGUAGE 'plpythonu' +$$ LANGUAGE '@@plpythonu@@' VOLATILE PARALLEL UNSAFE SECURITY DEFINER @@ -191,7 +191,7 @@ $$ params = json.loads(conf) auth = 'Basic %s' % plpy.execute("SELECT @extschema@._CDB_Group_API_Auth('%s', '%s') as auth" % (params['username'], params['password']))[0]['auth'] return { "host": params['host'], "port": params['port'], 'timeout': params['timeout'], 'auth': auth } -$$ LANGUAGE 'plpythonu' VOLATILE PARALLEL UNSAFE; +$$ LANGUAGE '@@plpythonu@@' VOLATILE PARALLEL UNSAFE; CREATE OR REPLACE FUNCTION @extschema@._CDB_Group_API_Auth(username text, password text) @@ -199,7 +199,7 @@ FUNCTION @extschema@._CDB_Group_API_Auth(username text, password text) $$ import base64 return base64.encodestring('%s:%s' % (username, password)).replace('\n', '') -$$ LANGUAGE 'plpythonu' VOLATILE PARALLEL UNSAFE; +$$ LANGUAGE '@@plpythonu@@' VOLATILE PARALLEL UNSAFE; -- url must contain a '%s' placeholder that will be replaced by current_database, for security reasons. CREATE OR REPLACE @@ -239,5 +239,5 @@ $$ raise last_err return None -$$ LANGUAGE 'plpythonu' VOLATILE PARALLEL UNSAFE; +$$ LANGUAGE '@@plpythonu@@' VOLATILE PARALLEL UNSAFE; revoke all on function @extschema@._CDB_Group_API_Request(text, text, text, int[]) from public; diff --git a/scripts-available/CDB_QueryStatements.sql b/scripts-available/CDB_QueryStatements.sql index 54b7115..ff60d35 100644 --- a/scripts-available/CDB_QueryStatements.sql +++ b/scripts-available/CDB_QueryStatements.sql @@ -11,4 +11,4 @@ RETURNS SETOF TEXT AS $$ cleaned = match[0].strip() if ( cleaned ): yield cleaned -$$ language 'plpythonu' IMMUTABLE STRICT PARALLEL SAFE; +$$ language '@@plpythonu@@' IMMUTABLE STRICT PARALLEL SAFE;