Created
October 3, 2014 01:07
-
-
Save bremac/20bbd878eb570fbbd1e5 to your computer and use it in GitHub Desktop.
One approach to timezone safety issues in pg_partman
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sql/functions/apply_constraints.sql b/sql/functions/apply_constraints.sql | |
index 4afaa83..c0c5303 100644 | |
--- a/sql/functions/apply_constraints.sql | |
+++ b/sql/functions/apply_constraints.sql | |
@@ -3,6 +3,7 @@ | |
*/ | |
CREATE FUNCTION apply_constraints(p_parent_table text, p_child_table text DEFAULT NULL, p_analyze boolean DEFAULT TRUE, p_debug boolean DEFAULT FALSE) RETURNS void | |
LANGUAGE plpgsql | |
+ SET timezone = 'UTC' | |
AS $$ | |
DECLARE | |
diff --git a/sql/functions/create_parent.sql b/sql/functions/create_parent.sql | |
index 095c911..eba6976 100644 | |
--- a/sql/functions/create_parent.sql | |
+++ b/sql/functions/create_parent.sql | |
@@ -15,6 +15,7 @@ CREATE FUNCTION create_parent( | |
, p_debug boolean DEFAULT false) | |
RETURNS void | |
LANGUAGE plpgsql SECURITY DEFINER | |
+ SET timezone = 'UTC' | |
AS $$ | |
DECLARE | |
diff --git a/sql/functions/create_time_function.sql b/sql/functions/create_time_function.sql | |
index a2de076..c2dc058 100644 | |
--- a/sql/functions/create_time_function.sql | |
+++ b/sql/functions/create_time_function.sql | |
@@ -3,6 +3,7 @@ | |
*/ | |
CREATE FUNCTION create_time_function(p_parent_table text) RETURNS void | |
LANGUAGE plpgsql SECURITY DEFINER | |
+ SET timezone = 'UTC' | |
AS $$ | |
DECLARE | |
diff --git a/sql/functions/create_time_partition.sql b/sql/functions/create_time_partition.sql | |
index ad400f8..dc42d00 100644 | |
--- a/sql/functions/create_time_partition.sql | |
+++ b/sql/functions/create_time_partition.sql | |
@@ -4,6 +4,7 @@ | |
CREATE FUNCTION create_time_partition (p_parent_table text, p_partition_times timestamp[]) | |
RETURNS text | |
LANGUAGE plpgsql SECURITY DEFINER | |
+ SET timezone = 'UTC' | |
AS $$ | |
DECLARE | |
diff --git a/sql/functions/drop_partition_time.sql b/sql/functions/drop_partition_time.sql | |
index 85860b3..8dfa233 100644 | |
--- a/sql/functions/drop_partition_time.sql | |
+++ b/sql/functions/drop_partition_time.sql | |
@@ -4,6 +4,7 @@ | |
*/ | |
CREATE FUNCTION drop_partition_time(p_parent_table text, p_retention interval DEFAULT NULL, p_keep_table boolean DEFAULT NULL, p_keep_index boolean DEFAULT NULL, p_retention_schema text DEFAULT NULL) RETURNS int | |
LANGUAGE plpgsql SECURITY DEFINER | |
+ SET timezone = 'UTC' | |
AS $$ | |
DECLARE | |
diff --git a/sql/functions/partition_data_time.sql b/sql/functions/partition_data_time.sql | |
index 46d1c42..e13cdbf 100644 | |
--- a/sql/functions/partition_data_time.sql | |
+++ b/sql/functions/partition_data_time.sql | |
@@ -3,6 +3,7 @@ | |
*/ | |
CREATE FUNCTION partition_data_time(p_parent_table text, p_batch_count int DEFAULT 1, p_batch_interval interval DEFAULT NULL, p_lock_wait numeric DEFAULT 0, p_order text DEFAULT 'ASC') RETURNS bigint | |
LANGUAGE plpgsql SECURITY DEFINER | |
+ SET timezone = 'UTC' | |
AS $$ | |
DECLARE | |
diff --git a/sql/functions/run_maintenance.sql b/sql/functions/run_maintenance.sql | |
index 0f59a3b..f3bea60 100644 | |
--- a/sql/functions/run_maintenance.sql | |
+++ b/sql/functions/run_maintenance.sql | |
@@ -4,6 +4,7 @@ | |
*/ | |
CREATE FUNCTION run_maintenance(p_jobmon BOOLEAN DEFAULT true) RETURNS void | |
LANGUAGE plpgsql SECURITY DEFINER | |
+ SET timezone = 'UTC' | |
AS $$ | |
DECLARE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment