londiste.upgrade_schema: fixed condition_timing vs action_timing
authormartinko <gamato@users.sf.net>
Mon, 17 Mar 2014 15:21:50 +0000 (16:21 +0100)
committermartinko <gamato@users.sf.net>
Mon, 17 Mar 2014 15:21:50 +0000 (16:21 +0100)
sql/londiste/functions/londiste.upgrade_schema.sql

index 508daea2b474fd723ef401d8f666fd9fb3b8b8a4..c0cf298673a10c7cab8316547b0e43d3a8a8036a 100644 (file)
@@ -3,8 +3,10 @@ create or replace function londiste.upgrade_schema()
 returns int4 as $$
 -- updates table structure if necessary
 declare
+    pgversion int;
     cnt int4 = 0;
 begin
+    show server_version_num into pgversion;
 
     -- table_info: check (dropped_ddl is null or merge_state in ('in-copy', 'catching-up'))
     perform 1 from information_schema.check_constraints
@@ -29,11 +31,19 @@ begin
     end if;
 
     -- table_info: change trigger timing
-    perform 1 from information_schema.triggers
-      where event_object_schema = 'londiste'
-        and event_object_table = 'table_info'
-        and trigger_name = 'table_info_trigger_sync'
-        and condition_timing = 'AFTER';
+    if pgversion >= 90100 then
+        perform 1 from information_schema.triggers
+          where event_object_schema = 'londiste'
+            and event_object_table = 'table_info'
+            and trigger_name = 'table_info_trigger_sync'
+            and action_timing = 'AFTER';
+    else
+        perform 1 from information_schema.triggers
+          where event_object_schema = 'londiste'
+            and event_object_table = 'table_info'
+            and trigger_name = 'table_info_trigger_sync'
+            and condition_timing = 'AFTER';
+    end if;
     if found then
         drop trigger table_info_trigger_sync on londiste.table_info;
         create trigger table_info_trigger_sync before delete on londiste.table_info