__CDB_RegenerateTable_Get_Commands: Replace with SET LOCAL

This commit is contained in:
Raúl Marín 2020-11-16 17:31:38 +01:00
parent a15b42d8f3
commit 88c212f3ba

View File

@ -6,6 +6,7 @@ CREATE OR REPLACE FUNCTION @extschema@.__CDB_RegenerateTable_Get_Commands(tableo
RETURNS text[]
AS $$
import subprocess
import re
query = "SELECT current_database()::text as dname"
rv = plpy.execute(query, 1)
@ -37,12 +38,10 @@ AS $$
sublines = [line.rstrip() for line in sublines]
sublines = [line for line in sublines if line]
sublines = [line for line in sublines if not line.startswith('--')]
sublines = [re.sub(r'^SET ', 'SET LOCAL ', line) for line in sublines]
if len(sublines):
clean_lines.append("".join(sublines))
# Add an extra query to reset the environment
clean_lines.append("RESET ALL");
return clean_lines
$$
LANGUAGE @@plpythonu@@ VOLATILE PARALLEL UNSAFE;